pysam
Package for reading, manipulating, and writing genomic data
Decision gist · record as of 2026-08-14
Yes. pysam is actively maintained, has no runtime dependencies, carries a permissive MIT license, and is essential for any Python-based genomic data processing. Medium install friction is offset by prebuilt wheels for modern Python versions and the absence of external runtime requirements. No known vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires HTSlib C library and development headers; pysam is a compiled extension and cannot be used without a compatible binary wheel or build environment.
- Medium install friction due to compiled C extensions via Cython wrapping HTSlib; prebuilt wheels available for common Python versions (3.10–3.13) and platforms (macOS, Linux, musl).
- Active maintenance with last commit 2026-08-10.
License · maintenance · safety
MIT License (permissive) — MIT License (permissive) allows use in proprietary and open-source projects with minimal restrictions; attribution required.
last release 2026-04-27 (109 days) · last repo commit 2026-08-10 · 905 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,291,977 downloads/mo, #4,103 on PyPI
Alternatives
Verify before relying
import pysam
# Open and read a BAM file
bamfile = pysam.AlignmentFile('example.bam', 'rb')
for read in bamfile:
print(read.query_name, read.query_sequence)
bamfile.close()- Whether the package works on Windows (classifiers list MacOS/POSIX/Unix but no Windows wheel evidence)
- Performance characteristics for large genomic datasets
- Exact HTSlib version bundled or required
What it is and what it does
pysam is a Python wrapper around HTSlib, the C library underlying samtools and bcftools, that lets you read and write genomic sequence data in standard formats (SAM, BAM, CRAM, VCF, BCF, BED, GFF, GTF, FASTA, FASTQ). It provides both low-level access to HTSlib's C API via Cython and a high-level Python interface for working with genomic data, including support for compression and random access through indexing.
The package is widely used in bioinformatics pipelines and genomic analysis workflows. It has no runtime dependencies beyond HTSlib itself (bundled in the wheel), making it straightforward to integrate into data processing scripts. Active maintenance and broad platform support (macOS, Linux) with prebuilt wheels for Python 3.10–3.13 mean installation is typically frictionless on supported systems.
Use it for
- Parse and filter SAM/BAM files in a genomic analysis pipeline without calling samtools as a subprocess
- Extract specific genomic regions or read alignments from indexed VCF/BCF files for variant analysis
- Convert between genomic file formats (e.g., BAM to CRAM) programmatically within a Python workflow
- Access samtools and bcftools functionality directly from Python without shell subprocess overhead
- Build custom bioinformatics tools that need to read FASTA/FASTQ sequences and alignment data
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pysam is actively maintained, has no runtime dependencies, carries a permissive MIT license, and is essential for any Python-based genomic data processing. Medium install friction is offset by prebuilt wheels for modern Python versions and the absence of external runtime requirements. No known vulnerabilities.
Install
pysam on PyPI
Before you install
Medium install friction due to compiled C extensions via Cython wrapping HTSlib; prebuilt wheels available for common Python versions (3.10–3.13) and platforms (macOS, Linux, musl). Active maintenance with last commit 2026-08-10.
Requires HTSlib C library and development headers; pysam is a compiled extension and cannot be used without a compatible binary wheel or build environment.
License in practice
MIT License (permissive) allows use in proprietary and open-source projects with minimal restrictions; attribution required.
Quickstart
import pysam
# Open and read a BAM file
bamfile = pysam.AlignmentFile('example.bam', 'rb')
for read in bamfile:
print(read.query_name, read.query_sequence)
bamfile.close()
Verify before relying
- Whether the package works on Windows (classifiers list MacOS/POSIX/Unix but no Windows wheel evidence)
- Performance characteristics for large genomic datasets
- Exact HTSlib version bundled or required
Package facts
| License | MIT License permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 109 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,291,977 / month, #4,103 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonTopic :: Scientific/EngineeringTopic :: Software Development |
Evidence: pysam-0.24.0-cp310-cp310-macosx_10_9_x86_64.whl; pysam-0.24.0-cp310-cp310-macosx_11_0_arm64.whl; pysam-0.24.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; pysam-0.24.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pysam-0.24.0-cp310-cp310-musllinux_1_2_aarch64.whl; pysam-0.24.0-cp310-cp310-musllinux_1_2_x86_64.whl; pysam-0.24.0-cp311-cp311-macosx_10_9_x86_64.whl; pysam-0.24.0-cp311-cp311-macosx_11_0_arm64.whl; pysam-0.24.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; pysam-0.24.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pysam-0.24.0-cp311-cp311-musllinux_1_2_aarch64.whl; pysam-0.24.0-cp311-cp311-musllinux_1_2_x86_64.whl; pysam-0.24.0-cp312-cp312-macosx_10_13_x86_64.whl; pysam-0.24.0-cp312-cp312-macosx_11_0_arm64.whl; pysam-0.24.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; pysam-0.24.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pysam-0.24.0-cp312-cp312-musllinux_1_2_aarch64.whl; pysam-0.24.0-cp312-cp312-musllinux_1_2_x86_64.whl; pysam-0.24.0-cp313-cp313-macosx_10_13_x86_64.whl; pysam-0.24.0-cp313-cp313-macosx_11_0_arm64.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 › “genomic file parsing”
- pysampysam reads, manipulates, and writes genomic data files…
- gtfparseParses GTF (gene transfer format) files into DataFrames, extracting…
- cyvcf2cyvcf2 is a Cython wrapper around htslib that parses VCF and BCF…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also cyvcf2 · dnaio · NREL-PySAM · pyfaidx · pyensembl · pybedtools · bio · pyteomics · pysylph · pybigtools