diff --git a/bin/parse_influenza_blast_results.py b/bin/parse_influenza_blast_results.py index c2bdc6c..b8c03d0 100755 --- a/bin/parse_influenza_blast_results.py +++ b/bin/parse_influenza_blast_results.py @@ -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), diff --git a/conf/modules_illumina.config b/conf/modules_illumina.config index d6c7c65..e6560a5 100644 --- a/conf/modules_illumina.config +++ b/conf/modules_illumina.config @@ -66,4 +66,14 @@ process { ] ] } + + withName: 'SOFTWARE_VERSIONS' { + publishDir = [ + [ + path: { "${params.outdir}/pipeline_info" }, + pattern: "software_versions.yml", + mode: params.publish_dir_mode + ] + ] + } } diff --git a/modules/local/cat_illumina_fastq.nf b/modules/local/cat_illumina_fastq.nf index fe62e55..0afe2bd 100644 --- a/modules/local/cat_illumina_fastq.nf +++ b/modules/local/cat_illumina_fastq.nf @@ -39,20 +39,21 @@ 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) { @@ -60,43 +61,49 @@ process CAT_ILLUMINA_FASTQ { 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 +""" } } } diff --git a/workflows/illumina.nf b/workflows/illumina.nf index 564f33c..342e6a5 100644 --- a/workflows/illumina.nf +++ b/workflows/illumina.nf @@ -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)