varona.bcftools
Module specifically for using (non-pysam) bcftools.
- ALLOWED_TAGS = {'AC', 'AF', 'AN', 'MAF'}
Set of allowed tags that can be added to the VCF file.
- HAVE_BCFTOOLS = False
True if the bcftools command is available on the system.
Regardless of whether the bcftools command can be found, this variable will be set to False if the environment variable
VARONA_DISABLE_BCFTOOLS
is set to “1”.
- class VariantFileFilledInTags(filename, _, fillin_tags: list[str], *args, **kwargs)[source]
Bases:
VariantFile
A subclass of
pysam.VariantFile
that fills in tags using bcftools.It’ll preprocess the original VCF before opening the processed VCF. The
- Parameters:
filename – Path to the VCF file.
_ – Ignored mode parameter (always “r” for read-only mode).
fillin_tags – List of tags to fill in the VCF file.
args – Additional arguments to pass to
pysam.VariantFile
.kwargs – Additional keyword arguments to pass to
pysam.VariantFile
.
- Raises:
RuntimeError – If bcftools isn’t available on the path.
- close(self)[source]
closes the
pysam.VariantFile
.
- run_bcftools_fill_tags(input_vcf: Path, output_vcf: Path, tags: list[str]) None [source]
Run the bcftools fill-tags plugin to add AN, AC, AF, and MAF tags.
- Parameters:
input_vcf – Path to the input VCF file (compressed with bgzip).
output_vcf – Path to the output VCF file (compressed with bgzip).
tags – List of tags to add to the VCF file can be any of AN, AC, AF, MAF.
- Raises:
subprocess.CalledProcessError – If the bcftools command fails.