If you're working with genomic data in Python, this is the standard tool for reading and writing alignment files (BAM/CRAM), variant files (VCF/BCF), and reference sequences (FASTA/FASTQ). It wraps htslib so you get the full samtools/bcftools ecosystem with a Pythonic interface. The main thing to watch for is the coordinate system: it uses 0-based half-open intervals except when you pass region strings to fetch(), which are 1-based like samtools. You'll need index files for random access, and the documentation here covers the core workflows like calculating coverage, validating variants against reads, and filtering based on quality metrics. It's mature, well maintained, and handles the file format complexity so you don't have to.
- skills.sh installs
- 233
- GitHub stars
- 33.2K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add davila7/claude-code-templates --skill pysam --agent claude-codeInstalls into .claude/skills of the current project.
Files
Pysam
Overview
Pysam is a Python module for reading, manipulating, and writing genomic datasets. Read/write SAM/BAM/CRAM alignment files, VCF/BCF variant files, and FASTA/FASTQ sequences with a Pythonic interface to htslib. Query tabix-indexed files, perform pileup analysis for coverage, and execute samtools/bcftools commands.
When to Use This Skill
This skill should be used when:
- Working with sequencing alignment files (BAM/CRAM)
- Analyzing genetic variants (VCF/BCF)
- Extracting reference sequences or gene regions
- Processing raw sequencing data (FASTQ)
- Calculating coverage or read depth
- Implementing bioinformatics analysis pipelines
- Quality control of sequencing data
- Variant calling and annotation workflows
Quick Start
Installation
uv pip install pysam
Basic Examples
Read alignment file:
import pysam
# Open BAM file and fetch reads in region
samfile = pysam.AlignmentFile("example.bam", "rb")
for read in samfile.fetch("chr1", 1000, 2000):
print(f"{read.query_name}: {read.reference_start}")
samfile.close()
Sponsors
Details
- Repository
- github.com/davila7/claude-code-templates
- Category
- Testing & QA
- First seen
- Jun 3, 2026
More from davila7/claude-code-templates
All 618- Pufferlib232
- Web Quality Audit232
- Cc Skill Strategic Compact231
- Cc Skill Project Guidelines Example230
- Internal Comms230
- Professional Communication227
- Datacommons Client225
- Brenda Database222
- Heygen Best Practices222
- Hmdb Database222
- Umap Learn222
- Arboreto221
- Clerk Auth220
- Cellxgene Census219
- Kaizen219
- Lamindb219
- Nosql Expert219
- Opentargets Database219
- Pyopenms219
- Capa Officer218
- Deeptools218
- Ena Database218
- Naming Analyzer218
- Popup Cro218
