If you're processing NGS data, this is the Python wrapper around htslib you'll reach for constantly. It handles SAM/BAM/CRAM alignments, VCF/BCF variants, and FASTA/FASTQ sequences with a clean interface for fetching regions, running pileups, and calculating coverage. The 0-based coordinates take a minute to internalize (except when using region strings, which are 1-based like samtools), but once you do, it's straightforward. You'll need index files for random access, which is standard for this domain. It really shines when you're chaining operations across file types, like validating variants against aligned reads or extracting reference context around mutation sites.
- skills.sh installs
- 2K
- GitHub stars
- 56.6K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add k-dense-ai/scientific-agent-skills --skill pysam --agent claude-codeInstalls into .claude/skills of the current project.
Files
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.1 (7 September 2026), wrapping
HTSlib/samtools/bcftools 1.24. Read references/sources.md before updating
version-specific guidance.
Installation
Use the pinned release for reproducible work:
uv pip install "pysam==0.24.1"
Confirm the runtime:
import pysam
print(pysam.__version__) # 0.24.1
print(pysam.__samtools_version__) # 1.24
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:
Sponsors
Details
- Repository
- github.com/k-dense-ai/scientific-agent-skills
- Categories
- Testing & QA, Documentation, AI & Agent Building, Python
- First seen
- Jun 3, 2026
More from k-dense-ai/scientific-agent-skills
All 137- Cirq2K
- Pathml2K
- Treatment Plans2K
- Etetoolkit2K
- Geniml2K
- Pennylane2K
- Flowio2K
- Labarchive Integration2K
- Pytdc2K
- Lamindb2K
- Phylogenetics2K
- Scvelo2K
- Usfiscaldata2K
- Qiskit2K
- Gtars2K
- Matchms2K
- Protocolsio Integration2K
- Histolab2K
- Polars Bio2K
- Neuropixels Analysis2K
- Pyopenms2K
- Dnanexus Integration2K
- Latchbio Integration2K
- Qutip2K
