From 878a4c088560afa5ca1f067bb25079bd6b9f73a4 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Fri, 19 Jan 2024 12:41:41 +1300 Subject: [PATCH 1/5] Added a draft for LAI --- modules/nf-core/lai/environment.yml | 9 ++ modules/nf-core/lai/main.nf | 71 ++++++++++++ modules/nf-core/lai/meta.yml | 68 ++++++++++++ modules/nf-core/lai/tests/main.nf.test | 115 ++++++++++++++++++++ modules/nf-core/lai/tests/main.nf.test.snap | 45 ++++++++ modules/nf-core/lai/tests/nextflow.config | 12 ++ modules/nf-core/lai/tests/tags.yml | 2 + 7 files changed, 322 insertions(+) create mode 100644 modules/nf-core/lai/environment.yml create mode 100644 modules/nf-core/lai/main.nf create mode 100644 modules/nf-core/lai/meta.yml create mode 100644 modules/nf-core/lai/tests/main.nf.test create mode 100644 modules/nf-core/lai/tests/main.nf.test.snap create mode 100644 modules/nf-core/lai/tests/nextflow.config create mode 100644 modules/nf-core/lai/tests/tags.yml diff --git a/modules/nf-core/lai/environment.yml b/modules/nf-core/lai/environment.yml new file mode 100644 index 00000000000..94fadbd2846 --- /dev/null +++ b/modules/nf-core/lai/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "lai" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::LTR_retriever=2.9.0" diff --git a/modules/nf-core/lai/main.nf b/modules/nf-core/lai/main.nf new file mode 100644 index 00000000000..2e7b7ba1ecf --- /dev/null +++ b/modules/nf-core/lai/main.nf @@ -0,0 +1,71 @@ +process LAI { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ltr_retriever:2.9.0--hdfd78af_2': + 'biocontainers/ltr_retriever:2.9.0--hdfd78af_2' }" + + input: + tuple val(meta), path(fasta) + path pass_list + path annotation_out + path monoploid_seqs + + output: + tuple val(meta), path("*.LAI.log") , emit: log + tuple val(meta), path("*.LAI.out") , emit: lai_out , optional: true + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def monoploid_param = monoploid_seqs ? "-mono $monoploid_seqs" : '' + def lai_output_name = monoploid_seqs ? "${annotation_out}.${monoploid_seqs}.out.LAI" : "${annotation_out}.LAI" + def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + """ + # Remove comments from genome fasta, + # otherwise LAI triggers its sequence name change logic + + sed \\ + '/^>/ s/\\s.*\$//' \\ + $fasta \\ + > for_lai_no_comments.fsa + + LAI \\ + -genome for_lai_no_comments.fsa \\ + -intact $pass_list \\ + -all $annotation_out \\ + -t $task.cpus \\ + $monoploid_param \\ + $args \\ + > "${prefix}.LAI.log" + + mv \\ + $lai_output_name \\ + "${prefix}.LAI.out" \\ + || echo "LAI did not produce the output file" + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + lai: $VERSION + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + """ + touch ${prefix}.LAI.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + lai: $VERSION + END_VERSIONS + """ +} diff --git a/modules/nf-core/lai/meta.yml b/modules/nf-core/lai/meta.yml new file mode 100644 index 00000000000..6fd7aef625b --- /dev/null +++ b/modules/nf-core/lai/meta.yml @@ -0,0 +1,68 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "lai" +description: Estimates the mean LTR sequence identity in the genome +keywords: + - genomics + - annotation + - repeat + - long terminal retrotransposon + - retrotransposon + - stats + - qc +tools: + - "lai": + description: Assessing genome assembly quality using the LTR Assembly Index (LAI) + homepage: "https://github.com/oushujun/LTR_retriever" + documentation: "https://github.com/oushujun/LTR_retriever" + tool_dev_url: "https://github.com/oushujun/LTR_retriever" + doi: "10.1093/nar/gky730" + licence: ["GPL v3"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1' ]` + - fasta: + type: file + description: The genome file that is used to generate everything + pattern: "*.{fsa,fa,fasta}" + - pass_list: + type: file + description: A list of intact LTR-RTs generated by LTR_retriever + pattern: "*.pass.list" + - annotation_out: + type: file + description: RepeatMasker annotation of all LTR sequences in the genome + pattern: "*.out" + - monoploid_seqs: + type: file + description: | + This parameter is mainly for ployploid genomes. User provides a list of + sequence names that represent a monoploid (1x). LAI will be calculated only + on these sequences if provided. + pattern: "*.txt" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - log: + type: file + description: Log from LAI + pattern: "*.LAI.log" + - lai_out: + type: file + description: | + Output file from LAI if LAI is able to estimate the index from the inputs + pattern: "*.LAI.out" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@GallVp" +maintainers: + - "@GallVp" diff --git a/modules/nf-core/lai/tests/main.nf.test b/modules/nf-core/lai/tests/main.nf.test new file mode 100644 index 00000000000..afc8f8c0010 --- /dev/null +++ b/modules/nf-core/lai/tests/main.nf.test @@ -0,0 +1,115 @@ +nextflow_process { + + name "Test Process LAI" + script "../main.nf" + process "LAI" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "lai" + tag "gt/suffixerator" + tag "gt/ltrharvest" + tag "ltrretriever" + + test("homo_sapiens-genome_21_fasta-success") { + + setup { + run("GT_SUFFIXERATOR") { + script "../../gt/suffixerator" + + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + ] + input[1] = 'dna' + """ + } + } + + run("GT_LTRHARVEST") { + script "../../gt/ltrharvest" + + process { + """ + input[0] = GT_SUFFIXERATOR.out.index + """ + } + } + + run("LTRRETRIEVER") { + script "../../ltrretriever" + + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + ] + input[1] = GT_LTRHARVEST.out.tabout.map { meta, tabout -> tabout } + input[2] = [] + input[3] = [] + input[4] = [] + """ + } + } + } + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + ] + input[1] = LTRRETRIEVER.out.pass_list.map { meta, pass_list -> pass_list } + input[2] = LTRRETRIEVER.out.annotation_out.map { meta, annotation_out -> annotation_out } + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert path(process.out.log.get(0).get(1)).text.contains("Dependency checking: Passed!") }, + { assert path(process.out.log.get(0).get(1)).text.contains("Calculate LAI:") }, + { assert path(process.out.log.get(0).get(1)).text.contains("Sorry, LAI is not applicable on the current genome assembly.") }, + { assert process.out.lai_out == [] }, + { assert snapshot(process.out.versions).match("versions") } + ) + } + + } + + test("stub") { + + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + ] + input[1] = [] + input[2] = [] + input[3] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() }, + { assert snapshot(process.out.versions).match("versions") } + ) + } + + } + +} diff --git a/modules/nf-core/lai/tests/main.nf.test.snap b/modules/nf-core/lai/tests/main.nf.test.snap new file mode 100644 index 00000000000..f58ca8b7e8c --- /dev/null +++ b/modules/nf-core/lai/tests/main.nf.test.snap @@ -0,0 +1,45 @@ +{ + "versions": { + "content": [ + [ + "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" + ] + ], + "timestamp": "2024-01-19T12:05:38.673249" + }, + "stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.LAI.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" + ], + "lai_out": [ + + ], + "log": [ + [ + { + "id": "test" + }, + "test.LAI.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" + ] + } + ], + "timestamp": "2024-01-19T12:05:58.781814" + } +} \ No newline at end of file diff --git a/modules/nf-core/lai/tests/nextflow.config b/modules/nf-core/lai/tests/nextflow.config new file mode 100644 index 00000000000..0df81b16bfe --- /dev/null +++ b/modules/nf-core/lai/tests/nextflow.config @@ -0,0 +1,12 @@ +process { + + withName: GT_SUFFIXERATOR { + ext.args = '-suf -lcp' + // GT_LTRHARVEST requires -suf, -lcp + } + + withName: GT_LTRHARVEST { + ext.args = '-minlenltr 100 -maxlenltr 7000 -mintsd 4 -maxtsd 6 -motif TGCA -motifmis 1 -similar 85 -vic 10 -seed 20 -seqids yes' + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage + } +} diff --git a/modules/nf-core/lai/tests/tags.yml b/modules/nf-core/lai/tests/tags.yml new file mode 100644 index 00000000000..dfc92643fec --- /dev/null +++ b/modules/nf-core/lai/tests/tags.yml @@ -0,0 +1,2 @@ +lai: + - "modules/nf-core/lai/**" From 7a53bab96dd7cf09f86129082b5077f3744d765b Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 15 Feb 2024 12:51:01 +1300 Subject: [PATCH 2/5] Added tests with larger local data --- modules/nf-core/lai/main.nf | 15 ++---- modules/nf-core/lai/meta.yml | 4 +- modules/nf-core/lai/tests/main.nf.test | 60 +++++++++++++++------ modules/nf-core/lai/tests/main.nf.test.snap | 4 +- modules/nf-core/lai/tests/nextflow.config | 14 +++-- 5 files changed, 62 insertions(+), 35 deletions(-) diff --git a/modules/nf-core/lai/main.nf b/modules/nf-core/lai/main.nf index 2e7b7ba1ecf..a1752b74800 100644 --- a/modules/nf-core/lai/main.nf +++ b/modules/nf-core/lai/main.nf @@ -28,27 +28,20 @@ process LAI { def lai_output_name = monoploid_seqs ? "${annotation_out}.${monoploid_seqs}.out.LAI" : "${annotation_out}.LAI" def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. """ - # Remove comments from genome fasta, - # otherwise LAI triggers its sequence name change logic - - sed \\ - '/^>/ s/\\s.*\$//' \\ - $fasta \\ - > for_lai_no_comments.fsa - LAI \\ - -genome for_lai_no_comments.fsa \\ + -genome $fasta \\ -intact $pass_list \\ -all $annotation_out \\ -t $task.cpus \\ $monoploid_param \\ $args \\ - > "${prefix}.LAI.log" + > >(tee "${prefix}.LAI.log") \\ + || echo "LAI failed! See ${prefix}.LAI.log" mv \\ $lai_output_name \\ "${prefix}.LAI.out" \\ - || echo "LAI did not produce the output file" + || echo "LAI failed to estimate assembly index. See ${prefix}.LAI.log" cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/lai/meta.yml b/modules/nf-core/lai/meta.yml index 6fd7aef625b..2a8fad72532 100644 --- a/modules/nf-core/lai/meta.yml +++ b/modules/nf-core/lai/meta.yml @@ -1,7 +1,9 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "lai" -description: Estimates the mean LTR sequence identity in the genome +description: | + Estimates the mean LTR sequence identity in the genome. The input genome fasta should + have short alphanumeric IDs without comments keywords: - genomics - annotation diff --git a/modules/nf-core/lai/tests/main.nf.test b/modules/nf-core/lai/tests/main.nf.test index afc8f8c0010..9768d7c05c3 100644 --- a/modules/nf-core/lai/tests/main.nf.test +++ b/modules/nf-core/lai/tests/main.nf.test @@ -15,15 +15,26 @@ nextflow_process { test("homo_sapiens-genome_21_fasta-success") { setup { - run("GT_SUFFIXERATOR") { - script "../../gt/suffixerator" + + run("GUNZIP") { + script "../../gunzip" process { """ input[0] = [ [ id:'test' ], - file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + file('/Users/hrauxr/Projects/nf-modules/tests/data/zenodo/actinidia_chinensis/chr1_7M.fasta.gz', checkIfExists: true) ] + """ + } + } + + run("GT_SUFFIXERATOR") { + script "../../gt/suffixerator" + + process { + """ + input[0] = GUNZIP.out.gunzip input[1] = 'dna' """ } @@ -39,16 +50,33 @@ nextflow_process { } } + run("LTRFINDER") { + script "../../ltrfinder" + + process { + """ + input[0] = GUNZIP.out.gunzip + """ + } + } + + run("CAT_CAT") { + script "../../cat/cat" + + process { + """ + input[0] = GT_LTRHARVEST.out.tabout.mix(LTRFINDER.out.scn).groupTuple() + """ + } + } + run("LTRRETRIEVER") { script "../../ltrretriever" process { """ - input[0] = [ - [ id:'test' ], - file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) - ] - input[1] = GT_LTRHARVEST.out.tabout.map { meta, tabout -> tabout } + input[0] = GUNZIP.out.gunzip + input[1] = CAT_CAT.out.file_out.map { meta, tabout -> tabout } input[2] = [] input[3] = [] input[4] = [] @@ -60,10 +88,7 @@ nextflow_process { when { process { """ - input[0] = [ - [ id:'test' ], - file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) - ] + input[0] = GUNZIP.out.gunzip input[1] = LTRRETRIEVER.out.pass_list.map { meta, pass_list -> pass_list } input[2] = LTRRETRIEVER.out.annotation_out.map { meta, annotation_out -> annotation_out } input[3] = [] @@ -74,10 +99,11 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert path(process.out.log.get(0).get(1)).text.contains("Dependency checking: Passed!") }, - { assert path(process.out.log.get(0).get(1)).text.contains("Calculate LAI:") }, - { assert path(process.out.log.get(0).get(1)).text.contains("Sorry, LAI is not applicable on the current genome assembly.") }, - { assert process.out.lai_out == [] }, + { assert path(process.out.log[0][1]).text.contains("Dependency checking: Passed!") }, + { assert path(process.out.log[0][1]).text.contains("Calculate LAI:") }, + { assert path(process.out.log[0][1]).text.contains("Done!") }, + { assert path(process.out.log[0][1]).text.contains("Result file:") }, + { assert Math.abs(Float.parseFloat(path(process.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 }, { assert snapshot(process.out.versions).match("versions") } ) } @@ -93,7 +119,7 @@ nextflow_process { """ input[0] = [ [ id:'test' ], - file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + file('/Users/hrauxr/Projects/nf-modules/tests/data/zenodo/actinidia_chinensis/chr1_7M.fasta.gz', checkIfExists: true) ] input[1] = [] input[2] = [] diff --git a/modules/nf-core/lai/tests/main.nf.test.snap b/modules/nf-core/lai/tests/main.nf.test.snap index f58ca8b7e8c..0b95b2f9030 100644 --- a/modules/nf-core/lai/tests/main.nf.test.snap +++ b/modules/nf-core/lai/tests/main.nf.test.snap @@ -5,7 +5,7 @@ "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" ] ], - "timestamp": "2024-01-19T12:05:38.673249" + "timestamp": "2024-02-02T12:38:52.348234" }, "stub": { "content": [ @@ -40,6 +40,6 @@ ] } ], - "timestamp": "2024-01-19T12:05:58.781814" + "timestamp": "2024-02-02T12:38:56.62072" } } \ No newline at end of file diff --git a/modules/nf-core/lai/tests/nextflow.config b/modules/nf-core/lai/tests/nextflow.config index 0df81b16bfe..6b6bcccefd9 100644 --- a/modules/nf-core/lai/tests/nextflow.config +++ b/modules/nf-core/lai/tests/nextflow.config @@ -1,12 +1,18 @@ process { - + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage withName: GT_SUFFIXERATOR { - ext.args = '-suf -lcp' - // GT_LTRHARVEST requires -suf, -lcp + ext.args = '-tis -suf -lcp -des -ssp -sds' } withName: GT_LTRHARVEST { ext.args = '-minlenltr 100 -maxlenltr 7000 -mintsd 4 -maxtsd 6 -motif TGCA -motifmis 1 -similar 85 -vic 10 -seed 20 -seqids yes' - // recommended parameters: https://github.com/oushujun/LTR_retriever#usage + } + + withName: LTRFINDER { + ext.args = '-harvest_out -size 1000000 -time 300' + } + + withName: CAT_CAT { + ext.prefix = { "${meta.id}_ltrharvest_ltrfinder.tabout" } } } From 4678f19f8dd93f88cb2c19917d0303d5228e2067 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 22 Feb 2024 19:20:50 +1300 Subject: [PATCH 3/5] Added ltrharvest to lai test --- modules/nf-core/lai/tests/tags.yml | 2 - .../{ => ltrretriever}/lai/environment.yml | 4 +- .../nf-core/{ => ltrretriever}/lai/main.nf | 6 +-- .../nf-core/{ => ltrretriever}/lai/meta.yml | 2 +- .../{ => ltrretriever}/lai/tests/main.nf.test | 48 ++++++++----------- .../lai/tests/main.nf.test.snap | 0 .../lai/tests/nextflow.config | 8 ++-- .../nf-core/ltrretriever/lai/tests/tags.yml | 2 + 8 files changed, 30 insertions(+), 42 deletions(-) delete mode 100644 modules/nf-core/lai/tests/tags.yml rename modules/nf-core/{ => ltrretriever}/lai/environment.yml (75%) rename modules/nf-core/{ => ltrretriever}/lai/main.nf (94%) rename modules/nf-core/{ => ltrretriever}/lai/meta.yml (98%) rename modules/nf-core/{ => ltrretriever}/lai/tests/main.nf.test (69%) rename modules/nf-core/{ => ltrretriever}/lai/tests/main.nf.test.snap (100%) rename modules/nf-core/{ => ltrretriever}/lai/tests/nextflow.config (63%) create mode 100644 modules/nf-core/ltrretriever/lai/tests/tags.yml diff --git a/modules/nf-core/lai/tests/tags.yml b/modules/nf-core/lai/tests/tags.yml deleted file mode 100644 index dfc92643fec..00000000000 --- a/modules/nf-core/lai/tests/tags.yml +++ /dev/null @@ -1,2 +0,0 @@ -lai: - - "modules/nf-core/lai/**" diff --git a/modules/nf-core/lai/environment.yml b/modules/nf-core/ltrretriever/lai/environment.yml similarity index 75% rename from modules/nf-core/lai/environment.yml rename to modules/nf-core/ltrretriever/lai/environment.yml index 94fadbd2846..e0e4968237b 100644 --- a/modules/nf-core/lai/environment.yml +++ b/modules/nf-core/ltrretriever/lai/environment.yml @@ -1,9 +1,9 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json -name: "lai" +name: "ltrretriever_lai" channels: - conda-forge - bioconda - defaults dependencies: - - "bioconda::LTR_retriever=2.9.0" + - "bioconda::LTR_retriever=2.9.9" diff --git a/modules/nf-core/lai/main.nf b/modules/nf-core/ltrretriever/lai/main.nf similarity index 94% rename from modules/nf-core/lai/main.nf rename to modules/nf-core/ltrretriever/lai/main.nf index a1752b74800..232d3386d7a 100644 --- a/modules/nf-core/lai/main.nf +++ b/modules/nf-core/ltrretriever/lai/main.nf @@ -1,11 +1,11 @@ -process LAI { +process LTRRETRIEVER_LAI { tag "$meta.id" label 'process_medium' conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/ltr_retriever:2.9.0--hdfd78af_2': - 'biocontainers/ltr_retriever:2.9.0--hdfd78af_2' }" + 'https://depot.galaxyproject.org/singularity/ltr_retriever:2.9.9--hdfd78af_0': + 'biocontainers/ltr_retriever:2.9.9--hdfd78af_0' }" input: tuple val(meta), path(fasta) diff --git a/modules/nf-core/lai/meta.yml b/modules/nf-core/ltrretriever/lai/meta.yml similarity index 98% rename from modules/nf-core/lai/meta.yml rename to modules/nf-core/ltrretriever/lai/meta.yml index 2a8fad72532..f84cf6ca329 100644 --- a/modules/nf-core/lai/meta.yml +++ b/modules/nf-core/ltrretriever/lai/meta.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json -name: "lai" +name: "ltrretriever_lai" description: | Estimates the mean LTR sequence identity in the genome. The input genome fasta should have short alphanumeric IDs without comments diff --git a/modules/nf-core/lai/tests/main.nf.test b/modules/nf-core/ltrretriever/lai/tests/main.nf.test similarity index 69% rename from modules/nf-core/lai/tests/main.nf.test rename to modules/nf-core/ltrretriever/lai/tests/main.nf.test index 9768d7c05c3..1f668ed660f 100644 --- a/modules/nf-core/lai/tests/main.nf.test +++ b/modules/nf-core/ltrretriever/lai/tests/main.nf.test @@ -1,57 +1,49 @@ nextflow_process { - name "Test Process LAI" + name "Test Process LTRRETRIEVER_LAI" script "../main.nf" - process "LAI" + process "LTRRETRIEVER_LAI" config "./nextflow.config" tag "modules" tag "modules_nfcore" - tag "lai" - tag "gt/suffixerator" - tag "gt/ltrharvest" + tag "gunzip" tag "ltrretriever" + tag "ltrretriever/ltrretriever" + tag "ltrretriever/lai" + tag "ltrharvest" + tag "ltrfinder" + tag "cat/cat" - test("homo_sapiens-genome_21_fasta-success") { + test("actinidia_chinensis-genome_21_fasta_gz-success") { setup { run("GUNZIP") { - script "../../gunzip" + script "../../../gunzip" process { """ input[0] = [ [ id:'test' ], - file('/Users/hrauxr/Projects/nf-modules/tests/data/zenodo/actinidia_chinensis/chr1_7M.fasta.gz', checkIfExists: true) + file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) ] """ } } - run("GT_SUFFIXERATOR") { - script "../../gt/suffixerator" + run("LTRHARVEST") { + script "../../../ltrharvest" process { """ input[0] = GUNZIP.out.gunzip - input[1] = 'dna' - """ - } - } - - run("GT_LTRHARVEST") { - script "../../gt/ltrharvest" - - process { - """ - input[0] = GT_SUFFIXERATOR.out.index """ } } run("LTRFINDER") { - script "../../ltrfinder" + script "../../../ltrfinder" process { """ @@ -61,7 +53,7 @@ nextflow_process { } run("CAT_CAT") { - script "../../cat/cat" + script "../../../cat/cat" process { """ @@ -71,7 +63,7 @@ nextflow_process { } run("LTRRETRIEVER") { - script "../../ltrretriever" + script "../../../ltrretriever" process { """ @@ -103,8 +95,7 @@ nextflow_process { { assert path(process.out.log[0][1]).text.contains("Calculate LAI:") }, { assert path(process.out.log[0][1]).text.contains("Done!") }, { assert path(process.out.log[0][1]).text.contains("Result file:") }, - { assert Math.abs(Float.parseFloat(path(process.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 }, - { assert snapshot(process.out.versions).match("versions") } + { assert Math.abs(Float.parseFloat(path(process.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 } ) } @@ -119,7 +110,7 @@ nextflow_process { """ input[0] = [ [ id:'test' ], - file('/Users/hrauxr/Projects/nf-modules/tests/data/zenodo/actinidia_chinensis/chr1_7M.fasta.gz', checkIfExists: true) + file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) ] input[1] = [] input[2] = [] @@ -131,8 +122,7 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() }, - { assert snapshot(process.out.versions).match("versions") } + { assert snapshot(process.out).match() } ) } diff --git a/modules/nf-core/lai/tests/main.nf.test.snap b/modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap similarity index 100% rename from modules/nf-core/lai/tests/main.nf.test.snap rename to modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap diff --git a/modules/nf-core/lai/tests/nextflow.config b/modules/nf-core/ltrretriever/lai/tests/nextflow.config similarity index 63% rename from modules/nf-core/lai/tests/nextflow.config rename to modules/nf-core/ltrretriever/lai/tests/nextflow.config index 6b6bcccefd9..ccf86b75a3d 100644 --- a/modules/nf-core/lai/tests/nextflow.config +++ b/modules/nf-core/ltrretriever/lai/tests/nextflow.config @@ -1,15 +1,13 @@ process { - // recommended parameters: https://github.com/oushujun/LTR_retriever#usage - withName: GT_SUFFIXERATOR { - ext.args = '-tis -suf -lcp -des -ssp -sds' - } - withName: GT_LTRHARVEST { + withName: LTRHARVEST { ext.args = '-minlenltr 100 -maxlenltr 7000 -mintsd 4 -maxtsd 6 -motif TGCA -motifmis 1 -similar 85 -vic 10 -seed 20 -seqids yes' + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage } withName: LTRFINDER { ext.args = '-harvest_out -size 1000000 -time 300' + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage } withName: CAT_CAT { diff --git a/modules/nf-core/ltrretriever/lai/tests/tags.yml b/modules/nf-core/ltrretriever/lai/tests/tags.yml new file mode 100644 index 00000000000..470f4687768 --- /dev/null +++ b/modules/nf-core/ltrretriever/lai/tests/tags.yml @@ -0,0 +1,2 @@ +ltrretriever/lai: + - "modules/nf-core/ltrretriever/lai/**" From c355074ebfeb5a9a784fd82baa189a96aaa94941 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 22 Feb 2024 20:29:41 +1300 Subject: [PATCH 4/5] Updated tests for lai --- modules/nf-core/ltrretriever/lai/main.nf | 15 +++- .../ltrretriever/lai/tests/main.nf.test | 49 ++++++++++-- .../ltrretriever/lai/tests/main.nf.test.snap | 77 ++++++++++++++++--- .../ltrretriever/lai/tests/nextflow.config | 5 +- 4 files changed, 122 insertions(+), 24 deletions(-) diff --git a/modules/nf-core/ltrretriever/lai/main.nf b/modules/nf-core/ltrretriever/lai/main.nf index 232d3386d7a..464b215b892 100644 --- a/modules/nf-core/ltrretriever/lai/main.nf +++ b/modules/nf-core/ltrretriever/lai/main.nf @@ -50,11 +50,18 @@ process LTRRETRIEVER_LAI { """ stub: - def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" - def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def monoploid_param = monoploid_seqs ? "-mono $monoploid_seqs" : '' + def lai_output_name = monoploid_seqs ? "${annotation_out}.${monoploid_seqs}.out.LAI" : "${annotation_out}.LAI" + def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. """ - touch ${prefix}.LAI.log + touch "${prefix}.LAI.log" + touch "$lai_output_name" + + mv \\ + $lai_output_name \\ + "${prefix}.LAI.out" cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/ltrretriever/lai/tests/main.nf.test b/modules/nf-core/ltrretriever/lai/tests/main.nf.test index 1f668ed660f..df7db2cf0a1 100644 --- a/modules/nf-core/ltrretriever/lai/tests/main.nf.test +++ b/modules/nf-core/ltrretriever/lai/tests/main.nf.test @@ -57,13 +57,13 @@ nextflow_process { process { """ - input[0] = GT_LTRHARVEST.out.tabout.mix(LTRFINDER.out.scn).groupTuple() + input[0] = LTRHARVEST.out.scn.mix(LTRFINDER.out.scn).groupTuple() """ } } - run("LTRRETRIEVER") { - script "../../../ltrretriever" + run("LTRRETRIEVER_LTRRETRIEVER") { + script "../../ltrretriever" process { """ @@ -81,8 +81,8 @@ nextflow_process { process { """ input[0] = GUNZIP.out.gunzip - input[1] = LTRRETRIEVER.out.pass_list.map { meta, pass_list -> pass_list } - input[2] = LTRRETRIEVER.out.annotation_out.map { meta, annotation_out -> annotation_out } + input[1] = LTRRETRIEVER_LTRRETRIEVER.out.pass_list.map { meta, pass_list -> pass_list } + input[2] = LTRRETRIEVER_LTRRETRIEVER.out.annotation_out.map { meta, annotation_out -> annotation_out } input[3] = [] """ } @@ -108,12 +108,16 @@ nextflow_process { when { process { """ + def pass_list = new File('test.pass.list') + def out_file = new File('test.out') + def monoploid_seqs = new File('some_seqs.list.txt') + input[0] = [ [ id:'test' ], file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) ] - input[1] = [] - input[2] = [] + input[1] = pass_list.toPath() + input[2] = out_file.toPath() input[3] = [] """ } @@ -128,4 +132,35 @@ nextflow_process { } + test("stub_with_monoploid_seqs") { + + options '-stub' + + when { + process { + """ + def pass_list = new File('test.pass.list') + def out_file = new File('test.out') + def monoploid_seqs = new File('some_seqs.list.txt') + + input[0] = [ + [ id:'test' ], + file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true) + ] + input[1] = pass_list.toPath() + input[2] = out_file.toPath() + input[3] = monoploid_seqs.toPath() + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + } diff --git a/modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap b/modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap index 0b95b2f9030..e1c8086bc3a 100644 --- a/modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap +++ b/modules/nf-core/ltrretriever/lai/tests/main.nf.test.snap @@ -1,13 +1,54 @@ { - "versions": { + "stub": { "content": [ - [ - "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" - ] + { + "0": [ + [ + { + "id": "test" + }, + "test.LAI.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.LAI.out:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,e04e27f9408e771795cd44d96518b7cd" + ], + "lai_out": [ + [ + { + "id": "test" + }, + "test.LAI.out:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "log": [ + [ + { + "id": "test" + }, + "test.LAI.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,e04e27f9408e771795cd44d96518b7cd" + ] + } ], - "timestamp": "2024-02-02T12:38:52.348234" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-22T20:09:00.558021" }, - "stub": { + "stub_with_monoploid_seqs": { "content": [ { "0": [ @@ -19,13 +60,23 @@ ] ], "1": [ - + [ + { + "id": "test" + }, + "test.LAI.out:md5,d41d8cd98f00b204e9800998ecf8427e" + ] ], "2": [ - "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" + "versions.yml:md5,e04e27f9408e771795cd44d96518b7cd" ], "lai_out": [ - + [ + { + "id": "test" + }, + "test.LAI.out:md5,d41d8cd98f00b204e9800998ecf8427e" + ] ], "log": [ [ @@ -36,10 +87,14 @@ ] ], "versions": [ - "versions.yml:md5,2ac93e1e6324236af6f9a794bbac2099" + "versions.yml:md5,e04e27f9408e771795cd44d96518b7cd" ] } ], - "timestamp": "2024-02-02T12:38:56.62072" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-22T20:10:08.213842" } } \ No newline at end of file diff --git a/modules/nf-core/ltrretriever/lai/tests/nextflow.config b/modules/nf-core/ltrretriever/lai/tests/nextflow.config index ccf86b75a3d..2faabca9fe0 100644 --- a/modules/nf-core/ltrretriever/lai/tests/nextflow.config +++ b/modules/nf-core/ltrretriever/lai/tests/nextflow.config @@ -1,13 +1,14 @@ process { withName: LTRHARVEST { + ext.prefix = { "${meta.id}_ltrharvest" } ext.args = '-minlenltr 100 -maxlenltr 7000 -mintsd 4 -maxtsd 6 -motif TGCA -motifmis 1 -similar 85 -vic 10 -seed 20 -seqids yes' - // recommended parameters: https://github.com/oushujun/LTR_retriever#usage + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage } withName: LTRFINDER { ext.args = '-harvest_out -size 1000000 -time 300' - // recommended parameters: https://github.com/oushujun/LTR_retriever#usage + // recommended parameters: https://github.com/oushujun/LTR_retriever#usage } withName: CAT_CAT { From 1e81d01bac78b08903346dac46bfa2feda69dfae Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 22 Feb 2024 21:06:53 +1300 Subject: [PATCH 5/5] Removed unnecessary args --- modules/nf-core/ltrretriever/lai/tests/nextflow.config | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/nf-core/ltrretriever/lai/tests/nextflow.config b/modules/nf-core/ltrretriever/lai/tests/nextflow.config index 2faabca9fe0..75edf1a996b 100644 --- a/modules/nf-core/ltrretriever/lai/tests/nextflow.config +++ b/modules/nf-core/ltrretriever/lai/tests/nextflow.config @@ -2,8 +2,6 @@ process { withName: LTRHARVEST { ext.prefix = { "${meta.id}_ltrharvest" } - ext.args = '-minlenltr 100 -maxlenltr 7000 -mintsd 4 -maxtsd 6 -motif TGCA -motifmis 1 -similar 85 -vic 10 -seed 20 -seqids yes' - // recommended parameters: https://github.com/oushujun/LTR_retriever#usage } withName: LTRFINDER {