Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nf-test to metaphlan #6139

Merged
merged 33 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a25499d
add nf-test to metaphlan
LilyAnderssonLee Aug 8, 2024
c06bd0e
add config file
LilyAnderssonLee Aug 9, 2024
a8e3949
Merge branch 'master' into metaphlan
jfy133 Aug 11, 2024
fb08ffc
Remove metaphlan/metaphlan form pytest from config
jfy133 Aug 11, 2024
a73a265
Remove ypyest files
jfy133 Aug 11, 2024
359e3db
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
b3ee6fd
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
c0de044
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
a5ddfb6
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
5074f29
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
a8b767a
Update modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
LilyAnderssonLee Aug 13, 2024
b046bc1
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 13, 2024
2383cd3
update nf-test
LilyAnderssonLee Aug 13, 2024
7e10573
update snapshot for metaphlan subworkflow
LilyAnderssonLee Aug 13, 2024
6cd3648
update metaphaln/mergemetaphlan
LilyAnderssonLee Aug 13, 2024
c86e473
Update metaphlan/metaphlan assertions
jfy133 Aug 15, 2024
6d11ac5
Merge branch 'master' into metaphlan
jfy133 Aug 15, 2024
cabbddc
Add stub and fix tests
jfy133 Aug 15, 2024
e5e7da7
Update subworkflow
jfy133 Aug 15, 2024
46556bc
Merge branch 'metaphlan' of https://github.com/LilyAnderssonLee/modul…
jfy133 Aug 15, 2024
7ae5a9d
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 22, 2024
f6a513b
Try adding docker.runOptions
SPPearce Aug 22, 2024
15d9ccb
Merge branch 'master' into metaphlan
SPPearce Aug 22, 2024
061a47f
Actually commit the second config
SPPearce Aug 22, 2024
f4fe038
Try adding no-same-owner
SPPearce Aug 22, 2024
6799023
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 22, 2024
8dc421f
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 26, 2024
e21cbb9
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 26, 2024
61f6f6d
add config to docker
LilyAnderssonLee Aug 27, 2024
79dbc54
Merge branch 'master' into metaphlan
LilyAnderssonLee Aug 27, 2024
1309783
remove enable docker from config
LilyAnderssonLee Aug 27, 2024
257bbf0
Update snapshot
SPPearce Aug 27, 2024
b311270
Merge branch 'master' into metaphlan
SPPearce Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ channels:
- bioconda
- defaults
dependencies:
- bioconda::metaphlan=4.0.6
- bioconda::metaphlan=4.1.1
16 changes: 14 additions & 2 deletions modules/nf-core/metaphlan/mergemetaphlantables/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ process METAPHLAN_MERGEMETAPHLANTABLES {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/metaphlan:4.0.6--pyhca03a8a_0' :
'biocontainers/metaphlan:4.0.6--pyhca03a8a_0' }"
'https://depot.galaxyproject.org/singularity/metaphlan:4.1.1--pyhdfd78af_0' :
'biocontainers/metaphlan:4.1.1--pyhdfd78af_0' }"

