Skip to content

Commit

Permalink
Add coptr module (#6935)
Browse files Browse the repository at this point in the history
* Initial addition

* Updated snapshot

* Updated snapshot

* Updated tests.

* Updated tests.

* Updated snapshot

* removed extra directory creation

* Added plugin to only compare bam reads, not header

* Added plugin to only compare bam reads, not header

* Added plugin to only compare bam reads, not header

* Output filename now also contains index id so as to not to repeat filenames

* Updated snapshot

* Updated snapshot

* Added paired end test

* Added paired end test

* Updated tests to deal with bams changing order of reads each time

* Updated tests to deal with bams changing order of reads each time

* Updated tests to deal with bams changing order of reads each time

* Updated tests to deal with bams changing order of reads each time

* Updated container used

* Added number of lines test for review

* Added number of lines test for review

* Updated nft-bam plugin

* Updated container

* Updated counting of reads

* Updated counting of reads

* removed

* updated snapshot

* Updated test and snapshot

* Updated test and snapshot

* fixed versions issue

* fixed versions issue

* fixed versions issue

* fixed versions issue

* fixed versions issue

* fixed versions issue

* Updated test

* Updated test

* Updated snapshot

* Updated tag

* Updated tests

* Updated tests

* Improved descriptions

---------

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
Co-authored-by: Igor Trujnara <53370556+itrujnara@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent af27a50 commit 367a163
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 82 deletions.
5 changes: 3 additions & 2 deletions modules/nf-core/coptr/index/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process COPTR_INDEX {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/coptr:1.1.4--pyhdfd78af_1':
'biocontainers/coptr:1.1.4--pyhdfd78af_1' }"
'https://depot.galaxyproject.org/singularity/coptr:1.1.4--pyhdfd78af_3':
'biocontainers/coptr:1.1.4--pyhdfd78af_3' }"

