From d1535889747781d919bc81da2344952f4bfa2be4 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Wed, 3 Jul 2024 18:50:24 +1200 Subject: [PATCH] Added agat/spfilterfeaturefromkilllist (#5771) * Added agat/spfilterfeaturefromkilllist * Added AGAT config * Included test with agat config --- .../environment.yml | 9 ++ .../agat/spfilterfeaturefromkilllist/main.nf | 53 +++++++++ .../agat/spfilterfeaturefromkilllist/meta.yml | 60 ++++++++++ .../tests/main.nf.test | 104 ++++++++++++++++++ .../tests/main.nf.test.snap | 101 +++++++++++++++++ tests/config/test_data.config | 7 +- 6 files changed, 331 insertions(+), 3 deletions(-) create mode 100644 modules/nf-core/agat/spfilterfeaturefromkilllist/environment.yml create mode 100644 modules/nf-core/agat/spfilterfeaturefromkilllist/main.nf create mode 100644 modules/nf-core/agat/spfilterfeaturefromkilllist/meta.yml create mode 100644 modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test create mode 100644 modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test.snap diff --git a/modules/nf-core/agat/spfilterfeaturefromkilllist/environment.yml b/modules/nf-core/agat/spfilterfeaturefromkilllist/environment.yml new file mode 100644 index 00000000000..fb2df4893d7 --- /dev/null +++ b/modules/nf-core/agat/spfilterfeaturefromkilllist/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "agat_spfilterfeaturefromkilllist" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::agat=1.4.0" diff --git a/modules/nf-core/agat/spfilterfeaturefromkilllist/main.nf b/modules/nf-core/agat/spfilterfeaturefromkilllist/main.nf new file mode 100644 index 00000000000..4918ed7f340 --- /dev/null +++ b/modules/nf-core/agat/spfilterfeaturefromkilllist/main.nf @@ -0,0 +1,53 @@ +process AGAT_SPFILTERFEATUREFROMKILLLIST { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/agat:1.4.0--pl5321hdfd78af_0': + 'biocontainers/agat:1.4.0--pl5321hdfd78af_0' }" + + input: + tuple val(meta), path(gff) + path kill_list + path config + + output: + tuple val(meta), path("*.gff"), emit: gff + 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 config_param = config ? "--config $config" : '' + if( "$gff" == "${prefix}.gff" ) error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + agat_sp_filter_feature_from_kill_list.pl \\ + --gff $gff \\ + --kill_list $kill_list \\ + $config_param \\ + $args \\ + --output "${prefix}.gff" + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + agat: \$(agat_sp_filter_feature_from_kill_list.pl -h | sed -n 's/.*(AGAT) - Version: \\(.*\\) .*/\\1/p') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + if( "$gff" == "${prefix}.gff" ) error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + touch "${prefix}.gff" + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + agat: \$(agat_sp_filter_feature_from_kill_list.pl -h | sed -n 's/.*(AGAT) - Version: \\(.*\\) .*/\\1/p') + END_VERSIONS + """ +} diff --git a/modules/nf-core/agat/spfilterfeaturefromkilllist/meta.yml b/modules/nf-core/agat/spfilterfeaturefromkilllist/meta.yml new file mode 100644 index 00000000000..d408fe7fe3b --- /dev/null +++ b/modules/nf-core/agat/spfilterfeaturefromkilllist/meta.yml @@ -0,0 +1,60 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "agat_spfilterfeaturefromkilllist" +description: | + The script aims to remove features based on a kill list. The default behaviour is to look at the features's ID. + If the feature has an ID (case insensitive) listed among the kill list it will be removed. /!\ Removing a level1 + or level2 feature will automatically remove all linked subfeatures, and removing all children of a feature will + automatically remove this feature too. +keywords: + - genomics + - gff + - remove + - feature +tools: + - "agat": + description: "Another Gff Analysis Toolkit (AGAT). Suite of tools to handle gene annotations in any GTF/GFF format." + homepage: "https://agat.readthedocs.io/en/latest/" + documentation: "https://agat.readthedocs.io/en/latest/tools/agat_sp_filter_feature_from_kill_list.html" + tool_dev_url: "https://github.com/NBISweden/AGAT" + doi: "10.5281/zenodo.3552717" + licence: ["GPL v3"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - gff: + type: file + description: Input GFF3 file that will be read + pattern: "*.{gff,gff3}" + - kill_list: + type: file + description: Kill list. One value per line. + pattern: "*.txt" + - config: + type: file + description: | + Input agat config file. By default AGAT takes as input agat_config.yaml file from the working directory if any, otherwise it takes the orignal agat_config.yaml shipped with AGAT. To get the agat_config.yaml locally type: "agat config --expose". The --config option gives you the possibility to use your own AGAT config file (located elsewhere or named differently). + pattern: "*.yaml" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - gff: + type: file + description: Output GFF file. + pattern: "*.gff" + +authors: + - "@GallVp" +maintainers: + - "@GallVp" diff --git a/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test b/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test new file mode 100644 index 00000000000..82a3c307413 --- /dev/null +++ b/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test @@ -0,0 +1,104 @@ +nextflow_process { + + name "Test Process AGAT_SPFILTERFEATUREFROMKILLLIST" + script "../main.nf" + process "AGAT_SPFILTERFEATUREFROMKILLLIST" + + tag "modules" + tag "modules_nfcore" + tag "agat" + tag "agat/spfilterfeaturefromkilllist" + + test("sarscov2 - gff3") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true) + ] + + def kill_list = "unknown_transcript_1" + def kill_list_file = new File('kill.list.txt') + kill_list_file.text = kill_list + + input[1] = kill_list_file.toPath() + + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - gff3 - config") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true) + ] + + def kill_list = "unknown_transcript_1" + def kill_list_file = new File('kill.list.txt') + kill_list_file.text = kill_list + + input[1] = kill_list_file.toPath() + + input[2] = file(params.modules_testdata_base_path + 'generic/config/agat_config.yaml', checkIfExists: true) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - gff3 - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3', checkIfExists: true) + ] + + def kill_list = "unknown_transcript_1" + def kill_list_file = new File('kill.list.txt') + kill_list_file.text = kill_list + + input[1] = kill_list_file.toPath() + + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} \ No newline at end of file diff --git a/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test.snap b/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test.snap new file mode 100644 index 00000000000..8322d0fd864 --- /dev/null +++ b/modules/nf-core/agat/spfilterfeaturefromkilllist/tests/main.nf.test.snap @@ -0,0 +1,101 @@ +{ + "sarscov2 - gff3 - config": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.gff:md5,df19e1b84ba6f691d20c72b397c88abf" + ] + ], + "1": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ], + "gff": [ + [ + { + "id": "test" + }, + "test.gff:md5,df19e1b84ba6f691d20c72b397c88abf" + ] + ], + "versions": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-07-03T15:32:54.707393" + }, + "sarscov2 - gff3 - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.gff:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ], + "gff": [ + [ + { + "id": "test" + }, + "test.gff:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-07-03T15:32:59.888053" + }, + "sarscov2 - gff3": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.gff:md5,df19e1b84ba6f691d20c72b397c88abf" + ] + ], + "1": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ], + "gff": [ + [ + { + "id": "test" + }, + "test.gff:md5,df19e1b84ba6f691d20c72b397c88abf" + ] + ], + "versions": [ + "versions.yml:md5,e2962240799182aee69421c746be183a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-07-03T15:32:47.772624" + } +} \ No newline at end of file diff --git a/tests/config/test_data.config b/tests/config/test_data.config index 25b2af15db4..a3e87193dd1 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -744,9 +744,10 @@ params { seed_file = "${params.test_data_base}/data/delete_me/estsfs/seedfile.txt" } 'config' { - ncbi_user_settings = "${params.test_data_base}/data/generic/config/ncbi_user_settings.mkfg" - config_test_datavzrd = "${params.test_data_base}/data/generic/config/config_test.datavzrd.yaml" + agat_config = "${params.test_data_base}/data/generic/config/agat_config.yaml" config_network_datavzrd = "${params.test_data_base}/data/generic/config/config_network.datavzrd.yaml" + config_test_datavzrd = "${params.test_data_base}/data/generic/config/config_test.datavzrd.yaml" + ncbi_user_settings = "${params.test_data_base}/data/generic/config/ncbi_user_settings.mkfg" } 'unsorted_data' { 'unsorted_text' { @@ -774,7 +775,7 @@ params { } 'parameter' { maxquant = "${params.test_data_base}/data/proteomics/parameter/mqpar.xml" - sage_base_config = "${params.test_data_base}/data/proteomics/parameter/sage_base_config.json" + sage_base_config = "${params.test_data_base}/data/proteomics/parameter/sage_base_config.json" } 'openms' { idxml1 = "${params.test_data_base}/data/proteomics/openms/HepG2_rep1_small.idXML"