From cfe3660c173c810a37eb8e86e899209b7215ff24 Mon Sep 17 00:00:00 2001 From: Sofia Stamouli <91951607+sofstam@users.noreply.github.com> Date: Thu, 30 Jan 2025 10:57:52 +0100 Subject: [PATCH] Add sylph/profile module (#7118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add sylph/profile module and remove unnecessary pattern from sylph/sketch * Remove description * Update snap * Try again with linting * Update snap * Fix linting for meta.yaml * Update tests * Add contains in nf-test * Add contains * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update description * Remove single_end from the output * Update meta.yml file to include info if fastq/fasta files are provided * Add tests * Fix test * Fix tests * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Mahesh Binzer-Panchal * Update to latest paths * Rename variable to database * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/sketch/meta.yml Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Apply review suggestions * Update snap * Snapshot * Test snap * Update snapshot to pass the tests * Remove test_2.fastq.gz from single_end test * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update snapshot * Add threads * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Mahesh Binzer-Panchal * Update modules/nf-core/sylph/profile/meta.yml Co-authored-by: Mahesh Binzer-Panchal * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Mahesh Binzer-Panchal * Update modules/nf-core/sylph/profile/tests/main.nf.test Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> * Update modules/nf-core/sylph/profile/main.nf Co-authored-by: Mahesh Binzer-Panchal * add better debugging * Update tests * Update snapshot --------- Co-authored-by: Matthias Hörtenhuber Co-authored-by: Famke Bäuerle <45968370+famosab@users.noreply.github.com> Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Co-authored-by: Mahesh Binzer-Panchal Co-authored-by: mashehu --- .github/actions/get-shards/action.yml | 13 +-- modules/nf-core/sylph/profile/environment.yml | 7 ++ modules/nf-core/sylph/profile/main.nf | 49 ++++++++++++ modules/nf-core/sylph/profile/meta.yml | 51 ++++++++++++ .../nf-core/sylph/profile/tests/main.nf.test | 80 +++++++++++++++++++ .../sylph/profile/tests/main.nf.test.snap | 61 ++++++++++++++ modules/nf-core/sylph/sketch/meta.yml | 3 +- 7 files changed, 256 insertions(+), 8 deletions(-) create mode 100644 modules/nf-core/sylph/profile/environment.yml create mode 100644 modules/nf-core/sylph/profile/main.nf create mode 100644 modules/nf-core/sylph/profile/meta.yml create mode 100644 modules/nf-core/sylph/profile/tests/main.nf.test create mode 100644 modules/nf-core/sylph/profile/tests/main.nf.test.snap diff --git a/.github/actions/get-shards/action.yml b/.github/actions/get-shards/action.yml index c2b511c2672..3669d0d88ef 100644 --- a/.github/actions/get-shards/action.yml +++ b/.github/actions/get-shards/action.yml @@ -17,7 +17,6 @@ outputs: total_shards: description: "Total number of shards" value: ${{ steps.shards.outputs.total_shards }} - runs: using: "composite" steps: @@ -26,22 +25,24 @@ runs: with: version: ${{ env.NFT_VER }} install-pdiff: true - - name: Get number of shards id: shards shell: bash run: | - # Prepare tag parameter if tags are provided TAGS=$([ -n "${{ inputs.tags }}" ] && echo "--tag ${{ inputs.tags }}" || echo "") - # Run nf-test with dynamic tag parameter + + # Run nf-test with dynamic parameter nftest_output=$(nf-test test \ --dry-run \ --profile docker \ ${TAGS} \ --filter process,workflow \ - ${{ inputs.paths }}) - + ${{ inputs.paths }}) || { + echo "nf-test command failed with exit code $?" + echo "Full output: $nftest_output" + exit 1 + } echo "nf-test dry-run output: $nftest_output" # Default values for shard and total_shards diff --git a/modules/nf-core/sylph/profile/environment.yml b/modules/nf-core/sylph/profile/environment.yml new file mode 100644 index 00000000000..fd9d6bf1294 --- /dev/null +++ b/modules/nf-core/sylph/profile/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::sylph=0.7.0" diff --git a/modules/nf-core/sylph/profile/main.nf b/modules/nf-core/sylph/profile/main.nf new file mode 100644 index 00000000000..ae85e9198fd --- /dev/null +++ b/modules/nf-core/sylph/profile/main.nf @@ -0,0 +1,49 @@ +process SYLPH_PROFILE { + 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/sylph:0.7.0--h919a2d8_0' : + 'biocontainers/sylph:0.7.0--h919a2d8_0' }" + + input: + tuple val(meta), path(reads) + path(database) + + output: + tuple val(meta), path('*.tsv'), emit: profile_out + 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}" + """ + sylph profile \\ + -t $task.cpus \\ + $args \\ + $reads \\ + $database\\ + -o ${prefix}.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sylph: \$(sylph -V | awk '{print \$2}') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.tsv + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sylph: \$(sylph -V | awk '{print \$2}') + END_VERSIONS + """ + +} diff --git a/modules/nf-core/sylph/profile/meta.yml b/modules/nf-core/sylph/profile/meta.yml new file mode 100644 index 00000000000..ce41070719c --- /dev/null +++ b/modules/nf-core/sylph/profile/meta.yml @@ -0,0 +1,51 @@ +name: "sylph_profile" +description: Sylph profile command for taxonoming profiling +keywords: + - profile + - metagenomics + - sylph + - classification +tools: + - sylph: + description: Sylph quickly enables querying of genomes against even low-coverage + shotgun metagenomes to find nearest neighbour ANI. + homepage: https://github.com/bluenote-1577/sylph + documentation: https://github.com/bluenote-1577/sylph + tool_dev_url: https://github.com/bluenote-1577/sylph + doi: 10.1038/s41587-024-02412-y + licence: ["MIT"] + identifier: biotools:sylph +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - reads: + type: file + description: | + List of input FastQ/FASTA files of size 1 and 2 for single-end and paired-end data, + respectively. They are automatically sketched to .sylsp/.syldb + - - database: + type: file + description: Pre-sketched *.syldb/*.sylsp files. Raw single-end fastq/fasta are allowed and will be automatically sketched to .sylsp/.syldb. + pattern: "*.{syldb,sylsp,fasta,fastq}" +output: + - profile_out: + - meta: + type: map + description: Groovy Map containing sample information + - "*.tsv": + type: file + description: Output file of species-level taxonomic profiling with abundances and ANIs. + pattern: "*tsv" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@jiahang1234" + - "@sofstam" +maintainers: + - "@sofstam" diff --git a/modules/nf-core/sylph/profile/tests/main.nf.test b/modules/nf-core/sylph/profile/tests/main.nf.test new file mode 100644 index 00000000000..8d1993e20ec --- /dev/null +++ b/modules/nf-core/sylph/profile/tests/main.nf.test @@ -0,0 +1,80 @@ +nextflow_process { + + name "Test Process SYLPH_PROFILE" + script "../main.nf" + process "SYLPH_PROFILE" + tag "modules" + tag "modules_nfcore" + tag "sylph" + tag "sylph/profile" + + test("sarscov2 illumina single-end [fastq_gz]") { + when { + process { + """ + input[0] = [ [ id:'test' ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true) + ] + ] + input[1] = file(params.modules_testdata_base_path +'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + """ + } + } + + then { + assert process.success + assert snapshot( + process.out.versions, + file(process.out.profile_out[0][1]).readLines()[0] + ).match() + } + } + + test("sarscov2 illumina paired-end [fastq_gz]") { + when { + process { + """ + input[0] = [ [ id:'test' ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = file(params.modules_testdata_base_path +'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + """ + } + } + + then { + assert process.success + assert snapshot( + process.out.versions, + file(process.out.profile_out[0][1]).readLines()[0] + ).match() + } + } + + test("sarscov2 illumina paired-end [fastq_gz]-stub") { + options "-stub" + + when { + process { + """ + input[0] = [ [ id:'test' ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = file(params.modules_testdata_base_path +'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + """ + } + } + + then { + assert process.success + assert snapshot(process.out).match() + } + } +} diff --git a/modules/nf-core/sylph/profile/tests/main.nf.test.snap b/modules/nf-core/sylph/profile/tests/main.nf.test.snap new file mode 100644 index 00000000000..d7a487c401e --- /dev/null +++ b/modules/nf-core/sylph/profile/tests/main.nf.test.snap @@ -0,0 +1,61 @@ +{ + "sarscov2 illumina paired-end [fastq_gz]": { + "content": [ + [ + "versions.yml:md5,7b5a545483277cc0ff9189f8891e737f" + ], + "Sample_file\tGenome_file\tTaxonomic_abundance\tSequence_abundance\tAdjusted_ANI\tEff_cov\tANI_5-95_percentile\tEff_lambda\tLambda_5-95_percentile\tMedian_cov\tMean_cov_geq1\tContainment_ind\tNaive_ANI\tkmers_reassigned\tContig_name" + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-01-27T15:47:59.374481624" + }, + "sarscov2 illumina single-end [fastq_gz]": { + "content": [ + [ + "versions.yml:md5,7b5a545483277cc0ff9189f8891e737f" + ], + "Sample_file\tGenome_file\tTaxonomic_abundance\tSequence_abundance\tAdjusted_ANI\tEff_cov\tANI_5-95_percentile\tEff_lambda\tLambda_5-95_percentile\tMedian_cov\tMean_cov_geq1\tContainment_ind\tNaive_ANI\tkmers_reassigned\tContig_name" + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-01-27T15:47:53.556942841" + }, + "sarscov2 illumina paired-end [fastq_gz]-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,7b5a545483277cc0ff9189f8891e737f" + ], + "profile_out": [ + [ + { + "id": "test" + }, + "test.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,7b5a545483277cc0ff9189f8891e737f" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-01-27T15:48:04.991824868" + } +} \ No newline at end of file diff --git a/modules/nf-core/sylph/sketch/meta.yml b/modules/nf-core/sylph/sketch/meta.yml index 7a9abdf85b1..a7278db68be 100644 --- a/modules/nf-core/sylph/sketch/meta.yml +++ b/modules/nf-core/sylph/sketch/meta.yml @@ -34,8 +34,7 @@ output: type: map description: | Groovy Map containing sample information - e.g. [ id:'test', single_end:false ] - pattern: "my_sketches/*.sylsp" + e.g. [ id:'test'] - my_sketches/*.sylsp: type: map description: |