If you're working with genomic data in Python, this is the standard tool for reading and writing alignment files (BAM/CRAM), variant files (VCF/BCF), and reference sequences (FASTA/FASTQ). It wraps htslib so you get the full samtools/bcftools ecosystem with a Pythonic interface. The main thing to watch for is the coordinate system: it uses 0-based half-open intervals except when you pass region strings to fetch(), which are 1-based like samtools. You'll need index files for random access, and the documentation here covers the core workflows like calculating coverage, validating variants against reads, and filtering based on quality metrics. It's mature, well maintained, and handles the file format complexity so you don't have to.

skills.sh installs
233
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill pysam --agent claude-code

Installs into .claude/skills of the current project.

Files

Pysam

Overview

Pysam is a Python module for reading, manipulating, and writing genomic datasets. Read/write SAM/BAM/CRAM alignment files, VCF/BCF variant files, and FASTA/FASTQ sequences with a Pythonic interface to htslib. Query tabix-indexed files, perform pileup analysis for coverage, and execute samtools/bcftools commands.

When to Use This Skill

This skill should be used when:

  • Working with sequencing alignment files (BAM/CRAM)
  • Analyzing genetic variants (VCF/BCF)
  • Extracting reference sequences or gene regions
  • Processing raw sequencing data (FASTQ)
  • Calculating coverage or read depth
  • Implementing bioinformatics analysis pipelines
  • Quality control of sequencing data
  • Variant calling and annotation workflows

Quick Start

Installation

uv pip install pysam

Basic Examples

Read alignment file:

import pysam

# Open BAM file and fetch reads in region
samfile = pysam.AlignmentFile("example.bam", "rb")
for read in samfile.fetch("chr1", 1000, 2000):
    print(f"{read.query_name}: {read.reference_start}")
samfile.close()

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Category
Testing & QA
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1triggerdotdev avatartrigger-dev-taskstriggerdotdev/trigger.devUse this skill when writing, designing, or optimizing Trigger.dev background tasks and workflows. This includes creating reliable async tasks, implementing AI w233skills.sh installs
2guia-matthieu avatarlanding-page-optimizerguia-matthieu/clawfu-skillsOptimize landing pages for maximum conversions using proven frameworks from Unbounce and Oli Gardner—apply the "one goal, one message, one action" principle wit232skills.sh installs
3upload-post avatartiktok-app-marketingupload-post/upload-post-larry-marketing-skillAutomate TikTok + Instagram slideshow marketing for any app or product. Researches competitors, generates AI images, adds text overlays, posts via Upload-Post (232skills.sh installs
4openai avatardocs-syncopenai/openai-agents-pythonAnalyze main branch implementation and configuration to find missing, incorrect, or outdated documentation in docs/. Use when asked to audit doc coverage, sync 231skills.sh installs
5personamanagmentlayer avatarsecurity-expertpersonamanagmentlayer/pclExpert-level application security, OWASP Top 10, penetration testing, and security best practices228skills.sh installs
6yonatangross avatarweb-research-workflowyonatangross/orchestkitUnified decision tree for web research and competitive monitoring. Auto-selects WebFetch, Tavily, or agent-browser based on target site characteristics and avai227skills.sh installs