Skip to content

Commit

Permalink
feat: Added specific param for strandness (#474)
Browse files Browse the repository at this point in the history
* Added specific param for strandness

* Added explanation to params.strand option
  • Loading branch information
fgvieira committed Apr 25, 2022
1 parent 4672e5b commit 12b7978
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bio/subread/featurecounts/meta.yaml
@@ -1,6 +1,7 @@
name: subread featureCounts
description: >
FeatureCounts assign mapped reads or fragments (paired-end data) to genomic features such as genes, exons and promoters.
url: http://subread.sourceforge.net/
author:
- Antonie Vietor
- Filipe G. Vieira
Expand All @@ -14,6 +15,5 @@ output:
- Summary file including summary statistics (tab separated)
- Junction counts file including count number of reads supporting each exon-exon junction (tab separated)
notes: |
* The `strand` param allows to specify the strandness of the library (0: unstranded, 1: stranded, and 2: reversely stranded)
* The `extra` param allows for additional program arguments.
* For more information see, http://subread.sourceforge.net/ and https://bioconductor.org/packages/release/bioc/vignettes/Rsubread/inst/doc/SubreadUsersGuide.pdf
* For a tutorial see, http://bioinf.wehi.edu.au/featureCounts/
8 changes: 5 additions & 3 deletions bio/subread/featurecounts/test/Snakefile
@@ -1,10 +1,11 @@
rule feature_counts:
input:
samples="{sample}.bam", # list of sam or bam files
# list of sam or bam files
samples="{sample}.bam",
annotation="annotation.gtf",
# optional input
# chr_names="", # implicitly sets the -A flag
# fasta="genome.fasta" # implicitly sets the -G flag
#chr_names="", # implicitly sets the -A flag
#fasta="genome.fasta" # implicitly sets the -G flag
output:
multiext(
"results/{sample}",
Expand All @@ -14,6 +15,7 @@ rule feature_counts:
),
threads: 2
params:
strand=0, # optional; strandness of the library (0: unstranded [default], 1: stranded, and 2: reversely stranded)
r_path="", # implicitly sets the --Rpath flag
extra="-O --fracOverlap 0.2 -J",
log:
Expand Down
20 changes: 14 additions & 6 deletions bio/subread/featurecounts/wrapper.py
Expand Up @@ -10,22 +10,30 @@
extra = snakemake.params.get("extra", "")

# optional input files and directories
fasta = snakemake.input.get("fasta", "")
chr_names = snakemake.input.get("chr_names", "")
r_path = snakemake.params.get("r_path", "")
strand = snakemake.params.get("strand", 0)

fasta = snakemake.input.get("fasta", "")
if fasta:
extra += " -G {}".format(fasta)
fasta = f"-G {fasta}"

chr_names = snakemake.input.get("chr_names", "")
if chr_names:
extra += " -A {}".format(chr_names)
chr_names = f"-A {chr_names}"

r_path = snakemake.params.get("r_path", "")
if r_path:
extra += " --Rpath {}".format(r_path)
r_path = f"--Rpath {r_path}"


with tempfile.TemporaryDirectory() as tmpdir:
shell(
"featureCounts"
" -T {snakemake.threads}"
" -s {strand}"
" -a {snakemake.input.annotation}"
" {fasta}"
" {chr_names}"
" {r_path}"
" {extra}"
" --tmpDir {tmpdir}"
" -o {snakemake.output[0]}"
Expand Down

0 comments on commit 12b7978

Please sign in to comment.