$npx -y skills add LeonChaoX/qinyan-academic-skills --skill gtarsHigh-performance toolkit for genomic interval analysis in Rust with Python bindings. Use when working with genomic regions, BED files, coverage tracks, overlap detection, tokenization for ML models, or fragment analysis in computational genomics and machine learning applications.
| 1 | # Gtars: Genomic Tools and Algorithms in Rust |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Gtars is a high-performance Rust toolkit for manipulating, analyzing, and processing genomic interval data. It provides specialized tools for overlap detection, coverage analysis, tokenization for machine learning, and reference sequence management. |
| 6 | |
| 7 | Use this skill when working with: |
| 8 | - Genomic interval files (BED format) |
| 9 | - Overlap detection between genomic regions |
| 10 | - Coverage track generation (WIG, BigWig) |
| 11 | - Genomic ML preprocessing and tokenization |
| 12 | - Fragment analysis in single-cell genomics |
| 13 | - Reference sequence retrieval and validation |
| 14 | |
| 15 | ## Installation |
| 16 | |
| 17 | ### Python Installation |
| 18 | |
| 19 | Install gtars Python bindings: |
| 20 | |
| 21 | ```bash |
| 22 | uv uv pip install gtars |
| 23 | ``` |
| 24 | |
| 25 | ### CLI Installation |
| 26 | |
| 27 | Install command-line tools (requires Rust/Cargo): |
| 28 | |
| 29 | ```bash |
| 30 | # Install with all features |
| 31 | cargo install gtars-cli --features "uniwig overlaprs igd bbcache scoring fragsplit" |
| 32 | |
| 33 | # Or install specific features only |
| 34 | cargo install gtars-cli --features "uniwig overlaprs" |
| 35 | ``` |
| 36 | |
| 37 | ### Rust Library |
| 38 | |
| 39 | Add to Cargo.toml for Rust projects: |
| 40 | |
| 41 | ```toml |
| 42 | [dependencies] |
| 43 | gtars = { version = "0.1", features = ["tokenizers", "overlaprs"] } |
| 44 | ``` |
| 45 | |
| 46 | ## Core Capabilities |
| 47 | |
| 48 | Gtars is organized into specialized modules, each focused on specific genomic analysis tasks: |
| 49 | |
| 50 | ### 1. Overlap Detection and IGD Indexing |
| 51 | |
| 52 | Efficiently detect overlaps between genomic intervals using the Integrated Genome Database (IGD) data structure. |
| 53 | |
| 54 | **When to use:** |
| 55 | - Finding overlapping regulatory elements |
| 56 | - Variant annotation |
| 57 | - Comparing ChIP-seq peaks |
| 58 | - Identifying shared genomic features |
| 59 | |
| 60 | **Quick example:** |
| 61 | ```python |
| 62 | import gtars |
| 63 | |
| 64 | # Build IGD index and query overlaps |
| 65 | igd = gtars.igd.build_index("regions.bed") |
| 66 | overlaps = igd.query("chr1", 1000, 2000) |
| 67 | ``` |
| 68 | |
| 69 | See `references/overlap.md` for comprehensive overlap detection documentation. |
| 70 | |
| 71 | ### 2. Coverage Track Generation |
| 72 | |
| 73 | Generate coverage tracks from sequencing data with the uniwig module. |
| 74 | |
| 75 | **When to use:** |
| 76 | - ATAC-seq accessibility profiles |
| 77 | - ChIP-seq coverage visualization |
| 78 | - RNA-seq read coverage |
| 79 | - Differential coverage analysis |
| 80 | |
| 81 | **Quick example:** |
| 82 | ```bash |
| 83 | # Generate BigWig coverage track |
| 84 | gtars uniwig generate --input fragments.bed --output coverage.bw --format bigwig |
| 85 | ``` |
| 86 | |
| 87 | See `references/coverage.md` for detailed coverage analysis workflows. |
| 88 | |
| 89 | ### 3. Genomic Tokenization |
| 90 | |
| 91 | Convert genomic regions into discrete tokens for machine learning applications, particularly for deep learning models on genomic data. |
| 92 | |
| 93 | **When to use:** |
| 94 | - Preprocessing for genomic ML models |
| 95 | - Integration with geniml library |
| 96 | - Creating position encodings |
| 97 | - Training transformer models on genomic sequences |
| 98 | |
| 99 | **Quick example:** |
| 100 | ```python |
| 101 | from gtars.tokenizers import TreeTokenizer |
| 102 | |
| 103 | tokenizer = TreeTokenizer.from_bed_file("training_regions.bed") |
| 104 | token = tokenizer.tokenize("chr1", 1000, 2000) |
| 105 | ``` |
| 106 | |
| 107 | See `references/tokenizers.md` for tokenization documentation. |
| 108 | |
| 109 | ### 4. Reference Sequence Management |
| 110 | |
| 111 | Handle reference genome sequences and compute digests following the GA4GH refget protocol. |
| 112 | |
| 113 | **When to use:** |
| 114 | - Validating reference genome integrity |
| 115 | - Extracting specific genomic sequences |
| 116 | - Computing sequence digests |
| 117 | - Cross-reference comparisons |
| 118 | |
| 119 | **Quick example:** |
| 120 | ```python |
| 121 | # Load reference and extract sequences |
| 122 | store = gtars.RefgetStore.from_fasta("hg38.fa") |
| 123 | sequence = store.get_subsequence("chr1", 1000, 2000) |
| 124 | ``` |
| 125 | |
| 126 | See `references/refget.md` for reference sequence operations. |
| 127 | |
| 128 | ### 5. Fragment Processing |
| 129 | |
| 130 | Split and analyze fragment files, particularly useful for single-cell genomics data. |
| 131 | |
| 132 | **When to use:** |
| 133 | - Processing single-cell ATAC-seq data |
| 134 | - Splitting fragments by cell barcodes |
| 135 | - Cluster-based fragment analysis |
| 136 | - Fragment quality control |
| 137 | |
| 138 | **Quick example:** |
| 139 | ```bash |
| 140 | # Split fragments by clusters |
| 141 | gtars fragsplit cluster-split --input fragments.tsv --clusters clusters.txt --output-dir ./by_cluster/ |
| 142 | ``` |
| 143 | |
| 144 | See `references/cli.md` for fragment processing commands. |
| 145 | |
| 146 | ### 6. Fragment Scoring |
| 147 | |
| 148 | Score fragment overlaps against reference datasets. |
| 149 | |
| 150 | **When to use:** |
| 151 | - Evaluating fragment enrichment |
| 152 | - Comparing experimental data to references |
| 153 | - Quality metrics computation |
| 154 | - Batch scoring across samples |
| 155 | |
| 156 | **Quick example:** |
| 157 | ```bash |
| 158 | # Score fragments against reference |
| 159 | gtars scoring score --fragments fragments.bed --reference reference.bed --output scores.txt |
| 160 | ``` |
| 161 | |
| 162 | ## Common Workflows |
| 163 | |
| 164 | ### Workflow 1: Peak Overlap Analysis |
| 165 | |
| 166 | Identify overlapping genomic features: |
| 167 | |
| 168 | ```python |
| 169 | import gtars |
| 170 | |
| 171 | # Load two region sets |
| 172 | peaks = gtars.RegionSet.from_bed("chip_peaks.bed") |
| 173 | promoters = gtars.RegionSet.from_bed("promoters.bed") |
| 174 | |
| 175 | # Find overlaps |
| 176 | overlapping_peaks = peaks.filter_overlapping(promoters) |
| 177 | |
| 178 | # Export |