input:
tuple val(meta), path(indexfasta, stageAs: "fastafolder/*")
Expand All @@ -29,6 +29,7 @@ process COPTR_INDEX {
--bt2-threads $task.cpus \
fastafolder \
bowtie2/${prefix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/')
Expand Down
27 changes: 2 additions & 25 deletions modules/nf-core/coptr/index/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,7 @@ nextflow_process {

}

test("coptr index with multiple fastqs") {

when {
process {
"""
input[0] = [
[id:'indexNameExample'],
[file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome2.fasta', checkIfExists: true),file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome3.fasta', checkIfExists: true)]
]
"""
}
}

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

}

test("coptr index with multiple fastqs - stub") {
test("coptr index with single fastq - stub") {

options "-stub"

Expand All @@ -63,7 +41,7 @@ nextflow_process {
"""
input[0] = [
[id:'indexNameExample'],
[file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome2.fasta', checkIfExists: true),file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome3.fasta', checkIfExists: true)]
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
Expand All @@ -78,5 +56,4 @@ nextflow_process {

}


}
59 changes: 5 additions & 54 deletions modules/nf-core/coptr/index/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
}
],
"meta": {
"nf-test": "0.9.1",
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-01T15:20:08.028567181"
"timestamp": "2024-11-15T13:37:15.478846"
},
"coptr index with multiple fastqs - stub": {
"coptr index with single fastq - stub": {
"content": [
{
"0": [
Expand Down Expand Up @@ -92,58 +92,9 @@
}
],
"meta": {
"nf-test": "0.9.1",
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-01T15:28:00.318435045"
},
"coptr index with multiple fastqs": {
"content": [
{
"0": [
[
{
"id": "indexNameExample"
},
[
"indexNameExample.1.bt2:md5,e88e383183a9dec8dd453b04dc89a903",
"indexNameExample.2.bt2:md5,ae84a18d674ecc823c82188f5ca1ffc9",
"indexNameExample.3.bt2:md5,702fe6c79ef7bc9b54b3661f2f4aaa0b",
"indexNameExample.4.bt2:md5,a2234db869afc50b40f7e7d1289f5f0b",
"indexNameExample.genomes:md5,d4ed161da3cf2ced8e7c66c0c90e8d3e",
"indexNameExample.rev.1.bt2:md5,75d78b73949d636ec9750269a5ea1c8b",
"indexNameExample.rev.2.bt2:md5,39a1186f6aad701a71d773074408b51e"
]
]
],
"1": [
"versions.yml:md5,6013eeb9d8ac97351260150f44091986"
],
"index_dir": [
[
{
"id": "indexNameExample"
},
[
"indexNameExample.1.bt2:md5,e88e383183a9dec8dd453b04dc89a903",
"indexNameExample.2.bt2:md5,ae84a18d674ecc823c82188f5ca1ffc9",
"indexNameExample.3.bt2:md5,702fe6c79ef7bc9b54b3661f2f4aaa0b",
"indexNameExample.4.bt2:md5,a2234db869afc50b40f7e7d1289f5f0b",
"indexNameExample.genomes:md5,d4ed161da3cf2ced8e7c66c0c90e8d3e",
"indexNameExample.rev.1.bt2:md5,75d78b73949d636ec9750269a5ea1c8b",
"indexNameExample.rev.2.bt2:md5,39a1186f6aad701a71d773074408b51e"
]
]
],
"versions": [
"versions.yml:md5,6013eeb9d8ac97351260150f44091986"
]
}
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-01T15:24:04.847842182"
"timestamp": "2024-11-15T13:37:21.536745"
}
}
7 changes: 7 additions & 0 deletions modules/nf-core/coptr/map/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::coptr=1.1.4"
61 changes: 61 additions & 0 deletions modules/nf-core/coptr/map/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
process COPTR_MAP {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/coptr:1.1.4--pyhdfd78af_3':
'biocontainers/coptr:1.1.4--pyhdfd78af_3' }"

input:
tuple val(meta), path(fasta, stageAs: "fastafolder/*")
tuple val(meta2), path(index)

output:
tuple val(meta), path("*.bam"), emit: bam
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}"
def prefix2 = task.ext.prefix ?: "${meta2.id}"

def paired_end = ""
if ( ! meta.single_end ) {
paired_end = "--paired"
}
"""
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/\\.rev.1.bt2\$//"`
[ -z "\$INDEX" ] && INDEX=`find -L ./ -name "*.rev.1.bt2l" | sed "s/\\.rev.1.bt2l\$//"`
[ -z "\$INDEX" ] && echo "Bowtie2 index files not found" 1>&2 && exit 1
coptr \
map \
$args $paired_end \
--threads $task.cpus \
\$INDEX \
fastafolder \
.
mv ${prefix}.bam ${prefix}_${prefix2}.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
coptr: \$(coptr |& sed -E '11!d ; s/CoPTR.*?\\(v(.*?)\\).*/\\1/')
END_VERSIONS
"""
}
63 changes: 63 additions & 0 deletions modules/nf-core/coptr/map/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "coptr_map"
description: Maps the reads to the reference database
keywords:
- coptr
- mapping
- ptr
tools:
- "coptr":
description: "Accurate and robust inference of microbial growth dynamics from
metagenomic sequencing reads."
homepage: "https://github.com/tyjo/coptr"
documentation: "https://coptr.readthedocs.io/"
tool_dev_url: "https://github.com/tyjo/coptr"
doi: "10.1101/gr.275533.121"
licence: ["GPL v3"]
identifier: biotools:coptr

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- fasta:
type: file
description: fastq file with reads
pattern: "*.{.fastq,.fq,.fastq.gz,fq.gz}"
ontologies:
- edam: "http://edamontology.org/format_1929"
- - meta2:
type: map
description: |
Groovy Map containing index genome id and path
e.g. [ id:'test', 'bowtie2' ]
- index:
type: file
description: Directory with Bowtie2 genome index files
pattern: "*.ebwt"

output:
- bam:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.bam":
type: file
description: Alignment (BAM) file of reads mapped to the reference database
pattern: "*.{bam}"
ontologies:
- edam: "http://edamontology.org/format_2572"
- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@ramirobarrantes"
maintainers:
- "@ramirobarrantes"
106 changes: 106 additions & 0 deletions modules/nf-core/coptr/map/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
nextflow_process {

name "Test Process COPTR_MAP"
script "../main.nf"
process "COPTR_MAP"

tag "modules"
tag "modules_nfcore"
tag "coptr"
tag "coptr/index"
tag "coptr/map"

setup {
run("COPTR_INDEX") {
script "../../index/main.nf"
process {
"""
input[0] = [
[id:'test_0'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
}
}

test("sarscov2 - single end test") {

when {
process {
"""
input[0] = [
[ id:'test_1', single_end: true ],
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true)
]
input[1] = COPTR_INDEX.out.index_dir
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.bam.collect{bam(it[1]).getReads(10)},
process.out.bam.collect{bam(it[1]).getStatistics(include:["readCount"])},
process.out.versions
).match() }
)
}
}

test("sarscov2 - paired end") {

when {
process {
"""
input[0] = [
[ id:'test', single_end: false ],
[
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] = COPTR_INDEX.out.index_dir
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.bam.collect{bam(it[1]).getStatistics(include:["readCount"])},
process.out.versions
).match() }
)
}
}


test("sarscov2 - single end - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end: true ],
file(params.modules_testdata_base_path + "genomics/sarscov2/illumina/fastq/test_1.fastq.gz", checkIfExists: true)
]
input[1] = COPTR_INDEX.out.index_dir
"""
}
}

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

}
Loading

0 comments on commit 367a163

Please sign in to comment.