pysam

pysam is a skill for Claude Code from K-Dense-AI/scientific-agent-skills. It costs 64 tokens per session (3,175 once invoked), scanned A, original, MIT.

A Python interface to HTSlib for working with common genomic files, including DNA sequences, sequencing alignments, genetic variants, and indexed annotation tables. HTSlib is a library used by many genomics command-line tools.

In plain words
What is it for?
Use it to process SAM, BAM, CRAM, VCF, BCF, FASTA, FASTQ, BED, GFF, and GTF files, including coverage calculations, pileups, and region-based queries.
Why use it?
It lets programs stream, query, filter, index, and write large sequencing datasets without implementing each file format from scratch.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to process SAM, BAM, CRAM, VCF, BCF, FASTA, FASTQ, BED, GFF, and GTF files, including coverage calculations, pileups, and region-based queries.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/k-dense-ai/scientific-agent-skills/pysam
About the project

Scientific Agent Skills is a collection of reusable procedures that give AI agents capabilities for scientific research across areas such as biology, chemistry, medicine, and drug discovery. It is used by researchers and by people building AI scientist workflows with compatible coding agents. The catalogue contains many of the project's skills and supporting instructions.

K-Dense-AI/scientific-agent-skills · 44,469 stars · on GitHub · arxiv.org

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add K-Dense-AI/scientific-agent-skills --skill pysam
Clone the repo
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pysam

README.md
[![agentmods](https://agentmods.dev/badge/skills/k-dense-ai/scientific-agent-skills/pysam/github.svg)](https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/pysam)
Your own site
<a href="https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/pysam"><img src="https://agentmods.dev/badge/skills/k-dense-ai/scientific-agent-skills/pysam/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pysam

Your own site · 80×15
<a href="https://agentmods.dev/skills/k-dense-ai/scientific-agent-skills/pysam"><img src="https://agentmods.dev/badge/skills/k-dense-ai/scientific-agent-skills/pysam.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,175 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 9 Apr 2026
  • Snyk pass 9 Apr 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00064 $0.03175
Opus 5 $0.00032 $0.01588
Sonnet 5 $0.00013 $0.00635
Haiku 4.5 $0.00006 $0.00317

Measured 9d ago against content hash 4cbfdbd80b4a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

pysam scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (scripts/alignment_qc.py, scripts/filter_alignments.py, scripts/inspect_hts.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

bam.fetch(region="chr1:100-199") # 1-based inclusive
skills/pysam/SKILL.md · 348 lines

How it starts

The opening of the file, as written. The whole thing — 348 lines — stays where its author put it; the contents beside it link to each section on GitHub.

pysam

Overview

Use pysam for low-level, streaming access to HTSlib-supported genomic formats:

  • AlignmentFile and AlignedSegment for SAM/BAM/CRAM
  • VariantFile, VariantHeader, and VariantRecord for VCF/BCF
  • FastaFile for indexed FASTA and FastxFile for sequential FASTA/FASTQ
  • TabixFile for BGZF-compressed, tabix-indexed BED/GFF/GTF/custom tables
  • pysam.samtools and pysam.bcftools for wrapped command dispatchers

Current upstream baseline: pysam 0.24.0 (27 April 2026), wrapping HTSlib/samtools/bcftools 1.23.1. Read references/sources.md before updating version-specific guidance.

Installation

Use the pinned release for reproducible work:

uv pip install "pysam==0.24.0"

Confirm the runtime:

import pysam

print(pysam.__version__)           # 0.24.0
print(pysam.__samtools_version__)  # 1.23.1

Prebuilt wheels are available for supported macOS and Linux platforms. A source build needs a C compiler and HTSlib build dependencies; read the official installation guide linked from references/sources.md.

First Decide

Before writing code:

  1. Identify the real format, compression, sort order, and available index.
  2. Decide whether coordinates are numeric Python coordinates or a region string. Do not mix them.
  3. For CRAM, identify the exact reference assembly and FASTA.
  4. Prefer indexed region access; use sequential iteration only when intended.
  5. Preserve headers when writing and write to a new path by default.
  6. State filtering semantics: mapping/base quality, flags, overlap handling, duplicate handling, and pileup depth cap.

For unfamiliar files, start with the bundled read-only inspector:

python scripts/inspect_hts.py sample.bam
python scripts/inspect_hts.py cohort.vcf.gz
python scripts/inspect_hts.py reference.fa

Bundled Scripts

Script Purpose Typical call
scripts/inspect_hts.py Metadata-only inspection for alignment, variant, FASTA, FASTQ, and tabix files python scripts/inspect_hts.py sample.cram --reference ref.fa
scripts/alignment_qc.py Streaming aggregate read/QC counts as JSON python scripts/alignment_qc.py sample.bam --max-records 100000
scripts/variant_summary.py Streaming variant, FILTER, and genotype summary as JSON python scripts/variant_summary.py cohort.vcf.gz --region chr1:1-1000000
scripts/filter_alignments.py Filter SAM/BAM/CRAM without changing record order python scripts/filter_alignments.py input.bam output.bam --exclude-secondary

Read the full file on GitHub · 348 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 348 lines · 64 tokens per session scan A 4cbfdbd80b4a

Subscribe to this mod's changes

pysam is a skill published in the GitHub repository K-Dense-AI/scientific-agent-skills (44,469 stars, last pushed yesterday), licensed MIT. It adds 64 tokens to every session and 3,175 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

bio-prefect-dask-nextflow

Design reproducible bioinformatics pipelines with Prefect plus Dask or Nextflow. Use when scaffolding local, distributed, or scheduler-backed workflows.

fmschulz/omics-skills · 37 tokens

discovery-toolbox

A routed repertoire of 90 scientific thinking operators for biological research agents - visual reasoning, detectability and information budgets, search reframing, causal identification, competing explanations, observation and selection processes, pipeline artifact diagnosis, effort allocation, and confirmation…

dekan-aleksandr/biodiscovery-skills · 122 tokens

rdkit-qsar-pharmacophore

Computes 2048-bit ECFP4 Morgan fingerprints from SMILES, trains LightGBM regressors for pIC50 prediction, and extracts SHAP feature attributions.

YuliaNuzhnenko/bioinformatics-agent-skills · 46 tokens

discovery-director

Operate as a research director making original discoveries from a given biological question and dataset. Use when the task is open-ended scientific research, exploring omics or experimental data for findings, hypothesis generation and testing, screening a large candidate space of genes, variants, features or…

dekan-aleksandr/biodiscovery-skills · 114 tokens

bulk-rnaseq-counts-to-de-deseq2

Run differential expression analysis on bulk RNA-seq count data with DESeq2 (R). Covers DESeqDataSet construction from a count matrix, tximport (Salmon/Kallisto), featureCounts, or SummarizedExperiment; pre-filtering; design formulas (simple, batch, paired, interaction, multi-factor, LRT); result extraction by…

hossainlab/omics-skills · 141 tokens

seurat-skill

Comprehensive Seurat v5 (R) guide for single-cell RNA-seq and multimodal analysis. Covers installation, standard workflows (Normalize/SCTransform), clustering, integration (CCA/RPCA/Harmony), differential expression (FindMarkers/FindAllMarkers), visualization (DimPlot/FeaturePlot/VlnPlot/DoHeatmap), spatial…

Agents365-ai/seurat-skill · 167 tokens