pysam

Read, write, and analyze genomic alignment and variant files in Python.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/jasrajtulsi/GRAD-SCOPE --skill pysam-jasrajtulsi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/jasrajtulsi/GRAD-SCOPE/tree/main/.claude/skills/pysam
Command: npx skills add https://github.com/jasrajtulsi/GRAD-SCOPE --skill pysam-jasrajtulsi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill removes the friction of working with genomic file formats by giving you a Pythonic way to read, write, query, and transform sequencing data without hand-coding low-level file handling.

Core Features & Use Cases

  • Alignment handling: Open and inspect SAM, BAM, and CRAM files, fetch reads by region, calculate coverage, and run pileup-based analysis.
  • Variant processing: Read and write VCF and BCF files, inspect genotypes and INFO/FORMAT fields, and filter variants by quality or support.
  • Sequence access and workflows: Query indexed FASTA files, process FASTQ reads sequentially, and combine BAM, VCF, BED, and reference data in bioinformatics pipelines.
  • Use case: A researcher can trace low-coverage regions, validate variant calls against read support, and extract sequence context around candidate mutations in one workflow.

Quick Start

Ask the assistant to analyze your BAM, VCF, FASTA, or FASTQ files and return the exact reads, variants, sequences, or coverage summaries you need for your bioinformatics task.

Frequently Asked Questions about pysam

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

FAQPage Schema
How do I calculate coverage and run pileup analysis on a BAM file in Python?

To calculate BAM coverage in Python, you open the alignment file and iterate through reads by region. Pileup analysis is performed by applying htslib-backed access patterns to inspect each position and extract exact read support.

How do I query indexed FASTA files to extract reference sequences around mutations?

Querying indexed FASTA files in Python requires htslib-backed access patterns for random retrieval. You fetch specific sequence contexts around candidate mutations by applying region-based extraction to the indexed reference data.

Do I need indexed inputs for random retrieval when analyzing CRAM and SAM files?

Yes, indexed inputs are required for random retrieval when analyzing CRAM and SAM files. Fetching reads by region or running pileup-based analysis depends on htslib-backed access patterns that necessitate properly indexed alignment data.

What is the best way to combine BED, VCF, and BAM data in a sequencing pipeline?

The best way to combine BED, VCF, and BAM data in a sequencing pipeline is using Pythonic file handling. This approach traces low-coverage regions and validates variant calls against read support within a single workflow.

Can I process FASTQ reads sequentially and extract tabix-indexed data?

Yes, you can process FASTQ reads sequentially and extract tabix-indexed data in Python. Sequential processing handles read transformation while htslib-backed access patterns retrieve tabix-indexed data for bioinformatics pipelines.