diff --git a/modules/nf-core/pridepy/fetchsdrf/environment.yml b/modules/nf-core/pridepy/fetchsdrf/environment.yml new file mode 100644 index 00000000000..ae2c90d80db --- /dev/null +++ b/modules/nf-core/pridepy/fetchsdrf/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "bioconda::pridepy=0.0.15" diff --git a/modules/nf-core/pridepy/fetchsdrf/main.nf b/modules/nf-core/pridepy/fetchsdrf/main.nf new file mode 100644 index 00000000000..8682f101b72 --- /dev/null +++ b/modules/nf-core/pridepy/fetchsdrf/main.nf @@ -0,0 +1,47 @@ +process PRIDEPY_FETCHSDRF { + tag "${meta.id}" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container + ? 'https://depot.galaxyproject.org/singularity/pridepy:0.0.15--pyhdfd78af_0' + : 'quay.io/biocontainers/pridepy:0.0.15--pyhdfd78af_0'}" + + input: + tuple val(meta), val(pride_id) + + output: + tuple val(meta), path("${prefix}.sdrf.tsv"), emit: sdrf + tuple val("${task.process}"), val('pridepy'), eval('python -c "from importlib.metadata import version; print(version(\'pridepy\'))"'), topic: versions, emit: versions_pridepy + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + """ + pridepy stream-files-metadata \\ + -a "${pride_id}" \\ + -o files_metadata.json \\ + ${args} + + # Check if SDRF is present in metadata and extract + sdrf_name=\$(awk -F'"' '/"fileName" *: *"(sdrf\\.tsv|[^"]+\\.sdrf\\.tsv)"/ {print \$4; exit}' files_metadata.json) + [ -n "\$sdrf_name" ] || { echo "ERROR: No SDRF file found for ${pride_id}" >&2; exit 1; } + + pridepy download-file-by-name \\ + -a "${pride_id}" \\ + -f "\$sdrf_name" \\ + -o . \\ + ${args} + + mv "\$sdrf_name" "${prefix}.sdrf.tsv" + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.sdrf.tsv + """ +} diff --git a/modules/nf-core/pridepy/fetchsdrf/meta.yml b/modules/nf-core/pridepy/fetchsdrf/meta.yml new file mode 100644 index 00000000000..1a84b8e0ab1 --- /dev/null +++ b/modules/nf-core/pridepy/fetchsdrf/meta.yml @@ -0,0 +1,68 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "pridepy_fetchsdrf" +description: Fetch an SDRF file from the PRIDE Archive for a given project accession. +keywords: + - pride + - sdrf + - proteomics + - download + - metadata +tools: + - "pridepy": + description: | + Python client library to access PRIDE Archive data programmatically, + including downloading files and metadata for public proteomics datasets. + homepage: "https://github.com/PRIDE-Archive/pridepy" + documentation: "https://github.com/PRIDE-Archive/pridepy" + tool_dev_url: "https://github.com/PRIDE-Archive/pridepy" + licence: ["Apache-2.0"] + identifier: "" + +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'PXD004684' ]` + - pride_id: + type: string + description: PRIDE Archive project accession (e.g. PXD004684) + +output: + sdrf: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'PXD004684' ]` + - "${prefix}.sdrf.tsv": + type: file + description: SDRF (Sample and Data Relationship Format) file describing the experimental design of the PRIDE project + pattern: "*.sdrf.tsv" + versions_pridepy: + - - ${task.process}: + type: string + description: The process the versions were collected from + - pridepy: + type: string + description: The tool name + - 'python -c "from importlib.metadata import version; print(version(''pridepy''))"': + type: string + description: The command used to generate the version of the tool + +topics: + versions: + - - ${task.process}: + type: string + description: The process the versions were collected from + - pridepy: + type: string + description: The tool name + - 'python -c "from importlib.metadata import version; print(version(''pridepy''))"': + type: string + description: The command used to generate the version of the tool + +authors: + - "@jonasscheid" +maintainers: + - "@jonasscheid" diff --git a/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test b/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test new file mode 100644 index 00000000000..87538999921 --- /dev/null +++ b/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test @@ -0,0 +1,59 @@ +nextflow_process { + + name "Test Process PRIDEPY_FETCHSDRF" + script "../main.nf" + process "PRIDEPY_FETCHSDRF" + + tag "modules" + tag "modules_nfcore" + tag "pridepy" + tag "pridepy/fetchsdrf" + + test("pride - PXD004684") { + + when { + process { + """ + input[0] = [ + [ id:'PXD004684' ], + 'PXD004684' + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert path(process.out.sdrf[0][1]).text.contains('Source Name') }, + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + + test("pride - PXD004684 - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'PXD004684' ], + 'PXD004684' + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + +} diff --git a/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test.snap b/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test.snap new file mode 100644 index 00000000000..87b5e107f32 --- /dev/null +++ b/modules/nf-core/pridepy/fetchsdrf/tests/main.nf.test.snap @@ -0,0 +1,54 @@ +{ + "pride - PXD004684 - stub": { + "content": [ + { + "sdrf": [ + [ + { + "id": "PXD004684" + }, + "PXD004684.sdrf.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_pridepy": [ + [ + "PRIDEPY_FETCHSDRF", + "pridepy", + "0.0.15" + ] + ] + } + ], + "timestamp": "2026-05-04T07:51:07.096175717", + "meta": { + "nf-test": "0.9.5", + "nextflow": "25.10.4" + } + }, + "pride - PXD004684": { + "content": [ + { + "sdrf": [ + [ + { + "id": "PXD004684" + }, + "PXD004684.sdrf.tsv:md5,a8a2aa91d85adb241110fe3a7ce8f372" + ] + ], + "versions_pridepy": [ + [ + "PRIDEPY_FETCHSDRF", + "pridepy", + "0.0.15" + ] + ] + } + ], + "timestamp": "2026-05-04T07:50:51.643144802", + "meta": { + "nf-test": "0.9.5", + "nextflow": "25.10.4" + } + } +} \ No newline at end of file