From d1ebcb034a36eadfe4582df0ffb00501bf722b51 Mon Sep 17 00:00:00 2001 From: Tyghe Vallard Date: Thu, 28 Jan 2016 15:42:57 -0500 Subject: [PATCH] Slightly working --- pyjip/README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++ pyjip/bwa_index.jip | 8 +------- pyjip/cutadapt.jip | 24 ++++++++++++++++------- pyjip/simplepipe.jip | 11 +++++++---- 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 pyjip/README.md diff --git a/pyjip/README.md b/pyjip/README.md new file mode 100644 index 0000000..c145d8c --- /dev/null +++ b/pyjip/README.md @@ -0,0 +1,46 @@ +# Simple jip pipeline + +[Jip Docs](http://pyjip.readthedocs.org/en/latest) + +# Dirty install + +Would be fun later to maybe make a task to install executables inside a jip task +using conda. + +For now do it manually +``` +conda install bwa samtools cutadapt +``` + +# Execute pipeline + +For the examples/tests I ran I used the 947 sample that comes with the ngs_mapper pipeline + + +## Single threaded(non-piped) + +``` +./simplepipe.jip -r ../../functional/947.ref.fasta -f ../../functional/947/947_S32_L001_R{1,2}_001_2013_12_17.fastq +``` + +### Dry run + +``` +./simplepipe.jip -r ../../functional/947.ref.fasta -f ../../functional/947/947_S32_L001_R{1,2}_001_2013_12_17.fastq -- --show --dry +``` + +## Multy threaded(named pipe) + +``` +jip server & +cat < ~/.jip/jip.json + { + "cluster": "jip.grids.JIP", + "jip_cluster":{ + "port": 5556 + } + } +EOF + +jip submit simplepipe.jip -r ../../functional/947.ref.fasta -f ../../functional/947/947_S32_L001_R{1,2}_001_2013_12_17.fastq --pipe +``` diff --git a/pyjip/bwa_index.jip b/pyjip/bwa_index.jip index 1fb86e6..83d6f88 100755 --- a/pyjip/bwa_index.jip +++ b/pyjip/bwa_index.jip @@ -14,13 +14,7 @@ options['output'].default = "${reference}.bwt" #%end #%begin validate -import os -try: - os.makedirs(options['output'].get()) -except OSError as e: - if e.errno != 17: - validation_error('Failed to create "${output}": ' + str(e)) #%end -cp ${reference|abs} ${output} +cp ${reference|abs} ${output|ext} bwa index ${output|ext} diff --git a/pyjip/cutadapt.jip b/pyjip/cutadapt.jip index df00dc0..ed73e9e 100755 --- a/pyjip/cutadapt.jip +++ b/pyjip/cutadapt.jip @@ -2,30 +2,40 @@ # Runs cutadapt with only quality filter # # usage: -# cutadapt [-o ] -q ... -f ... +# cutadapt -q ... -f ... [-o ] [-p ] [--pipe] # # Options: # -f, --fastq The input fastq file[s] # -q, --qualcutoff The quality cutoff [Default: 25] -# -o, --outsuffix The output suffix [Default: .cutadapt] +# -o, --outr1 R1 output fastq [Default: output_r1.cutadapt] +# -p, --outr2 R2 output fastq +# --pipe Flag to create named pipes for output [Default: False] #%begin init -add_output('output_r1', '', short='-o') -add_output('output_r2', '', short='-p') +add_output('output', [options['outr1']], nargs='+') #%end #%begin setup -options['output_r1'].set('output_r1' + options['outsuffix'].get()) if len(options['fastq']) == 2: options['qualcutoff'].join = ',' if len(options['qualcutoff']) != len(options['fastq']): qualcutoff = options['qualcutoff'].value[0] options['qualcutoff'].set([qualcutoff,qualcutoff]) - options['output_r2'].set('output_r2' + options['outsuffix'].get()) + if not options['outr2']: + options['outr2'].set('output_r2.cutadapt') + options['output'].append(options['outr2']) #%end #%begin validate assert len(options['fastq']) == len(options['qualcutoff']), validation_error('qualcuttoff must have same number of entries as fastq') #%end -cutadapt ${output_r1|arg} ${output_r2|arg|else('')} -q ${qualcutoff} ${fastq} +if [ "${pipe|arg}" == "--pipe" ] +then + mkfifo ${outr1} ${outr2|else('')} +fi +cutadapt ${outr1|arg} ${outr2|arg|else('')} -q ${qualcutoff} ${fastq} +if [ "${pipe|arg}" == "--pipe" ] +then + rm ${outr1} ${outr2|else('')} +fi diff --git a/pyjip/simplepipe.jip b/pyjip/simplepipe.jip index 764acaa..4bd20b1 100755 --- a/pyjip/simplepipe.jip +++ b/pyjip/simplepipe.jip @@ -3,7 +3,7 @@ # Simple pipeline to run cutadapt, bwa index, bwa mem, samtools view # # Usage: -# simplepipe -r -f ... [-q ...] [-o ] +# simplepipe -r -f ... [-q ...] [-o ] [--pipe] # # Options: # -r, --reference Reference file to index and map to @@ -12,11 +12,14 @@ # [Default: 25] # -o, --output The output bam file # [Default: mapped.bam] +# -p, --pipe To use named pipe(have to submit jip job for this to work) +# [Default: False] #%begin pipeline -trimmed = run('cutadapt', fastq=options['fastq'], qualcutoff=options['qualcutoff']) +trimmed = run('cutadapt', fastq=options['fastq'], qualcutoff=options['qualcutoff'], pipe=options['pipe']) index_ref = run('bwa_index', reference=options['reference']) -sam = run('bwa_mem', reference=reference, fastq=[trimmed.output_r1, trimmed.output_r2]) +sam = run('bwa_mem', reference=reference, fastq=['output_r1.cutadapt', 'output_r2.cutadapt']) bam = run('sam_to_bam', input=sam, output=options['output']) -index_ref >> sam + +index_ref >> (sam | bam) #%end