pysam

Read and write SAM/BAM/CRAM alignments, VCF/BCF variants, and FASTA/FASTQ sequences.

18|1|Updated Dec 27, 2025
One-click install
npx skills add https://github.com/LogauaEngstrom/claude-scientific-skills --skill pysam-logauaengstrom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/LogauaEngstrom/claude-scientific-skills/tree/main/scientific-skills/pysam
Command: npx skills add https://github.com/LogauaEngstrom/claude-scientific-skills --skill pysam-logauaengstrom

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pysam provides a Pythonic interface to read, manipulate, and write genomic data across SAM/BAM/CRAM alignments, VCF/BCF variants, and FASTA/FASTQ sequences, with indexing and region-based queries to streamline workflows.

Core Features & Use Cases

  • Read/write SAM/BAM/CRAM alignments with region queries, pileup, and basic QC.
  • Read/write VCF/BCF variants and access genotype data, INFO/FORMAT fields, and multi-sample support.
  • Access indexed reference sequences from FASTA/FASTQ and perform sequence extraction and basic validation.
  • Integrate multiple data types for common bioinformatics analyses (quality control, variant validation, and coverage assessment).
  • Leverage command-line tooling wrappers to interact with samtools/bcftools workflows when needed.

Quick Start

Install pysam and run a simple Python snippet to open an input BAM and iterate over reads.

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/CRAM alignments in Python?

This toolkit reads and writes SAM/BAM/CRAM alignments in Python by providing a Pythonic interface for genomic data I/O. It supports region queries, pileup operations, and basic quality control across these alignment formats.

Can I access VCF/BCF variant data and genotype fields with Python?

Yes, you can read and write VCF/BCF variant data in Python using this toolkit. It allows you to access genotype data, INFO/FORMAT fields, and provides multi-sample support for variant analysis.

How do I extract specific regions from indexed FASTA sequences?

You extract specific regions from indexed FASTA sequences by performing region queries with this Python toolkit. It enables efficient sequence extraction and basic validation from indexed reference sequences.

Do I need to index my BAM or FASTA files for random access?

Yes, you need to index your BAM or FASTA files for random access. This toolkit relies on index requirements to perform efficient region queries and random access for genomic data processing.

What coordinate system does pysam use for genomic regions?

This toolkit relies on 0-based coordinate handling for genomic regions. Understanding this coordinate system is essential for accurate alignment processing, variant analysis, and sequence extraction.

Can I integrate samtools and bcftools workflows into my Python scripts?

Yes, you can integrate samtools and bcftools workflows into your Python scripts using this toolkit. It provides command-line tooling wrappers to interact with htslib-based tooling when needed for bioinformatics analyses.