-
Notifications
You must be signed in to change notification settings - Fork 209
feat: bcftools fixploidy wrapper #5176
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
Open
tdayris
wants to merge
10
commits into
snakemake:master
Choose a base branch
from
tdayris:bcftools_fixploidy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
03fd666
feat: bcftools fixploidy wrapper
tdayris cd26351
bccftools opts passed
tdayris 85f00cc
format
tdayris 3a4e82f
requested changes
tdayris a74314f
Merge branch 'master' into bcftools_fixploidy
tdayris e1dd34d
fix key error
tdayris ac5dc42
Merge branch 'master' into bcftools_fixploidy
fgvieira c208e23
Merge branch 'master' into bcftools_fixploidy
fgvieira 26bc07b
Update bio/bcftools/fixploidy/wrapper.py
tdayris d952415
Code format
fgvieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../filter/test/a.bcf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}") | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this what it is suggesting?
Suggested change
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: snakemake/snakemake-wrappers
Length of output: 692
🏁 Script executed:
Repository: snakemake/snakemake-wrappers
Length of output: 268
🏁 Script executed:
Repository: snakemake/snakemake-wrappers
Length of output: 2153
🏁 Script executed:
Repository: snakemake/snakemake-wrappers
Length of output: 394
🏁 Script executed:
Repository: snakemake/snakemake-wrappers
Length of output: 7360
🏁 Script executed:
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:
Repository: snakemake/snakemake-wrappers
Length of output: 1627
🏁 Script executed:
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
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tdayris is this relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.