diff --git a/modules/nf-core/openmsthirdparty/cometadapter/environment.yml b/modules/nf-core/openmsthirdparty/cometadapter/environment.yml new file mode 100644 index 00000000000..3c2729e75f1 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::openms-thirdparty=3.1.0" diff --git a/modules/nf-core/openmsthirdparty/cometadapter/main.nf b/modules/nf-core/openmsthirdparty/cometadapter/main.nf new file mode 100644 index 00000000000..b193974ae86 --- /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.1.0--h9ee0642_4' : + 'biocontainers/openms-thirdparty:3.1.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 00000000000..e37f6af8264 --- /dev/null +++ b/modules/nf-core/openmsthirdparty/cometadapter/meta.yml @@ -0,0 +1,55 @@ +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/nmeth.3959" + licence: ["BSD"] + +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: + - 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" + - idxml: + type: file + description: File containing target and decoy hits in idXML format + pattern: "*.{idXML}" + - pin: + type: file + description: TSV file tailored as Percolator input (pin) file + pattern: "*.{tsv}" + +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 00000000000..cf1a0bcddcd --- /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 00000000000..9eb65951ab5 --- /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.1.0", + "Comet": "2023.01 rev. 2" + } + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-13T13:57:35.577894316" + } +} \ 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 00000000000..04e89d92942 --- /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 00000000000..44dd62ab99a --- /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/tests/config/test_data.config b/tests/config/test_data.config index 3614b827fe2..852544d51f4 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -769,6 +769,7 @@ params { } 'database' { yeast_ups = "${params.test_data_base}/data/proteomics/database/yeast_UPS.fasta" + swissprot = "${params.test_data_base}/data/proteomics/database/UP000005640_9606.fasta" } 'maxquant' { mq_contrasts = "${params.test_data_base}/data/proteomics/maxquant/MaxQuant_contrasts.csv"