Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

pysam

Skill by davila7

Pysam is a Python module for reading, writing and manipulating genomic files. It covers SAM/BAM/CRAM alignments, VCF/BCF variants and FASTA/FASTQ sequences for NGS data processing pipelines.

  • Score 94
  • 34k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install pysam

Built from the published package, never by AI.

git clone --depth 1 https://github.com/davila7/claude-code-templates /tmp/claude-code-templates && mkdir -p ~/.claude/skills && cp -r /tmp/claude-code-templates/cli-tool/components/skills/scientific/pysam ~/.claude/skills/pysam

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install pysam in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

Pysam is a Python module for reading, manipulating, and writing genomic datasets. It handles SAM, BAM and CRAM alignment files, VCF and BCF variant files, and FASTA and FASTQ sequences through a Pythonic interface to htslib. It can also query tabix-indexed files, run pileup analysis for coverage, and execute samtools and bcftools commands.

The skill gives an AI assistant guidance for these tasks, including coordinate conventions, index requirements and common pitfalls. Installation uses uv pip install pysam, and separate reference files cover alignments, variants, sequences and integrated workflows. It is aimed at bioinformatics work on sequencing data, such as alignment processing, variant analysis and quality control. Official documentation is at pysam.readthedocs.io.

Written from the project's SKILL.md and checked against it.

What it can do

  • Alignment file operationsOpen and read BAM/SAM/CRAM files, fetch reads by region, filter, and write alignments.
  • Variant file operationsRead and write VCF/BCF files, query regions, and access INFO and genotype data.
  • Sequence file operationsQuery FASTA reference sequences by coordinates and read FASTQ files with quality scores.
  • Integrated workflowsCombine alignment, variant and reference files for coverage and variant validation tasks.
  • Coverage and pileup analysisCalculate coverage statistics and run base-by-base pileup analysis on alignments.
  • samtools and bcftools accessRun samtools and bcftools commands from Python, such as sort, index, view and bcftools view.

What you need

  • Python
  • pysam installed with uv pip install pysam
  • Index files (.bai, .crai, .fai, .tbi, .csi) for random access

Try asking

  • Use pysam to list reads overlapping chr1:1000-2000 in my BAM file
  • Write a pysam script that counts variants in a VCF per chromosome
  • Extract the reference sequence for chr1 positions 1000-2000 with pysam

Good to know

  • Uses 0-based, half-open coordinates, while fetch region strings are 1-based
  • Random access needs index files; otherwise use sequential reading with until_eof=True
  • Only stdin and stdout are supported for streaming
  • Thread safety has not been fully validated

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: cli-tool/components/skills/scientific/pysam/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

  • SKILL.md10 KB
  • references/alignment_files.md8 KB
  • references/common_workflows.md15 KB
  • references/sequence_files.md11 KB
  • references/variant_files.md9 KB

Alternatives to pysam

All alternatives →

Compare with literature-search-arxiv, alphafold-database-fetch-and-analyze or quickgo-database

pysam: common questions

Does pysam use 0-based or 1-based coordinates?

Pysam uses 0-based, half-open coordinates in Python. Region strings passed to fetch() follow the 1-based samtools convention.

Which index files does pysam need?

BAM files need a .bai index, CRAM needs .crai, FASTA needs .fai, VCF.gz needs a .tbi tabix index, and BCF needs a .csi index.

Can pysam run samtools and bcftools commands?

Yes. The source shows pysam.samtools and pysam.bcftools calls for sorting, indexing, viewing regions and converting VCF output, with pysam.SamtoolsError for error handling.

How do I install pysam?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is pysam free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is pysam safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to pysam?

Similar skills: literature-search-arxiv, alphafold-database-fetch-and-analyze, quickgo-database, peloton.

Add to stack

Loading.