Set fastq option straight
This commit is contained in:
parent
4a72aee687
commit
e8e584d451
@ -99,7 +99,7 @@ OUTPUT=output
|
|||||||
nextflow run epi2me-labs/wf-template \
|
nextflow run epi2me-labs/wf-template \
|
||||||
-w ${OUTPUT}/workspace \
|
-w ${OUTPUT}/workspace \
|
||||||
-profile standard \
|
-profile standard \
|
||||||
--fastq test_data/reads.fq.gz \
|
--fastq test_data \
|
||||||
--out_dir ${OUTPUT}
|
--out_dir ${OUTPUT}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -23,12 +23,17 @@ def main():
|
|||||||
"""Run entry point."""
|
"""Run entry point."""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"directory", help="Directory containing .fastq(.gz) files")
|
"fastq", help="Directory containing .fastq(.gz) files, or single fastq")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"output", help="Output file")
|
"output", help="Output file")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if os.path.isfile(args.fastq):
|
||||||
|
fastqs = [args.fastq]
|
||||||
|
elif os.path.isdir(args.fastq):
|
||||||
fastqs = glob.glob(os.path.join(args.directory, "*.fastq*"))
|
fastqs = glob.glob(os.path.join(args.directory, "*.fastq*"))
|
||||||
|
else:
|
||||||
|
raise IOError("fastq argument should be directory of file.")
|
||||||
reads = itertools.chain.from_iterable(
|
reads = itertools.chain.from_iterable(
|
||||||
pysam.FastxFile(fname) for fname in fastqs)
|
pysam.FastxFile(fname) for fname in fastqs)
|
||||||
|
|
||||||
|
|||||||
37
main.nf
37
main.nf
@ -27,6 +27,40 @@ Script Options:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
process concatFastq {
|
||||||
|
// concatenate fastq and fastq.gz in a dir
|
||||||
|
|
||||||
|
label "pysam"
|
||||||
|
cpus 1
|
||||||
|
input:
|
||||||
|
file "input"
|
||||||
|
output:
|
||||||
|
file "reads.fastq.gz"
|
||||||
|
|
||||||
|
shell:
|
||||||
|
'''
|
||||||
|
#!/usr/bin/env python
|
||||||
|
from glob import glob
|
||||||
|
import gzip
|
||||||
|
import itertools
|
||||||
|
import os
|
||||||
|
import pysam
|
||||||
|
|
||||||
|
# we use pysam just because it will read both fastq and fastq.gz
|
||||||
|
# and we don't have to worry about having a combination or not
|
||||||
|
with gzip.open("reads.fastq.gz", "wt") as fh:
|
||||||
|
files = itertools.chain(
|
||||||
|
glob("input/*.fastq"), glob("input/*.fastq.gz"))
|
||||||
|
records = itertools.chain.from_iterable(
|
||||||
|
pysam.FastxFile(fn) for fn in files)
|
||||||
|
for rec in records:
|
||||||
|
annot = " {}".format(rec.comment) if rec.comment else ""
|
||||||
|
qual = rec.quality if rec.quality else "+"*len(rec.sequence)
|
||||||
|
fh.write("@{}{}\\n{}\\n+\\n{}\\n".format(rec.name, annot, rec.sequence, qual))
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
process readSeqs {
|
process readSeqs {
|
||||||
// Just write a file with sequence lengths
|
// Just write a file with sequence lengths
|
||||||
label "pysam"
|
label "pysam"
|
||||||
@ -75,6 +109,7 @@ workflow pipeline {
|
|||||||
take:
|
take:
|
||||||
reads
|
reads
|
||||||
main:
|
main:
|
||||||
|
reads = concatFastq(reads)
|
||||||
summary = readSeqs(reads)
|
summary = readSeqs(reads)
|
||||||
report = makeReport(summary)
|
report = makeReport(summary)
|
||||||
emit:
|
emit:
|
||||||
@ -99,7 +134,7 @@ workflow {
|
|||||||
|
|
||||||
reads = file("$params.fastq/*.fastq*", type: 'file', maxdepth: 1)
|
reads = file("$params.fastq/*.fastq*", type: 'file', maxdepth: 1)
|
||||||
if (reads) {
|
if (reads) {
|
||||||
reads = Channel.fromPath(params.fastq, type: 'dir', maxDepth: 1)
|
reads = Channel.fromPath(params.fastq, type: 'dir', checkIfExists: true)
|
||||||
results = pipeline(reads)
|
results = pipeline(reads)
|
||||||
output(results)
|
output(results)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user