Skip to content

Commit

Permalink
rm fasta from bwameth index folder to be handled separately (#6780)
Browse files Browse the repository at this point in the history
* rm fasta from bwameth index folder to be handled separately + update test + snaps

* provide fasta separtely to index folder

* add stub test
  • Loading branch information
sateeshperi authored Oct 16, 2024
1 parent 847683c commit aa2f432
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 79 deletions.
10 changes: 5 additions & 5 deletions modules/nf-core/bwameth/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ process BWAMETH_ALIGN {

input:
tuple val(meta), path(reads)
path index
tuple val(meta2), path(fasta)
tuple val(meta3), path(index)

output:
tuple val(meta), path("*.bam"), emit: bam
Expand All @@ -24,17 +25,16 @@ process BWAMETH_ALIGN {
def prefix = task.ext.prefix ?: "${meta.id}"
def read_group = meta.read_group ? "-R ${meta.read_group}" : ""
"""
INDEX=`find -L ${index} -name "*.bwameth.c2t" | sed 's/\\.bwameth.c2t\$//'`
# Modify the timestamps so that bwameth doesn't complain about building the index
# See https://github.com/nf-core/methylseq/pull/217
touch -c -- *
touch -c $index/*
mv $fasta $index/
bwameth.py \\
$args \\
$read_group \\
-t $task.cpus \\
--reference \$INDEX \\
--reference $index/$fasta \\
$reads \\
| samtools view $args2 -@ $task.cpus -bhS -o ${prefix}.bam -
Expand Down
15 changes: 14 additions & 1 deletion modules/nf-core/bwameth/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ input:
description: |
List of input FastQ files of size 1 and 2 for single-end and paired-end data,
respectively.
- - index:
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: Input genome fasta file
- - meta3:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- index:
type: directory
description: Directory containing bwameth genome index
output:
Expand Down
69 changes: 39 additions & 30 deletions modules/nf-core/bwameth/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,29 @@ nextflow_process {
script "../../../bwameth/index/main.nf"
process {
"""
input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[0] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
"""
}
}
}

test("test-bwameth-align-single-end") {
test("sarscov2 methylated single_end [fastq]") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:true ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true)
]
]
input[1] = BWAMETH_INDEX.out.index
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true)
])
input[1] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
input[2] = BWAMETH_INDEX.out.index
"""
}
}
Expand All @@ -52,20 +55,23 @@ nextflow_process {
}
}

