pysam

Automate genomic data processing with pysam for SAM, BAM, CRAM, VCF, BCF, FASTA, and FASTQ files.

13|3|Updated Jun 10, 2026
One-click install
npx skills add https://github.com/tassiovale/claude-code-kit --skill pysam-tassiovale
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pysam
Source: https://github.com/tassiovale/claude-code-kit/tree/main/skills/pysam
Command: npx skills add https://github.com/tassiovale/claude-code-kit --skill pysam-tassiovale

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill simplifies genomic data processing, allowing users to efficiently read, manipulate, and write genomic datasets, including SAM/BAM/CRAM alignments, VCF/BCF variants, and FASTA/FASTQ sequences.

Core Features & Use Cases

  • Alignment File Operations: Read, manipulate, and write SAM/BAM/CRAM files for alignment analysis.
  • Variant File Operations: Work with VCF/BCF files for variant analysis and annotation.
  • Sequence File Operations: Extract reference sequences or gene regions from FASTA/FASTQ files.
  • Use Case: Imagine you have a BAM file with aligned sequencing reads. Use this Skill to calculate coverage statistics, extract sequences around variant positions, and perform variant calling and annotation.

Quick Start

Use the pysam skill to calculate coverage for the region chr1:1000-2000 in the alignment file 'aligned_reads.bam'.

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, or CRAM alignment files in Python?

You can read, manipulate, and write SAM, BAM, and CRAM alignment files in Python by using the pysam library, which interfaces with htslib for efficient genomic data handling.

How do I extract reference sequences from FASTA or FASTQ files for specific gene regions?

To extract reference sequences or specific gene regions from FASTA and FASTQ files, you can use Python sequence file operations that parse genomic data and isolate the target intervals efficiently.

Can I perform variant calling and analysis on VCF or BCF files using Python?

Yes, you can perform variant analysis and annotation directly on VCF and BCF files using Python libraries that interact with htslib to process variant datasets.

Do I need pysam and htslib to calculate coverage statistics for NGS data pipelines?

Yes, calculating coverage statistics from aligned sequencing reads in NGS data pipelines requires the pysam Python library to interact with the underlying htslib framework for efficient file processing.

What is the best way to extract sequences around variant positions from a BAM file?

The best way to extract sequences around variant positions from a BAM file is using Python genomic data processing tools to calculate coverage and isolate the target sequence intervals.

Are there limitations when using Python for large-scale genomic sequence processing?

Python genomic sequence processing relies on the pysam library to interact with htslib, so limitations depend on the underlying htslib file handling efficiency and available system memory for large NGS datasets.