Skip to content
Open
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
51 changes: 51 additions & 0 deletions bio/bcftools/fixploidy/environment.linux-64.pin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
# created-by: conda 24.9.2
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81
https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda#f0991f0f84902f6b6009b4d2350a83aa
https://conda.anaconda.org/conda-forge/linux-64/libgomp-15.2.0-he0feb66_16.conda#26c46f90d0e727e95c6c9498a33a09f3
https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-8_cp314.conda#0539938c55b6b1a59b560e843ad864a4
https://conda.anaconda.org/conda-forge/noarch/tzdata-2025c-h8577fbf_0.conda#338201218b54cadff2e774ac27733990
https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2#73aaf86a425cc6e73fcf236a5a46396d
https://conda.anaconda.org/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda#6d0363467e6ed84f11435eb309f2ff06
https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-hda65f42_8.conda#51a19bba1b8ebfb60df25cde030b7ebc
https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.34.6-hb03c661_0.conda#920bb03579f15389b9e512095ad995b7
https://conda.anaconda.org/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda#b38117a3c920364aff79f870c984b4a3
https://conda.anaconda.org/conda-forge/linux-64/libdeflate-1.22-hb9d3cd8_0.conda#b422943d5d772b7cc858b36ad2a92db5
https://conda.anaconda.org/conda-forge/linux-64/libexpat-2.7.3-hecca717_0.conda#8b09ae86839581147ef2e5c5e229d164
https://conda.anaconda.org/conda-forge/linux-64/libffi-3.5.2-h9ec8514_0.conda#35f29eec58405aaf55e01cb470d8c26a
https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-15.2.0-h69a702a_16.conda#5a68259fac2da8f2ee6f7bfe49c9eb8b
https://conda.anaconda.org/conda-forge/linux-64/libgfortran5-15.2.0-h68bc16d_16.conda#39183d4e0c05609fd65f130633194e37
https://conda.anaconda.org/conda-forge/linux-64/liblzma-5.8.1-hb9d3cd8_2.conda#1a580f7796c7bf6393fddb8bbbde58dc
https://conda.anaconda.org/conda-forge/linux-64/libmpdec-4.0.0-hb9d3cd8_0.conda#c7e925f37e3b40d893459e625f6a53f1
https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_16.conda#68f68355000ec3f1d6f26ea13e8f525f
https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.41.2-h5347b49_1.conda#41f5c09a211985c3ce642d60721e7c3e
https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda#edb0dca6bc32e4f4789199455a1dbeb8
https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.5-h2d0b736_3.conda#47e340acb35de30501a76c7c799c41d7
https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda#9ee58d5c534af06558933af3c845a780
https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20250104-pl5321h7949ede_0.conda#c277e0a4d549b03ac1e9d6cbbe3d017b
https://conda.anaconda.org/conda-forge/linux-64/libev-4.33-hd590300_2.conda#172bf1cd1ff8629f2b1179945ed45055
https://conda.anaconda.org/conda-forge/linux-64/libgfortran-15.2.0-h69a702a_16.conda#40d9b534410403c821ff64f00d0adc22
https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_0.conda#2e1b84d273b01835256e53fd938de355
https://conda.anaconda.org/conda-forge/linux-64/libssh2-1.11.1-hcf80075_0.conda#eecce068c7e4eddeb169591baac20ac4
https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_16.conda#1b3152694d236cf233b76b8c56bf0eae
https://conda.anaconda.org/conda-forge/linux-64/libxcrypt-4.4.36-hd590300_1.conda#5aa797f8787fe7a17d1b0821485b5adc
https://conda.anaconda.org/conda-forge/linux-64/readline-8.3-h853b02a_0.conda#d7d95fc8287ea7bf33e0e7116d2b95ec
https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_ha0e22de_103.conda#86bc20552bf46075e3d92b67f089172d
https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda#4a13eeac0b5c8e5b8ab496e6c4ddd829
https://conda.anaconda.org/conda-forge/linux-64/krb5-1.21.3-h659f571_0.conda#3f43953b7d3fb3aaa1d0d0723d91e368
https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_104.conda#a6abd2796fc332536735f68ba23f7901
https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.67.0-had1ee68_0.conda#b499ce4b026493a13774bcf0f4c33849
https://conda.anaconda.org/conda-forge/linux-64/libopenblas-0.3.30-pthreads_h94d23a6_4.conda#be43915efc66345cccb3c310b6ed0374
https://conda.anaconda.org/conda-forge/linux-64/perl-5.32.1-7_hd590300_perl5.conda#f2cfec9406850991f4e3d960cc9e3321
https://conda.anaconda.org/conda-forge/linux-64/libblas-3.11.0-5_h4a7cf45_openblas.conda#c160954f7418d7b6e87eaf05a8913fa9
https://conda.anaconda.org/conda-forge/linux-64/libcurl-8.17.0-h4e3cde8_1.conda#117499f93e892ea1e57fdca16c2e8351
https://conda.anaconda.org/conda-forge/linux-64/python-3.14.2-h32b2ec7_100_cp314.conda#1cef1236a05c3a98f68c33ae9425f656
https://conda.anaconda.org/bioconda/linux-64/htslib-1.23-h566b1c6_0.conda#307124911d36a3d976cd76f350085ead
https://conda.anaconda.org/conda-forge/linux-64/libcblas-3.11.0-5_h0358290_openblas.conda#6636a2b6f1a87572df2970d3ebc87cc0
https://conda.anaconda.org/conda-forge/noarch/pip-25.3-pyh145f28c_0.conda#bf47878473e5ab9fdb4115735230e191
https://conda.anaconda.org/bioconda/noarch/snakemake-wrapper-utils-0.8.0-pyhdfd78af_0.conda#1650e521333852f45468d97b1b2fdcce
https://conda.anaconda.org/conda-forge/linux-64/gsl-2.7-he838d99_0.tar.bz2#fec079ba39c9cca093bf4c00001825de
https://conda.anaconda.org/bioconda/linux-64/bcftools-1.23-h3a4d415_0.conda#51a78d8b2f5a3d373ce369803b5e76e3
7 changes: 7 additions & 0 deletions bio/bcftools/fixploidy/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- bcftools =1.23
- snakemake-wrapper-utils =0.8.0
14 changes: 14 additions & 0 deletions bio/bcftools/fixploidy/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: bcftools fixploidy
url: https://samtools.github.io/bcftools/bcftools.html
author:
- Thibault Dayris
description: |
Set correct ploidy on variants calls
input:
- Path to variants file (VCF/VCF.GZ/BCF)
output:
- Path to corrected variants file (VCF/BCF/VCF.GZ)
params:
- extra: Optional parameters besides IO and their formats.
notes: |
This wrapper requires additional threads for IO compression.
12 changes: 12 additions & 0 deletions bio/bcftools/fixploidy/test/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rule test_bcftools_fixploidy:
input:
"a.bcf",
output:
"a.fixed.bcf",
threads: 3
params:
extra="",
log:
"test_bcftools_fixploidy.log",
wrapper:
"master/bio/bcftools/fixploidy"
1 change: 1 addition & 0 deletions bio/bcftools/fixploidy/test/a.bcf
14 changes: 14 additions & 0 deletions bio/bcftools/fixploidy/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2026, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"


