diff --git a/modules.json b/modules.json index 09fd711b..f9c0995c 100644 --- a/modules.json +++ b/modules.json @@ -81,7 +81,7 @@ "pfr": { "fasta_ltrretriever_lai": { "branch": "main", - "git_sha": "10b046eaac396f279c08e7e2bb067482ccd9c74e", + "git_sha": "8088445a270d324cb06e085f18790839c9684754", "installed_by": ["subworkflows"] }, "fastq_bwa_mem_samblaster": { diff --git a/subworkflows/pfr/fasta_ltrretriever_lai/main.nf b/subworkflows/pfr/fasta_ltrretriever_lai/main.nf index 7bdc2c28..5c392795 100644 --- a/subworkflows/pfr/fasta_ltrretriever_lai/main.nf +++ b/subworkflows/pfr/fasta_ltrretriever_lai/main.nf @@ -32,6 +32,7 @@ workflow FASTA_LTRRETRIEVER_LAI { | join( ch_monoploid_seqs ?: Channel.empty() ) + | filter { meta, tsv, seqs -> seqs } // Cater to channel: [ meta, tsv, [] ] | map { meta, short_ids_tsv, monoploid_seqs -> map_monoploid_seqs_to_new_ids(meta, short_ids_tsv, monoploid_seqs) } diff --git a/subworkflows/pfr/fasta_ltrretriever_lai/tests/main.nf.test b/subworkflows/pfr/fasta_ltrretriever_lai/tests/main.nf.test index 2f31d1d1..4eff67ca 100644 --- a/subworkflows/pfr/fasta_ltrretriever_lai/tests/main.nf.test +++ b/subworkflows/pfr/fasta_ltrretriever_lai/tests/main.nf.test @@ -18,22 +18,22 @@ nextflow_workflow { tag "ltrretriever/lai" tag "custom/restoregffids" - test("actinidia_chinensis-genome_21_fasta_gz") { - - setup { - run("GUNZIP") { - script "../../../../modules/nf-core/gunzip" - - process { - """ - input[0] = [ - [ id:'test' ], - file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) - ] - """ - } + setup { + run("GUNZIP") { + script "../../../../modules/nf-core/gunzip" + + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['actinidia_chinensis']['genome']['genome_1_fasta_gz'], checkIfExists: true) + ] + """ } } + } + + test("actinidia_chinensis-genome_1_fasta_gz") { when { workflow { @@ -57,23 +57,43 @@ nextflow_workflow { } } - test("actinidia_chinensis-genome_21_fasta_gz-with_mono") { + test("actinidia_chinensis-genome_1_fasta_gz-with_mono") { - setup { - run("GUNZIP") { - script "../../../../modules/nf-core/gunzip" + when { + workflow { + """ + GUNZIP.out.gunzip.map { meta, fasta -> + def fa = new File('test.fa') + fa.write(fasta.text.replaceAll('>chr1', '>chr_xxxxxxxxxxxxxxx_1')) - process { - """ - input[0] = [ - [ id:'test' ], - file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) - ] - """ + [ meta, fa.toPath() ] } + | set { ch_fa } + + def monoploid_seqs = new File('test.mono.seq.txt') + monoploid_seqs.write("chr_xxxxxxxxxxxxxxx_1") + + input[0] = ch_fa + input[1] = Channel.of( [ [ id:'test' ], monoploid_seqs.toPath() ] ) + input[2] = false + """ } } + then { + assertAll( + { assert workflow.success }, + { assert file(workflow.out.annotation_gff[0][1]).text.contains('Copia_LTR_retrotransposon') }, + { assert file(workflow.out.lai_log[0][1]).text.contains('Calculate LAI:') }, + { assert file(workflow.out.lai_log[0][1]).text.contains('Done!') }, + { assert Math.abs(Float.parseFloat(path(workflow.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 }, + { assert file(workflow.out.ltrlib[0][1]).text.contains('#LTR/Copia') } + ) + } + } + + test("actinidia_chinensis-genome_1_fasta_gz-with_empty_mono_channel") { + when { workflow { """ @@ -85,11 +105,8 @@ nextflow_workflow { } | set { ch_fa } - def monoploid_seqs = new File('test.mono.seq.txt') - monoploid_seqs.write("chr_xxxxxxxxxxxxxxx_1") - input[0] = ch_fa - input[1] = Channel.of( [ [ id:'test' ], monoploid_seqs.toPath() ] ) + input[1] = ch_fa.map { meta, fasta -> [ meta, [] ] } input[2] = false """ } @@ -107,25 +124,42 @@ nextflow_workflow { } } - test("actinidia_chinensis-genome_21_fasta_gz-without_lai") { + test("actinidia_chinensis-genome_1_fasta_gz-with_empty_mono") { - options '-stub' + when { + workflow { + """ + GUNZIP.out.gunzip.map { meta, fasta -> + def fa = new File('test.fa') + fa.write(fasta.text.replaceAll('>chr1', '>chr_xxxxxxxxxxxxxxx_1')) - setup { - run("GUNZIP") { - script "../../../../modules/nf-core/gunzip" - - process { - """ - input[0] = [ - [ id:'test' ], - file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) - ] - """ + [ meta, fa.toPath() ] } + | set { ch_fa } + + input[0] = ch_fa + input[1] = [] + input[2] = false + """ } } + then { + assertAll( + { assert workflow.success }, + { assert file(workflow.out.annotation_gff[0][1]).text.contains('Copia_LTR_retrotransposon') }, + { assert file(workflow.out.lai_log[0][1]).text.contains('Calculate LAI:') }, + { assert file(workflow.out.lai_log[0][1]).text.contains('Done!') }, + { assert Math.abs(Float.parseFloat(path(workflow.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 }, + { assert file(workflow.out.ltrlib[0][1]).text.contains('#LTR/Copia') } + ) + } + } + + test("actinidia_chinensis-genome_1_fasta_gz-without_lai") { + + options '-stub' + when { workflow { """