diff --git a/modules/nf-core/openms/idmassaccuracy/environment.yml b/modules/nf-core/openms/idmassaccuracy/environment.yml new file mode 100644 index 00000000000..5793e993cc5 --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::openms=3.1.0" diff --git a/modules/nf-core/openms/idmassaccuracy/main.nf b/modules/nf-core/openms/idmassaccuracy/main.nf new file mode 100644 index 00000000000..9759ad40919 --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/main.nf @@ -0,0 +1,52 @@ +process OPENMS_IDMASSACCURACY { + 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.1.0--h191ead1_4' : + 'biocontainers/openms:3.1.0--h191ead1_4' }" + + input: + tuple val(meta), path(mzmls), path(idxmls) + + output: + tuple val(meta), path("*frag_mass_err.tsv") , emit: frag_err + tuple val(meta), path("*prec_mass_err.tsv") , emit: prec_err, 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}" + + """ + IDMassAccuracy \\ + -in $mzmls \\ + -id_in $idxmls \\ + -out_fragment ${prefix}_frag_mass_err.tsv \\ + -threads $task.cpus \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + OpenMS: \$(FileInfo 2>&1 | grep -E '^Version(.*)' | cut -d ' ' -f 2 | cut -d '-' -f 1) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + touch ${prefix}_frag_mass_err.tsv + touch ${prefix}_prec_mass_err.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + OpenMS: \$(FileInfo 2>&1 | grep -E '^Version(.*)' | cut -d ' ' -f 2 | cut -d '-' -f 1) + END_VERSIONS + """ +} diff --git a/modules/nf-core/openms/idmassaccuracy/meta.yml b/modules/nf-core/openms/idmassaccuracy/meta.yml new file mode 100644 index 00000000000..e14a2eb09bb --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/meta.yml @@ -0,0 +1,55 @@ +name: "openms_idmassaccuracy" +description: Calculates a distribution of the mass error from given mass spectra and IDs. +keywords: + - mass_error + - 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"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - mzmls: + type: file + description: | + List containing one or more mzML files + e.g. `[ 'file1.mzML', 'file2.mzML' ]` + pattern: "*.{mzML}" + - idxmls: + type: file + description: | + List containing one or more idXML files + e.g. `[ 'file1.idXML', 'file2.idXML' ]` + pattern: "*.{idXML}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test' ]` + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - frag_err: + type: file + description: TSV file containing the fragment mass errors + pattern: "*frag_mass_err.{tsv}" + - prec_err: + type: file + description: Optional TSV file containing the precursor mass errors + pattern: "*prec_mass_err.{tsv}" + +authors: + - "@jonasscheid" diff --git a/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test b/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test new file mode 100644 index 00000000000..b267fe15623 --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test @@ -0,0 +1,81 @@ +nextflow_process { + + name "Test Process OPENMS_IDMASSACCURACY" + script "../main.nf" + process "OPENMS_IDMASSACCURACY" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "openms" + tag "openms/idmassaccuracy" + tag "thermorawfileparser" + tag "openms/decoydatabase" + tag "openmsthirdparty/cometadapter" + + 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) + ]) + """ + } + } + run("OPENMSTHIRDPARTY_COMETADAPTER") { + script "../../../openmsthirdparty/cometadapter/main.nf" + process { + """ + input[0] = THERMORAWFILEPARSER.out.spectra.join(OPENMS_DECOYDATABASE.out.decoy_fasta) + """ + } + } + } + + test("proteomics - openms - mass_error") { + when { + process { + """ + input[0] = THERMORAWFILEPARSER.out.spectra.join(OPENMSTHIRDPARTY_COMETADAPTER.out.idxml) + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("proteomics - openms - mass_error - stub") { + options "-stub" + when { + process { + """ + input[0] = THERMORAWFILEPARSER.out.spectra.join(OPENMSTHIRDPARTY_COMETADAPTER.out.idxml) + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test.snap b/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test.snap new file mode 100644 index 00000000000..9accf9a2acc --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/tests/main.nf.test.snap @@ -0,0 +1,90 @@ +{ + "proteomics - openms - mass_error - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_frag_mass_err.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test_prec_mass_err.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,84212cbbf016bbcae0eb1bb0fcc30db7" + ], + "frag_err": [ + [ + { + "id": "test" + }, + "test_frag_mass_err.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "prec_err": [ + [ + { + "id": "test" + }, + "test_prec_mass_err.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,84212cbbf016bbcae0eb1bb0fcc30db7" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-16T05:12:06.655389198" + }, + "proteomics - openms - mass_error": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_frag_mass_err.tsv:md5,c659254bc1305edde65eca890a6cf36f" + ] + ], + "1": [ + + ], + "2": [ + "versions.yml:md5,84212cbbf016bbcae0eb1bb0fcc30db7" + ], + "frag_err": [ + [ + { + "id": "test" + }, + "test_frag_mass_err.tsv:md5,c659254bc1305edde65eca890a6cf36f" + ] + ], + "prec_err": [ + + ], + "versions": [ + "versions.yml:md5,84212cbbf016bbcae0eb1bb0fcc30db7" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-16T05:11:55.087464408" + } +} \ No newline at end of file diff --git a/modules/nf-core/openms/idmassaccuracy/tests/nextflow.config b/modules/nf-core/openms/idmassaccuracy/tests/nextflow.config new file mode 100644 index 00000000000..d104b31303e --- /dev/null +++ b/modules/nf-core/openms/idmassaccuracy/tests/nextflow.config @@ -0,0 +1,27 @@ +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() + } + + withName:OPENMS_IDMASSACCURACY { + ext.args = [ + "-precursor_error_ppm", + "-fragment_mass_tolerance 0.50025" + ].join(' ').trim() + } + +}