from snakemake.shell import shell
from snakemake_wrapper_utils.bcftools import get_bcftools_opts

bcftools_opts = get_bcftools_opts(snakemake, parse_ref=False, parse_memory=False)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

shell("bcftools plugin fixploidy {bcftools_opts} {extra} {snakemake.input[0]} {log}")
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Mar 27, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n bio/bcftools/fixploidy/wrapper.py

Repository: snakemake/snakemake-wrappers

Length of output: 692


🏁 Script executed:

find bio/bcftools/fixploidy -type f

Repository: snakemake/snakemake-wrappers

Length of output: 268


🏁 Script executed:

# Search for bcftools fixploidy usage patterns in the repository
rg "fixploidy" -A 5 -B 5

Repository: snakemake/snakemake-wrappers

Length of output: 2153


🏁 Script executed:

cat -n bio/bcftools/fixploidy/test/Snakefile

Repository: snakemake/snakemake-wrappers

Length of output: 394


🏁 Script executed:

# Search for other bcftools plugin wrappers to see argument ordering patterns
find bio/bcftools -name "wrapper.py" -type f | head -10 | xargs -I {} sh -c 'echo "=== {} ===" && cat {}'

Repository: snakemake/snakemake-wrappers

Length of output: 7360


🏁 Script executed:

# Check bcftools documentation for fixploidy plugin argument parsing
web_search "bcftools fixploidy plugin argument parsing order"

Repository: snakemake/snakemake-wrappers

Length of output: 122


🌐 Web query:

bcftools fixploidy plugin documentation argument parsing

💡 Result:

The bcftools +fixploidy plugin uses standard C getopt_long for argument parsing in its init function. Plugin options (after the "--" separator) are parsed using a static struct option long_options[] defining: - {"default-ploidy",1,0,'d'} - {"force-ploidy",1,0,'f'} - {"ploidy",1,0,'p'} - {"samples",1,0,'s'} Short options: -d, -f, -p, -s. The getopt_long loop processes these: case 'd': default_ploidy = strtod(optarg,&tmp); case 'f': force_ploidy = strtod(optarg,&tmp); case 'p': ploidy_fname = strdup(optarg); case 's': sex_fname = strdup(optarg); It initializes ploidy with defaults for chrX PAR regions if no -p file given, reads samples/sex from -s file, maps samples to sex, and sets sex-to-ploidy mapping. To view full usage: bcftools +fixploidy -h Source code: https://github.com/samtools/bcftools/blob/develop/plugins/fixploidy.c

