Skip to content
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
15 changes: 5 additions & 10 deletions modules/nf-core/trgt/merge/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ process TRGT_MERGE {

output:
tuple val(meta), path("*.{vcf,vcf.gz,bcf,bcf.gz}"), emit: vcf
tuple val(meta), path("*.{tbi,csi}") , emit: index, optional: true
tuple val("${task.process}"), val('trgt'), eval("trgt --version | sed 's/.* //g'"), emit: versions_trgt, topic: versions

when:
Expand All @@ -32,15 +33,11 @@ process TRGT_MERGE {

"""
trgt merge \\
--threads ${task.cpus} \\
$args \\
$reference \\
$output \\
--vcf ${vcfs}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
END_VERSIONS
"""

stub:
Expand All @@ -52,12 +49,10 @@ process TRGT_MERGE {
args.contains("--output-type v") || args.contains("-Ov") ? "vcf" :
"vcf"
def create_cmd = extension.endsWith(".gz") ? "echo '' | gzip >" : "touch"
def index_type = extension == "vcf.gz" ? "tbi" : extension == "bcf.gz" ? "csi" : ''
def create_index = args.contains("--write-index") && extension.endsWith(".gz") ? "touch ${prefix}.${extension}.${index_type}" : ''
"""
$create_cmd ${prefix}.${extension}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
END_VERSIONS
$create_index
"""
}
11 changes: 11 additions & 0 deletions modules/nf-core/trgt/merge/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ output:
description: "Merged output file"
pattern: "*.{vcf,vcf.gz,bcf,bcf.gz}"
ontologies: []
index:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.{tbi,csi}":
type: file
description: "Index of merged output file"
pattern: "*.{tbi,csi}"
ontologies: []
versions_trgt:
- - ${task.process}:
type: string
Expand Down
89 changes: 83 additions & 6 deletions modules/nf-core/trgt/merge/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ nextflow_process {
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
path(process.out.vcf.get(0).get(1)).vcf.summary,
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
process.out.index,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
Expand All @@ -120,6 +121,7 @@ nextflow_process {
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
path(process.out.vcf.get(0).get(1)).vcf.summary,
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
process.out.index,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
Expand All @@ -132,6 +134,7 @@ nextflow_process {
input[0] = BCFTOOLS_SORT.out.vcf
.join(BCFTOOLS_SORT.out.tbi)
.first()
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
"""
Expand All @@ -143,16 +146,17 @@ nextflow_process {
)
}
}
test("homo sapiens - 1 VCF - --force-single") {
test("homo sapiens - 1 VCF - --force-single --output-type z --write-index") {
when {
params {
trgt_merge_args = "--force-single"
trgt_merge_args = "--force-single --output-type z --write-index"
}
process {
"""
input[0] = BCFTOOLS_SORT.out.vcf
.join(BCFTOOLS_SORT.out.tbi)
.first()
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
"""
Expand All @@ -165,11 +169,87 @@ nextflow_process {
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
path(process.out.vcf.get(0).get(1)).vcf.summary,
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
process.out.index,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
}
}
test("homo sapiens - 1 VCF - --force-single --output-type b --write-index") {
when {
params {
trgt_merge_args = "--force-single --output-type b --write-index"
}
process {
"""
input[0] = BCFTOOLS_SORT.out.vcf
.join(BCFTOOLS_SORT.out.tbi)
.first()
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.vcf.get(0).get(1)).name,
process.out.index,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
}
}
test("homo sapiens - 2 VCFs - tbi index - stub") {
options "-stub"
when {
params {
trgt_merge_args = "--output-type z --write-index"
}
process {
"""
input[0] = BCFTOOLS_SORT.out.vcf
.join(BCFTOOLS_SORT.out.tbi)
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
.groupTuple()
input[1] = [[],[]]
input[2] = [[],[]]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("homo sapiens - 2 VCFs - csi index - stub") {
options "-stub"
when {
params {
trgt_merge_args = "--output-type b --write-index"
}
process {
"""
input[0] = BCFTOOLS_SORT.out.vcf
.join(BCFTOOLS_SORT.out.tbi)
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
.groupTuple()
input[1] = [[],[]]
input[2] = [[],[]]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
test("homo sapiens - 2 VCFs - stub") {
options "-stub"
when {
Expand All @@ -187,10 +267,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
{ assert snapshot(process.out).match() }
)
}
}
Expand Down
Loading
Loading