pysam

Read and manipulate SAM, BAM, CRAM, VCF, and BCF genomic files.

2|Updated Jun 4, 2026
One-click install
npx skills add https://github.com/Lord1Egypt/scientific-agent-toolkit --skill pysam-lord1egypt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/Lord1Egypt/scientific-agent-toolkit/tree/main/scientific-skills/pysam
Command: npx skills add https://github.com/Lord1Egypt/scientific-agent-toolkit --skill pysam-lord1egypt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pysam, and includes references (resource) components.

What problem does it solve?

This skill addresses the complexity of working with high-throughput sequencing data formats like SAM, BAM, CRAM, and VCF, which are notoriously difficult to parse and manipulate manually.

Core Features & Use Cases

  • Genomic File Manipulation: Seamlessly read, write, and query alignment and variant files.
  • Region-Based Analysis: Efficiently extract reads or variants from specific genomic coordinates using indexed files.
  • Workflow Integration: Combine alignment data, variant calls, and reference sequences to perform quality control, coverage analysis, and variant annotation.

Quick Start

Use the pysam skill to open the alignment file example.bam and fetch all reads overlapping the region chr1 from position 1000 to 2000.

Frequently Asked Questions about pysam

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

FAQPage Schema
How do I extract reads from a specific genomic region in a BAM file?

To extract reads from a BAM file, you use region-based analysis with indexed genomic datasets. This allows efficient coordinate-based queries to fetch all reads overlapping specific genomic coordinates like chr1 positions 1000 to 2000.

Can I use Python to parse and manipulate VCF and BCF variant files?

Yes, you can parse and manipulate VCF and BCF variant files using a comprehensive Python interface. It facilitates complex bioinformatics workflows including reading, writing, and querying variant calls for variant annotation.

What is the best way to perform coverage analysis on high-throughput sequencing data?

The best way to perform coverage analysis on high-throughput sequencing data is by integrating alignment data and reference sequences. This approach combines BAM files and reference genomes to calculate sequencing depth across genomic coordinates.

Does pysam require htslib integration for processing CRAM files?

Yes, processing CRAM files requires htslib integration. This underlying integration provides the high-performance random access needed to query and manipulate compressed genomic alignment datasets efficiently.

How do I read and write SAM, BAM, and CRAM alignment formats in a bioinformatics workflow?

You read and write SAM, BAM, and CRAM alignment formats through a Python interface designed for genomic file manipulation. It seamlessly handles parsing and querying these high-throughput sequencing formats within custom bioinformatics workflows.

Why do I need indexed genomic datasets for coordinate-based queries?

Indexed genomic datasets are required for coordinate-based queries because they enable high-performance random access. Without indexing, extracting reads or variants from specific regions in large sequencing files would be computationally inefficient.