cyvcf2
fast vcf parsing with cython + htslib
Decision gist · record as of 2026-08-14
Yes. cyvcf2 is actively maintained, widely used in bioinformatics, has no known vulnerabilities, and offers permissive licensing. Binary wheels make installation frictionless for most users. Install it if you need to parse VCF or BCF files in Python and want speed and direct numpy integration; avoid it only if you cannot tolerate the C compiler requirement for source builds or the array-lifetime gotcha.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires htslib >= 1.10 (bundled in wheels); source builds need a C compiler and htslib development headers.
- Binary wheels are available for Python 3.9–3.13 on macOS, Linux, and Windows, so most users will install without compilation.
- Medium friction remains because source builds require htslib and a C compiler; the package is actively maintained with a recent release.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute cyvcf2 freely as long as you include the license notice.
last release 2026-06-25 (50 days) · last repo commit 2026-06-25 · 446 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 217,227 downloads/mo, #9,361 on PyPI
Alternatives
Verify before relying
pip install cyvcf2
from cyvcf2 import VCF
for variant in VCF('some.vcf.gz'):
print(variant.CHROM, variant.start, variant.REF, variant.ALT)
dp = variant.format('DP') # numpy array of depth per sample- Whether the numpy array backing behavior (arrays becoming invalid when variant goes out of scope) is a practical concern for typical workflows.
- Performance characteristics on very large VCF files or with many concurrent region queries.
What it is and what it does
cyvcf2 is a high-performance Python interface to VCF and BCF genomic variant files, built as a Cython wrapper around the C library htslib. It parses variant records and returns their attributes—chromosome, position, reference and alternate alleles, genotypes, depths, and custom INFO/FORMAT fields—as numpy arrays ready for immediate analysis. The package supports region-based queries on indexed files and works with Python 3.9 and later.
Typical use involves iterating over variants in a file, extracting genotype or depth information as numpy arrays, and filtering or aggregating them downstream. A key design detail is that numpy arrays returned by attributes like `gt_ref_depths` are backed by the underlying C data structure, so they become invalid once the variant object goes out of scope; users must explicitly copy arrays they wish to persist. The package includes a command-line tool for basic VCF inspection and filtering.
Use it for
- Filter variants by allele frequency or quality thresholds extracted from INFO fields and genotype depths.
- Extract genotype matrices or depth arrays from large VCF files for population genetics or association studies.
- Query specific genomic regions in indexed VCF/BCF files without loading the entire file into memory.
- Convert VCF records to numpy arrays for downstream machine learning or statistical analysis pipelines.
- Rapidly scan VCF files from the command line to inspect headers, sample counts, or variant statistics.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
cyvcf2 is actively maintained, widely used in bioinformatics, has no known vulnerabilities, and offers permissive licensing. Binary wheels make installation frictionless for most users. Install it if you need to parse VCF or BCF files in Python and want speed and direct numpy integration; avoid it only if you cannot tolerate the C compiler requirement for source builds or the array-lifetime gotcha.
Install
cyvcf2 on PyPI
Before you install
Binary wheels are available for Python 3.9–3.13 on macOS, Linux, and Windows, so most users will install without compilation. Medium friction remains because source builds require htslib and a C compiler; the package is actively maintained with a recent release.
Requires htslib >= 1.10 (bundled in wheels); source builds need a C compiler and htslib development headers.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute cyvcf2 freely as long as you include the license notice.
Quickstart
pip install cyvcf2
from cyvcf2 import VCF
for variant in VCF('some.vcf.gz'):
print(variant.CHROM, variant.start, variant.REF, variant.ALT)
dp = variant.format('DP') # numpy array of depth per sample
Verify before relying
- Whether the numpy array backing behavior (arrays becoming invalid when variant goes out of scope) is a practical concern for typical workflows.
- Performance characteristics on very large VCF files or with many concurrent region queries.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 3 packagesnumpycoloredlogsclick |
| Maintenance | Actively maintained 50 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 217,227 / month, #9,361 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: CythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Scientific/Engineering :: Bio-Informatics |
Evidence: cyvcf2-0.34.0-cp310-cp310-macosx_10_9_x86_64.whl; cyvcf2-0.34.0-cp310-cp310-macosx_11_0_arm64.whl; cyvcf2-0.34.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cyvcf2-0.34.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; cyvcf2-0.34.0-cp310-cp310-musllinux_1_2_x86_64.whl; cyvcf2-0.34.0-cp311-cp311-macosx_10_9_x86_64.whl; cyvcf2-0.34.0-cp311-cp311-macosx_11_0_arm64.whl; cyvcf2-0.34.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cyvcf2-0.34.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; cyvcf2-0.34.0-cp311-cp311-musllinux_1_2_aarch64.whl; cyvcf2-0.34.0-cp311-cp311-musllinux_1_2_x86_64.whl; cyvcf2-0.34.0-cp312-cp312-macosx_10_13_x86_64.whl; cyvcf2-0.34.0-cp312-cp312-macosx_11_0_arm64.whl; cyvcf2-0.34.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; cyvcf2-0.34.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; cyvcf2-0.34.0-cp312-cp312-musllinux_1_2_aarch64.whl; cyvcf2-0.34.0-cp312-cp312-musllinux_1_2_x86_64.whl; cyvcf2-0.34.0-cp313-cp313-macosx_10_13_x86_64.whl; cyvcf2-0.34.0-cp313-cp313-macosx_11_0_arm64.whl; cyvcf2-0.34.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “vcf parsing python”
- cyvcf2cyvcf2 is a Cython wrapper around htslib that parses VCF and BCF…
- pysampysam reads, manipulates, and writes genomic data files…
- vmware-vapi-runtimeVMware vAPI Runtime provides HTTP client, message serialization, and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Bio-Informatics packages
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
Biopython provides Python tools for computational molecular biology, including sequence analysis, structure parsing, database access, and phylogenetic tree manipulation.
However, verify that the custom Biopython License Agreement aligns with your project's licensing requirements before committing to it in production or proprietary work.
Client library for the Firecrawl API that scrapes, crawls, and searches the web, returning clean Markdown or structured data; also indexes research papers from PubMed, bioRxiv, medRxiv, and arXiv.
A self-balancing interval tree data structure that stores and queries overlapping or enveloped ranges, supporting point lookups, range overlaps, and range envelopment queries.
Install it if you need to store and query overlapping or enveloped ranges; the self-balancing design and rich query interface make it significantly easier than…
Albumentations applies image transformations to training data, supporting classification, segmentation, object detection, and pose estimation with a unified API for images, masks, bounding boxes, and keypoints.
Install it if you need a unified, production-grade augmentation API for computer vision tasks.
PubChemPy is a Python wrapper around the PubChem REST API that lets you search for chemical compounds by name, substructure, or similarity, retrieve their properties, and convert between chemical file formats.
Install it if you need programmatic access to PubChem data.
See also pysam · ifcopenshell · pythonvCard4 · pyfaidx · gtfparse · pyranges · cyseq · Cython · pyxDamerauLevenshtein · bio