[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASWJ0FSBVA6FEAQGC6HSTQ":3,"skill-same:01M7ASWJ0FSBVA6FEAQGC6HSTQ":105},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":14,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":34,"install":35,"resources":48},"01M7ASWJ0FSBVA6FEAQGC6HSTQ","pysam",null,"Python\u002FHTSlib workflows for genomic files. Use when reading, querying, filtering, or writing SAM\u002FBAM\u002FCRAM, VCF\u002FBCF, FASTA\u002FFASTQ, or tabix data with pysam, including pileup, coverage, indexing, and CRAM references.","nikhilesh-s\u002Fclaude-toolkit","nikhilesh-s","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F123913414?v=4","01M7ARX6NXB6DFY1CCP91599KE","Nikhilesh Suravarjjala","01M7ARX6PFTQKR6ME1K2S4AZ9K",0,"MIT","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: pysam\ndescription: Python\u002FHTSlib workflows for genomic files. Use when reading, querying, filtering, or writing SAM\u002FBAM\u002FCRAM, VCF\u002FBCF, FASTA\u002FFASTQ, or tabix data with pysam, including pileup, coverage, indexing, and CRAM references.\nlicense: MIT\nallowed-tools: Read Write Edit Bash\ncompatibility: Requires Python 3.8–3.14 and pysam 0.24.0. Bundled scripts use local files. CRAM decoding may require the matching reference FASTA or an explicitly configured REF_PATH\u002FREF_CACHE.\nmetadata:\n  version: \"2.0\"\n  skill-author: K-Dense Inc.\n---\n\n# pysam\n\n## Overview\n\nUse pysam for low-level, streaming access to HTSlib-supported genomic formats:\n\n- `AlignmentFile` and `AlignedSegment` for SAM\u002FBAM\u002FCRAM\n- `VariantFile`, `VariantHeader`, and `VariantRecord` for VCF\u002FBCF\n- `FastaFile` for indexed FASTA and `FastxFile` for sequential FASTA\u002FFASTQ\n- `TabixFile` for BGZF-compressed, tabix-indexed BED\u002FGFF\u002FGTF\u002Fcustom tables\n- `pysam.samtools` and `pysam.bcftools` for wrapped command dispatchers\n\nCurrent upstream baseline: **pysam 0.24.0** (27 April 2026), wrapping\nHTSlib\u002Fsamtools\u002Fbcftools 1.23.1. Read `references\u002Fsources.md` before updating\nversion-specific guidance.\n\n## Installation\n\nUse the pinned release for reproducible work:\n\n```bash\nuv pip install \"pysam==0.24.0\"\n```\n\nConfirm the runtime:\n\n```python\nimport pysam\n\nprint(pysam.__version__)           # 0.24.0\nprint(pysam.__samtools_version__)  # 1.23.1\n```\n\nPrebuilt wheels are available for supported macOS and Linux platforms. A\nsource build needs a C compiler and HTSlib build dependencies; read the\nofficial installation guide linked from `references\u002Fsources.md`.\n\n## First Decide\n\nBefore writing code:\n\n1. Identify the real format, compression, sort order, and available index.\n2. Decide whether coordinates are numeric Python coordinates or a region\n   string. Do not mix them.\n3. For CRAM, identify the exact reference assembly and FASTA.\n4. Prefer indexed region access; use sequential iteration only when intended.\n5. Preserve headers when writing and write to a new path by default.\n6. State filtering semantics: mapping\u002Fbase quality, flags, overlap handling,\n   duplicate handling, and pileup depth cap.\n\nFor unfamiliar files, start with the bundled read-only inspector:\n\n```bash\npython scripts\u002Finspect_hts.py sample.bam\npython scripts\u002Finspect_hts.py cohort.vcf.gz\npython scripts\u002Finspect_hts.py reference.fa\n```\n\n## Bundled Scripts\n\n| Script | Purpose | Typical call |\n|---|---|---|\n| `scripts\u002Finspect_hts.py` | Metadata-only inspection for alignment, variant, FASTA, FASTQ, and tabix files | `python scripts\u002Finspect_hts.py sample.cram --reference ref.fa` |\n| `scripts\u002Falignment_qc.py` | Streaming aggregate read\u002FQC counts as JSON | `python scripts\u002Falignment_qc.py sample.bam --max-records 100000` |\n| `scripts\u002Fvariant_summary.py` | Streaming variant, FILTER, and genotype summary as JSON | `python scripts\u002Fvariant_summary.py cohort.vcf.gz --region chr1:1-1000000` |\n| `scripts\u002Ffilter_alignments.py` | Filter SAM\u002FBAM\u002FCRAM without changing record order | `python scripts\u002Ffilter_alignments.py input.bam output.bam --exclude-secondary` |\n\nAll scripts refuse to overwrite existing outputs. Run each with `--help` for\ncoordinate, index, and privacy notes.\n\n## Coordinate Contract\n\n**Numeric coordinates accepted by pysam APIs are 0-based, half-open.** This\nincludes numeric `AlignmentFile.fetch()`, `VariantFile.fetch()`,\n`FastaFile.fetch()`, `TabixFile.fetch()`, and `pileup()` arguments.\n\n**Region strings are samtools-style: 1-based and inclusive.**\n\n```python\n# The same 100 bases:\nbam.fetch(\"chr1\", 99, 199)          # [99, 199)\nbam.fetch(region=\"chr1:100-199\")    # 1-based inclusive\n```\n\nVCF text uses 1-based `POS`, while record properties expose both systems:\n\n```python\nrecord.pos    # 1-based\nrecord.start  # 0-based inclusive\nrecord.stop   # 0-based exclusive\n```\n\nRead `references\u002Fcoordinates_and_indexing.md` for format conversions, overlap\nsemantics, index choices, and contig-name checks.\n\n## Alignment Files\n\nUse context managers and explicit modes:\n\n```python\nimport pysam\n\nwith pysam.AlignmentFile(\"sample.bam\", \"rb\", threads=4) as bam:\n    for read in bam.fetch(\"chr1\", 1_000, 2_000):\n        if (\n            not read.is_unmapped\n            and not read.is_secondary\n            and not read.is_supplementary\n            and read.mapping_quality >= 30\n        ):\n            print(read.query_name, read.reference_start, read.cigarstring)\n```\n\nUse `fetch(until_eof=True)` to stream every record in file order, including\nunplaced unmapped reads, without requiring an index:\n\n```python\nwith pysam.AlignmentFile(\"sample.bam\", \"rb\") as bam:\n    for read in bam.fetch(until_eof=True):\n        ...\n```\n\nImportant distinctions:\n\n- `fetch()` returns alignment records overlapping a region.\n- `count()` counts records and defaults to `read_callback=\"nofilter\"`.\n- `count_coverage()` returns A\u002FC\u002FG\u002FT base counts and defaults to base quality\n  15 plus `read_callback=\"all\"`.\n- `pileup()` exposes per-column reads and has its own filtering, base-quality,\n  overlap, orphan, and `max_depth=8000` defaults.\n\nFor exact-region pileups, set `truncate=True` and explicit filters:\n\n```python\nwith pysam.FastaFile(\"reference.fa\") as fasta, pysam.AlignmentFile(\n    \"sample.bam\", \"rb\"\n) as bam:\n    for column in bam.pileup(\n        \"chr1\",\n        1_000,\n        2_000,\n        truncate=True,\n        stepper=\"samtools\",\n        fastafile=fasta,\n        min_mapping_quality=20,\n        min_base_quality=20,\n        max_depth=100_000,\n    ):\n        print(column.reference_pos, column.get_num_aligned())\n```\n\nRead `references\u002Falignment_files.md` for flags, CIGAR operations, tags,\nmodified bases, writing records, pileup details, and iterator lifetime.\n\n## Variant Files\n\nInput format is auto-detected. Numeric fetch coordinates remain 0-based:\n\n```python\nimport pysam\n\nwith pysam.VariantFile(\"cohort.vcf.gz\", threads=4) as variants:\n    for record in variants.fetch(\"chr1\", 999_999, 2_000_000):\n        print(record.contig, record.pos, record.ref, record.alts)\n        for sample_name, call in record.samples.items():\n            print(sample_name, call.get(\"GT\"))\n```\n\nSubset samples **before retrieving records**:\n\n```python\nwith pysam.VariantFile(\"cohort.bcf\") as variants:\n    variants.subset_samples([\"sample_A\", \"sample_B\"])\n    for record in variants:\n        ...\n```\n\nWhen changing a header, copy each record and translate it to the destination\nheader before assigning newly declared INFO\u002FFORMAT\u002FFILTER fields. Do not\nmanually clear and rebuild `header.samples`.\n\nRead `references\u002Fvariant_files.md` for safe headers, writing, sample\nsubsetting, missing genotypes, symbolic alleles, filtering, translation, and\nindexing.\n\n## FASTA, FASTQ, and Tabix\n\nIndexed FASTA uses numeric 0-based coordinates:\n\n```python\nwith pysam.FastaFile(\"reference.fa\") as fasta:\n    sequence = fasta.fetch(\"chr1\", 999, 1_099)\n```\n\n`FastxFile` is sequential. `persist=False` is faster but yielded records become\ninvalid after iteration advances:\n\n```python\nwith pysam.FastxFile(\"reads.fastq.gz\", persist=False) as reads:\n    for read in reads:\n        qualities = read.get_quality_array()\n        ...\n```\n\nTabix input must be coordinate-sorted and BGZF-compressed, not ordinary gzip.\nUse a non-destructive two-step workflow:\n\n```python\npysam.tabix_compress(\"regions.bed\", \"regions.bed.gz\")\npysam.tabix_index(\"regions.bed.gz\", preset=\"bed\")\n\nwith pysam.TabixFile(\"regions.bed.gz\", parser=pysam.asBed()) as tbx:\n    for interval in tbx.fetch(\"chr1\", 1_000, 2_000):\n        print(interval.contig, interval.start, interval.end)\n```\n\nRead `references\u002Fsequence_files.md` for FASTA\u002FFASTQ records and safe tabix\ncreation.\n\n## CRAM, Remote I\u002FO, and Threads\n\npysam 0.24 changed inherited HTSlib behavior:\n\n- Newly written CRAM defaults to CRAM 3.1, not 3.0.\n- HTSlib no longer contacts the EBI reference server by default.\n- Prefer `reference_filename=\"reference.fa\"` for deterministic local reads and\n  writes.\n\n```python\nwith pysam.AlignmentFile(\n    \"sample.cram\",\n    \"rc\",\n    reference_filename=\"reference.fa\",\n    threads=4,\n) as cram:\n    for read in cram.fetch(\"chr1\", 1_000, 2_000):\n        ...\n```\n\nOnly configure `REF_PATH`\u002F`REF_CACHE` when reference-by-MD5 lookup is\nintentional. Do not assume a CRAM is self-contained. `threads=` accelerates\ncompression\u002Fdecompression; it does not parallelize Python analysis.\n\nRead `references\u002Fcram_and_performance.md` before CRAM conversion, remote access,\nor concurrent iteration.\n\n## Wrapped samtools and bcftools\n\nImport command modules explicitly. Pass each command-line token as a separate\nstring:\n\n```python\nimport pysam.samtools\nimport pysam.bcftools\n\npysam.samtools.sort(\n    \"-@\", \"4\", \"-o\", \"sorted.bam\", \"input.bam\", catch_stdout=False\n)\npysam.samtools.index(\"-@\", \"4\", \"sorted.bam\", catch_stdout=False)\n\npysam.bcftools.index(\"--csi\", \"variants.vcf.gz\", catch_stdout=False)\n```\n\nDispatchers capture stdout by default. For large or binary output, use the\ntool's `-o` option with `catch_stdout=False`, or `save_stdout=...`, rather than\nreturning the complete output in memory.\n\n```python\ntry:\n    pysam.samtools.quickcheck(\"-v\", \"sample.bam\")\nexcept pysam.SamtoolsError as error:\n    messages = pysam.samtools.quickcheck.get_messages()\n    raise RuntimeError(messages or str(error)) from error\n```\n\nUse the Python API for record-level logic and dispatchers for mature bulk\noperations such as sort, index, merge, view, and normalization. Never compose\ndispatcher arguments by splitting an untrusted shell command.\n\n## Writing Rules\n\n- Copy or construct a valid header before opening output.\n- Write to a new path; do not use `force=True` unless replacement is explicit.\n- Preserve sort order if the output will be indexed.\n- Set `query_sequence` before `query_qualities`.\n- Prefer `pysam.CIGAR_OPS` enum members; top-level constants such as\n  `pysam.CMATCH` are compatibility aliases slated for future removal.\n- Validate outputs with `pysam.samtools.quickcheck()` for alignments and reopen\n  variant\u002Fsequence outputs before downstream use.\n- Use CSI rather than BAI\u002FTBI when references or coordinates exceed legacy\n  index limits.\n\n## Reference Map\n\n| Need | Read |\n|---|---|\n| Alignment API, flags, CIGAR, pileup, modified bases | `references\u002Falignment_files.md` |\n| VCF\u002FBCF headers, records, samples, writing | `references\u002Fvariant_files.md` |\n| FASTA\u002FFASTQ and tabix-indexed tables | `references\u002Fsequence_files.md` |\n| Coordinate conversion and index selection | `references\u002Fcoordinates_and_indexing.md` |\n| CRAM references, remote I\u002FO, threads, performance | `references\u002Fcram_and_performance.md` |\n| Correct integrated analysis patterns | `references\u002Fcommon_workflows.md` |\n| Compact current API signatures and defaults | `references\u002Fapi_reference.md` |\n| Upgrade notes for existing environments | `references\u002Fmigration_to_0_24.md` |\n| Official docs, specifications, and release sources | `references\u002Fsources.md` |\n\n## Common Failure Modes\n\n- Treating numeric `VariantFile.fetch()` coordinates as 1-based\n- Using ordinary gzip where BGZF plus tabix\u002FCSI is required\n- Calling region fetch without an index\n- Assuming `fetch()` includes unplaced unmapped alignments\n- Forgetting `truncate=True` for an exact pileup interval\n- Ignoring pileup defaults such as base quality 13 and depth cap 8000\n- Sharing one file handle across active iterators or threads\n- Decoding CRAM without its exact reference\n- Assigning a new VCF field before declaring it in the output header\n- Capturing large samtools\u002Fbcftools output in memory\n- Using a SNP base-counting method for indels or symbolic alleles\n","# pysam\n\n## Overview\n\nUse pysam for low-level, streaming access to HTSlib-supported genomic formats:\n\n- `AlignmentFile` and `AlignedSegment` for SAM\u002FBAM\u002FCRAM\n- `VariantFile`, `VariantHeader`, and `VariantRecord` for VCF\u002FBCF\n- `FastaFile` for indexed FASTA and `FastxFile` for sequential FASTA\u002FFASTQ\n- `TabixFile` for BGZF-compressed, tabix-indexed BED\u002FGFF\u002FGTF\u002Fcustom tables\n- `pysam.samtools` and `pysam.bcftools` for wrapped command dispatchers\n\nCurrent upstream baseline: **pysam 0.24.0** (27 April 2026), wrapping\nHTSlib\u002Fsamtools\u002Fbcftools 1.23.1. Read `references\u002Fsources.md` before updating\nversion-specific guidance.\n\n## Installation\n\nUse the pinned release for reproducible work:\n\n```bash\nuv pip install \"pysam==0.24.0\"\n```\n\nConfirm the runtime:\n\n```python\nimport pysam\n\nprint(pysam.__version__)           # 0.24.0\nprint(pysam.__samtools_version__)  # 1.23.1\n```\n\nPrebuilt wheels are available for supported macOS and Linux platforms. A\nsource build needs a C compiler and HTSlib build dependencies; read the\nofficial installation guide linked from `references\u002Fsources.md`.\n\n## First Decide\n\nBefore writing code:\n\n1. Identify the real format, compression, sort order, and available index.\n2. Decide whether coordinates are numeric Python coordinates or a region\n   string. Do not mix them.\n3. For CRAM, identify the exact reference assembly and FASTA.\n4. Prefer indexed region access; use sequential iteration only when intended.\n5. Preserve headers when writing and write to a new path by default.\n6. State filtering semantics: mapping\u002Fbase quality, flags, overlap handling,\n   duplicate handling, and pileup depth cap.\n\nFor unfamiliar files, start with the bundled read-only inspector:\n\n```bash\npython scripts\u002Finspect_hts.py sample.bam\npython scripts\u002Finspect_hts.py cohort.vcf.gz\npython scripts\u002Finspect_hts.py reference.fa\n```\n\n## Bundled Scripts\n\n| Script | Purpose | Typical call |\n|---|---|---|\n| `scripts\u002Finspect_hts.py` | Metadata-only inspection for alignment, variant, FASTA, FASTQ, and tabix files | `python scripts\u002Finspect_hts.py sample.cram --reference ref.fa` |\n| `scripts\u002Falignment_qc.py` | Streaming aggregate read\u002FQC counts as JSON | `python scripts\u002Falignment_qc.py sample.bam --max-records 100000` |\n| `scripts\u002Fvariant_summary.py` | Streaming variant, FILTER, and genotype summary as JSON | `python scripts\u002Fvariant_summary.py cohort.vcf.gz --region chr1:1-1000000` |\n| `scripts\u002Ffilter_alignments.py` | Filter SAM\u002FBAM\u002FCRAM without changing record order | `python scripts\u002Ffilter_alignments.py input.bam output.bam --exclude-secondary` |\n\nAll scripts refuse to overwrite existing outputs. Run each with `--help` for\ncoordinate, index, and privacy notes.\n\n## Coordinate Contract\n\n**Numeric coordinates accepted by pysam APIs are 0-based, half-open.** This\nincludes numeric `AlignmentFile.fetch()`, `VariantFile.fetch()`,\n`FastaFile.fetch()`, `TabixFile.fetch()`, and `pileup()` arguments.\n\n**Region strings are samtools-style: 1-based and inclusive.**\n\n```python\n# The same 100 bases:\nbam.fetch(\"chr1\", 99, 199)          # [99, 199)\nbam.fetch(region=\"chr1:100-199\")    # 1-based inclusive\n```\n\nVCF text uses 1-based `POS`, while record properties expose both systems:\n\n```python\nrecord.pos    # 1-based\nrecord.start  # 0-based inclusive\nrecord.stop   # 0-based exclusive\n```\n\nRead `references\u002Fcoordinates_and_indexing.md` for format conversions, overlap\nsemantics, index choices, and contig-name checks.\n\n## Alignment Files\n\nUse context managers and explicit modes:\n\n```python\nimport pysam\n\nwith pysam.AlignmentFile(\"sample.bam\", \"rb\", threads=4) as bam:\n    for read in bam.fetch(\"chr1\", 1_000, 2_000):\n        if (\n            not read.is_unmapped\n            and not read.is_secondary\n            and not read.is_supplementary\n            and read.mapping_quality >= 30\n        ):\n            print(read.query_name, read.reference_start, read.cigarstring)\n```\n\nUse `fetch(until_eof=True)` to stream every record in file order, including\nunplaced unmapped reads, without requiring an index:\n\n```python\nwith pysam.AlignmentFile(\"sample.bam\", \"rb\") as bam:\n    for read in bam.fetch(until_eof=True):\n        ...\n```\n\nImportant distinctions:\n\n- `fetch()` returns alignment records overlapping a region.\n- `count()` counts records and defaults to `read_callback=\"nofilter\"`.\n- `count_coverage()` returns A\u002FC\u002FG\u002FT base counts and defaults to base quality\n  15 plus `read_callback=\"all\"`.\n- `pileup()` exposes per-column reads and has its own filtering, base-quality,\n  overlap, orphan, and `max_depth=8000` defaults.\n\nFor exact-region pileups, set `truncate=True` and explicit filters:\n\n```python\nwith pysam.FastaFile(\"reference.fa\") as fasta, pysam.AlignmentFile(\n    \"sample.bam\", \"rb\"\n) as bam:\n    for column in bam.pileup(\n        \"chr1\",\n        1_000,\n        2_000,\n        truncate=True,\n        stepper=\"samtools\",\n        fastafile=fasta,\n        min_mapping_quality=20,\n        min_base_quality=20,\n        max_depth=100_000,\n    ):\n        print(column.reference_pos, column.get_num_aligned())\n```\n\nRead `references\u002Falignment_files.md` for flags, CIGAR operations, tags,\nmodified bases, writing records, pileup details, and iterator lifetime.\n\n## Variant Files\n\nInput format is auto-detected. Numeric fetch coordinates remain 0-based:\n\n```python\nimport pysam\n\nwith pysam.VariantFile(\"cohort.vcf.gz\", threads=4) as variants:\n    for record in variants.fetch(\"chr1\", 999_999, 2_000_000):\n        print(record.contig, record.pos, record.ref, record.alts)\n        for sample_name, call in record.samples.items():\n            print(sample_name, call.get(\"GT\"))\n```\n\nSubset samples **before retrieving records**:\n\n```python\nwith pysam.VariantFile(\"cohort.bcf\") as variants:\n    variants.subset_samples([\"sample_A\", \"sample_B\"])\n    for record in variants:\n        ...\n```\n\nWhen changing a header, copy each record and translate it to the destination\nheader before assigning newly declared INFO\u002FFORMAT\u002FFILTER fields. Do not\nmanually clear and rebuild `header.samples`.\n\nRead `references\u002Fvariant_files.md` for safe headers, writing, sample\nsubsetting, missing genotypes, symbolic alleles, filtering, translation, and\nindexing.\n\n## FASTA, FASTQ, and Tabix\n\nIndexed FASTA uses numeric 0-based coordinates:\n\n```python\nwith pysam.FastaFile(\"reference.fa\") as fasta:\n    sequence = fasta.fetch(\"chr1\", 999, 1_099)\n```\n\n`FastxFile` is sequential. `persist=False` is faster but yielded records become\ninvalid after iteration advances:\n\n```python\nwith pysam.FastxFile(\"reads.fastq.gz\", persist=False) as reads:\n    for read in reads:\n        qualities = read.get_quality_array()\n        ...\n```\n\nTabix input must be coordinate-sorted and BGZF-compressed, not ordinary gzip.\nUse a non-destructive two-step workflow:\n\n```python\npysam.tabix_compress(\"regions.bed\", \"regions.bed.gz\")\npysam.tabix_index(\"regions.bed.gz\", preset=\"bed\")\n\nwith pysam.TabixFile(\"regions.bed.gz\", parser=pysam.asBed()) as tbx:\n    for interval in tbx.fetch(\"chr1\", 1_000, 2_000):\n        print(interval.contig, interval.start, interval.end)\n```\n\nRead `references\u002Fsequence_files.md` for FASTA\u002FFASTQ records and safe tabix\ncreation.\n\n## CRAM, Remote I\u002FO, and Threads\n\npysam 0.24 changed inherited HTSlib behavior:\n\n- Newly written CRAM defaults to CRAM 3.1, not 3.0.\n- HTSlib no longer contacts the EBI reference server by default.\n- Prefer `reference_filename=\"reference.fa\"` for deterministic local reads and\n  writes.\n\n```python\nwith pysam.AlignmentFile(\n    \"sample.cram\",\n    \"rc\",\n    reference_filename=\"reference.fa\",\n    threads=4,\n) as cram:\n    for read in cram.fetch(\"chr1\", 1_000, 2_000):\n        ...\n```\n\nOnly configure `REF_PATH`\u002F`REF_CACHE` when reference-by-MD5 lookup is\nintentional. Do not assume a CRAM is self-contained. `threads=` accelerates\ncompression\u002Fdecompression; it does not parallelize Python analysis.\n\nRead `references\u002Fcram_and_performance.md` before CRAM conversion, remote access,\nor concurrent iteration.\n\n## Wrapped samtools and bcftools\n\nImport command modules explicitly. Pass each command-line token as a separate\nstring:\n\n```python\nimport pysam.samtools\nimport pysam.bcftools\n\npysam.samtools.sort(\n    \"-@\", \"4\", \"-o\", \"sorted.bam\", \"input.bam\", catch_stdout=False\n)\npysam.samtools.index(\"-@\", \"4\", \"sorted.bam\", catch_stdout=False)\n\npysam.bcftools.index(\"--csi\", \"variants.vcf.gz\", catch_stdout=False)\n```\n\nDispatchers capture stdout by default. For large or binary output, use the\ntool's `-o` option with `catch_stdout=False`, or `save_stdout=...`, rather than\nreturning the complete output in memory.\n\n```python\ntry:\n    pysam.samtools.quickcheck(\"-v\", \"sample.bam\")\nexcept pysam.SamtoolsError as error:\n    messages = pysam.samtools.quickcheck.get_messages()\n    raise RuntimeError(messages or str(error)) from error\n```\n\nUse the Python API for record-level logic and dispatchers for mature bulk\noperations such as sort, index, merge, view, and normalization. Never compose\ndispatcher arguments by splitting an untrusted shell command.\n\n## Writing Rules\n\n- Copy or construct a valid header before opening output.\n- Write to a new path; do not use `force=True` unless replacement is explicit.\n- Preserve sort order if the output will be indexed.\n- Set `query_sequence` before `query_qualities`.\n- Prefer `pysam.CIGAR_OPS` enum members; top-level constants such as\n  `pysam.CMATCH` are compatibility aliases slated for future removal.\n- Validate outputs with `pysam.samtools.quickcheck()` for alignments and reopen\n  variant\u002Fsequence outputs before downstream use.\n- Use CSI rather than BAI\u002FTBI when references or coordinates exceed legacy\n  index limits.\n\n## Reference Map\n\n| Need | Read |\n|---|---|\n| Alignment API, flags, CIGAR, pileup, modified bases | `references\u002Falignment_files.md` |\n| VCF\u002FBCF headers, records, samples, writing | `references\u002Fvariant_files.md` |\n| FASTA\u002FFASTQ and tabix-indexed tables | `references\u002Fsequence_files.md` |\n| Coordinate conversion and index selection | `references\u002Fcoordinates_and_indexing.md` |\n| CRAM references, remote I\u002FO, threads, performance | `references\u002Fcram_and_performance.md` |\n| Correct integrated analysis patterns | `references\u002Fcommon_workflows.md` |\n| Compact current API signatures and defaults | `references\u002Fapi_reference.md` |\n| Upgrade notes for existing environments | `references\u002Fmigration_to_0_24.md` |\n| Official docs, specifications, and release sources | `references\u002Fsources.md` |\n\n## Common Failure Modes\n\n- Treating numeric `VariantFile.fetch()` coordinates as 1-based\n- Using ordinary gzip where BGZF plus tabix\u002FCSI is required\n- Calling region fetch without an index\n- Assuming `fetch()` includes unplaced unmapped alignments\n- Forgetting `truncate=True` for an exact pileup interval\n- Ignoring pileup defaults such as base quality 13 and depth cap 8000\n- Sharing one file handle across active iterators or threads\n- Decoding CRAM without its exact reference\n- Assigning a new VCF field before declaring it in the output header\n- Capturing large samtools\u002Fbcftools output in memory\n- Using a SNP base-counting method for indels or symbolic alleles\n",{"name":5,"license":15,"metadata":24,"description":7,"allowed-tools":27,"compatibility":28},{"version":25,"skill-author":26},"2.0","K-Dense Inc.","Read Write Edit Bash","Requires Python 3.8–3.14 and pysam 0.24.0. Bundled scripts use local files. CRAM decoding may require the matching reference FASTA or an explicitly configured REF_PATH\u002FREF_CACHE.","nik-claude-toolkit","4feaa2876384b593d9e30d9190bc56985eeeeb8e","skills\u002Fpysam","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s","2026-10-22 14:30:58",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add nikhilesh-s\u002Fclaude-toolkit --skill pysam",{"tool":41,"command":42},"bunx","bunx skills add nikhilesh-s\u002Fclaude-toolkit --skill pysam",{"tool":44,"command":45},"pnpm","pnpm dlx skills add nikhilesh-s\u002Fclaude-toolkit --skill pysam","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002FSKILL.md",true,[49,55,59,63,67,71,75,79,83,87,93,97,101],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002Falignment_files.md","REFERENCE","参考文档",11183,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Falignment_files.md",{"path":56,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fapi_reference.md",9085,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fapi_reference.md",{"path":60,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fcommon_workflows.md",11969,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fcommon_workflows.md",{"path":64,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fcoordinates_and_indexing.md",8215,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fcoordinates_and_indexing.md",{"path":68,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fcram_and_performance.md",8970,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fcram_and_performance.md",{"path":72,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fmigration_to_0_24.md",4735,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fmigration_to_0_24.md",{"path":76,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fsequence_files.md",8853,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fsequence_files.md",{"path":80,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fsources.md",6045,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fsources.md",{"path":84,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fvariant_files.md",10748,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Freferences\u002Fvariant_files.md",{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"scripts\u002Falignment_qc.py","SCRIPT","脚本",10204,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Fscripts\u002Falignment_qc.py",{"path":94,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":95,"sourceHtmlUrl":96},"scripts\u002Ffilter_alignments.py",11223,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Fscripts\u002Ffilter_alignments.py",{"path":98,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":99,"sourceHtmlUrl":100},"scripts\u002Finspect_hts.py",13784,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Fscripts\u002Finspect_hts.py",{"path":102,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":103,"sourceHtmlUrl":104},"scripts\u002Fvariant_summary.py",11119,"https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fpysam\u002Fscripts\u002Fvariant_summary.py",[106,113,121,128,135,142],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M7AT8339CZMCRMRZP6G1R329","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":117,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":19},"01M7AT77E7JPH96ETQBNDVVYDM","video-use","Edit any video by conversation. Transcribe, cut, color grade, generate overlay animations, burn subtitles — for talking heads, montages, tutorials, travel, interviews. No presets, no menus. Ask questions, confirm the plan, execute, iterate, persist. Production-correctness rules are hard; everything else is artistic freedom.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fvideo-use\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fvideo-use\u002FSKILL.md",[],[],{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":19},"01M7AT6YVX000D73Q40SBPZYKP","venue-templates","Prepare journal manuscripts, conference papers, research posters, and grant documents using venue-specific formatting guidance and bundled LaTeX scaffolds. Use when selecting an official template, checking current page or anonymity rules, adapting academic writing to a venue, or inspecting a submission PDF.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fvenue-templates\u002FSKILL.md",[],[],{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":19},"01M7AT6SGGBENKX1G6V8V9G2MJ","vaex","Use this skill for processing and analyzing large tabular datasets (billions of rows) that exceed available RAM. Vaex excels at out-of-core DataFrame operations, lazy evaluation, fast aggregations, efficient visualization of big data, and machine learning on large datasets. Apply when users need to work with large CSV\u002FHDF5\u002FArrow\u002FParquet files, perform fast statistics on massive datasets, create visualizations of big data, or build ML pipelines that do not fit in memory.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fvaex\u002FSKILL.md",[],[],{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":19},"01M7AT6HHDJ54MR4HDPFHJYR7G","usfiscaldata","Query the U.S. Treasury Fiscal Data REST API for federal financial data. No API key required. Use for national debt (Debt to the Penny), Daily Treasury Statements, Monthly Treasury Statements, Treasury securities auctions, interest rates, foreign exchange rates, savings bonds, or U.S. government revenue and spending statistics.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Fusfiscaldata\u002FSKILL.md",[],[],{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":19},"01M7AT662JFE4THBVAZBB3ANJD","uncertainty-and-units","Track physical units and propagate measurement uncertainty in scientific calculations using pint and uncertainties. Use for unit conversion and dimensional checking, GUM uncertainty budgets, Type A and Type B evaluation, coverage factors and expanded uncertainty, Monte Carlo propagation, significant-figure and plus-minus reporting, error propagation through curve fits, CODATA constants, auditing Python code for stripped units or broken uncertainty propagation, and order-of-magnitude plausibility checks using dimensionless groups (Reynolds, Peclet, Damkohler, Knudsen, Biot, Womersley), characteristic scales such as diffusion time or Debye length, and observed magnitude ranges. Trigger on \"is this number physically reasonable\", \"sanity check these units\", \"what regime is this flow in\", or a result that looks off by orders of magnitude.","https:\u002F\u002Fgithub.com\u002Fnikhilesh-s\u002Fclaude-toolkit\u002Fblob\u002Fnik-claude-toolkit\u002Fskills\u002Funcertainty-and-units\u002FSKILL.md",[],[]]