@diegosouzapw/polars-bio
BA high-performance skill for processing genomic data (VCF, FASTA, BED) using polars-bio. Features streaming VCF processing, interval joins, FASTA analysis, and variant annotation.
Install
agr install @diegosouzapw/polars-bio --target claudeWrites 2 files into .claude/skills/, pinned to git-c199b996.
- .claude/skills/polars-bio/SKILL.md
- .claude/skills/polars-bio/metadata.json
Document
name: polars-bio description: A high-performance skill for processing genomic data (VCF, FASTA, BED) using polars-bio. Features streaming VCF processing, interval joins, FASTA analysis, and variant annotation. license: Apache-2.0
Polars-Bio Skill
Overview
This skill leverages polars-bio and polars to provide a robust toolkit for large-scale genomic data analysis. It is designed to handle datasets larger than memory using Polars' streaming engine and lazy evaluation.
Capabilities
1. VCF Processing
- Lazy Loading: Use
pb.scan_vcf()to define execution plans without loading data into memory immediately. - Streaming Conversion: Efficiently convert VCFs to Parquet (
sink_parquet) for faster downstream queries. - Filtering & Cleaning: Parse INFO fields and filter variants using Polars expressions.
2. Genomic Interval Operations
- Overlap Joins: High-performance interval joins (finding variants within genomic regions like Cytobands or Genes) using
pb.overlap().
3. Sequence Analysis
- FASTA Processing: Lazy reading of FASTA files (
pb.scan_fasta) to calculate sequence metrics (e.g., GC content, sequence length).
4. Variant Annotation
- Database Integration: Annotate VCF variants with external datasets (e.g., gnomAD, dbSNP) using efficient point-joins on
chrom,start,ref,alt.
Quick Start
Basic VCF Loading & Interval Join
import polars as pl
import polars_bio as pb
# 1. Lazy Load VCF
vcf_lf = pb.scan_vcf("data/clinvar.vcf.gz")
# 2. Load Regions (e.g., BED file)
regions_lf = pl.scan_csv("data/regions.bed", separator="\t", has_header=False,
new_columns=["chrom", "start", "end", "name"])
# 3. Perform Interval Overlap
# Finds variants in VCF that overlap with regions
joined_lf = pb.overlap(vcf_lf, regions_lf)
# 4. Execute (Streaming)
result = joined_lf.collect(streaming=True)
print(result)
Convert VCF to Parquet
# Efficiently convert large VCF to Parquet without high memory usage
pb.scan_vcf("input.vcf").sink_parquet("output.parquet")
FASTA GC Content Analysis
lf = pb.scan_fasta("genome.fa")
lf = lf.with_columns(
pl.col("sequence").str.count_matches("G|C").alias("gc_count"),
pl.col("sequence").str.len_chars().alias("len")
)
print(lf.select(pl.col("gc_count").sum() / pl.col("len").sum()).collect())
Benchmarks
The skill includes a benchmark comparing Eager vs. Streaming execution. Streaming mode has been shown to reduce memory usage by ~33% on standard workloads. See ANALYSIS_REPORT.md for details.
Dependencies
polarspolars-biopyarrow(for Parquet)
Trustgrade B
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- warnLicenseno SPDX license detected
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-c199b996765b2026-07-31