Skip to content

Commit

Permalink
fix: proper tempfile handling for STAR and improved documentation (#430)
Browse files Browse the repository at this point in the history
* Implemented proper handling of temp files and updated version

* Added notes with link

* Added dummy folder since STAR requires tempdir to not exist
  • Loading branch information
fgvieira committed Jan 17, 2022
1 parent 961edb8 commit 922cf87
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bio/star/align/environment.yaml
Expand Up @@ -2,4 +2,4 @@ channels:
- bioconda
- conda-forge
dependencies:
- star ==2.7.8a
- star ==2.7.9a
3 changes: 3 additions & 0 deletions bio/star/align/meta.yaml
Expand Up @@ -3,3 +3,6 @@ description: Map reads with STAR.
authors:
- Johannes Köster
- Tomás Di Domenico
notes: |
* The `extra` param allows for additional program arguments.
* For more information see, https://github.com/alexdobin/STAR
19 changes: 10 additions & 9 deletions bio/star/align/test/Snakefile
Expand Up @@ -2,36 +2,37 @@ rule star_pe_multi:
input:
# use a list for multiple fastq files for one sample
# usually technical replicates across lanes/flowcells
fq1 = ["reads/{sample}_R1.1.fastq", "reads/{sample}_R1.2.fastq"],
fq1=["reads/{sample}_R1.1.fastq", "reads/{sample}_R1.2.fastq"],
# paired end reads needs to be ordered so each item in the two lists match
fq2 = ["reads/{sample}_R2.1.fastq", "reads/{sample}_R2.2.fastq"] #optional
fq2=["reads/{sample}_R2.1.fastq", "reads/{sample}_R2.2.fastq"], #optional
output:
# see STAR manual for additional output files
"star/pe/{sample}/Aligned.out.sam"
"star/pe/{sample}/Aligned.out.sam",
log:
"logs/star/pe/{sample}.log"
"logs/star/pe/{sample}.log",
params:
# path to STAR reference genome index
index="index",
# optional parameters
extra=""
extra="",
threads: 8
wrapper:
"master/bio/star/align"


rule star_se:
input:
fq1 = "reads/{sample}_R1.1.fastq"
fq1="reads/{sample}_R1.1.fastq",
output:
# see STAR manual for additional output files
"star/{sample}/Aligned.out.sam"
"star/{sample}/Aligned.out.sam",
log:
"logs/star/{sample}.log"
"logs/star/{sample}.log",
params:
# path to STAR reference genome index
index="index",
# optional parameters
extra=""
extra="",
threads: 8
wrapper:
"master/bio/star/align"
25 changes: 14 additions & 11 deletions bio/star/align/wrapper.py
Expand Up @@ -5,6 +5,7 @@


import os
import tempfile
from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
Expand Down Expand Up @@ -46,14 +47,16 @@
if outprefix == os.path.dirname(snakemake.output[0]):
outprefix += "/"

shell(
"STAR "
"{extra} "
"--runThreadN {snakemake.threads} "
"--genomeDir {snakemake.params.index} "
"--readFilesIn {input_str} "
"{readcmd} "
"--outFileNamePrefix {outprefix} "
"--outStd Log "
"{log}"
)
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"STAR "
"{extra} "
"--runThreadN {snakemake.threads} "
"--genomeDir {snakemake.params.index} "
"--readFilesIn {input_str} "
"{readcmd} "
"--outFileNamePrefix {outprefix} "
"--outStd Log "
"--outTmpDir {tmpdir}/STARtmp "
"{log}"
)

0 comments on commit 922cf87

Please sign in to comment.