Skip to content

Commit

Permalink
Slightly working
Browse files Browse the repository at this point in the history
  • Loading branch information
necrolyte2 committed Jan 28, 2016
1 parent 4754bd9 commit d1ebcb0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
46 changes: 46 additions & 0 deletions pyjip/README.md
Original file line number Diff line number Diff line change
@@ -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 <<EOF > ~/.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
```
8 changes: 1 addition & 7 deletions pyjip/bwa_index.jip
Original file line number Diff line number Diff line change
Expand Up @@ -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}
24 changes: 17 additions & 7 deletions pyjip/cutadapt.jip
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,40 @@
# Runs cutadapt with only quality filter
#
# usage:
# cutadapt [-o <outsuffix>] -q <qualcutoff>... -f <fastq>...
# cutadapt -q <qualcutoff>... -f <fastq>... [-o <outr1>] [-p <outr2>] [--pipe]
#
# Options:
# -f, --fastq <fastq> The input fastq file[s]
# -q, --qualcutoff <qualcutoff> The quality cutoff [Default: 25]
# -o, --outsuffix <outsuffix> The output suffix [Default: .cutadapt]
# -o, --outr1 <outr1> R1 output fastq [Default: output_r1.cutadapt]
# -p, --outr2 <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
11 changes: 7 additions & 4 deletions pyjip/simplepipe.jip
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Simple pipeline to run cutadapt, bwa index, bwa mem, samtools view
#
# Usage:
# simplepipe -r <reference> -f <fastq>... [-q <qualcutoff>...] [-o <output>]
# simplepipe -r <reference> -f <fastq>... [-q <qualcutoff>...] [-o <output>] [--pipe]
#
# Options:
# -r, --reference <reference> Reference file to index and map to
Expand All @@ -12,11 +12,14 @@
# [Default: 25]
# -o, --output <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

0 comments on commit d1ebcb0

Please sign in to comment.