pysam

Access and manipulate SAM/BAM/CRAM, VCF/BCF, and FASTA/FASTQ files in Python.

1|2|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/fuzzy-dynamics/strings --skill pysam-fuzzy-dynamics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/fuzzy-dynamics/strings/tree/main/packages/skills/pysam
Command: npx skills add https://github.com/fuzzy-dynamics/strings --skill pysam-fuzzy-dynamics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pysam provides a Pythonic interface to common genomic data formats (SAM/BAM/CRAM, VCF/BCF, FASTA/FASTQ) enabling fast, reproducible access, manipulation, and analysis in pipelines.

Core Features & Use Cases

  • Read/write SAM/BAM/CRAM alignments and perform region-based queries
  • Process VCF/BCF variant data including genotype extraction and filtering
  • Extract reference sequences and support integrated genomic workflows

Quick Start

Install pysam and run a simple example to read a BAM file and print the coverage for 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 write SAM/BAM alignment files in Python?

Pysam enables you to read and write SAM/BAM alignment files in Python through a Pythonic interface that supports indexed access and region-based queries for fast and reproducible genomics pipelines.

What is the best way to extract coverage or perform pileup analysis on a BAM file?

The best way to perform pileup analysis and extract coverage from a BAM file is using pysam, which supports coordinate-based queries to calculate per-region coverage directly within Python workflows.

Can I process VCF and BCF variant files with Python?

Yes, you can process VCF and BCF variant files with Python using pysam, which supports genotype extraction, variant filtering, and writing updated data back to new VCF or BCF files.

Does pysam support FASTA and FASTQ file manipulation?

Pysam supports FASTA and FASTQ file manipulation, allowing you to extract reference sequences and perform integrated file I/O for end-to-end genomics workflows.

How do I query CRAM files by specific genomic regions?

You query CRAM files by specific genomic regions using pysam's coordinate-based querying capabilities, which provide fast indexed access to sequencing alignments directly in Python.

Why do I need indexed access for NGS data formats?

Indexed access for NGS data formats is needed to enable fast region-based queries on large alignment and variant files, a mechanism pysam facilitates for SAM/BAM/CRAM and VCF/BCF formats.