pysam

Process SAM/BAM/CRAM, VCF/BCF, and FASTA/FASTQ genomic files via htslib.

8|Updated Nov 19, 2025
One-click install
npx skills add https://github.com/sanand0/scientific-research --skill pysam-sanand0
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/sanand0/scientific-research/tree/main/.claude/skills/pysam
Command: npx skills add https://github.com/sanand0/scientific-research --skill pysam-sanand0

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a powerful Python interface for efficiently reading, manipulating, and writing complex genomic data files, streamlining bioinformatics workflows.

Core Features & Use Cases

  • Genomic File Handling: Read and write SAM/BAM/CRAM alignments, VCF/BCF variants, and FASTA/FASTQ sequences.
  • Data Analysis: Extract genomic regions, calculate coverage, and perform pileup analysis.
  • Use Case: Analyze variant calls from a VCF file, filter them based on quality and allele frequency, and extract the corresponding reference sequences from a FASTA file for further investigation.

Quick Start

Use the pysam skill to read the first 1000 bases from chromosome 1 in the 'reference.fasta' file.

Frequently Asked Questions about pysam

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

FAQPage Schema
How do I read and process VCF variant files in Python for NGS analysis?

You can read, filter, and manipulate VCF/BCF variant files in Python by using a htslib-based interface designed for NGS analysis. This provides a Pythonic way to parse variant calls and extract data like quality scores and allele frequency directly.

Can I extract specific genomic regions from a BAM file using Python?

Yes, extracting specific genomic regions from SAM/BAM/CRAM alignments is supported through region-based querying. This allows you to target specific chromosome coordinates directly in Python to calculate coverage or perform pileup analysis.

Does this Python interface support FASTA and FASTQ sequence manipulation?

FASTA and FASTQ sequence manipulation is fully supported for NGS data processing. You can efficiently read, write, and extract reference sequences to integrate them into genomic analysis workflows alongside alignment and variant data.

What is the best way to perform pileup analysis on genomic alignments in Python?

Performing pileup analysis on genomic alignments is best handled by using a Pythonic interface to the htslib library. This enables efficient calculation of base coverage and extraction of alignment data across specific genomic regions.

How do I filter variant calls based on allele frequency from a VCF file?

To filter variant calls based on allele frequency from a VCF file, you can parse the variants using a Pythonic htslib interface. This allows you to apply custom filters to quality scores and allele frequencies, then extract corresponding reference sequences from a FASTA file for further investigation.