Skip to content

Commit 62011b9

Browse files
authored
Add module BCFTOOLS_PLUGINFIXPLOIDY (#10276)
* Add BCFTOOLS_PLUGINFIXPLOIDY * run linter * nf-core module lint * Add tests * reviewer comments
1 parent f0ee159 commit 62011b9

10 files changed

Lines changed: 706 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
3+
channels:
4+
- conda-forge
5+
- bioconda
6+
dependencies:
7+
# renovate: datasource=conda depName=bioconda/htslib
8+
- bioconda::bcftools=1.22
9+
- bioconda::htslib=1.22.1
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
process BCFTOOLS_PLUGINFIXPLOIDY {
2+
tag "${meta.id}"
3+
label 'process_single'
4+
5+
conda "${moduleDir}/environment.yml"
6+
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
7+
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/47/474a5ea8dc03366b04df884d89aeacc4f8e6d1ad92266888e7a8e7958d07cde8/data'
8+
: 'community.wave.seqera.io/library/bcftools_htslib:0a3fa2654b52006f'}"
9+
10+
input:
11+
tuple val(meta), path(vcf), path(index)
12+
path ploidy
13+
path sex
14+
path regions
15+
path targets
16+
17+
output:
18+
tuple val(meta), path("*.{vcf,vcf.gz,bcf,bcf.gz}"), emit: vcf
19+
tuple val(meta), path("*.tbi"), emit: tbi, optional: true
20+
tuple val(meta), path("*.csi"), emit: csi, optional: true
21+
tuple val("${task.process}"), val('bcftools'), eval("bcftools --version | sed '1!d; s/^.*bcftools //'"), topic: versions, emit: versions_bcftools
22+
23+
when:
24+
task.ext.when == null || task.ext.when
25+
26+
script:
27+
def args = task.ext.args ?: '' // bcftools/common args before `--`
28+
def args2 = task.ext.args2 ?: '' // plugin args after `--` (e.g. -f 2 -t GT)
29+
def prefix = task.ext.prefix ?: "${meta.id}"
30+
def regions_arg = regions ? "--regions-file ${regions}" : ""
31+
def targets_arg = targets ? "--targets-file ${targets}" : ""
32+
def ploidy_arg = ploidy ? "-p ${ploidy}" : ""
33+
def sex_arg = sex ? "-s ${sex}" : ""
34+
35+
def extension = args.contains("--output-type b") || args.contains("-Ob")
36+
? "bcf.gz"
37+
: args.contains("--output-type u") || args.contains("-Ou")
38+
? "bcf"
39+
: args.contains("--output-type z") || args.contains("-Oz")
40+
? "vcf.gz"
41+
: args.contains("--output-type v") || args.contains("-Ov")
42+
? "vcf"
43+
: "vcf"
44+
45+
"""
46+
bcftools +fixploidy \\
47+
--output ${prefix}.${extension} \\
48+
${regions_arg} \\
49+
${targets_arg} \\
50+
${args} \\
51+
--threads ${task.cpus} \\
52+
${vcf} \\
53+
-- \\
54+
${ploidy_arg} \\
55+
${sex_arg} \\
56+
${args2}
57+
"""
58+
59+
stub:
60+
def args = task.ext.args ?: ''
61+
def prefix = task.ext.prefix ?: "${meta.id}"
62+
def extension = args.contains("--output-type b") || args.contains("-Ob")
63+
? "bcf.gz"
64+
: args.contains("--output-type u") || args.contains("-Ou")
65+
? "bcf"
66+
: args.contains("--output-type z") || args.contains("-Oz")
67+
? "vcf.gz"
68+
: args.contains("--output-type v") || args.contains("-Ov")
69+
? "vcf"
70+
: "vcf"
71+
def stub_index = args.contains("--write-index=tbi") || args.contains("-W=tbi")
72+
? "tbi"
73+
: args.contains("--write-index=csi") || args.contains("-W=csi")
74+
? "csi"
75+
: args.contains("--write-index") || args.contains("-W")
76+
? "csi"
77+
: ""
78+
def create_cmd = extension.endsWith(".gz") ? "echo '' | gzip >" : "touch"
79+
def create_index = extension.endsWith(".gz") && stub_index.matches("csi|tbi") ? "touch ${prefix}.${extension}.${stub_index}" : ""
80+
"""
81+
${create_cmd} ${prefix}.${extension}
82+
${create_index}
83+
"""
84+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: "bcftools_pluginfixploidy"
2+
description: "The fixploidy plugin fixes ploidy in genotype fields according to specified
3+
ploidy rules, sample sex assignments, or a forced ploidy value. For example, haploid
4+
genotypes can be converted to diploid genotypes."
5+
keywords:
6+
- fixploidy
7+
- bcftools
8+
- ploidy
9+
- vcf
10+
tools:
11+
- "bcftools":
12+
description: "BCFtools is a set of utilities that manipulate variant calls in
13+
the Variant Call Format (VCF) and its binary counterpart BCF. All commands work
14+
transparently with both VCFs and BCFs, both uncompressed and BGZF-compressed.\
15+
\ Most commands accept VCF, bgzipped VCF and BCF with filetype detected automatically
16+
even when streaming from a pipe. Indexed VCF and BCF will work in all situations.
17+
Un-indexed VCF and BCF and streams will work in most, but not all situations."
18+
homepage: "https://samtools.github.io/bcftools/howtos/index.html"
19+
documentation: "https://samtools.github.io/bcftools/bcftools.html"
20+
tool_dev_url: "https://github.com/samtools/bcftools"
21+
doi: "10.1093/bioinformatics/btp352"
22+
licence:
23+
- "MIT"
24+
args_id: "$args"
25+
identifier: biotools:bcftools
26+
- "bcftools plugin fixploidy":
27+
description: "Bcftools plugins are tools that can be used with bcftools to manipulate
28+
variant calls in Variant Call Format (VCF) and BCF. The fixploidy plugin fixes
29+
ploidy in genotype fields according to specified ploidy rules, sample sex assignments,
30+
or a forced ploidy value. For example, haploid genotypes can be converted to
31+
diploid genotypes."
32+
homepage: "https://samtools.github.io/bcftools/howtos/plugins.html"
33+
documentation: "https://samtools.github.io/bcftools/howtos/plugin.setGT.html"
34+
tool_dev_url: "https://github.com/samtools/bcftools"
35+
doi: "10.1093/bioinformatics/btp352"
36+
licence:
37+
- "MIT"
38+
args_id: "$args2"
39+
identifier: biotools:bcftools
40+
input:
41+
- - meta:
42+
type: map
43+
description: |
44+
Groovy Map containing sample information
45+
e.g. [ id:'test', single_end:false ]
46+
- vcf:
47+
type: file
48+
description: |
49+
Input VCF/BCF file to fix ploidy in.
50+
e.g. 'sample.vcf.gz'
51+
ontologies: []
52+
- index:
53+
type: file
54+
description: |
55+
Index file for the input VCF/BCF (e.g. .tbi or .csi).
56+
e.g. 'sample.vcf.gz.tbi'
57+
ontologies: []
58+
- ploidy:
59+
type: file
60+
description: |
61+
Optional ploidy definition file for the fixploidy plugin (`-p`), with
62+
space/tab-delimited columns: CHROM, FROM, TO, SEX, PLOIDY.
63+
e.g. 'ploidy.txt'
64+
ontologies: []
65+
- sex:
66+
type: file
67+
description: |
68+
Optional sample sex assignment file for the fixploidy plugin (`-s`),
69+
containing lines of the form: NAME SEX.
70+
Samples not listed are treated as female by the plugin.
71+
e.g. 'samples_sex.txt'
72+
ontologies: []
73+
- regions:
74+
type: file
75+
description: |
76+
Optionally restrict the operation to regions listed in this file
77+
(indexed input required; passed as a bcftools regions file argument).
78+
e.g. 'regions.bed'
79+
ontologies: []
80+
- targets:
81+
type: file
82+
description: |
83+
Optionally restrict the operation to targets listed in this file
84+
(does not rely on index jumps in the same way as regions; passed as a
85+
bcftools targets file argument).
86+
e.g. 'targets.bed'
87+
ontologies: []
88+
output:
89+
vcf:
90+
- - meta:
91+
type: map
92+
description: |
93+
Groovy Map containing sample information
94+
e.g. [ id:'test', single_end:false ]
95+
- "*.{vcf,vcf.gz,bcf,bcf.gz}":
96+
type: file
97+
description: VCF output file containing GT fields with modified ploidy
98+
pattern: "*.{vcf,vcf.gz,bcf,bcf.gz}"
99+
ontologies: []
100+
tbi:
101+
- - meta:
102+
type: map
103+
description: |
104+
Groovy Map containing sample information
105+
e.g. [ id:'test', single_end:false ]
106+
- "*.tbi":
107+
type: file
108+
description: Alternative VCF file index
109+
pattern: "*.tbi"
110+
ontologies: []
111+
csi:
112+
- - meta:
113+
type: map
114+
description: |
115+
Groovy Map containing sample information
116+
e.g. [ id:'test', single_end:false ]
117+
- "*.csi":
118+
type: file
119+
description: Default VCF file index
120+
pattern: "*.csi"
121+
ontologies: []
122+
versions_bcftools:
123+
- - ${task.process}:
124+
type: string
125+
description: The process the versions were collected from
126+
- bcftools:
127+
type: string
128+
description: The tool name
129+
- "bcftools --version | sed '1!d; s/^.*bcftools //'":
130+
type: eval
131+
description: The command used to generate the version of the tool
132+
topics:
133+
versions:
134+
- - ${task.process}:
135+
type: string
136+
description: The process the versions were collected from
137+
- bcftools:
138+
type: string
139+
description: The tool name
140+
- "bcftools --version | sed '1!d; s/^.*bcftools //'":
141+
type: eval
142+
description: The command used to generate the version of the tool
143+
authors:
144+
- "@alkc"
145+
maintainers:
146+
- "@alkc"

0 commit comments

Comments
 (0)