Skip to content

Commit

Permalink
Merge branch 'master' into 2FAST2Q
Browse files Browse the repository at this point in the history
  • Loading branch information
afombravo authored Jan 24, 2025
2 parents f114f57 + 271b0be commit b350d66
Show file tree
Hide file tree
Showing 10 changed files with 429 additions and 4 deletions.
4 changes: 1 addition & 3 deletions modules/nf-core/catpack/addnames/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ output:
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
pattern: "*.{bam,cram,sam}"
- ${prefix}.txt:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
CAT/BAT/RAT classification file with added taxonomic names
pattern: "*.{bam,cram,sam}"
ontologies:
- edam: "http://edamontology.org/format_3475"
Expand Down
4 changes: 4 additions & 0 deletions modules/nf-core/catpack/bins/tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ process {
withName: CATPACK_BINS {
ext.args = "--bin_suffix .fasta"
}

withName: CATPACK_ADDNAMES {
ext.args = "--only_official"
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/catpack/download/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ process CATPACK_DOWNLOAD {
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
echo "CAT_pack \\
download \\
${args} \\
--db ${db}
-o ${prefix}/"
mkdir ${prefix}/
cat <<-END_VERSIONS > versions.yml
Expand Down
7 changes: 7 additions & 0 deletions modules/nf-core/catpack/summarise/environment.yml
Original file line number Diff line number Diff line change
@@ -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::cat=6.0.1"
62 changes: 62 additions & 0 deletions modules/nf-core/catpack/summarise/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
process CATPACK_SUMMARISE {
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/cat:6.0.1--hdfd78af_0'
: 'biocontainers/cat:6.0.1--hdfd78af_0'}"

input:
tuple val(meta), path(classification)
tuple val(meta2), path(contigs)

output:
tuple val(meta), path("*.txt"), emit: txt
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}"
if ("${classification}" == "${prefix}.txt") {
error("Input and output names are the same, set prefix in module configuration to disambiguate!")
}
def insert_contigs = contigs ? "-c ${contigs}" : ''
"""
CAT_pack summarise \\
${args} \\
-i ${classification} \\
${insert_contigs} \\
-o ${prefix}.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
catpack: \$(CAT_pack --version | sed 's/CAT_pack pack v//g;s/ .*//g')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
if ("${classification}" == "${prefix}.txt") {
error("Input and output names are the same, set prefix in module configuration to disambiguate!")
}
def insert_contigs = contigs ? "-c ${contigs}" : ''
"""
echo "CAT_pack summarise \\
${args} \\
-i ${classification} \\
${insert_contigs} \\
-o ${prefix}.txt"
touch ${prefix}.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
catpack: \$(CAT_pack --version | sed 's/CAT_pack pack v//g;s/ .*//g')
END_VERSIONS
"""
}
72 changes: 72 additions & 0 deletions modules/nf-core/catpack/summarise/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "catpack_summarise"
description: Summarises results from CAT/BAT/RAT classification steps
keywords:
- taxonomic classification
- classification
- long reads
- mags
- assembly
tools:
- "catpack":
description: "CAT/BAT: tool for taxonomic classification of contigs and metagenome-assembled
genomes (MAGs)"
homepage: "https://github.com/MGXlab/CAT_pack"
documentation: "https://github.com/MGXlab/CAT_pack"
tool_dev_url: "https://github.com/MGXlab/CAT_pack"
doi: "10.1186/s13059-019-1817-x"
licence: ["MIT"]
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- classification:
type: file
description: CAT/BAT/RAT classification table annotated with official names (from CAT_pack addnames)
pattern: "*.txt"
ontologies:
- edam: "http://edamontology.org/format_3475"
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- contigs:
type: file
description: Optional nucleotide FASTA file containing long DNA sequences such as contigs that were classified (only if classification table is from CAT_pack contigs)
pattern: "*.{fasta,fna,fa,fas}"
ontologies:
- edam: "http://edamontology.org/format_1929"

output:
- txt:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.txt":
type: file
description: |
Summary statistics table of CAT/BAT/RAT results
pattern: "*.txt"
ontologies:
- edam: "http://edamontology.org/format_3475"

- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@jfy133"
maintainers:
- "@jfy133"
158 changes: 158 additions & 0 deletions modules/nf-core/catpack/summarise/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
nextflow_process {

name "Test Process CATPACK_SUMMARISE"
script "../main.nf"
process "CATPACK_SUMMARISE"
config './nextflow.config'

tag "modules"
tag "modules_nfcore"
tag "catpack"
tag "catpack/summarise"
tag "catpack/prepare"
tag "catpack/contigs"
tag "catpack/bins"
tag "catpack/addnames"

setup {
run('CATPACK_PREPARE') {
script '../../prepare/main.nf'
process {
"""
input[0] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/proteome.fasta', checkIfExists: true) ] ]
input[1] = [ file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/prot_nodes.dmp', checkIfExists: true) ]
input[2] = [ file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/prot_names.dmp', checkIfExists: true) ]
input[3] = [ file(params.modules_testdata_base_path + 'genomics/sarscov2/metagenome/prot.accession2taxid.gz', checkIfExists: true) ]
"""
}
}
}

test("sarscov2 - contigs - with names") {

setup {
run('CATPACK_CONTIGS') {
script '../../contigs/main.nf'
process {
"""
input[0] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] ]
input[1] = CATPACK_PREPARE.out.db
input[2] = CATPACK_PREPARE.out.taxonomy
input[3] = [[:], []]
input[4] = [[:], []]
"""
}
}

run('CATPACK_ADDNAMES') {
script '../../addnames/main.nf'
process {
"""
input[0] = CATPACK_CONTIGS.out.contig2classification
input[1] = CATPACK_PREPARE.out.taxonomy
"""
}
}
}

when {
process {
"""
input[0] = CATPACK_ADDNAMES.out.txt
input[1] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - bins - raw") {

setup {
run('CATPACK_BINS') {
script '../../bins/main.nf'
process {
"""
input[0] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] ]
input[1] = CATPACK_PREPARE.out.db
input[2] = CATPACK_PREPARE.out.taxonomy
input[3] = [[:], []]
input[4] = [[:], []]
"""
}
}

run('CATPACK_ADDNAMES') {
script '../../addnames/main.nf'
process {
"""
input[0] = CATPACK_BINS.out.bin2classification
input[1] = CATPACK_PREPARE.out.taxonomy
"""
}
}
}

when {
process {
"""
input[0] = CATPACK_ADDNAMES.out.txt
input[1] = [[:],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - contigs - stub") {

options "-stub"

setup {
run('CATPACK_CONTIGS') {
script '../../contigs/main.nf'
process {
"""
input[0] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] ]
input[1] = CATPACK_PREPARE.out.db
input[2] = CATPACK_PREPARE.out.taxonomy
input[3] = [[:], []]
input[4] = [[:], []]
"""
}
}
}

when {
process {
"""
input[0] = CATPACK_CONTIGS.out.contig2classification
input[1] = [ [id:'test'], [ file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading

0 comments on commit b350d66

Please sign in to comment.