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 tests for fq2bam #6902

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ jobs:
path: modules/nf-core/parabricks/fq2bammeth
- profile: singularity
path: modules/nf-core/parabricks/fq2bammeth
- profile: conda
sateeshperi marked this conversation as resolved.
Show resolved Hide resolved
path: modules/nf-core/parabricks/fq2bam
- profile: docker_self_hosted
path: modules/nf-core/parabricks/fq2bam
- profile: singularity
path: modules/nf-core/parabricks/fq2bam
- profile: conda
path: subworkflows/nf-core/vcf_annotate_ensemblvep
- profile: conda
Expand Down
37 changes: 14 additions & 23 deletions modules/nf-core/parabricks/fq2bam/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ process PARABRICKS_FQ2BAM {
tag "$meta.id"
label 'process_high'

container "nvcr.io/nvidia/clara/clara-parabricks:4.3.0-1"
container "nvcr.io/nvidia/clara/clara-parabricks:4.3.2-1"

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

output:
tuple val(meta), path("*.bam") , emit: bam
tuple val(meta), path("*.bai") , emit: bai
path "versions.yml" , emit: versions
path "qc_metrics", optional:true , emit: qc_metrics
path("*.table"), optional:true , emit: bqsr_table
path("duplicate-metrics.txt"), optional:true , emit: duplicate_metrics
tuple val(meta), path("*.bam") , emit: bam
tuple val(meta), path("*.bai") , emit: bai
path "versions.yml" , emit: versions
path "qc_metrics" , emit: qc_metrics , optional:true
path("*.table") , emit: bqsr_table , optional:true
path("duplicate-metrics.txt") , emit: duplicate_metrics , optional:true

when:
task.ext.when == null || task.ext.when
Expand All @@ -32,21 +33,20 @@ process PARABRICKS_FQ2BAM {
def known_sites_command = known_sites ? known_sites.collect{"--knownSites $it"}.join(' ') : ""
def known_sites_output = known_sites ? "--out-recal-file ${prefix}.table" : ""
def interval_file_command = interval_file ? interval_file.collect{"--interval-file $it"}.join(' ') : ""
def num_gpus = task.accelerator ? "--num-gpus $task.accelerator.request" : ''
"""

INDEX=`find -L ./ -name "*.amb" | sed 's/\\.amb\$//'`
mv $fasta \$INDEX
cp $fasta \$INDEX

pbrun \\
fq2bam \\
--ref \$INDEX \\
$in_fq_command \\
--read-group-sm $meta.id \\
--out-bam ${prefix}.bam \\
$known_sites_command \\
$known_sites_output \\
$interval_file_command \\
--num-gpus $task.accelerator.request \\
$num_gpus \\
$args

cat <<-END_VERSIONS > versions.yml
Expand All @@ -62,19 +62,10 @@ process PARABRICKS_FQ2BAM {
}
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def in_fq_command = meta.single_end ? "--in-se-fq $reads" : "--in-fq $reads"
def known_sites_command = known_sites ? known_sites.collect{"--knownSites $it"}.join(' ') : ""
def known_sites_output = known_sites ? "--out-recal-file ${prefix}.table" : ""
def interval_file_command = interval_file ? interval_file.collect{"--interval-file $it"}.join(' ') : ""
def metrics_output_command = args = "--out-duplicate-metrics duplicate-metrics.txt" ? "touch duplicate-metrics.txt" : ""
def known_sites_output_command = known_sites ? "touch ${prefix}.table" : ""
def qc_metrics_output_command = args = "--out-qc-metrics-dir qc_metrics " ? "mkdir qc_metrics && touch qc_metrics/alignment.txt" : ""
"""
touch ${prefix}.bam
touch ${prefix}.bam.bai
$metrics_output_command
$known_sites_output_command
$qc_metrics_output_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
pbrun: \$(echo \$(pbrun version 2>&1) | sed 's/^Please.* //' )
Expand Down
11 changes: 6 additions & 5 deletions modules/nf-core/parabricks/fq2bam/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ input:
type: file
description: fastq.gz files
pattern: "*.fastq.gz"
- interval_file:
type: file
description: (optional) file(s) containing genomic intervals for use in base
quality score recalibration (BQSR)
pattern: "*.{bed,interval_list,picard,list,intervals}"
- - meta2:
type: map
description: |
Expand All @@ -45,6 +40,11 @@ input:
type: file
description: reference BWA index
pattern: "*.{amb,ann,bwt,pac,sa}"
- - interval_file:
sateeshperi marked this conversation as resolved.
Show resolved Hide resolved
type: file
description: (optional) file(s) containing genomic intervals for use in base
quality score recalibration (BQSR)
pattern: "*.{bed,interval_list,picard,list,intervals}"
- - known_sites:
type: file
description: (optional) known sites file(s) for calculating BQSR. markdups must
Expand Down Expand Up @@ -99,3 +99,4 @@ authors:
maintainers:
- "@bsiranosian"
- "@adamrtalbot"
- "@gallvp"
174 changes: 174 additions & 0 deletions modules/nf-core/parabricks/fq2bam/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
nextflow_process {

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

tag "bwa/index"
tag "modules"
tag "parabricks/fq2bam"
tag "modules_nfcore"
tag "parabricks"

setup {
run("BWA_INDEX") {
script "../../../bwa/index/main.nf"
process {
"""
input[0] = Channel.of([
[ id:'test' ], // meta map
file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa', checkIfExists: true)
])
"""
}
}

run("BWA_INDEX", alias: 'BWA_INDEX_PE') {
script "../../../bwa/index/main.nf"
sateeshperi marked this conversation as resolved.
Show resolved Hide resolved
process {
"""
input[0] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
"""
}
}
}

test("SRR389222 - fastq - se") {

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
[
file('https://github.com/nf-core/test-datasets/raw/methylseq/testdata/SRR389222_sub1.fastq.gz', checkIfExists: true)
]
])
input[1] = Channel.of([
[ id:'test' ], // meta map
file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa', checkIfExists: true)
])
input[2] = BWA_INDEX.out.index
input[3] = []
input[4] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
file(process.out.bai[0][1]).name,
process.out.versions
).match() }
)
}
}

test("SRR389222 - fastq - se - stub") {
options '-stub'

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
[
file('https://github.com/nf-core/test-datasets/raw/methylseq/testdata/SRR389222_sub1.fastq.gz', checkIfExists: true)
]
])
input[1] = Channel.of([
[ id:'test' ], // meta map
file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa', checkIfExists: true)
])
input[2] = BWA_INDEX.out.index
input[3] = []
input[4] = []
"""
}
}

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

test("sarscov2 - fastq - pe") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
sateeshperi marked this conversation as resolved.
Show resolved Hide resolved
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_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] = BWA_INDEX_PE.out.index
input[3] = []
input[4] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
file(process.out.bai[0][1]).name,
process.out.versions
).match() }
)
}

}

test("sarscov2 - fastq - pe - stub") {
options '-stub'

when {
process {
"""
input[0] = [
[ 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] = Channel.of([
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
])
input[2] = BWA_INDEX_PE.out.index
input[3] = []
input[4] = []
"""
}
}

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

}

}
Loading
Loading