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
11 changes: 9 additions & 2 deletions modules/nf-core/bcftools/isec/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process BCFTOOLS_ISEC {
: 'community.wave.seqera.io/library/bcftools_htslib:0a3fa2654b52006f'}"

input:
tuple val(meta), path(vcfs), path(tbis)
tuple val(meta), path(vcfs), path(tbis), path(file_list), path(targets_file), path(regions_file)

output:
tuple val(meta), path("${prefix}", type: "dir"), emit: results
Expand All @@ -20,11 +20,18 @@ process BCFTOOLS_ISEC {
script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
targets_file_args = targets_file ? "-T ${targets_file}" : ''
regions_file_args = regions_file ? "-R ${regions_file}" : ''
vcf_files = file_list ? "-l ${file_list}" : "${vcfs}"

"""
bcftools isec \\
${args} \\
${targets_file_args} \\
${regions_file_args} \\
-p ${prefix} \\
${vcfs} """
${vcf_files} \\
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
Expand Down
37 changes: 33 additions & 4 deletions modules/nf-core/bcftools/isec/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,51 @@ input:
description: |
List containing 2 or more vcf/bcf files. These must be compressed and have an associated index.
e.g. [ 'file1.vcf.gz', 'file2.vcf' ]
pattern: "*.{vcf,vcf.gz,bcf,bcf.gz}"
ontologies:
- edam: "http://edamontology.org/format_3016" # VCF
- edam: "http://edamontology.org/format_3570" # BCF
- tbis:
type: list
description: |
List containing the tbi index files corresponding to the vcf/bcf input files
e.g. [ 'file1.vcf.tbi', 'file2.vcf.tbi' ]
pattern: "*.tbi"
ontologies:
- edam: "http://edamontology.org/format_3475" # Tabix index
- file_list:
type: file
description: |
Optional text file containing the list of VCF/BCF files to be processed by bcftools isec, one per line.
ontologies:
- edam: "http://edamontology.org/format_2330" # Text file
- targets_file:
type: file
description: |
Optional file containing target regions to restrict the analysis to.
ontologies:
- edam: "http://edamontology.org/format_3003" # BED
- edam: "http://edamontology.org/format_3475" # Tab-separated
- regions_file:
type: file
description: |
Optional file containing regions to restrict the analysis to.
ontologies:
- edam: "http://edamontology.org/format_3003" # BED
- edam: "http://edamontology.org/format_3475" # Tab-separated
output:
results:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- '"${prefix}", type: "dir"':
- ${prefix}:
type: directory
description: Folder containing the set operations results perform on the vcf files
pattern: "${prefix}"
description: Directory containing the output files from bcftools isec
pattern: "${prefix}/"
ontologies:
- edam: "http://edamontology.org/format_3016" # VCF
- edam: "http://edamontology.org/format_3570" # BCF
versions_bcftools:
- - ${task.process}:
type: string
Expand Down
243 changes: 241 additions & 2 deletions modules/nf-core/bcftools/isec/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ nextflow_process {
[
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)
]
],
[],
[],
[]
]
"""
}
Expand Down Expand Up @@ -63,7 +66,82 @@ nextflow_process {
[
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() }
)
}
}

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

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)
],
[],
[file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', 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.findAll { key, val -> key.startsWith("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" && it.getFileName().toString() != "sites.txt"
}
).match()
}
)
}
}

test("sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]] - targets - 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)
],
[],
[file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', checkIfExists: true)],
[]
]
"""
}
Expand All @@ -76,4 +154,165 @@ nextflow_process {
)
}
}

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

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)
],
[],
[],
[file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', 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.findAll { key, val -> key.startsWith("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" && it.getFileName().toString() != "sites.txt"
}
).match()
}
)
}
}

test("sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]] - regions - stub") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a test for the file_list input. Can you please add one? You can generate the list on the fly with a setup block if needed.

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)
],
[],
[],
[file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', checkIfExists: true)]
]
"""
}
}

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

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

setup{
new File("${launchDir}/file_list.txt").text = """
test.vcf.gz
test2.vcf.gz
""".stripIndent().trim()
}


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)
],
[file("${launchDir}/file_list.txt", 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.findAll { key, val -> key.startsWith("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.gz, vcf2.gz], [tbi1, tbi2]] - file_list - stub") {
options "-stub"

setup{
new File("${launchDir}/file_list.txt").text = """
test.vcf.gz
test2.vcf.gz
""".stripIndent().trim()
}


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)
],
[file("${launchDir}/file_list.txt", checkIfExists: true)],
[],
[]
]
"""
}
}

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

)
}
}
}
Loading
Loading