From c415c463fdacb13f7dd81d773c03c28557289a22 Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 14:39:14 +0000 Subject: [PATCH 1/8] Exchange local filefilter module with nf-core module --- conf/modules.config | 2 + modules.json | 5 ++ modules/local/openms_filefilter.nf | 45 ------------ .../nf-core/openms/filefilter/environment.yml | 5 ++ modules/nf-core/openms/filefilter/main.nf | 55 ++++++++++++++ modules/nf-core/openms/filefilter/meta.yml | 70 ++++++++++++++++++ .../openms/filefilter/tests/main.nf.test | 69 ++++++++++++++++++ .../openms/filefilter/tests/main.nf.test.snap | 73 +++++++++++++++++++ .../openms/filefilter/tests/nextflow.config | 6 ++ nextflow.config | 15 ++-- workflows/mhcquant.nf | 4 +- 11 files changed, 294 insertions(+), 55 deletions(-) delete mode 100644 modules/local/openms_filefilter.nf create mode 100644 modules/nf-core/openms/filefilter/environment.yml create mode 100644 modules/nf-core/openms/filefilter/main.nf create mode 100644 modules/nf-core/openms/filefilter/meta.yml create mode 100644 modules/nf-core/openms/filefilter/tests/main.nf.test create mode 100644 modules/nf-core/openms/filefilter/tests/main.nf.test.snap create mode 100644 modules/nf-core/openms/filefilter/tests/nextflow.config diff --git a/conf/modules.config b/conf/modules.config index 52e69c5c..029a7b35 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -221,6 +221,8 @@ process { } withName: 'OPENMS_FILEFILTER' { + ext.prefix = {"${mzml.baseName}_filtered"} + ext.args = "-peak_options:rm_pc_charge 0" publishDir = [ enabled: false ] diff --git a/modules.json b/modules.json index bbad939c..5d26ce24 100644 --- a/modules.json +++ b/modules.json @@ -20,6 +20,11 @@ "git_sha": "bbcad23c681ff85336aef1c41345bc313d921b5d", "installed_by": ["modules"] }, + "openms/filefilter": { + "branch": "master", + "git_sha": "26a34ecd378f06094eb253615932d8cc634474cb", + "installed_by": ["modules"] + }, "openms/idfilter": { "branch": "master", "git_sha": "bbcad23c681ff85336aef1c41345bc313d921b5d", diff --git a/modules/local/openms_filefilter.nf b/modules/local/openms_filefilter.nf deleted file mode 100644 index 292fae42..00000000 --- a/modules/local/openms_filefilter.nf +++ /dev/null @@ -1,45 +0,0 @@ -process OPENMS_FILEFILTER { - tag "$meta.id" - label 'process_low' - - conda "bioconda::openms=3.1.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/openms:3.1.0--h8964181_3' : - 'biocontainers/openms:3.1.0--h8964181_3' }" - - input: - tuple val(meta), path(mzml) - - output: - tuple val(meta), path("*.mzML"), emit: cleaned_mzml - path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - - script: - def prefix = task.ext.prefix ?: "${mzml.baseName}_filtered" - """ - FileFilter -in $mzml \\ - -out ${prefix}.mzML \\ - -peak_options:rm_pc_charge 0 \\ - -threads $task.cpus - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ - - stub: - def prefix = task.ext.prefix ?: "${mzml.baseName}_filtered" - - """ - touch ${prefix}.mzML - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ -} diff --git a/modules/nf-core/openms/filefilter/environment.yml b/modules/nf-core/openms/filefilter/environment.yml new file mode 100644 index 00000000..5ec74436 --- /dev/null +++ b/modules/nf-core/openms/filefilter/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::openms=3.2.0" diff --git a/modules/nf-core/openms/filefilter/main.nf b/modules/nf-core/openms/filefilter/main.nf new file mode 100644 index 00000000..51aeff7b --- /dev/null +++ b/modules/nf-core/openms/filefilter/main.nf @@ -0,0 +1,55 @@ +process OPENMS_FILEFILTER { + 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/openms:3.2.0--haddbca4_4' : + 'biocontainers/openms:3.2.0--haddbca4_4' }" + + input: + tuple val(meta), path(file) + + output: + tuple val(meta), path("*.mzML"), emit: mzml, optional: true + tuple val(meta), path("*.featureXML"), emit: featurexml, optional: true + tuple val(meta), path("*.consensusXML"), emit: consensusxml, 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 suffix = "${file.getExtension()}" + if ("$file" == "${prefix}.${suffix}") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + + """ + FileFilter \\ + -in $file \\ + -out ${prefix}.${suffix} \\ + -threads $task.cpus \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = "${file.getExtension()}" + if ("$file" == "${prefix}.${suffix}") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + + """ + touch ${prefix}.${suffix} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/nf-core/openms/filefilter/meta.yml b/modules/nf-core/openms/filefilter/meta.yml new file mode 100644 index 00000000..4c26bd1e --- /dev/null +++ b/modules/nf-core/openms/filefilter/meta.yml @@ -0,0 +1,70 @@ +name: "openms_filefilter" +description: Filters peptide/protein identification results by different criteria. +keywords: + - filter + - mzML + - openms + - proteomics +tools: + - "openms": + description: "OpenMS is an open-source software C++ library for LC-MS data management + and analyses" + homepage: "https://openms.de" + documentation: "https://openms.readthedocs.io/en/latest/index.html" + tool_dev_url: "https://github.com/OpenMS/OpenMS" + doi: "10.1038/s41592-024-02197-7" + licence: ["BSD"] + identifier: "" + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - file: + type: file + description: Peptide-spectrum matches. + pattern: "*.{mzML,featureXML,consensusXML}" + +output: + - mzml: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - "*.mzML": + type: file + description: Filtered mzML file. + pattern: "*.mzML" + - featurexml: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - "*.featureXML": + type: file + description: Filtered featureXML file. + pattern: "*.featureXML" + - consensusxml: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - "*.consensusXML": + type: file + description: Filtered consensusXML file. + pattern: "*.consensusXML" + - versions: + - versions.yml: + type: file + description: File containing software version + pattern: "versions.yml" + +authors: + - "@jonasscheid" +maintainers: + - "@jonasscheid" diff --git a/modules/nf-core/openms/filefilter/tests/main.nf.test b/modules/nf-core/openms/filefilter/tests/main.nf.test new file mode 100644 index 00000000..fb8334d1 --- /dev/null +++ b/modules/nf-core/openms/filefilter/tests/main.nf.test @@ -0,0 +1,69 @@ +nextflow_process { + + name "Test Process OPENMS_FILEFILTER" + script "../main.nf" + process "OPENMS_FILEFILTER" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "openms" + tag "openms/filefilter" + tag "thermorawfileparser" + + setup { + run("THERMORAWFILEPARSER") { + script "../../../thermorawfileparser/main.nf" + process { + """ + input[0] = Channel.of([ + [ id:'test'], + file(params.modules_testdata_base_path + 'proteomics/msspectra/PXD012083_e005640_II.raw', checkIfExists: true) + ]) + """ + } + } + } + + test("filter - mzml") { + + when { + process { + """ + input[0] = THERMORAWFILEPARSER.out.spectra + """ + } + } + + then { + assertAll( + { assert process.success }, + // work dir is written into xml file. Check only the first few lines + { assert snapshot(path(process.out.mzml[0][1]).readLines().take(15)).match() } + ) + } + + } + + test("filter - mzml - stub") { + + options "-stub" + + when { + process { + """ + input[0] = THERMORAWFILEPARSER.out.spectra + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/openms/filefilter/tests/main.nf.test.snap b/modules/nf-core/openms/filefilter/tests/main.nf.test.snap new file mode 100644 index 00000000..61762bc2 --- /dev/null +++ b/modules/nf-core/openms/filefilter/tests/main.nf.test.snap @@ -0,0 +1,73 @@ +{ + "filter - mzml": { + "content": [ + [ + "", + "", + "", + "\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t", + "\t", + "\t\t", + "\t\t\t", + "\t\t\t", + "\t\t" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-21T13:07:14.535106314" + }, + "filter - mzml - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_filtered.mzML:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + "versions.yml:md5,a8ec8f78f4a0da0328482bf90dc2df00" + ], + "consensusxml": [ + + ], + "featurexml": [ + + ], + "mzml": [ + [ + { + "id": "test" + }, + "test_filtered.mzML:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,a8ec8f78f4a0da0328482bf90dc2df00" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-21T13:09:28.723787747" + } +} \ No newline at end of file diff --git a/modules/nf-core/openms/filefilter/tests/nextflow.config b/modules/nf-core/openms/filefilter/tests/nextflow.config new file mode 100644 index 00000000..7c1eccf5 --- /dev/null +++ b/modules/nf-core/openms/filefilter/tests/nextflow.config @@ -0,0 +1,6 @@ +process { + withName: OPENMS_FILEFILTER { + ext.prefix = {"${meta.id}_filtered"} + ext.args = '-mz 1000:2000' + } +} diff --git a/nextflow.config b/nextflow.config index bc61b1f4..a9e139f3 100644 --- a/nextflow.config +++ b/nextflow.config @@ -250,14 +250,13 @@ env { } // Set bash options -process.shell = """\ -bash - -set -e # Exit if a tool returns a non-zero status/exit code -set -u # Treat unset variables and parameters as an error -set -o pipefail # Returns the status of the last command to exit with a non-zero status or zero if all successfully execute -set -C # No clobber - prevent output redirection from overwriting files. -""" +process.shell = [ + "bash", + "-C", // No clobber - prevent output redirection from overwriting files. + "-e", // Exit if a tool returns a non-zero status/exit code + "-u", // Treat unset variables and parameters as an error + "-o pipefail" // Returns the status of the last command to exit with a non-zero status or zero if all successfully execute +] // Disable process selector warnings by default. Use debug profile to enable warnings. nextflow.enable.configProcessNamesValidation = false diff --git a/workflows/mhcquant.nf b/workflows/mhcquant.nf index d6496094..b2dd5b39 100644 --- a/workflows/mhcquant.nf +++ b/workflows/mhcquant.nf @@ -8,7 +8,6 @@ // MODULE: Loaded from modules/local/ // -include { OPENMS_FILEFILTER } from '../modules/local/openms_filefilter' include { PYOPENMS_CHROMATOGRAMEXTRACTOR } from '../modules/local/pyopenms_chromatogramextractor' include { OPENMS_COMETADAPTER } from '../modules/local/openms_cometadapter' include { OPENMS_PEPTIDEINDEXER } from '../modules/local/openms_peptideindexer' @@ -33,6 +32,7 @@ include { QUANT } from '../subworkflows/local/quant' // // MODULE: Installed directly from nf-core/modules // +include { OPENMS_FILEFILTER } from '../modules/nf-core/openms/filefilter/main' include { OPENMS_DECOYDATABASE } from '../modules/nf-core/openms/decoydatabase/main' include { OPENMS_IDMASSACCURACY } from '../modules/nf-core/openms/idmassaccuracy/main' include { OPENMS_IDMERGER } from '../modules/nf-core/openms/idmerger/main' @@ -77,7 +77,7 @@ workflow MHCQUANT { if (params.filter_mzml){ OPENMS_FILEFILTER(PREPARE_SPECTRA.out.mzml) ch_versions = ch_versions.mix(OPENMS_FILEFILTER.out.versions) - ch_clean_mzml_file = OPENMS_FILEFILTER.out.cleaned_mzml + ch_clean_mzml_file = OPENMS_FILEFILTER.out.mzml } else { ch_clean_mzml_file = PREPARE_SPECTRA.out.mzml } From 74bd372a879f57161cc71a2f3d5aee51b7c8dc35 Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 15:00:23 +0000 Subject: [PATCH 2/8] Replace local with nf-core openms_peptideindexer --- conf/modules.config | 32 ++++---- modules.json | 5 ++ modules/local/openms_peptideindexer.nf | 48 ------------ .../openms/peptideindexer/environment.yml | 6 ++ modules/nf-core/openms/peptideindexer/main.nf | 51 ++++++++++++ .../nf-core/openms/peptideindexer/meta.yml | 56 +++++++++++++ .../openms/peptideindexer/tests/main.nf.test | 78 +++++++++++++++++++ .../peptideindexer/tests/main.nf.test.snap | 68 ++++++++++++++++ .../peptideindexer/tests/nextflow.config | 9 +++ .../openms/peptideindexer/tests/tags.yml | 2 + workflows/mhcquant.nf | 15 ++-- 11 files changed, 300 insertions(+), 70 deletions(-) delete mode 100644 modules/local/openms_peptideindexer.nf create mode 100644 modules/nf-core/openms/peptideindexer/environment.yml create mode 100644 modules/nf-core/openms/peptideindexer/main.nf create mode 100644 modules/nf-core/openms/peptideindexer/meta.yml create mode 100644 modules/nf-core/openms/peptideindexer/tests/main.nf.test create mode 100644 modules/nf-core/openms/peptideindexer/tests/main.nf.test.snap create mode 100644 modules/nf-core/openms/peptideindexer/tests/nextflow.config create mode 100644 modules/nf-core/openms/peptideindexer/tests/tags.yml diff --git a/conf/modules.config b/conf/modules.config index 029a7b35..97e4139f 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -62,6 +62,14 @@ process { ] } + withName: 'OPENMS_FILEFILTER' { + ext.prefix = {"${file.baseName}_filtered"} + ext.args = "-peak_options:rm_pc_charge 0" + publishDir = [ + enabled: false + ] + } + withName: 'OPENMS_DECOYDATABASE' { ext.args = [ "-decoy_string DECOY_", @@ -81,6 +89,16 @@ process { ] } + withName: 'OPENMS_PEPTIDEINDEXER' { + ext.args = [ + "-decoy_string DECOY", + "-enzyme:specificity none" + ].join(' ').trim() + publishDir = [ + enabled: false + ] + } + withName: 'OPENMS_IDMERGER|OPENMS_IDMERGER_QUANT' { ext.args = [ "-annotate_file_origin true", @@ -220,14 +238,6 @@ process { ] } - withName: 'OPENMS_FILEFILTER' { - ext.prefix = {"${mzml.baseName}_filtered"} - ext.args = "-peak_options:rm_pc_charge 0" - publishDir = [ - enabled: false - ] - } - withName: 'PYOPENMS_CHROMATOGRAMEXTRACTOR' { publishDir = [ enabled: false @@ -277,12 +287,6 @@ process { ] } - withName: 'OPENMS_PEPTIDEINDEXER' { - publishDir = [ - enabled: false - ] - } - withName: 'OPENMS_IDMASSACCURACY' { ext.prefix = {"${meta.spectra}"} ext.args = [ diff --git a/modules.json b/modules.json index 5d26ce24..abc1a0c8 100644 --- a/modules.json +++ b/modules.json @@ -55,6 +55,11 @@ "git_sha": "bbcad23c681ff85336aef1c41345bc313d921b5d", "installed_by": ["modules"] }, + "openms/peptideindexer": { + "branch": "master", + "git_sha": "573ba82ecf1505775d1a4332bc3cf55cacc3d094", + "installed_by": ["modules"] + }, "thermorawfileparser": { "branch": "master", "git_sha": "2d0e53d398315b4e8ed06e81c175dc05d90f33d5", diff --git a/modules/local/openms_peptideindexer.nf b/modules/local/openms_peptideindexer.nf deleted file mode 100644 index 162f6abc..00000000 --- a/modules/local/openms_peptideindexer.nf +++ /dev/null @@ -1,48 +0,0 @@ -process OPENMS_PEPTIDEINDEXER { - tag "$meta.id" - label 'process_single' - - conda "bioconda::openms=3.1.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/openms:3.1.0--h8964181_3' : - 'biocontainers/openms:3.1.0--h8964181_3' }" - - input: - tuple val(meta), path(idxml), path(fasta) - - output: - tuple val(meta), path("*.idXML"), emit: idxml - path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - - script: - def prefix = task.ext.prefix ?: "${meta.id}_${meta.sample}_${meta.condition}_idx" - - """ - PeptideIndexer -in $idxml \\ - -out ${prefix}.idXML \\ - -threads $task.cpus \\ - -fasta $fasta \\ - -decoy_string DECOY \\ - -enzyme:specificity none - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ - - stub: - def prefix = task.ext.prefix ?: "${meta.id}_${meta.sample}_${meta.condition}_idx" - - """ - touch ${prefix}.idXML - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ -} diff --git a/modules/nf-core/openms/peptideindexer/environment.yml b/modules/nf-core/openms/peptideindexer/environment.yml new file mode 100644 index 00000000..d6e51812 --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/environment.yml @@ -0,0 +1,6 @@ +--- +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::openms=3.2.0" diff --git a/modules/nf-core/openms/peptideindexer/main.nf b/modules/nf-core/openms/peptideindexer/main.nf new file mode 100644 index 00000000..2bf824c3 --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/main.nf @@ -0,0 +1,51 @@ +process OPENMS_PEPTIDEINDEXER { + 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/openms:3.2.0--haddbca4_4': + 'biocontainers/openms:3.2.0--haddbca4_4' }" + + input: + tuple val(meta), path(id_file) + tuple val(meta), path(id_fasta) + + output: + tuple val(meta), path("*.idXML"), emit: id_file_pi + 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}_pi" + + """ + PeptideIndexer \\ + -in $id_file \\ + -fasta $id_fasta \\ + -out ${prefix}.idXML \\ + -threads $task.cpus \\ + $args \\ + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}_pi" + + """ + touch ${prefix}.idXML + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + openms: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/nf-core/openms/peptideindexer/meta.yml b/modules/nf-core/openms/peptideindexer/meta.yml new file mode 100644 index 00000000..10f808d2 --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/meta.yml @@ -0,0 +1,56 @@ +name: "openms_peptideindexer" +description: Refreshes the protein references for all peptide hits. +keywords: + - refresh + - idXML + - openms + - proteomics +tools: + - "openms": + description: "OpenMS is an open-source software C++ library for LC-MS data management + and analyses" + homepage: "https://openms.de" + documentation: "https://openms.readthedocs.io/en/latest/index.html" + tool_dev_url: "https://github.com/OpenMS/OpenMS" + doi: "10.1038/s41592-024-02197-7" + licence: ["BSD"] + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - id_file: + type: file + description: idXML identification file + pattern: "*.{idXML}" + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - id_fasta: + type: file + description: Input sequence database in FASTA format + pattern: "*.fasta" +output: + - id_file_pi: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.idXML": + type: file + description: Refreshed idXML identification file + pattern: "*.{idXML}" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@jonasscheid" +maintainers: + - "@jonasscheid" diff --git a/modules/nf-core/openms/peptideindexer/tests/main.nf.test b/modules/nf-core/openms/peptideindexer/tests/main.nf.test new file mode 100644 index 00000000..1238bc36 --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/tests/main.nf.test @@ -0,0 +1,78 @@ +nextflow_process { + + name "Test Process OPENMS_PEPTIDEINDEXER" + script "../main.nf" + process "OPENMS_PEPTIDEINDEXER" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "openms" + tag "openms/decoydatabase" + tag "openms/peptideindexer" + + setup { + run("OPENMS_DECOYDATABASE") { + script "../../decoydatabase/main.nf" + process { + """ + input[0] = [ + [id:'test'], + file(params.modules_testdata_base_path + 'proteomics/database/UP000005640_9606.fasta', checkIfExists: true) + ] + """ + } + } + } + + test("proteomics - refresh_idxml") { + + when { + process { + """ + input[0] = [ + [id:'test'], + file(params.modules_testdata_base_path + 'proteomics/openms/HepG2_rep1_small.idXML', checkIfExists: true) + ] + input[1] = OPENMS_DECOYDATABASE.out.decoy_fasta + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("proteomics - refresh_idxml - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [id:'test'], + file(params.modules_testdata_base_path + 'proteomics/openms/HepG2_rep1_small.idXML', checkIfExists: true) + ] + input[1] = OPENMS_DECOYDATABASE.out.decoy_fasta + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/openms/peptideindexer/tests/main.nf.test.snap b/modules/nf-core/openms/peptideindexer/tests/main.nf.test.snap new file mode 100644 index 00000000..bc41f966 --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/tests/main.nf.test.snap @@ -0,0 +1,68 @@ +{ + "proteomics - refresh_idxml": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_pi.idXML:md5,f18620bed99c99f292b4e1804c3a47ad" + ] + ], + "1": [ + "versions.yml:md5,01ee06728114ec0a7b0980ad83eedd42" + ], + "id_file_pi": [ + [ + { + "id": "test" + }, + "test_pi.idXML:md5,f18620bed99c99f292b4e1804c3a47ad" + ] + ], + "versions": [ + "versions.yml:md5,01ee06728114ec0a7b0980ad83eedd42" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-10-08T11:26:20.161342857" + }, + "proteomics - refresh_idxml - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_pi.idXML:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,01ee06728114ec0a7b0980ad83eedd42" + ], + "id_file_pi": [ + [ + { + "id": "test" + }, + "test_pi.idXML:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,01ee06728114ec0a7b0980ad83eedd42" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-10-08T11:26:28.558838022" + } +} \ No newline at end of file diff --git a/modules/nf-core/openms/peptideindexer/tests/nextflow.config b/modules/nf-core/openms/peptideindexer/tests/nextflow.config new file mode 100644 index 00000000..33c1adcd --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/tests/nextflow.config @@ -0,0 +1,9 @@ +process { + + withName:OPENMS_PEPTIDEINDEXER { + + ext.args = "-missing_decoy_action 'silent' -unmatched_action 'remove'" + + } + +} diff --git a/modules/nf-core/openms/peptideindexer/tests/tags.yml b/modules/nf-core/openms/peptideindexer/tests/tags.yml new file mode 100644 index 00000000..027e07cb --- /dev/null +++ b/modules/nf-core/openms/peptideindexer/tests/tags.yml @@ -0,0 +1,2 @@ +openms/peptideindexer: + - "modules/nf-core/openms/peptideindexer/**" diff --git a/workflows/mhcquant.nf b/workflows/mhcquant.nf index b2dd5b39..acfd7cac 100644 --- a/workflows/mhcquant.nf +++ b/workflows/mhcquant.nf @@ -10,7 +10,6 @@ include { PYOPENMS_CHROMATOGRAMEXTRACTOR } from '../modules/local/pyopenms_chromatogramextractor' include { OPENMS_COMETADAPTER } from '../modules/local/openms_cometadapter' -include { OPENMS_PEPTIDEINDEXER } from '../modules/local/openms_peptideindexer' include { DATAMASH_HISTOGRAM } from '../modules/local/datamash_histogram' include { PYOPENMS_IONANNOTATOR } from '../modules/local/pyopenms_ionannotator' include { OPENMS_TEXTEXPORTER } from '../modules/local/openms_textexporter' @@ -35,6 +34,7 @@ include { QUANT } from '../subworkflows/local/quant' include { OPENMS_FILEFILTER } from '../modules/nf-core/openms/filefilter/main' include { OPENMS_DECOYDATABASE } from '../modules/nf-core/openms/decoydatabase/main' include { OPENMS_IDMASSACCURACY } from '../modules/nf-core/openms/idmassaccuracy/main' +include { OPENMS_PEPTIDEINDEXER } from '../modules/nf-core/openms/peptideindexer/main' include { OPENMS_IDMERGER } from '../modules/nf-core/openms/idmerger/main' include { MULTIQC } from '../modules/nf-core/multiqc/main' include { paramsSummaryMap } from 'plugin/nf-schema' @@ -68,9 +68,8 @@ workflow MHCQUANT { OPENMS_DECOYDATABASE(ch_fasta) ch_versions = ch_versions.mix(OPENMS_DECOYDATABASE.out.versions) ch_decoy_db = OPENMS_DECOYDATABASE.out.decoy_fasta - .map{ meta, fasta -> [fasta] } } else { - ch_decoy_db = ch_fasta.map{ meta, fasta -> [fasta] } + ch_decoy_db = ch_fasta } // Optionally clean up mzML files @@ -88,15 +87,15 @@ workflow MHCQUANT { ch_multiqc_files = ch_multiqc_files.mix(PYOPENMS_CHROMATOGRAMEXTRACTOR.out.csv.map{ meta, mzml -> mzml }) // Run comet database search - OPENMS_COMETADAPTER(ch_clean_mzml_file.combine(ch_decoy_db)) + OPENMS_COMETADAPTER(ch_clean_mzml_file.combine(ch_decoy_db.map{ meta, fasta -> [fasta] })) ch_versions = ch_versions.mix(OPENMS_COMETADAPTER.out.versions) // Index decoy and target hits - OPENMS_PEPTIDEINDEXER(OPENMS_COMETADAPTER.out.idxml.combine(ch_decoy_db)) + OPENMS_PEPTIDEINDEXER(OPENMS_COMETADAPTER.out.idxml, ch_decoy_db) ch_versions = ch_versions.mix(OPENMS_PEPTIDEINDEXER.out.versions) // Compute mass errors for multiQC report - OPENMS_IDMASSACCURACY(PREPARE_SPECTRA.out.mzml.join(OPENMS_PEPTIDEINDEXER.out.idxml)) + OPENMS_IDMASSACCURACY(PREPARE_SPECTRA.out.mzml.join(OPENMS_PEPTIDEINDEXER.out.id_file_pi)) ch_versions = ch_versions.mix(OPENMS_IDMASSACCURACY.out.versions) // Bin and count mass errors for multiQC report DATAMASH_HISTOGRAM(OPENMS_IDMASSACCURACY.out.frag_err) @@ -104,12 +103,12 @@ workflow MHCQUANT { ch_multiqc_files = ch_multiqc_files.mix(DATAMASH_HISTOGRAM.out.binned_tsv.map{ meta, frag_err_hist -> frag_err_hist }) // Save indexed runs for later use to keep meta-run information. Sort based on file id - OPENMS_PEPTIDEINDEXER.out.idxml + OPENMS_PEPTIDEINDEXER.out.id_file_pi .map { meta, idxml -> [ groupKey([id: "${meta.sample}_${meta.condition}"], meta.group_count), meta] } .groupTuple() .set { merge_meta_map } - OPENMS_PEPTIDEINDEXER.out.idxml + OPENMS_PEPTIDEINDEXER.out.id_file_pi .map { meta, idxml -> [ groupKey([id: "${meta.sample}_${meta.condition}"], meta.group_count), idxml] } .groupTuple() .set { ch_runs_to_merge } From 5fd303977b9152517af4f9866a3acaaf69c23dea Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 16:04:14 +0000 Subject: [PATCH 3/8] replace cometadapter local with nf-core moule --- conf/modules.config | 59 +++++++------ modules.json | 5 ++ modules/nf-core/openms/peptideindexer/main.nf | 5 +- .../cometadapter/environment.yml | 5 ++ .../openmsthirdparty/cometadapter/main.nf | 55 ++++++++++++ .../openmsthirdparty/cometadapter/meta.yml | 63 ++++++++++++++ .../cometadapter/tests/main.nf.test | 86 +++++++++++++++++++ .../cometadapter/tests/main.nf.test.snap | 59 +++++++++++++ .../cometadapter/tests/nextflow.config | 20 +++++ .../cometadapter/tests/tags.yml | 2 + nextflow.config | 4 +- nextflow_schema.json | 4 +- workflows/mhcquant.nf | 30 ++++--- 13 files changed, 352 insertions(+), 45 deletions(-) create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/environment.yml create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/main.nf create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/meta.yml create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test.snap create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/tests/nextflow.config create mode 100644 modules/nf-core/openmsthirdparty/cometadapter/tests/tags.yml diff --git a/conf/modules.config b/conf/modules.config index 97e4139f..eeb73462 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -89,7 +89,42 @@ process { ] } + withName: 'OPENMSTHIRDPARTY_COMETADAPTER' { + ext.prefix = {"${mzml.baseName}"} + ext.args = { [ + (params.default_params_file_comet != " ") ? "-default_params_file ${params.default_params_file_comet}" : "", + "-pin_out ${mzml.baseName}_pin.tsv", + "-instrument ${params.instrument}", + "-spectrum_batch_size ${params.spectrum_batch_size}", + "-activation_method ${params.activation_method}", + "-precursor_mass_tolerance ${params.precursor_mass_tolerance}", + "-precursor_error_units ${params.precursor_error_units}", + "-fragment_mass_tolerance ${params.fragment_mass_tolerance}", + "-fragment_bin_offset ${params.fragment_bin_offset}", + "-num_hits ${params.num_hits}", + "-digest_mass_range ${params.digest_mass_range}", + "-max_variable_mods_in_peptide ${params.number_mods}", + "-missed_cleavages 0", + "-precursor_charge ${params.prec_charge}", + "-fixed_modifications ${params.fixed_mods.tokenize(',').collect {"'${it}'"}.join(" ")}", + "-variable_modifications ${params.variable_mods.tokenize(',').collect {"'${it}'"}.join(" ")}", + "-enzyme '${params.enzyme}'", + "-use_X_ions ${params.use_x_ions}", + "-use_Z_ions ${params.use_z_ions}", + "-use_A_ions ${params.use_a_ions}", + "-use_C_ions ${params.use_c_ions}", + "-use_NL_ions ${params.use_NL_ions}", + "-remove_precursor_peak ${params.remove_precursor_peak}" + ].join(' ').trim() } + publishDir = [ + path: {"${params.outdir}/intermediate_results/comet"}, + mode: params.publish_dir_mode, + pattern: '*.tsv' + ] + } + withName: 'OPENMS_PEPTIDEINDEXER' { + ext.prefix = {"${meta.id}_idx"} ext.args = [ "-decoy_string DECOY", "-enzyme:specificity none" @@ -263,30 +298,6 @@ process { ] } - withName: 'OPENMS_COMETADAPTER' { - ext.args = [ - "-precursor_mass_tolerance ${params.precursor_mass_tolerance}", - "-precursor_error_units ${params.precursor_error_units}", - "-fragment_mass_tolerance ${params.fragment_mass_tolerance}", - "-fragment_bin_offset ${params.fragment_bin_offset}", - "-instrument ${params.instrument}", - "-num_hits ${params.num_hits}", - "-digest_mass_range ${params.digest_mass_range}", - "-max_variable_mods_in_peptide ${params.number_mods}", - "-missed_cleavages 0", - "-precursor_charge ${params.prec_charge}", - "-activation_method ${params.activation_method}", - "-variable_modifications ${params.variable_mods.tokenize(',').collect {"'${it}'"}.join(" ")}", - "-enzyme '${params.enzyme}'", - "-spectrum_batch_size ${params.spectrum_batch_size}" - ].join(' ').trim() - publishDir = [ - path: {"${params.outdir}/intermediate_results/comet"}, - mode: params.publish_dir_mode, - pattern: '*.tsv' - ] - } - withName: 'OPENMS_IDMASSACCURACY' { ext.prefix = {"${meta.spectra}"} ext.args = [ diff --git a/modules.json b/modules.json index abc1a0c8..1a554afa 100644 --- a/modules.json +++ b/modules.json @@ -60,6 +60,11 @@ "git_sha": "573ba82ecf1505775d1a4332bc3cf55cacc3d094", "installed_by": ["modules"] }, + "openmsthirdparty/cometadapter": { + "branch": "master", + "git_sha": "573ba82ecf1505775d1a4332bc3cf55cacc3d094", + "installed_by": ["modules"] + }, "thermorawfileparser": { "branch": "master", "git_sha": "2d0e53d398315b4e8ed06e81c175dc05d90f33d5", diff --git a/modules/nf-core/openms/peptideindexer/main.nf b/modules/nf-core/openms/peptideindexer/main.nf index 2bf824c3..5cd32f66 100644 --- a/modules/nf-core/openms/peptideindexer/main.nf +++ b/modules/nf-core/openms/peptideindexer/main.nf @@ -8,8 +8,7 @@ process OPENMS_PEPTIDEINDEXER { 'biocontainers/openms:3.2.0--haddbca4_4' }" input: - tuple val(meta), path(id_file) - tuple val(meta), path(id_fasta) + tuple val(meta), path(id_file), path(fasta) output: tuple val(meta), path("*.idXML"), emit: id_file_pi @@ -25,7 +24,7 @@ process OPENMS_PEPTIDEINDEXER { """ PeptideIndexer \\ -in $id_file \\ - -fasta $id_fasta \\ + -fasta $fasta \\ -out ${prefix}.idXML \\ -threads $task.cpus \\ $args \\ diff --git a/modules/nf-core/openmsthirdparty/cometadapter/environment.yml b/modules/nf-core/openmsthirdparty/cometadapter/environment.yml new file mode 100644 index 00000000..dfc10603 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::openms-thirdparty=3.2.0" diff --git a/modules/nf-core/openmsthirdparty/cometadapter/main.nf b/modules/nf-core/openmsthirdparty/cometadapter/main.nf new file mode 100644 index 00000000..15a28391 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/main.nf @@ -0,0 +1,55 @@ +process OPENMSTHIRDPARTY_COMETADAPTER { + tag "$meta.id" + label 'process_high' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/openms-thirdparty:3.2.0--h9ee0642_4' : + 'biocontainers/openms-thirdparty:3.2.0--h9ee0642_4' }" + + input: + tuple val(meta), path(mzml), path(fasta) + + output: + tuple val(meta), path("*.idXML"), emit: idxml + tuple val(meta), path("*.tsv") , emit: pin, 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}" + + """ + CometAdapter \\ + -in $mzml \\ + -database $fasta \\ + -out ${prefix}.idXML \\ + -threads $task.cpus \\ + $args + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + CometAdapter: \$(CometAdapter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1 | cut -d '-' -f 1) + Comet: \$(comet 2>&1 | grep -E "Comet version.*" | sed 's/Comet version //g' | sed 's/"//g') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + touch ${prefix}.idXML + touch ${prefix}_pin.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + CometAdapter: \$(CometAdapter 2>&1 | grep -E '^Version(.*)' | sed 's/Version: //g' | cut -d ' ' -f 1 | cut -d '-' -f 1) + Comet: \$(comet 2>&1 | grep -E "Comet version.*" | sed 's/Comet version //g' | sed 's/"//g') + END_VERSIONS + """ +} diff --git a/modules/nf-core/openmsthirdparty/cometadapter/meta.yml b/modules/nf-core/openmsthirdparty/cometadapter/meta.yml new file mode 100644 index 00000000..453781fb --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/meta.yml @@ -0,0 +1,63 @@ +name: "openmsthirdparty_cometadapter" +description: Annotates MS/MS spectra using Comet. +keywords: + - search engine + - fasta + - mzml + - openms + - proteomics +tools: + - openms: + description: "OpenMS is an open-source software C++ library for LC-MS data management + and analyses" + homepage: "https://openms.de" + documentation: "https://openms.readthedocs.io/en/latest/index.html" + tool_dev_url: "https://github.com/OpenMS/OpenMS" + doi: "10.1038/s41592-024-02197-7" + licence: ["BSD"] + identifier: "" + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - mzml: + type: file + description: File containing mass spectra in mzML format + pattern: "*.{mzML}" + - fasta: + type: file + description: Protein sequence database containing targets and decoys + pattern: "*.{fasta}" +output: + - idxml: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.idXML": + type: file + description: File containing target and decoy hits in idXML format + pattern: "*.{idXML}" + - pin: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.tsv": + type: file + description: TSV file tailored as Percolator input (pin) file + pattern: "*.{tsv}" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@jonasscheid" +maintainers: + - "@jonasscheid" diff --git a/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test b/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test new file mode 100644 index 00000000..cf1a0bcd --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test @@ -0,0 +1,86 @@ +nextflow_process { + + name "Test Process OPENMSTHIRDPARTY_COMETADAPTER" + script "../main.nf" + process "OPENMSTHIRDPARTY_COMETADAPTER" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "openms" + tag "openmsthirdparty" + tag "openmsthirdparty/cometadapter" + tag "thermorawfileparser" + tag "openms/decoydatabase" + + setup { + run("THERMORAWFILEPARSER") { + script "../../../thermorawfileparser/main.nf" + process { + """ + input[0] = Channel.of([ + [ id:'test'], + file(params.modules_testdata_base_path + 'proteomics/msspectra/PXD012083_e005640_II.raw', checkIfExists: true) + ]) + """ + } + } + + run("OPENMS_DECOYDATABASE") { + script "../../../openms/decoydatabase/main.nf" + process { + """ + input[0] = Channel.of([ + [ id:'test'], + file(params.modules_testdata_base_path + 'proteomics/database/UP000005640_9606.fasta', checkIfExists: true) + ]) + """ + } + } + } + + test("proteomics - comet") { + + when { + process { + """ + input[0] = + THERMORAWFILEPARSER.out.spectra.join( + OPENMS_DECOYDATABASE.out.decoy_fasta + ) + """ + } + } + // Comet stores timestamp in output file, so we cannot compare checksums + then { + assert process.success + // Assert the search metadata + assert snapshot(file(process.out.idxml[0][1]).readLines()[0..30]).match() + // Make sure the file is not empty + assert file(process.out.idxml[0][1]).readLines().any { it.contains('ProteinHit') } + assert file(process.out.idxml[0][1]).readLines().any { it.contains('PeptideHit') } + assert snapshot(path(process.out.versions.get(0)).yaml).match("versions") + } + } + + test("proteomics - comet - stub") { + + options "-stub" + + when { + process { + """ + input[0] = + THERMORAWFILEPARSER.out.spectra.join( + OPENMS_DECOYDATABASE.out.decoy_fasta + ) + """ + } + } + + then { + assert process.success + } + } + +} diff --git a/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test.snap b/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test.snap new file mode 100644 index 00000000..939aa415 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/tests/main.nf.test.snap @@ -0,0 +1,59 @@ +{ + "proteomics - comet": { + "content": [ + [ + "", + "", + "", + "\t", + "\t\t", + "\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t", + "\t\t\t\t" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-13T13:57:34.932657501" + }, + "versions": { + "content": [ + { + "OPENMSTHIRDPARTY_COMETADAPTER": { + "CometAdapter": "3.2.0", + "Comet": "2023.01 rev. 2" + } + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-10-08T11:29:53.094774827" + } +} \ No newline at end of file diff --git a/modules/nf-core/openmsthirdparty/cometadapter/tests/nextflow.config b/modules/nf-core/openmsthirdparty/cometadapter/tests/nextflow.config new file mode 100644 index 00000000..04e89d92 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/tests/nextflow.config @@ -0,0 +1,20 @@ +process { + + withName:OPENMSTHIRDPARTY_COMETADAPTER { + ext.args = [ + "-instrument low_res", + "-fragment_bin_offset 0.4", + "-precursor_mass_tolerance 5", + "-precursor_error_units 'ppm'", + "-fragment_mass_tolerance 0.50025", + "-digest_mass_range '800:5000'", + "-max_variable_mods_in_peptide 1", + "-precursor_charge '2:5'", + "-activation_method 'CID'", + "-variable_modifications 'Oxidation (M)'", + "-enzyme 'unspecific cleavage'", + "-spectrum_batch_size 0" + ].join(' ').trim() + } + +} diff --git a/modules/nf-core/openmsthirdparty/cometadapter/tests/tags.yml b/modules/nf-core/openmsthirdparty/cometadapter/tests/tags.yml new file mode 100644 index 00000000..44dd62ab --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/tests/tags.yml @@ -0,0 +1,2 @@ +openmsthirdparty/cometadapter: + - "modules/nf-core/openmsthirdparty/cometadapter/**" diff --git a/nextflow.config b/nextflow.config index a9e139f3..6fd3bb16 100644 --- a/nextflow.config +++ b/nextflow.config @@ -32,7 +32,7 @@ params { fragment_bin_offset = 0.0 fragment_mass_tolerance = 0.01 number_mods = 3 - fixed_mods = ' ' + fixed_mods = '' variable_mods = 'Oxidation (M)' num_hits = 1 use_x_ions = false @@ -40,7 +40,7 @@ params { use_a_ions = false use_c_ions = false use_NL_ions = false - remove_precursor_peak = false + remove_precursor_peak = 'no' spectrum_batch_size = 0 // Preprocessing settings diff --git a/nextflow_schema.json b/nextflow_schema.json index 9f8ada9e..252031a7 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -228,10 +228,10 @@ "description": "Include NL ions into the peptide spectrum matching" }, "remove_precursor_peak": { - "type": "boolean", + "type": "string", "fa_icon": "fas fa-pipe", "description": "Include if you want to remove all peaks around precursor m/z", - "default": false + "default": "no" }, "spectrum_batch_size": { "type": "integer", diff --git a/workflows/mhcquant.nf b/workflows/mhcquant.nf index acfd7cac..44c2d646 100644 --- a/workflows/mhcquant.nf +++ b/workflows/mhcquant.nf @@ -31,16 +31,17 @@ include { QUANT } from '../subworkflows/local/quant' // // MODULE: Installed directly from nf-core/modules // -include { OPENMS_FILEFILTER } from '../modules/nf-core/openms/filefilter/main' -include { OPENMS_DECOYDATABASE } from '../modules/nf-core/openms/decoydatabase/main' -include { OPENMS_IDMASSACCURACY } from '../modules/nf-core/openms/idmassaccuracy/main' -include { OPENMS_PEPTIDEINDEXER } from '../modules/nf-core/openms/peptideindexer/main' -include { OPENMS_IDMERGER } from '../modules/nf-core/openms/idmerger/main' -include { MULTIQC } from '../modules/nf-core/multiqc/main' -include { paramsSummaryMap } from 'plugin/nf-schema' -include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline' -include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline' -include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_mhcquant_pipeline' +include { OPENMS_FILEFILTER } from '../modules/nf-core/openms/filefilter/main' +include { OPENMS_DECOYDATABASE } from '../modules/nf-core/openms/decoydatabase/main' +include { OPENMS_IDMASSACCURACY } from '../modules/nf-core/openms/idmassaccuracy/main' +include { OPENMSTHIRDPARTY_COMETADAPTER } from '../modules/nf-core/openmsthirdparty/cometadapter/main' +include { OPENMS_PEPTIDEINDEXER } from '../modules/nf-core/openms/peptideindexer/main' +include { OPENMS_IDMERGER } from '../modules/nf-core/openms/idmerger/main' +include { MULTIQC } from '../modules/nf-core/multiqc/main' +include { paramsSummaryMap } from 'plugin/nf-schema' +include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline' +include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline' +include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_mhcquant_pipeline' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -67,7 +68,7 @@ workflow MHCQUANT { // Generate reversed decoy database OPENMS_DECOYDATABASE(ch_fasta) ch_versions = ch_versions.mix(OPENMS_DECOYDATABASE.out.versions) - ch_decoy_db = OPENMS_DECOYDATABASE.out.decoy_fasta + ch_decoy_db = OPENMS_DECOYDATABASE.out.decoy_fasta.map{ meta, fasta -> [fasta] } } else { ch_decoy_db = ch_fasta } @@ -87,11 +88,11 @@ workflow MHCQUANT { ch_multiqc_files = ch_multiqc_files.mix(PYOPENMS_CHROMATOGRAMEXTRACTOR.out.csv.map{ meta, mzml -> mzml }) // Run comet database search - OPENMS_COMETADAPTER(ch_clean_mzml_file.combine(ch_decoy_db.map{ meta, fasta -> [fasta] })) - ch_versions = ch_versions.mix(OPENMS_COMETADAPTER.out.versions) + OPENMSTHIRDPARTY_COMETADAPTER(ch_clean_mzml_file.combine(ch_decoy_db)) + ch_versions = ch_versions.mix(OPENMSTHIRDPARTY_COMETADAPTER.out.versions) // Index decoy and target hits - OPENMS_PEPTIDEINDEXER(OPENMS_COMETADAPTER.out.idxml, ch_decoy_db) + OPENMS_PEPTIDEINDEXER(OPENMSTHIRDPARTY_COMETADAPTER.out.idxml.combine(ch_decoy_db)) ch_versions = ch_versions.mix(OPENMS_PEPTIDEINDEXER.out.versions) // Compute mass errors for multiQC report @@ -103,6 +104,7 @@ workflow MHCQUANT { ch_multiqc_files = ch_multiqc_files.mix(DATAMASH_HISTOGRAM.out.binned_tsv.map{ meta, frag_err_hist -> frag_err_hist }) // Save indexed runs for later use to keep meta-run information. Sort based on file id + OPENMS_PEPTIDEINDEXER.out.id_file_pi.view() OPENMS_PEPTIDEINDEXER.out.id_file_pi .map { meta, idxml -> [ groupKey([id: "${meta.sample}_${meta.condition}"], meta.group_count), meta] } .groupTuple() From 95d970cdc8845a062f0ec4e8f5cd13e350642f68 Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 16:06:30 +0000 Subject: [PATCH 4/8] rm local cometadapter module --- modules/local/openms_cometadapter.nf | 69 ---------------------------- 1 file changed, 69 deletions(-) delete mode 100644 modules/local/openms_cometadapter.nf diff --git a/modules/local/openms_cometadapter.nf b/modules/local/openms_cometadapter.nf deleted file mode 100644 index 224a41b2..00000000 --- a/modules/local/openms_cometadapter.nf +++ /dev/null @@ -1,69 +0,0 @@ -process OPENMS_COMETADAPTER { - tag "$meta.id" - label 'process_high' - - conda "bioconda::openms-thirdparty=3.1.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/openms-thirdparty:3.1.0--h9ee0642_3' : - 'biocontainers/openms-thirdparty:3.1.0--h9ee0642_3' }" - - input: - tuple val(meta), path(mzml), path(fasta) - - output: - tuple val(meta), path("*.idXML"), emit: idxml - tuple val(meta), path("*.tsv") , emit: tsv - path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - - script: - def prefix = task.ext.prefix ?: "${mzml.baseName}" - def args = task.ext.args ?: '' - - def mods = params.fixed_mods != " " ? "-fixed_modifications ${params.fixed_mods.tokenize(',').collect { "'${it}'"}.join(" ")}" : "-fixed_modifications" - def params_file = params.default_params_file_comet != " " ? "-default_params_file ${params.default_params_file_comet}" : "" - def xions = params.use_x_ions ? "-use_X_ions true" : "" - def zions = params.use_z_ions ? "-use_Z_ions true" : "" - def aions = params.use_a_ions ? "-use_A_ions true" : "" - def cions = params.use_c_ions ? "-use_C_ions true" : "" - def nlions = params.use_NL_ions ? "-use_NL_ions true" : "" - def remove_precursor = params.remove_precursor_peak ? "-remove_precursor_peak yes" : "" - - """ - CometAdapter -in $mzml \\ - -out ${prefix}.idXML \\ - -database $fasta \\ - -threads $task.cpus \\ - -pin_out ${prefix}_pin.tsv \\ - $params_file \\ - $args \\ - $mods \\ - $xions \\ - $zions \\ - $aions \\ - $cions \\ - $nlions \\ - $remove_precursor - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms-thirdparty: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ - - stub: - def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}_ms2rescore" - - """ - touch ${prefix}.idXML - touch ${prefix}_pin.tsv - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - openms-thirdparty: \$(echo \$(FileInfo --help 2>&1) | sed 's/^.*Version: //; s/-.*\$//' | sed 's/ -*//; s/ .*\$//') - END_VERSIONS - """ -} From 0c81c959d2dbe0f82c07e156c17fb87a345a36fc Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 16:07:27 +0000 Subject: [PATCH 5/8] revert fasta channel mapping --- workflows/mhcquant.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflows/mhcquant.nf b/workflows/mhcquant.nf index 44c2d646..dd33432b 100644 --- a/workflows/mhcquant.nf +++ b/workflows/mhcquant.nf @@ -70,7 +70,7 @@ workflow MHCQUANT { ch_versions = ch_versions.mix(OPENMS_DECOYDATABASE.out.versions) ch_decoy_db = OPENMS_DECOYDATABASE.out.decoy_fasta.map{ meta, fasta -> [fasta] } } else { - ch_decoy_db = ch_fasta + ch_decoy_db = ch_fasta.map{ meta, fasta -> [fasta] } } // Optionally clean up mzML files From 214c9a3a58c4bc28754402632798842bbb4c2a98 Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 18:59:39 +0000 Subject: [PATCH 6/8] remove local comet import --- workflows/mhcquant.nf | 1 - 1 file changed, 1 deletion(-) diff --git a/workflows/mhcquant.nf b/workflows/mhcquant.nf index dd33432b..6dc29f53 100644 --- a/workflows/mhcquant.nf +++ b/workflows/mhcquant.nf @@ -9,7 +9,6 @@ // include { PYOPENMS_CHROMATOGRAMEXTRACTOR } from '../modules/local/pyopenms_chromatogramextractor' -include { OPENMS_COMETADAPTER } from '../modules/local/openms_cometadapter' include { DATAMASH_HISTOGRAM } from '../modules/local/datamash_histogram' include { PYOPENMS_IONANNOTATOR } from '../modules/local/pyopenms_ionannotator' include { OPENMS_TEXTEXPORTER } from '../modules/local/openms_textexporter' From a7c890a75a76fad7f30a8601a867e62c6dac1ed5 Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Tue, 21 Jan 2025 20:00:04 +0000 Subject: [PATCH 7/8] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9897400..f5e39c60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `OPENMS_IDMASSACCURACY` and `DATAMASH_HISTOGRAM` to compute fragment mass errors and visualizte them in multiQC report [#332](https://github.com/nf-core/mhcquant/pull/332) - Added global fdr evaluation in new local subworkflow `RESCORE` [#338](https://github.com/nf-core/mhcquant/pull/338) - Added `-weights` parameter in `OPENMS_PERCOLATORADAPTER` and visualize the median feature weights in multiQC report [#347](https://github.com/nf-core/mhcquant/pull/347) +- Replace local with nf-core modules [#350](https://github.com/nf-core/mhcquant/pull/347) ### `Fixed` From b3e9846a597737b015a644fa1dbaef9cdcd926cb Mon Sep 17 00:00:00 2001 From: jonasscheid Date: Wed, 22 Jan 2025 10:21:41 +0000 Subject: [PATCH 8/8] revert params.remove_precursor_peak to boolean for backwards compatibility --- conf/modules.config | 2 +- nextflow.config | 2 +- nextflow_schema.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index eeb73462..9f008643 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -114,7 +114,7 @@ process { "-use_A_ions ${params.use_a_ions}", "-use_C_ions ${params.use_c_ions}", "-use_NL_ions ${params.use_NL_ions}", - "-remove_precursor_peak ${params.remove_precursor_peak}" + params.remove_precursor_peak ? "-remove_precursor_peak yes" : "", ].join(' ').trim() } publishDir = [ path: {"${params.outdir}/intermediate_results/comet"}, diff --git a/nextflow.config b/nextflow.config index 6fd3bb16..57fc47a1 100644 --- a/nextflow.config +++ b/nextflow.config @@ -40,7 +40,7 @@ params { use_a_ions = false use_c_ions = false use_NL_ions = false - remove_precursor_peak = 'no' + remove_precursor_peak = false spectrum_batch_size = 0 // Preprocessing settings diff --git a/nextflow_schema.json b/nextflow_schema.json index 252031a7..567ca08f 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -228,10 +228,10 @@ "description": "Include NL ions into the peptide spectrum matching" }, "remove_precursor_peak": { - "type": "string", + "type": "boolean", "fa_icon": "fas fa-pipe", "description": "Include if you want to remove all peaks around precursor m/z", - "default": "no" + "default": "false" }, "spectrum_batch_size": { "type": "integer",