What problem does it solve?
Pysam streamlines NGS analysis by giving a Pythonic interface to read, query, and write genomic alignment, variant, and sequence data without stitching together many separate command-line tools.
Core Features & Use Cases
- Alignment (SAM/BAM/CRAM) handling: Fetch reads by genomic region, filter by mapping attributes, compute coverage, and run pileup-style analyses for depth and per-position statistics.
- Variant (VCF/BCF) handling: Iterate and query variants, access INFO/FORMAT fields and genotypes, and filter or write modified VCF/BCF outputs.
- Sequence (FASTA/FASTQ) handling: Random-access reference FASTA sequences (with indexing) and sequentially process FASTQ reads with quality scores.
- Integrated workflows: Combine BAM + VCF + FASTA for tasks like validating variants with read support, annotating variants with coverage, and extracting sequence contexts around loci.
Quick Start
Use the pysam skill to compute per-base coverage for chr1 from 1,000,000 to 1,000,500 from a BAM file named tumor.bam.