pysam

Read and analyze BAM, VCF, and FASTA genomic data in Python.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/SciMate-AI/scicli --skill pysam-scimate-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/SciMate-AI/scicli/tree/main/internal/skills/bundled/claude-scientific-skills/skills/pysam
Command: npx skills add https://github.com/SciMate-AI/scicli --skill pysam-scimate-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pysam provides a Pythonic interface to genomic data formats (SAM/BAM/CRAM, VCF/BCF, FASTA/FASTQ) enabling read/write and analysis within Python pipelines, removing the friction of low-level file parsing.

Core Features & Use Cases

  • Read and write SAM/BAM/CRAM alignment files, including region-based fetch and pileup analyses.
  • Read and write VCF/BCF variant files, with header, INFO, and FORMAT field access.
  • Access and query FASTA/FASTQ data, with indexed FASTA and tabix-backed variants for fast random access.
  • Integrate multiple data types in end-to-end workflows (e.g., BAM+VCF analyses, variant context extraction, and coverage calculation).

Quick Start

Install pysam in your Python environment and run a script that opens a BAM file and fetches reads in a region.

Frequently Asked Questions about pysam

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

FAQPage Schema
How do I read and analyze BAM files in Python?

To fetch reads from specific regions in a BAM file, use a Pythonic interface that supports indexed FASTA and tabix-backed files for fast random access. This enables efficient region-based fetch operations on genomic alignments.

Can I access VCF variant fields like INFO and FORMAT in Python?

Handling 0-based coordinates and index management for genomic files requires a Pythonic object model for reads and variants. It automatically satisfies requirements for .bai, .tbi, and .fai index handling during region-based access.

Does this approach support combining BAM and VCF analyses in end-to-end workflows?

CRAM alignment files are fully supported alongside SAM and BAM formats. You can read and write CRAM files for alignment analyses, including region-based fetch and pileup operations within your Python pipelines.

What is the best way to programmatically query FASTA sequences in Python?

To perform pileup analysis on genomic alignments, use a Pythonic interface that reads SAM/BAM/CRAM files. It allows you to compute read coverage and variant context across specified genomic regions.