Citations:


🌐 Web query:

bcftools plugin command line syntax "--" separator

💡 Result:

In BCFtools, the "--" separator is used in plugin command lines to distinguish between general/common options (shared across many bcftools commands, such as -o, -O, -r) that come before it, and plugin-specific options that come after it. The general syntax for running a plugin is: bcftools +plugin_name [general options] input.vcf -- [plugin options] Examples from official documentation: bcftools +fill-tags in.bcf -Ob -o out.bcf -- -t AN,AC bcftools +split-vep file.vcf.gz -- -a BCSQ bcftools +tag2tag in.vcf -- --LXX-to-XX -s 3 Some plugins do not accept general options and their usage is bcftools +plugin_name [input] [plugin options], without the "--" separator. Always check the plugin's usage with bcftools +plugin_name -h. To use plugins, set BCFTOOLS_PLUGINS=/path/to/bcftools/plugins or use full path like bcftools +/path/to/plugin.so.

Citations:


🏁 Script executed:

# Search for actual usage examples of bcftools plugin fixploidy in the codebase
rg "bcftools.*fixploidy" -A 3 -B 3

Repository: snakemake/snakemake-wrappers

Length of output: 1627


🏁 Script executed:

# Check bcftools documentation examples and common patterns
web_search "bcftools +fixploidy usage example input file position"

Repository: snakemake/snakemake-wrappers

Length of output: 122


🌐 Web query:

bcftools +fixploidy usage example input file position argument order

💡 Result:

The standard usage of bcftools +fixploidy follows the general bcftools plugin syntax: bcftools +fixploidy [general options] [input.vcf[.gz]] [-- [plugin options]]. Input file position: The VCF/BCF input file is provided as a positional argument after general options (like -O u for uncompressed BCF output) and before the -- separator. If omitted, it reads from standard input (stdin). Examples from source code and usage: - bcftools +fixploidy in.vcf -- -s samples.txt Here, "in.vcf" is the input file. - bcftools +fixploidy haploid.vcf -- -f 2 > diploid.vcf Here, "haploid.vcf" is the input file, -f 2 forces diploid ploidy for all sites. General syntax template: bcftools +fixploidy -Ou -o output.bcf input.vcf -- -s samples.txt -p ploidy.txt Plugin options (after --): - -d, --default-ploidy [default: 2] - -f, --force-ploidy Ignore -p, set same ploidy everywhere - -p, --ploidy CHROM FROM TO SEX PLOIDY - -s, --sex NAME SEX (M/F) - -t, --tags [GT] Ploidy file format example: X 1 60000 M 1 X 2699521 154931043 M 1 Y 1 59373566 M 1 Y 1 59373566 F 0 Sex file example: sampleName1 M

Citations:


Move input file before {extra} to follow bcftools plugin argument syntax.

The bcftools fixploidy plugin requires input files to be positioned before the -- separator and plugin-specific options. If {extra} contains plugin options (e.g., -- -s samples.txt), the current order places the input file after these options, causing incorrect parsing.

Suggested fix
-shell("bcftools plugin fixploidy {bcftools_opts} {extra} {snakemake.input[0]} {log}")
+shell("bcftools plugin fixploidy {bcftools_opts} {snakemake.input[0]} {extra} {log}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bio/bcftools/fixploidy/wrapper.py` at line 15, The bcftools plugin call in
wrapper.py places the input file after `{extra}`, which can break plugin option
parsing; update the shell invocation (the shell(...) call invoking "bcftools
plugin fixploidy") to move `{snakemake.input[0]}` immediately after
`{bcftools_opts}` and before `{extra}` so that the input file is passed before
the `--`/plugin options (keep `{log}` at the end).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tdayris is this relevant?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this what it is suggesting?

Suggested change
shell("bcftools plugin fixploidy {bcftools_opts} {extra} {snakemake.input[0]} {log}")
shell("bcftools plugin fixploidy {bcftools_opts} {snakemake.input[0]} -- {extra} {log}")

6 changes: 6 additions & 0 deletions test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,12 @@ def test_bcftools_filter_sample(run):
["snakemake", "--cores", "1", "a.filter_sample.vcf", "--use-conda", "-F"],
)

def test_bcftools_fixploidy(run):
run(
"bio/bcftools/fixploidy",
["snakemake", "--cores", "3", "a.fixed.bcf", "--use-conda", "-F"],
)


def test_bcftools_filter_vcf(run):
run(
Expand Down
Loading