Skip to content

Commit

Permalink
Add STAR wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Feb 19, 2017
1 parent b1541f4 commit 73f6404
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 0 deletions.
Empty file added bio/star/align/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions bio/star/align/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- bioconda
- r
dependencies:
- star ==2.5.2b
4 changes: 4 additions & 0 deletions bio/star/align/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: "star"
description: Map reads with STAR.
authors:
- Johannes Köster
16 changes: 16 additions & 0 deletions bio/star/align/test/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rule star:
input:
sample=["reads/{sample}.1.fastq", "reads/{sample}.2.fastq"]
output:
# see STAR manual for additional output files
"star/{sample}/Aligned.out.bam"
log:
"logs/star/{sample}.log"
params:
# path to STAR reference genome index
index="index/",
# optional parameters
extra=""
threads: 8
wrapper:
"master/bio/star/align"
2 changes: 2 additions & 0 deletions bio/star/align/test/genome.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>Sheila
GCTAGCTCAGAAAAAAAAAA
1 change: 1 addition & 0 deletions bio/star/align/test/index/chrLength.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
1 change: 1 addition & 0 deletions bio/star/align/test/index/chrName.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sheila
1 change: 1 addition & 0 deletions bio/star/align/test/index/chrNameLength.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sheila 20
2 changes: 2 additions & 0 deletions bio/star/align/test/index/chrStart.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0
262144
14 changes: 14 additions & 0 deletions bio/star/align/test/index/genomeParameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### STAR --runMode genomeGenerate --genomeDir index --genomeFastaFiles genome.fasta
versionGenome 20201
genomeFastaFiles genome.fasta
genomeSAindexNbases 14
genomeChrBinNbits 18
genomeSAsparseD 1
sjdbOverhang 0
sjdbFileChrStartEnd -
sjdbGTFfile -
sjdbGTFchrPrefix -
sjdbGTFfeatureExon exon
sjdbGTFtagExonParentTranscript transcript_id
sjdbGTFtagExonParentGene gene_id
sjdbInsertSave Basic
4 changes: 4 additions & 0 deletions bio/star/align/test/reads/a.1.fastq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@1
ACGGCAT
+
!!!!!!!
4 changes: 4 additions & 0 deletions bio/star/align/test/reads/a.2.fastq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@1
ACGGCAT
+
!!!!!!!
8 changes: 8 additions & 0 deletions bio/star/align/test_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import subprocess
import os

def setup_module():
os.chdir(os.path.join(os.path.dirname(__file__), "test"))

def test():
subprocess.check_call(["snakemake", "mapped/a/Aligned.out.bam", "--use-conda", "-F"])
34 changes: 34 additions & 0 deletions bio/star/align/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
__author__ = "Johannes Köster"
__copyright__ = "Copyright 2016, Johannes Köster"
__email__ = "koester@jimmy.harvard.edu"
__license__ = "MIT"


import os
from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

n = len(snakemake.input.sample)
assert n == 1 or n == 2, "input->sample must have 1 (single-end) or 2 (paired-end) elements."

if snakemake.input.sample[0].endswith(".gz"):
readcmd = "--readFilesCommand zcat"
else:
readcmd = ""


outprefix = os.path.dirname(snakemake.output[0])


shell(
"(STAR "
"{snakemake.params.extra} "
"--runThreadN {snakemake.threads} "
"--genomeDir {snakemake.params.index} "
"--readFilesIn {snakemake.input.sample} "
"{readcmd} "
"--outSAMtype BAM "
"--outFileNamePrefix {outprefix} "
"--outStd Log")

0 comments on commit 73f6404

Please sign in to comment.