pysam
Routes agents using pysam for SAM/BAM/CRAM, VCF/BCF, tabix-indexed tables, FASTA/FASTQ, bundled samtools/bcftools wrappers, and installation or build troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- pysam
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Routes agents using pysam for SAM/BAM/CRAM, VCF/BCF, tabix-indexed tables, FASTA/FASTQ, bundled samtools/bcftools wrappers, and installation or build troubleshooting.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/package-overview.md3.4 KB
- 参考文档references/repo-provenance.md2.0 KB
- 参考文档references/repo-routing-metadata.json335 B
- 参考文档references/troubleshooting.md3.0 KB
- 脚本scripts/check_pysam_environment.py4.9 KB
03 SKILL.md 正文
pysam
Use this repo skill when a task involves the Python package pysam: reading or writing high-throughput sequencing files, manipulating alignments or variants, indexing genomic interval files, fetching FASTA/FASTQ records, calling bundled samtools/bcftools commands from Python, or diagnosing install/build/import failures.
Start Here
- Read
references/package-overview.mdfor the package scope, install options, verified version facts, and route summary. - Read
references/troubleshooting.mdfor cross-cutting setup, coordinate, index, and routing failures. - Read
references/repo-provenance.mdbefore deciding whether this skill is current for a specific checkout. - Run
scripts/check_pysam_environment.pywhen you need a source-free import and smoke diagnostic for the active Python environment.
Install and Minimal Check
Prefer Bioconda when users want the most reliable install path:
conda config --add channels bioconda
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install pysam
PyPI wheels are usually enough for ordinary Python use:
python -m pip install pysam
python -c 'import pysam; print(pysam.__version__)'
For a deeper package check, run:
python scripts/check_pysam_environment.py
Route by Task
| User task | Read |
|---|---|
Open, read, write, index, fetch, count, or pile up SAM/BAM/CRAM data; edit AlignedSegment flags, CIGAR, tags, sequence, or qualities |
sub-skills/alignment-io/SKILL.md |
Read, write, filter, subset, or construct VCF/BCF files with VariantFile, VariantHeader, VariantRecord, INFO/FORMAT/sample fields, or indexed fetches |
sub-skills/variant-io/SKILL.md |
Compress/index/fetch tabix tables; parse BED/GTF/GFF/VCF rows; use FastaFile, FastxFile, or FASTQ quality arrays |
sub-skills/tabix-fasta/SKILL.md |
Translate shell samtools/bcftools commands into Python calls; handle catch_stdout, save_stdout, usage(), get_messages(), or SamtoolsError |
sub-skills/command-wrappers/SKILL.md |
Install pysam, build from source, link external htslib, compile Cython extensions, migrate legacy csamtools names, or inspect build helpers |
sub-skills/troubleshooting-build/SKILL.md |
Common Routing Decisions
- If a user asks about BAM rows, reads, CIGAR strings, pileup columns, or unmapped reads, start with
alignment-ioeven when the final solution also callssamtools. - If a user asks about VCF header metadata, sample genotypes, INFO/FORMAT types, or record writing, start with
variant-ioeven when the file is tabix-indexed. - If a user asks about generic compressed BED/GTF/GFF tables or FASTA/FASTQ sequence access, start with
tabix-fasta. - If a user gives a shell command such as
samtools sort,samtools faidx,bcftools view, orbcftools queryand wants Python code, start withcommand-wrappers. - If
import pysamor installation fails before any data workflow can run, start withtroubleshooting-build.
Coordinate and Index Defaults
- pysam Python integer intervals are usually 0-based and half-open.
- Region strings such as
chr1:101-200follow samtools-style 1-based inclusive conventions. AlignmentFile.fetch()andVariantFile.fetch()require an appropriate index for random access; use sequential modes only when the workflow supports them.- Tabix random access requires BGZF compression and a
.tbior.csiindex. - FASTA random access uses
.faiindexes; FASTQ streaming usesFastxFileand does not require random-access indexing.
Bundled Helpers
scripts/check_pysam_environment.pyverifies imports, versions, command wrapper presence, and tiny source-free operations across the major routes.sub-skills/alignment-io/scripts/alignment_smoke.pycreates a tiny BAM and exercises alignment reads, indexing, coverage, pileup, and quality helpers.sub-skills/variant-io/scripts/variant_smoke.pywrites and reads a tiny VCF with INFO/FORMAT/sample fields.sub-skills/tabix-fasta/scripts/tabix_fasta_smoke.pycreates tiny tabix, FASTA, and FASTQ fixtures.sub-skills/command-wrappers/scripts/command_wrapper_smoke.pychecks dispatcher usage, stdout handling, and safe samtools command behavior.sub-skills/troubleshooting-build/scripts/inspect_build_config.pyprints redacted build/import diagnostics.
What This Skill Does Not Cover
- It does not teach general genomics biology or variant interpretation beyond file/API mechanics.
- It does not require the original pysam source checkout for runtime use.
- It does not cover maintainer release engineering beyond install/build and extension-development troubleshooting.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).