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

bcftools isec input can be bcf or bcf.gz as well as vcf.gz #5685

Merged
merged 11 commits into from
Jul 4, 2024
24 changes: 21 additions & 3 deletions modules/nf-core/bcftools/isec/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ process BCFTOOLS_ISEC {
tuple val(meta), path(vcfs), path(tbis)

output:
tuple val(meta), path("${prefix}"), emit: results
path "versions.yml" , emit: versions
tuple val(meta), path("${prefix}", type: "dir"), emit: results
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -24,7 +24,25 @@ process BCFTOOLS_ISEC {
bcftools isec \\
$args \\
-p $prefix \\
*.vcf.gz
${vcfs}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir ${prefix}
touch ${prefix}/README.txt
touch ${prefix}/sites.txt
echo "" | gzip > ${prefix}/0000.vcf.gz
touch ${prefix}/0000.vcf.gz.tbi
echo "" | gzip > ${prefix}/0001.vcf.gz
touch ${prefix}/0001.vcf.gz.tbi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//')
Expand Down
7 changes: 4 additions & 3 deletions modules/nf-core/bcftools/isec/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ keywords:
- union
- complement
- VCF
- BCF
tools:
- isec:
description: |
Expand All @@ -23,12 +24,12 @@ input:
- vcfs:
type: list
description: |
List containing 2 or more vcf files
e.g. [ 'file1.vcf', 'file2.vcf' ]
List containing 2 or more vcf/bcf files. These must be compressed and have an associated index.
e.g. [ 'file1.vcf.gz', 'file2.vcf' ]
- tbis:
type: list
description: |
List containing the tbi index files corresponding to the vcfs input files
List containing the tbi index files corresponding to the vcf/bcf input files
e.g. [ 'file1.vcf.tbi', 'file2.vcf.tbi' ]
output:
- meta:
Expand Down
54 changes: 46 additions & 8 deletions modules/nf-core/bcftools/isec/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,69 @@ nextflow_process {

config "./nextflow.config"

test("sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]]") {
test("sarscov2 - [[vcf1.gz, vcf2.gz], [tbi1, tbi2]]") {

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test2_vcf_gz'], checkIfExists: true)],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test2.vcf.gz', checkIfExists: true)
],
[
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test2_vcf_gz_tbi'], checkIfExists: true)]
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf.gz.tbi', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test2.vcf.gz.tbi', checkIfExists: true)
]
]
"""
}
}

then {
def results_dir = new File(process.out.results[0][1])
def results_list = []
results_dir.eachFileRecurse { file -> results_list << file.getName() }
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.results.collect { it.collect { it instanceof Map ? it : file(it).name } },
process.out.versions
).match() }
process.out.versions,
results_list.sort(),
path("${process.out.results[0][1]}").list().findAll {
it.getFileName().toString() != "0000.vcf.gz.tbi" && it.getFileName().toString() != "0001.vcf.gz.tbi"
}
).match()
}
)
}

}

test("sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]] - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test2.vcf.gz', checkIfExists: true)
],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf.gz.tbi', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test2.vcf.gz.tbi', checkIfExists: true)
]
]
"""
}
}

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

Expand Down
71 changes: 62 additions & 9 deletions modules/nf-core/bcftools/isec/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,22 +1,75 @@
{
"sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]]": {
"sarscov2 - [[vcf1.gz, vcf2.gz], [tbi1, tbi2]]": {
"content": [
[
[
{
"id": "test"
},
"test"
]
"versions.yml:md5,c5b5a1204cf56fec79d17e1913eaca27"
],
[
"versions.yml:md5,c5b5a1204cf56fec79d17e1913eaca27"
"0000.vcf.gz",
"0000.vcf.gz.tbi",
"0001.vcf.gz",
"0001.vcf.gz.tbi",
"README.txt",
"sites.txt"
],
[
"0000.vcf.gz:md5,8e722884ffb75155212a3fc053918766",
"0001.vcf.gz:md5,b39a72f91458b94b346dd73690207649",
"README.txt:md5,10fc33b66522645600d44afbd41fb792",
"sites.txt:md5,1cea3fbde7f6d3c97f3d39036f9690df"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-03T11:43:55.820868944"
"timestamp": "2024-07-03T16:32:18.167072863"
},
"sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]] - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
[
"0000.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"0000.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e",
"0001.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"0001.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e",
"README.txt:md5,d41d8cd98f00b204e9800998ecf8427e",
"sites.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"1": [
"versions.yml:md5,c5b5a1204cf56fec79d17e1913eaca27"
],
"results": [
[
{
"id": "test"
},
[
"0000.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"0000.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e",
"0001.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"0001.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e",
"README.txt:md5,d41d8cd98f00b204e9800998ecf8427e",
"sites.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"versions": [
"versions.yml:md5,c5b5a1204cf56fec79d17e1913eaca27"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-03T09:45:52.881120953"
}
}
Loading