Skip to content

Commit

Permalink
fix parse_influenza_blast_results.py issue with Categorical type and …
Browse files Browse the repository at this point in the history
…CAT_ILLUMINA_FASTQ versions.yml wonkiness
  • Loading branch information
peterk87 committed Jul 7, 2023
1 parent e38c9ca commit 0d9db73
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 53 deletions.
2 changes: 1 addition & 1 deletion bin/parse_influenza_blast_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def report(flu_metadata, blast_results, excel_report, top, pident_threshold,
("Release_Date", pl.Categorical),
("Genus", pl.Categorical),
("Length", pl.UInt16),
("Genotype", pl.Categorical),
("Genotype", str),
("Segment", pl.Categorical),
("Publications", str),
("Geo_Location", pl.Categorical),
Expand Down
10 changes: 10 additions & 0 deletions conf/modules_illumina.config
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ process {
]
]
}

withName: 'SOFTWARE_VERSIONS' {
publishDir = [
[
path: { "${params.outdir}/pipeline_info" },
pattern: "software_versions.yml",
mode: params.publish_dir_mode
]
]
}
}
105 changes: 56 additions & 49 deletions modules/local/cat_illumina_fastq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -39,64 +39,71 @@ process CAT_ILLUMINA_FASTQ {
}
if (meta.single_end) {
if (fqList.size >= 1 || fqgzList.size >= 1) {
"""
touch ${prefix}.merged.fastq.gz
if [[ ${fqList.size} > 0 ]]; then
cat ${readList.join(' ')} | gzip -ck >> ${prefix}.merged.fastq.gz
fi
if [[ ${fqgzList.size} > 0 ]]; then
cat ${readList.join(' ')} >> ${prefix}.merged.fastq.gz
fi
"""
touch ${prefix}.merged.fastq.gz
if [[ ${fqList.size} > 0 ]]; then
cat ${readList.join(' ')} | gzip -ck >> ${prefix}.merged.fastq.gz
fi
if [[ ${fqgzList.size} > 0 ]]; then
cat ${readList.join(' ')} >> ${prefix}.merged.fastq.gz
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --help 2>&1) | sed 's/ (.*//')
gzip: \$(echo \$(gzip --help 2>&1) | sed 's/ (.*//')
END_VERSIONS
"""
}
} else {
if (readList.size >= 2) {
def read1 = []
def read1gz = []
def read2 = []
def read2gz = []
fqList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v }
fqgzList.eachWithIndex{ v, ix -> ( ix & 1 ? read2gz : read1gz ) << v }
"""
# append 1:N:0:. or 2:N:0:. to forward and reverse reads if "[12]:N:.*"
# not present in the FASTQ header for compatability with IRMA assembly
touch ${prefix}_1.merged.fastq.gz
touch ${prefix}_2.merged.fastq.gz
if [[ ${read1.size} > 0 ]]; then
cat ${read1.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 1:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_1.merged.fastq.gz
fi
if [[ ${read1gz.size} > 0 ]]; then
zcat ${read1gz.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 1:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_1.merged.fastq.gz
fi
if [[ ${read2.size} > 0 ]]; then
cat ${read2.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 2:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_2.merged.fastq.gz
fi
if [[ ${read2gz.size} > 0 ]]; then
zcat ${read2gz.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 2:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_2.merged.fastq.gz
fi
fqList.eachWithIndex { v, ix -> ( ix & 1 ? read2 : read1 ) << v }
fqgzList.eachWithIndex { v, ix -> ( ix & 1 ? read2gz : read1gz ) << v }
// append 1:N:0:. or 2:N:0:. to forward and reverse reads if "[12]:N:.*"
// not present in the FASTQ header for compatability with IRMA assembly
"""
touch ${prefix}_1.merged.fastq.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
touch ${prefix}_2.merged.fastq.gz
if [[ ${read1.size} > 0 ]]; then
cat ${read1.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 1:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_1.merged.fastq.gz
fi
if [[ ${read1gz.size} > 0 ]]; then
zcat ${read1gz.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 1:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_1.merged.fastq.gz
fi
if [[ ${read2.size} > 0 ]]; then
cat ${read2.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 2:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_2.merged.fastq.gz
fi
if [[ ${read2gz.size} > 0 ]]; then
zcat ${read2gz.join(' ')} \\
| perl -ne 'if (\$_ =~ /^@.*/ && !(\$_ =~ /^@.* [12]:N:.*/)){ chomp \$_; print "\$_ 2:N:0:.\n"; } else { print "\$_"; }' \\
| gzip -ck \\
>> ${prefix}_2.merged.fastq.gz
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --help 2>&1) | sed 's/ (.*//')
gzip: \$(echo \$(gzip --help 2>&1) | sed 's/ (.*//')
END_VERSIONS
"""
}
}
}
6 changes: 3 additions & 3 deletions workflows/illumina.nf
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ workflow ILLUMINA {
// Credit to nf-core/viralrecon. Source: https://github.com/nf-core/viralrecon/blob/a85d5969f9025409e3618d6c280ef15ce417df65/workflows/illumina.nf#L221
// Concatenate FastQ files from same sample if required
CAT_ILLUMINA_FASTQ(ch_input)
ch_versions = ch_versions.mix(CAT_ILLUMINA_FASTQ.out.versions)
ch_versions = ch_versions.mix(CAT_ILLUMINA_FASTQ.out.versions.first().ifEmpty(null))

IRMA(CAT_ILLUMINA_FASTQ.out.reads, irma_module)
ch_versions = ch_versions.mix(IRMA.out.versions)
ch_versions = ch_versions.mix(IRMA.out.versions.first().ifEmpty(null))

BLAST_BLASTN(IRMA.out.consensus, BLAST_MAKEBLASTDB.out.db)
ch_versions = ch_versions.mix(BLAST_BLASTN.out.versions)
ch_versions = ch_versions.mix(BLAST_BLASTN.out.versions.first().ifEmpty(null))

ch_blast = BLAST_BLASTN.out.txt.collect({ it[1] })
SUBTYPING_REPORT(ZSTD_DECOMPRESS_CSV.out.file, ch_blast)
Expand Down

0 comments on commit 0d9db73

Please sign in to comment.