input:
tuple val(meta), path(profiles)
Expand All @@ -30,4 +30,16 @@ process METAPHLAN_MERGEMETAPHLANTABLES {
metaphlan: \$(metaphlan --version 2>&1 | awk '{print \$3}')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
metaphlan: \$(metaphlan --version 2>&1 | awk '{print \$3}')
END_VERSIONS
"""
}
79 changes: 79 additions & 0 deletions modules/nf-core/metaphlan/mergemetaphlantables/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "untar"
tag "metaphlan"
tag "metaphlan/metaphlan"
tag "metaphlan/mergemetaphlantables"

setup {
run("UNTAR") {
script "../../../untar/main.nf"
process {
"""
input[0] = Channel.of([
[],
file( params.modules_testdata_base_path + 'delete_me/metaphlan4_database.tar.gz', checkIfExists: true )
])
"""
}
}
run("METAPHLAN_METAPHLAN") {
script "../../../metaphlan/metaphlan/main.nf"
process {
"""
input[0] = Channel.of(
[ [ id: 'test', single_end: true], file( params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz',checkIfExists: true ) ],
[ [ id: 'test2', single_end: true], file( params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz',checkIfExists: true ) ],
)
input[1] = UNTAR.out.untar.map{ it[1] }
"""
}
}
}

test("sarscov2 - illumina single end [fastq]") {

when {
process {
"""
input[0] = METAPHLAN_METAPHLAN.out.profile.map{meta, profile -> [[id: 'test'], profile]}.groupTuple()
"""
}
}

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


test("sarscov2 - illumina single end [fastq] - stub") {

options "-stub"

when {
process {
"""
input[0] = METAPHLAN_METAPHLAN.out.profile.map{meta, profile -> [[id: 'test'], profile]}.groupTuple()
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot( process.out ).match() }
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"sarscov2 - illumina single end [fastq] - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,4687feab0c102fdc65fe2e174431a7c7"
],
"txt": [
[
{
"id": "test"
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,4687feab0c102fdc65fe2e174431a7c7"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-15T07:57:23.888779527"
},
"sarscov2 - illumina single end [fastq]": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.txt:md5,671ac0cf0c2561154fc44109b6d8b973"
]
],
"1": [
"versions.yml:md5,4687feab0c102fdc65fe2e174431a7c7"
],
"txt": [
[
{
"id": "test"
},
"test.txt:md5,671ac0cf0c2561154fc44109b6d8b973"
]
],
"versions": [
"versions.yml:md5,4687feab0c102fdc65fe2e174431a7c7"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-15T07:53:05.914944433"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker {
fixOwnership = true
runOptions = '--platform=linux/amd64'
}

process {
withName: UNTAR {
ext.args2 = "--no-same-owner"
}
}
4 changes: 4 additions & 0 deletions modules/nf-core/metaphlan/mergemetaphlantables/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
metaphlan/mergemetaphlantables:
- "modules/nf-core/metaphlan/mergemetaphlantables/**"
- "modules/nf-core/metaphlan/metaphlan/**"
- "modules/nf-core/untar/**"
2 changes: 1 addition & 1 deletion modules/nf-core/metaphlan/metaphlan/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ channels:
- bioconda
- defaults
dependencies:
- bioconda::metaphlan=4.0.6
- bioconda::metaphlan=4.1.1
21 changes: 19 additions & 2 deletions modules/nf-core/metaphlan/metaphlan/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process METAPHLAN_METAPHLAN {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/metaphlan:4.0.6--pyhca03a8a_0' :
'biocontainers/metaphlan:4.0.6--pyhca03a8a_0' }"
'https://depot.galaxyproject.org/singularity/metaphlan:4.1.1--pyhdfd78af_0' :
'biocontainers/metaphlan:4.1.1--pyhdfd78af_0' }"

input:
tuple val(meta), path(input)
Expand Down Expand Up @@ -47,4 +47,21 @@ process METAPHLAN_METAPHLAN {
metaphlan: \$(metaphlan --version 2>&1 | awk '{print \$3}')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def input_type = "$input" =~ /.*\.(fastq|fq)/ ? "--input_type fastq" : "$input" =~ /.*\.(fasta|fna|fa)/ ? "--input_type fasta" : "$input".endsWith(".bowtie2out.txt") ? "--input_type bowtie2out" : "--input_type sam"
def input_data = ("$input_type".contains("fastq")) && !meta.single_end ? "${input[0]},${input[1]}" : "$input"
def bowtie2_out = "$input_type" == "--input_type bowtie2out" || "$input_type" == "--input_type sam" ? '' : "--bowtie2out ${prefix}.bowtie2out.txt"

"""
touch ${prefix}.biom
touch ${prefix}_profile.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
metaphlan: \$(metaphlan --version 2>&1 | awk '{print \$3}')
END_VERSIONS
"""
}
4 changes: 2 additions & 2 deletions modules/nf-core/metaphlan/metaphlan/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ input:
type: file
description: Metaphlan can classify the metagenome from a variety of input data types, including FASTQ files (single-end and paired-end), FASTA, bowtie2-produced SAM files (produced from alignments to the MetaPHlAn marker database) and intermediate bowtie2 alignment files (bowtie2out)
pattern: "*.{fastq.gz, fasta, fasta.gz, sam, bowtie2out.txt}"
- metaphlan_db:
- metaphlan_db_latest:
type: file
description: |
Directory containing pre-downloaded and uncompressed MetaPhlAn database downloaded from: http://cmprod1.cibio.unitn.it/biobakery4/metaphlan_databases/.
Expand All @@ -47,7 +47,7 @@ output:
type: file
description: General-use format for representing biological sample by observation contingency tables
pattern: "*.{biom}"
- bowtie2out:
- bt2out:
type: file
description: Intermediate Bowtie2 output produced from mapping the metagenome against the MetaPHlAn marker database ( not compatible with `bowtie2out` files generated with MetaPhlAn versions below 3 )
pattern: "*.{bowtie2out.txt}"
Expand Down
136 changes: 136 additions & 0 deletions modules/nf-core/metaphlan/metaphlan/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
nextflow_process {
name "Test Process METAPHLAN_METAPHLAN"
script "../main.nf"
config "./nextflow.config"

process "METAPHLAN_METAPHLAN"
tag "modules"
tag "modules_nfcore"
tag "untar"
tag "metaphlan"
tag "metaphlan/metaphlan"

setup {
run("UNTAR") {
script "modules/nf-core/untar/main.nf"
process {
"""
input[0] = Channel.of([
[],
file( params.modules_testdata_base_path + 'delete_me/metaphlan4_database.tar.gz', checkIfExists: true )
])
"""
}
}
}

test("sarscov2 - illumina single end [fastq]") {


when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
file( params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz',checkIfExists: true )
])
input[1] = UNTAR.out.untar.map{ it[1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.profile[0][1]).readLines()[2..5],
path(process.out.biom[0][1]).readLines().last().contains('Biological Observation Matrix'),
process.out.bt2out,
process.out.versions
).match()
}
)
}
}

test("sarscov2 - illumina pair end [fastq]") {

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:false ], // 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] = UNTAR.out.untar.map{ it[1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.profile[0][1]).readLines()[2..5],
path(process.out.biom[0][1]).readLines().last().contains('Biological Observation Matrix'),
process.out.bt2out,
process.out.versions
).match()
}
)
}
}

test("sarscov2 - illumina single end [fasta]") {

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
file( params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fasta/contigs.fasta',checkIfExists: true )
])
input[1] = UNTAR.out.untar.map{ it[1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.profile[0][1]).readLines()[2..5],
path(process.out.biom[0][1]).readLines().last().contains('Biological Observation Matrix'),
process.out.bt2out,
process.out.versions
).match()
} )
}
}

test("sarscov2 - illumina pair end [fastq] - stub") {

options "-stub"

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:false ], // 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] = UNTAR.out.untar.map{ it[1] }
"""
}
}

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