polars-bio
Skill này làm gì
Công cụ này giúp so sánh và xử lý các trình tự gen (như gen trong DNA). Bạn có thể tìm trình tự nào chồng lấp, trình tự nào gần nhất, gộp các trình tự liền kề, tính độ phủ và thực hiện nhiều phép toán khác.
Khi nào nên dùng
- ✓So sánh danh sách gen để xem những gen nào trùng nhau.
- ✓Tìm các vùng DNA không được phủ bởi quá trình giải trình tự.
- ✓Gộp các đoạn trình tự gen chồng lấp.
Liên kết skill
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/polars-bio/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Những gen nào trong danh sách A chồng lấp với gen trong danh sách B?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ đọc dữ liệu gen ở các định dạng phổ biến (như BED, VCF, BAM) và sắp xếp chúng thành bảng. Sau đó, nó áp dụng các phép toán để so sánh vị trí của các trình tự gen.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
polars-bio
Use this skill for genomic interval arithmetic and bioinformatics file I/O through Polars and DataFusion. It targets polars-bio 0.36.0, tested with Polars 1.44.2 on Python 3.13. The upstream package requires Polars >=1.37.1, PyArrow >=23.0.1,<25, DataFusion >=53,<54 and polars-config-meta >=0.3.2,<1. Keep this environment separate from packages needing incompatible Arrow or DataFusion releases.
uv pip install "polars-bio==0.36.0" "polars==1.44.2"
# Optional pandas interoperability (requires pandas >=3):
uv pip install "polars-bio[pandas]==0.36.0" "polars==1.44.2"
Verify new releases against the official release notes and package requirements. The examples below with named files are templates: substitute actual files and check their schemas. The synthetic interval example and small local format round trips were executed during this review.
Workflow
- Record the assembly, contig naming, coordinate convention, strand policy and unit of analysis. Identical contig names do not prove identical assemblies.
- Choose readers by format; BCF has its own reader. Inspect schemas and source metadata before selecting attributes or genotypes.
- Normalize all inputs to one coordinate system and validate their bounds.
- Choose pair output, hit counts, covered bases or read depth deliberately.
- Filter and project lazily, then inspect a small result before scaling up.
- Validate output counts and boundaries against a hand-computable fixture; preserve IDs, coordinate metadata and provenance when saving results.
Coordinate contract
The default is 1-based closed, including converted BED reads. Use
use_zero_based=True on genomic readers for 0-based half-open output.
This argument converts positions; it is not only a metadata label. For example,
BED [0,10) becomes [1,10] by default and remains [0,10) with the override.
SAM text POS is 1-based, whereas BAM stores its alignment position internally
as 0-based. Both readers expose the requested output convention.
For manually constructed DataFrames, metadata labels existing numbers and
does not convert them. Converting closed [s,e] to half-open means s-1,e.
Set metadata only after conversion. Never convert twice.
import polars as pl
import polars_bio as pb
pb.set_option("datafusion.bio.coordinate_system_zero_based", True)
pb.set_option("datafusion.bio.coordinate_system_check", True)
query = pl.DataFrame({
"query_id": ["q1", "q2", "q3"],
"chrom": ["chr1", "chr1", "chr2"],
"start": [0, 10, 0], "end": [10, 20, 10],
})
target = pl.DataFrame({
"chrom": ["chr1", "chr1"], "start": [5, 8], "end": [12, 15],
})
for frame in (query, target):
frame.config_meta.set(coordinate_system_zero_based=True)
pairs = pb.overlap(query, target).collect()
counts = pb.count_overlaps(query, target).collect().sort("query_id")
covered = pb.coverage(query, target).collect().sort("query_id")
assert pairs.height == 4
assert counts["count"].to_list() == [2, 2, 0]
assert covered["coverage"].to_list() == [5, 5, 0]
Require non-null contigs, integer positions and valid positive-length intervals
(0 <= start < end in half-open form), within the chosen assembly. Do not silently
turn points/insertions into nonempty intervals: choose the biological convention.
Mismatched input metadata raises CoordinateSystemMismatchError; missing metadata
warns and uses the global setting by default, or raises MissingCoordinateSystemError
in strict mode. Inspect pb.get_metadata(frame) after transformations and SQL.
See configuration.
Choose the operation
| Question | Operation | Interpretation |
|---|---|---|
| Which interval pairs intersect? | overlap(a, b) |
Inner pair join; a query can appear repeatedly |
| Which query rows have any hit? | overlap(a, b, overlap_output="left", distinct_output=True) |
One hit per original query row; duplicate input rows retain identity |
| How many target intervals intersect each query? | count_overlaps(a, b) |
Target-record count, including zero for no hit |
| How many query bases are covered? | coverage(a, b) |
Length of the union of target intersections; not read depth |
| Which targets are closest? | nearest(a, b, k=1) |
Up to k neighbors, with nullable target/distance for no candidate |
…
Câu hỏi thường gặp
“Khoảng gen” (genomic intervals) là gì?
Đó là các đoạn DNA được xác định bằng điểm bắt đầu và điểm kết thúc trên một nhiễm sắc thể hoặc chuỗi lớn hơn.
Công cụ hỗ trợ những định dạng tệp nào?
Nó hỗ trợ nhiều định dạng dùng trong sinh học phân tử, như BED, VCF, BAM, GFF, GTF, FASTA và FASTQ.
Công cụ xử lý cách đếm vị trí (bắt đầu từ 0 hay 1) như thế nào?
Mặc định nó dùng hệ đếm từ 1 (đóng), nhưng có thể được cấu hình sang hệ đếm từ 0 (nửa mở) nếu cần, điều này phổ biến ở một số công cụ.
Chi tiết
Mô tả gốc của tác giả
Performs genomic interval overlap, nearest, merge, coverage, complement and subtraction on Polars DataFrames, and reads or writes BED, VCF, BCF, BAM, CRAM, GFF, GTF, FASTA and FASTQ data. Use for coordinate-aware genomic joins, read-depth analysis, lazy bioinformatics I/O, SQL queries or migration from bioframe.
Độ phổ biến
- Sao GitHub
- 51k
- Vị trí xếp hạng
- #3529
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
13c-metabolic-flux
51kƯớc tính thông lượng chuyển hóa bằng dữ liệu theo dõi đồng vị carbon-13. Hữu ích để phân tích chuyển hóa tế bào và các con đường sinh hóa.
adaptyv
51kThiết kế thí nghiệm đặc trưng protein bằng Adaptyv API. Hỗ trợ ước tính chi phí, gửi trình tự và theo dõi kết quả phòng thí nghiệm.
aeon
51kThực hiện các tác vụ học máy trên dữ liệu chuỗi thời gian. Hữu ích để phân loại, dự báo, phát hiện bất thường và tìm mẫu trong dữ liệu tuần tự.
alphagenome
51kTra cứu các tác động di truyền đã được tính trước cho biến thể gen. Cung cấp điểm số và giải thích để hiểu ảnh hưởng của biến thể lên bộ gen.
Skill tương tự
pytorch-patterns
280kGiúp agent của bạn dùng PyTorch cho các mô hình học máy. Áp dụng thực hành tốt nhất để huấn luyện mô hình hiệu quả và đảm bảo kết quả có thể lặp lại.
evm-token-decimals
280kGiúp agent tránh lỗi về số thập phân khi làm việc với các mạng blockchain khác nhau. Đảm bảo giá trị token chính xác trong giao dịch và phép tính.
ito-inference
280kGiúp agent kiểm tra xem các mô hình AI đã sẵn sàng để dùng chưa. Kết nối yêu cầu tài nguyên tính toán với dịch vụ mô hình đã sẵn sàng.