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 K-Dense-AI

Gives AI assistants workflows for the pysam Python library, covering reading, querying, filtering and writing SAM, BAM, CRAM, VCF, BCF, FASTA, FASTQ and tabix data. Aimed at developers and analysts working with genomic files.

  • Score 94
  • 59k 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/K-Dense-AI/scientific-agent-skills /tmp/scientific-agent-skills && mkdir -p ~/.claude/skills && cp -r /tmp/scientific-agent-skills/skills/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 an agent skill that provides Python and HTSlib workflows for genomic files. It covers AlignmentFile for SAM, BAM and CRAM, VariantFile for VCF and BCF, FastaFile and FastxFile for FASTA and FASTQ, and TabixFile for tabix-indexed tables. The skill pins pysam 0.24.1 as its baseline and wraps HTSlib, samtools and bcftools 1.24.

The skill sets clear rules. Numeric pysam coordinates are 0-based and half-open, while region strings are 1-based and inclusive. It also covers indexed region access, CRAM reference handling, pileup filtering and writing to new paths. Four bundled scripts inspect files and produce QC or variant summaries, and they refuse to overwrite existing outputs. It is intended for developers and analysts who work with genomic data in Python.

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

What it can do

  • AlignmentFileReads and writes SAM, BAM and CRAM alignment files with AlignedSegment records.
  • VariantFileWorks with VCF and BCF files, including headers, records, samples and filtering.
  • FastaFile and FastxFileFetches indexed FASTA sequences and iterates over FASTA or FASTQ files sequentially.
  • TabixFileQueries BGZF-compressed, tabix-indexed BED, GFF, GTF and custom tables.
  • Pileup and coverageExplains pileup defaults, base and mapping quality filters, and count_coverage behaviour.
  • samtools and bcftools wrappersRuns mature bulk operations such as sort, index, merge, view and normalization.
  • inspect_hts.pyGives a metadata-only inspection of alignment, variant, FASTA, FASTQ and tabix files.
  • alignment_qc.pyStreams aggregate read and QC counts for a file and prints them as JSON.
  • variant_summary.pyStreams variant, FILTER and genotype summaries for a VCF or BCF as JSON.
  • filter_alignments.pyFilters SAM, BAM or CRAM files without changing record order.

What you need

  • Python 3.9 or later
  • pysam 0.24.1
  • Matching reference FASTA for CRAM decoding, unless REF_PATH or REF_CACHE is configured

Try asking

  • Use pysam to count reads per region in sample.bam with MAPQ 30 or higher
  • Inspect cohort.vcf.gz with the pysam inspector and summarise its FILTER values
  • Write a pysam script that extracts a region from a CRAM with reference.fa

Good to know

  • Remote storage and biological datasets are outside the local validation suite.
  • FASTA inspection requires an existing .fai index created with pysam.faidx() first.
  • threads= speeds up compression only and does not parallelize Python analysis.
  • samtools quickcheck does not read the middle of a file and cannot rule out internal corruption.

Security check

A

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

Checked automatically: skills/pysam/SKILL.md, skills/pysam/scripts/alignment_qc.py, skills/pysam/scripts/filter_alignments.py, skills/pysam/scripts/inspect_hts.py, skills/pysam/scripts/variant_summary.py. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: Read Write Edit Bash

  • SKILL.md13 KB
  • references/alignment_files.md13 KB
  • references/api_reference.md10 KB
  • references/common_workflows.md14 KB
  • references/coordinates_and_indexing.md9 KB
Show all 14 files
  • references/cram_and_performance.md9 KB
  • references/migration_to_0_24.md5 KB
  • references/sequence_files.md9 KB
  • references/sources.md7 KB
  • references/variant_files.md12 KB
  • scripts/alignment_qc.py11 KB
  • scripts/filter_alignments.py12 KB
  • scripts/inspect_hts.py14 KB
  • scripts/variant_summary.py12 KB

Alternatives to pysam

All alternatives →

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

pysam: common questions

What coordinate system does pysam use?

Numeric arguments to pysam fetch and pileup calls are 0-based and half-open. Region strings such as chr1:100-199 are 1-based and inclusive.

Does the skill need a reference file for CRAM?

CRAM decoding may require the matching reference FASTA. The skill recommends passing reference_filename for deterministic local reads.

Will the bundled scripts overwrite my files?

No. The source states that all bundled scripts refuse to overwrite existing outputs.

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.