pysam
Overview
Use pysam for low-level, streaming access to HTSlib-supported genomic formats:
AlignmentFileandAlignedSegmentfor SAM/BAM/CRAMVariantFile,VariantHeader, andVariantRecordfor VCF/BCFFastaFilefor indexed FASTA andFastxFilefor sequential FASTA/FASTQTabixFilefor BGZF-compressed, tabix-indexed BED/GFF/GTF/custom tablespysam.samtoolsandpysam.bcftoolsfor wrapped command dispatchers
Current upstream baseline: pysam 0.24.0 (27 April 2026), wrapping
HTSlib/samtools/bcftools 1.23.1. Read references/sources.md before updating
version-specific guidance.
Installation
Use the pinned release for reproducible work:
uv pip install "pysam==0.24.0"
Confirm the runtime:
import pysam
print(pysam.__version__) # 0.24.0
print(pysam.__samtools_version__) # 1.23.1
Prebuilt wheels are available for supported macOS and Linux platforms. A
source build needs a C compiler and HTSlib build dependencies; read the
official installation guide linked from references/sources.md.
First Decide
Before writing code:
- Identify the real format, compression, sort order, and available index.
- De…