Skip to content

Commit 69558f2

Browse files
committed
Add index and threads to trgt/merge
1 parent 22bb4dc commit 69558f2

File tree

4 files changed

+257
-25
lines changed

4 files changed

+257
-25
lines changed

modules/nf-core/trgt/merge/main.nf

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ process TRGT_MERGE {
1414

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

1920
when:
@@ -32,15 +33,11 @@ process TRGT_MERGE {
3233

3334
"""
3435
trgt merge \\
36+
--threads ${task.cpus} \\
3537
$args \\
3638
$reference \\
3739
$output \\
3840
--vcf ${vcfs}
39-
40-
cat <<-END_VERSIONS > versions.yml
41-
"${task.process}":
42-
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
43-
END_VERSIONS
4441
"""
4542

4643
stub:
@@ -52,12 +49,10 @@ process TRGT_MERGE {
5249
args.contains("--output-type v") || args.contains("-Ov") ? "vcf" :
5350
"vcf"
5451
def create_cmd = extension.endsWith(".gz") ? "echo '' | gzip >" : "touch"
52+
def index_type = extension == "vcf.gz" ? "tbi" : extension == "bcf.gz" ? "csi" : ''
53+
def create_index = args.contains("--write-index") && extension.endsWith(".gz") ? "touch ${prefix}.${extension}.${index_type}" : ''
5554
"""
5655
$create_cmd ${prefix}.${extension}
57-
58-
cat <<-END_VERSIONS > versions.yml
59-
"${task.process}":
60-
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
61-
END_VERSIONS
56+
$create_index
6257
"""
6358
}

modules/nf-core/trgt/merge/meta.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ output:
7272
description: "Merged output file"
7373
pattern: "*.{vcf,vcf.gz,bcf,bcf.gz}"
7474
ontologies: []
75+
index:
76+
- - meta:
77+
type: map
78+
description: |
79+
Groovy Map containing sample information
80+
e.g. `[ id:'sample1', single_end:false ]`
81+
- "*.{tbi,csi}":
82+
type: file
83+
description: "Index of merged output file"
84+
pattern: "*.{tbi,csi}"
85+
ontologies: []
7586
versions_trgt:
7687
- - ${task.process}:
7788
type: string

modules/nf-core/trgt/merge/tests/main.nf.test

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ nextflow_process {
9595
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
9696
path(process.out.vcf.get(0).get(1)).vcf.summary,
9797
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
98+
process.out.index,
9899
process.out.findAll { key, val -> key.startsWith("versions")}
99100
).match() }
100101
)
@@ -120,6 +121,7 @@ nextflow_process {
120121
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
121122
path(process.out.vcf.get(0).get(1)).vcf.summary,
122123
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
124+
process.out.index,
123125
process.out.findAll { key, val -> key.startsWith("versions")}
124126
).match() }
125127
)
@@ -143,10 +145,10 @@ nextflow_process {
143145
)
144146
}
145147
}
146-
test("homo sapiens - 1 VCF - --force-single") {
148+
test("homo sapiens - 1 VCF - --force-single --output-type z --write-index") {
147149
when {
148150
params {
149-
trgt_merge_args = "--force-single"
151+
trgt_merge_args = "--force-single --output-type z --write-index"
150152
}
151153
process {
152154
"""
@@ -165,11 +167,86 @@ nextflow_process {
165167
path(process.out.vcf.get(0).get(1)).vcf.variantsMD5,
166168
path(process.out.vcf.get(0).get(1)).vcf.summary,
167169
path(process.out.vcf.get(0).get(1)).vcf.sampleCount,
170+
process.out.index,
168171
process.out.findAll { key, val -> key.startsWith("versions")}
169172
).match() }
170173
)
171174
}
172175
}
176+
test("homo sapiens - 1 VCF - --force-single --output-type b --write-index") {
177+
when {
178+
params {
179+
trgt_merge_args = "--force-single --output-type b --write-index"
180+
}
181+
process {
182+
"""
183+
input[0] = BCFTOOLS_SORT.out.vcf
184+
.join(BCFTOOLS_SORT.out.tbi)
185+
.first()
186+
input[1] = GUNZIP.out.gunzip
187+
input[2] = SAMTOOLS_FAIDX.out.fai
188+
"""
189+
}
190+
}
191+
then {
192+
assertAll(
193+
{ assert process.success },
194+
{ assert snapshot(
195+
file(process.out.vcf.get(0).get(1)).name,
196+
process.out.index,
197+
process.out.findAll { key, val -> key.startsWith("versions")}
198+
).match() }
199+
)
200+
}
201+
}
202+
test("homo sapiens - 2 VCFs - tbi index - stub") {
203+
options "-stub"
204+
when {
205+
params {
206+
trgt_merge_args = "--output-type z --write-index"
207+
}
208+
process {
209+
"""
210+
input[0] = BCFTOOLS_SORT.out.vcf
211+
.join(BCFTOOLS_SORT.out.tbi)
212+
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
213+
.groupTuple()
214+
input[1] = [[],[]]
215+
input[2] = [[],[]]
216+
"""
217+
}
218+
}
219+
then {
220+
assertAll(
221+
{ assert process.success },
222+
{ assert snapshot(process.out).match() }
223+
)
224+
}
225+
}
226+
test("homo sapiens - 2 VCFs - csi index - stub") {
227+
options "-stub"
228+
when {
229+
params {
230+
trgt_merge_args = "--output-type b --write-index"
231+
}
232+
process {
233+
"""
234+
input[0] = BCFTOOLS_SORT.out.vcf
235+
.join(BCFTOOLS_SORT.out.tbi)
236+
.map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] }
237+
.groupTuple()
238+
input[1] = [[],[]]
239+
input[2] = [[],[]]
240+
"""
241+
}
242+
}
243+
then {
244+
assertAll(
245+
{ assert process.success },
246+
{ assert snapshot(process.out).match() }
247+
)
248+
}
249+
}
173250
test("homo sapiens - 2 VCFs - stub") {
174251
options "-stub"
175252
when {
@@ -187,10 +264,7 @@ nextflow_process {
187264
then {
188265
assertAll(
189266
{ assert process.success },
190-
{ assert snapshot(
191-
process.out,
192-
process.out.findAll { key, val -> key.startsWith("versions")}
193-
).match() }
267+
{ assert snapshot(process.out).match() }
194268
)
195269
}
196270
}

0 commit comments

Comments
 (0)