test("test-bwameth-align-paired-end") {
test("sarscov2 methylated paired_end [fastq]") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BWAMETH_INDEX.out.index
input[0] = Channel.of([
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_2.fastq.gz', checkIfExists: true)
]
])
input[1] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
input[2] = BWAMETH_INDEX.out.index
"""
}
}
Expand All @@ -88,15 +94,18 @@ nextflow_process {
when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BWAMETH_INDEX.out.index
input[0] = Channel.of([
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test.methylated_2.fastq.gz', checkIfExists: true)
]
])
input[1] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
input[2] = BWAMETH_INDEX.out.index
"""
}
}
Expand Down
32 changes: 16 additions & 16 deletions modules/nf-core/bwameth/align/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"test-bwameth-align-single-end": {
"sarscov2 methylated single_end [fastq]": {
"content": [
"5fdda0ada69daa3956c65a24c9d1c1e0",
[
Expand All @@ -10,20 +10,7 @@
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-04T20:43:02.509483"
},
"test-bwameth-align-paired-end": {
"content": [
"cbd5cfa8b446e26987898a45a94770ba",
[
"versions.yml:md5,c00660f78aeab4fabe00092c70656098"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-04T20:43:10.963043"
"timestamp": "2024-10-16T07:50:08.241201566"
},
"test-bwameth-align-paired-end-stub": {
"content": [
Expand Down Expand Up @@ -58,6 +45,19 @@
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-04T20:43:17.04632"
"timestamp": "2024-10-16T08:00:51.770330645"
},
"sarscov2 methylated paired_end [fastq]": {
"content": [
"cbd5cfa8b446e26987898a45a94770ba",
[
"versions.yml:md5,c00660f78aeab4fabe00092c70656098"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-16T07:50:20.75109829"
}
}
25 changes: 21 additions & 4 deletions modules/nf-core/bwameth/index/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,36 @@ process BWAMETH_INDEX {
'biocontainers/bwameth:0.2.7--pyh7cba7a3_0' }"

input:
path fasta, stageAs: "bwameth/*"
tuple val(meta), path(fasta)

output:
path "bwameth" , emit: index
path "versions.yml" , emit: versions
tuple val(meta), path("BwamethIndex"), emit: index
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
"""
bwameth.py index $fasta
mkdir BwamethIndex
mv $fasta BwamethIndex/
bwameth.py index BwamethIndex/$fasta
rm BwamethIndex/$fasta
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bwameth: \$(bwameth.py --version | cut -f2 -d" ")
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
"""
mkdir BwamethIndex
touch BwamethIndex/$fasta
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
14 changes: 12 additions & 2 deletions modules/nf-core/bwameth/index/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ tools:
licence: ["MIT"]
identifier: ""
input:
- - fasta:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: Input genome fasta file
output:
- index:
- bwameth:
- meta:
type: directory
description: Directory containing bwameth genome index
pattern: "index"
- BwamethIndex:
type: directory
description: Directory containing bwameth genome index
pattern: "index"
Expand All @@ -37,3 +46,4 @@ authors:
- "@phue"
maintainers:
- "@phue"
- "@sateeshperi"
11 changes: 7 additions & 4 deletions modules/nf-core/bwameth/index/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ nextflow_process {
tag "bwameth"
tag "bwameth/index"

test("test-bwameth-index") {
test("sarscov2 genome [fasta]") {

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[0] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
"""
}
}
Expand All @@ -27,5 +30,5 @@ nextflow_process {
)
}
}

}
42 changes: 25 additions & 17 deletions modules/nf-core/bwameth/index/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
{
"test-bwameth-index": {
"sarscov2 genome [fasta]": {
"content": [
{
"0": [
[
"genome.fasta:md5,6e9fe4042a72f2345f644f239272b7e6",
"genome.fasta.bwameth.c2t:md5,98039984526a41d04d6bd92fcc040c62",
"genome.fasta.bwameth.c2t.amb:md5,249a4195069071ce47cd0bae68abe376",
"genome.fasta.bwameth.c2t.ann:md5,46524d4359dcdfb203a235ab3b930dbb",
"genome.fasta.bwameth.c2t.bwt:md5,84f65df7d42dbe84c9ccfaddfdd5ea6b",
"genome.fasta.bwameth.c2t.pac:md5,4d8e51cb0bbdeaf24576bdf0264d8653",
"genome.fasta.bwameth.c2t.sa:md5,d25f6486f5134f57ed5b258f6fbb8673"
{
"id": "test"
},
[
"genome.fasta.bwameth.c2t:md5,98039984526a41d04d6bd92fcc040c62",
"genome.fasta.bwameth.c2t.amb:md5,249a4195069071ce47cd0bae68abe376",
"genome.fasta.bwameth.c2t.ann:md5,46524d4359dcdfb203a235ab3b930dbb",
"genome.fasta.bwameth.c2t.bwt:md5,84f65df7d42dbe84c9ccfaddfdd5ea6b",
"genome.fasta.bwameth.c2t.pac:md5,4d8e51cb0bbdeaf24576bdf0264d8653",
"genome.fasta.bwameth.c2t.sa:md5,d25f6486f5134f57ed5b258f6fbb8673"
]
]
],
"1": [
"versions.yml:md5,0827d461c1a0b41bd533aea470843c2c"
],
"index": [
[
"genome.fasta:md5,6e9fe4042a72f2345f644f239272b7e6",
"genome.fasta.bwameth.c2t:md5,98039984526a41d04d6bd92fcc040c62",
"genome.fasta.bwameth.c2t.amb:md5,249a4195069071ce47cd0bae68abe376",
"genome.fasta.bwameth.c2t.ann:md5,46524d4359dcdfb203a235ab3b930dbb",
"genome.fasta.bwameth.c2t.bwt:md5,84f65df7d42dbe84c9ccfaddfdd5ea6b",
"genome.fasta.bwameth.c2t.pac:md5,4d8e51cb0bbdeaf24576bdf0264d8653",
"genome.fasta.bwameth.c2t.sa:md5,d25f6486f5134f57ed5b258f6fbb8673"
{
"id": "test"
},
[
"genome.fasta.bwameth.c2t:md5,98039984526a41d04d6bd92fcc040c62",
"genome.fasta.bwameth.c2t.amb:md5,249a4195069071ce47cd0bae68abe376",
"genome.fasta.bwameth.c2t.ann:md5,46524d4359dcdfb203a235ab3b930dbb",
"genome.fasta.bwameth.c2t.bwt:md5,84f65df7d42dbe84c9ccfaddfdd5ea6b",
"genome.fasta.bwameth.c2t.pac:md5,4d8e51cb0bbdeaf24576bdf0264d8653",
"genome.fasta.bwameth.c2t.sa:md5,d25f6486f5134f57ed5b258f6fbb8673"
]
]
],
"versions": [
Expand All @@ -33,9 +41,9 @@
}
],
"meta": {
"nf-test": "0.8.4",
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-28T13:57:11.602104"
"timestamp": "2024-10-14T20:32:13.750317299"
}
}

0 comments on commit aa2f432

Please sign in to comment.