-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single pipe from reads->cutadapt->bwa->samtools using interleaved format
- Loading branch information
1 parent
9cc3027
commit d02c5d1
Showing
4 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env jip | ||
# | ||
# Converts 2 fastq paired files into single interleave | ||
# | ||
# Usage: | ||
# paired_to_interleave -f <forward> -r <reverse> [--outformat <outformat>] [-o <output>] | ||
# | ||
# Options: | ||
# -f, --forward <forward> The forward fastq input | ||
# -r, --reverse <reverse> The reverse fastq input | ||
# -o, --output <output> The interleaved output [default: stdout] | ||
# --outformat <outformat> The output format [default: fastq] | ||
|
||
#%begin validate | ||
if options['outformat'] not in ('fasta', 'fastq'): | ||
validation_error( | ||
"output format can only be fasta or fastq. You provided '%s'" | ||
% options['outformat'] | ||
) | ||
#%end | ||
|
||
#%begin command python | ||
import itertools | ||
|
||
from Bio import SeqIO | ||
|
||
def interleave(iter1, iter2): | ||
for forward, reverse in itertools.izip(iter1, iter2): | ||
assert forward.id == reverse.id, "%s did not match %s" % \ | ||
(forward.id, reverse.id) | ||
yield forward | ||
yield reverse | ||
|
||
f1, f2 = open("${forward}"), open("${reverse}") | ||
records = interleave(SeqIO.parse(f1, 'fastq'), SeqIO.parse(f2, 'fastq')) | ||
outfile = open("${output|else('/dev/stdout')}", 'w') | ||
count = SeqIO.write(records, outfile, "${outformat}") | ||
outfile.close() | ||
#%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters