pysam

Read and write SAM/BAM/CRAM, VCF/BCF, and FASTA/FASTQ genomic data.

6|Updated Dec 30, 2025
One-click install
npx skills add https://github.com/pur3v4d3r/pur3-pkb-codebase --skill pysam-pur3v4d3r
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/pur3v4d3r/pur3-pkb-codebase/tree/main/.claude/skills/__scientific-skills/pysam
Command: npx skills add https://github.com/pur3v4d3r/pur3-pkb-codebase --skill pysam-pur3v4d3r

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pysam provides programmatic access to common genomic data formats (SAM/BAM/CRAM, VCF/BCF, FASTA/FASTQ) for reading, writing, and analyzing sequencing data.

Core Features & Use Cases

  • Read and write alignment files (SAM/BAM/CRAM) with region fetch and pileup
  • Read and write variant files (VCF/BCF) and perform filtering or annotation
  • Access reference sequences (FASTA/FASTQ) and extract sequences for regions
  • Integrate multiple file types in end-to-end pipelines (quality control, coverage analysis, variant validation)

Quick Start

Open a BAM file, fetch a region, and print basic alignment information.

Frequently Asked Questions about pysam

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I read and fetch alignments from a specific region in a BAM file using Python?

To fetch alignments from a BAM file, use Python bindings to htslib for region-based queries. This approach supports reading SAM/BAM/CRAM formats, allowing you to open an alignment file, specify genomic coordinates, and programmatically extract matching sequence reads.

Can I filter and annotate variant calls directly within a VCF file?

Yes, you can read and write variant files in VCF/BCF formats to perform filtering or annotation. This provides programmatic access to variant records, enabling customized query logic and modification for downstream bioinformatics validation workflows.

What is the best way to extract reference sequences for specific genomic coordinates from FASTA files?

Extracting reference sequences from FASTA files requires accessing the sequences programmatically and querying by region. This allows you to retrieve exact nucleotide strings for specified coordinates, integrating reference data with alignment or variant analysis.

Does this genomic data toolkit support CRAM files for end-to-end sequencing workflows?

Yes, the toolkit supports CRAM files alongside SAM, BAM, VCF, BCF, FASTA, and FASTQ. This enables cross-format data integration for end-to-end bioinformatics pipelines, including quality control, coverage analysis, and variant validation.

How do I perform pileup analysis on genomic alignment data?

Pileup analysis is performed by reading alignment files and generating per-base stackups at specified genomic coordinates. This allows you to inspect coverage depth, base calls, and alignment mismatches across sequencing reads for quality control.