diff --git a/conf/modules.config b/conf/modules.config index 632fa69..5cdc4e9 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -197,6 +197,20 @@ process { '-outfmt', '"6 qseqid ppos"', ].join(' ').trim() + + publishDir = [ + [ + path: "${params.outdir}", + mode: params.publish_dir_mode, + failOnError: true, + saveAs: { + filename -> { + def output_file = new File(filename); + return "${study_reads_folder()}/assembly/${meta.assembler}/${meta.assembler_version}/decontamination/${output_file.name}"; + } + } + ] + ] } withName: 'SEQKIT_GREP' { @@ -319,24 +333,4 @@ process { // NOTICE: Maximum number of references (--max-ref-number) is set to 0, search in SILVA 16S rRNA database is disabled // ext.args = "--max-ref-num 0" } - - withName: 'PUBLISH_DECONTAMINATED' { - cpus = { check_max( 1 , 'cpus' ) } - memory = { check_max( 250.MB * task.attempt, 'memory' ) } - time = { check_max( 30.m , 'time' ) } - - publishDir = [ - [ - path: "${params.outdir}", - mode: params.publish_dir_mode, - failOnError: true, - saveAs: { - filename -> { - def output_file = new File(filename); - return "${study_reads_folder()}/assembly/${meta.assembler}/${meta.assembler_version}/decontamination/${output_file.name}"; - } - } - ] - ] - } } diff --git a/modules/local/publish_decontaminated.nf b/modules/local/publish_decontaminated.nf deleted file mode 100644 index c57383b..0000000 --- a/modules/local/publish_decontaminated.nf +++ /dev/null @@ -1,13 +0,0 @@ -process PUBLISH_DECONTAMINATED { - - input: - tuple val(meta), path(decontaminated_contigs) - - output: - path("${meta.id}_decontaminated_contigs.txt") - - script: - """ - mv ${decontaminated_contigs} ${meta.id}_decontaminated_contigs.txt - """ -} diff --git a/modules/nf-core/blast/blastn/main.nf b/modules/nf-core/blast/blastn/main.nf index 2613e54..9b44592 100644 --- a/modules/nf-core/blast/blastn/main.nf +++ b/modules/nf-core/blast/blastn/main.nf @@ -20,7 +20,7 @@ process BLAST_BLASTN { script: def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta2.id}" def is_compressed = fasta.getExtension() == "gz" ? true : false def fasta_name = is_compressed ? fasta.getBaseName() : fasta diff --git a/subworkflows/local/assembly_qc.nf b/subworkflows/local/assembly_qc.nf index a4cdc02..c81beb0 100644 --- a/subworkflows/local/assembly_qc.nf +++ b/subworkflows/local/assembly_qc.nf @@ -2,7 +2,6 @@ include { BLAST_BLASTN as BLAST_BLASTN_HUMAN_PHIX } from '../../modules/nf-core/ include { BLAST_BLASTN as BLAST_BLASTN_HOST } from '../../modules/nf-core/blast/blastn/main' include { SEQKIT_GREP } from '../../modules/nf-core/seqkit/grep/main' include { SEQKIT_SEQ } from '../../modules/nf-core/seqkit/seq/main' -include { PUBLISH_DECONTAMINATED } from '../../modules/local/publish_decontaminated' workflow ASSEMBLY_QC { @@ -40,7 +39,7 @@ workflow ASSEMBLY_QC { contaminated_contigs = BLAST_BLASTN_HUMAN_PHIX.out.txt } - if ( host_reference_genome != null) { + if ( host_reference_genome != null ) { ch_blast_host_refs = Channel.fromPath( "${params.blast_reference_genomes_folder}/${host_reference_genome}*", checkIfExists: true) .collect().map { @@ -54,23 +53,25 @@ workflow ASSEMBLY_QC { ch_versions = ch_versions.mix(BLAST_BLASTN_HOST.out.versions.first()) - contaminated_contigs = Channel.of( BLAST_BLASTN_HUMAN_PHIX.out.txt, BLAST_BLASTN_HOST.out.txt ) - .collectFile(name: "contaminated_contigs_host.txt", newLine: true) - } else { - contaminated_contigs = BLAST_BLASTN_HUMAN_PHIX.out.txt + contaminated_contigs = contaminated_contigs.mix( BLAST_BLASTN_HOST.out.txt ) } - // TODO: this process only function is to publish the decontaminated contigs txt file - PUBLISH_DECONTAMINATED( contaminated_contigs ) - + // TODO: this is not fit for samplesheets kind of inputs, it should .join with the contaminated contigs channel SEQKIT_GREP( SEQKIT_SEQ.out.fastx, - contaminated_contigs.map { meta, hits_txt -> { hits_txt }} + contaminated_contigs.map { meta, hits_txt -> { hits_txt }}.collectFile(name: "contaminated_contigs.txt", newLine: true) ) + if ( !params.remove_human_phix && host_reference_genome == null ) { + // No decontamination // + filtered_contigs = assembly + } else { + filtered_contigs = SEQKIT_GREP.out.filter + } + ch_versions = ch_versions.mix(SEQKIT_GREP.out.versions) emit: - filtered_contigs = SEQKIT_GREP.out.filter + filtered_contigs = filtered_contigs versions = ch_versions } diff --git a/tests/main.nf.test b/tests/main.nf.test index 54fd341..821dfa0 100644 --- a/tests/main.nf.test +++ b/tests/main.nf.test @@ -21,7 +21,7 @@ nextflow_pipeline { assert success assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 1 assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 0 - assert trace.succeeded().size() == 17 + assert trace.succeeded().size() == 16 } } @@ -45,7 +45,7 @@ nextflow_pipeline { assert success assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 0 assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1 - assert trace.tasks().size() == 17 + assert trace.tasks().size() == 16 } } @@ -111,7 +111,7 @@ nextflow_pipeline { assert success assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 0 assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1 - assert trace.tasks().size() == 17 + assert trace.tasks().size() == 16 } }