Skip to content

Instantly share code, notes, and snippets.

@thanhleviet
Last active April 9, 2020 23:33
Show Gist options
  • Save thanhleviet/1397a37d201bf403c6fe40aabcf31016 to your computer and use it in GitHub Desktop.
Save thanhleviet/1397a37d201bf403c6fe40aabcf31016 to your computer and use it in GitHub Desktop.
nextflow script to merge 4 fastq lanes for Illumina data
params.reads = "/beegfs/sars-cov2/Test_060420"
ch_reads = Channel.fromFilePairs(params.reads + "/" + "*_R{1,2}_001.fastq.gz", flat: true)
ch_reads
.map {
it -> [it[0].replaceAll(~/\_L00[1,2,3,4]/,""), it[1], it[2]]
}
.groupTuple(by:0)
.into {ch_reads_in; ch_test}
ch_test.countBy().subscribe{println it}
process fastq_merge_lanes {
publishDir "$baseDir/merged_fastq", mode: "move"
input:
tuple sample_id, file(forward), file(reverse) from ch_reads_in
output:
tuple sample_id, file("${sample_id}_R1.fastq.gz"), file("${sample_id}_R2.fastq.gz")
script:
"""
zcat $forward | gzip > ${sample_id}_R1.fastq.gz
zcat $reverse | gzip > ${sample_id}_R2.fastq.gz
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment