rustyomestats 0.2.0

Fast genome statistics: length, GC, N/L, 6-frame and FragGeneScan codon density, plus Castro U50 assembly metrics.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# ๐Ÿฆ€ RustyOmeStats

### *Blazing-fast assembly statistics for genomes, metagenomes, transcriptomes, and beyond.*

<div align="center">

![Rust](https://img.shields.io/badge/Rust-1.85%2B-black?logo=rust)
![Crates.io](https://img.shields.io/crates/v/rustyomestats?logo=rust)
![License](https://img.shields.io/badge/license-CC_BY--NC_4.0-blue)
![Build](https://img.shields.io/github/actions/workflow/status/raw937/rustyomestats/rust.yml?branch=main)
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20windows-success)
![Polars](https://img.shields.io/badge/powered%20by-polars-purple)
![Bioinformatics](https://img.shields.io/badge/domain-bioinformatics-green)

### โšก Modern Assembly Metrics โ€ข ๐Ÿ“Š Interactive Reports โ€ข ๐Ÿงฌ Codon Analytics โ€ข ๐Ÿš€ Parallelized Rust

</div>

---

# ๐Ÿ”ฌ What is RustyOmeStats?

**RustyOmeStats** is a high-performance bioinformatics toolkit written in **Rust** for calculating assembly statistics from:

* ๐Ÿงฌ Genomes
* ๐ŸŒ Metagenomes
* ๐Ÿงซ MAGs
* ๐Ÿงช Transcriptomes
* ๐Ÿง  Metatranscriptomes
* ๐Ÿ“– Reference-guided assemblies

Designed for **speed**, **reproducibility**, and **publication-ready outputs**, RustyOmeStats combines modern Rust parallelism with rich plotting/report generation.

---

# โœจ Features

<table>
<tr>
<td width="50%">

## ๐Ÿงฌ Genome / Metagenome Analytics

* GC%
* Sequence length statistics
* N/L metrics (N25โ€“N90)
* 6-frame codon density
* FragGeneScan predicted codon usage
* Parallel FASTA processing
* Folder-wide assembly analysis
* Polars-backed tabular outputs

</td>
<td width="50%">

## ๐Ÿ“Š Modern Assembly Metrics

* N50 / L50
* NG50 / LG50
* U50 / UL50
* UG50 / ULG50
* Gap interval detection
* Overlap interval detection
* Coverage visualization
* Reference-aware assembly evaluation

</td>
</tr>
</table>

---

# ๐Ÿ–ผ๏ธ Example Outputs

<div align="center">

| GC vs Length         | Codon Heatmap  | Coverage            |
| -------------------- | -------------- | ------------------- |
| ๐Ÿ“ˆ Publication-ready | ๐Ÿ”ฅ Frame-aware | ๐Ÿงฌ Reference-guided |

</div>

```text
โœ” Interactive HTML reports
โœ” Self-contained PNG figures
โœ” Polars DataFrames
โœ” Parallelized Rust backend
โœ” Reproducible workflows
```

---

# โšก Why RustyOmeStats?

| Feature                      | RustyOmeStats |
| ---------------------------- | ------------- |
| ๐Ÿš€ Multi-threaded Rust core  | โœ…             |
| ๐Ÿงฌ Codon density analysis    | โœ…             |
| ๐Ÿ“Š Automated visualization   | โœ…             |
| ๐ŸŒ Metagenome support        | โœ…             |
| ๐Ÿง  U50/UG50 implementation   | โœ…             |
| ๐Ÿ Python plotting layer     | โœ…             |
| ๐Ÿ“ Batch assembly processing | โœ…             |
| โš™๏ธ Polars DataFrames         | โœ…             |

---

# ๐Ÿงฑ Architecture

```mermaid
flowchart LR
    A[FASTA / BED Input] --> B[Rust Core]
    B --> C[Polars DataFrames]
    C --> D[CSV Outputs]
    D --> E[Python Plotter]
    E --> F[PNG Figures]
    E --> G[Interactive HTML Report]
```

---

# ๐Ÿฆ€ Tech Stack

| Component         | Technology           |
| ----------------- | -------------------- |
| Core engine       | Rust                 |
| Parallelism       | rayon                |
| DataFrames        | polars               |
| FASTA/BED parsing | rust-bio             |
| CLI               | clap                 |
| Error handling    | anyhow               |
| Plotting          | seaborn + matplotlib |
| ORF prediction    | FragGeneScanRs       |

---

# ๐Ÿš€ Installation

## 1๏ธโƒฃ Install Rust

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable
```

---

## 2๏ธโƒฃ Install RustyOmeStats

### From crates.io

```bash
cargo install rustyomestats
```

### From source

```bash
git clone https://github.com/raw937/rustyomestats
cd rustyomestats

cargo install --path .
```

---

## 3๏ธโƒฃ Optional: FragGeneScanRs

Required only for predicted codon density.

```bash
cargo install fraggenescanrs
```

or

```bash
conda install -c bioconda fraggenescanrs
```

---

## 4๏ธโƒฃ Install Plotting Dependencies

```bash
pip install polars seaborn matplotlib
```

---

# โšก Quick Start

## ๐Ÿงฌ Analyze a Genome

```bash
rustyomestats genome \
    -f my_genome.fna \
    -o out/ \
    -t 8
```

Generate plots + HTML report:

```bash
python scripts/plot_stats.py -d out/
```

---

# ๐Ÿ“ฆ Output Files

RustyOmeStats generates rich tabular outputs, publication-ready figures, and a fully self-contained interactive HTML report.

```text
summary_stats.csv
โ”œโ”€โ”€ Global assembly statistics
โ”œโ”€โ”€ Total sequences / total bp
โ”œโ”€โ”€ GC%
โ””โ”€โ”€ N25โ€“N90 and L25โ€“L90 assembly metrics

per_sequence.csv
โ”œโ”€โ”€ Per-contig / per-sequence statistics
โ”œโ”€โ”€ Sequence ID
โ”œโ”€โ”€ Length distribution
โ””โ”€โ”€ GC composition for every record

length_intervals.csv
โ”œโ”€โ”€ Length-bin frequency table
โ”œโ”€โ”€ Histogram-ready interval counts
โ””โ”€โ”€ Used for contig size distribution plots

codon_absolute.csv
โ”œโ”€โ”€ Raw 6-frame codon statistics
โ”œโ”€โ”€ Codon counts and densities
โ”œโ”€โ”€ Frame-specific measurements
โ””โ”€โ”€ Long-format analytics table

codon_absolute_aggregate.csv
โ”œโ”€โ”€ Global codon usage profile
โ”œโ”€โ”€ Aggregated across all sequences
โ””โ”€โ”€ 64-codon genome-wide abundance table

codon_predicted.csv
โ”œโ”€โ”€ FragGeneScan-predicted ORF codons
โ”œโ”€โ”€ Per-gene codon frequencies
โ””โ”€โ”€ Coding-region codon density statistics

codon_predicted_aggregate.csv
โ”œโ”€โ”€ Aggregate predicted ORF codon usage
โ”œโ”€โ”€ Genome-wide predicted CDS codon profile
โ””โ”€โ”€ Useful for translational bias analyses

codon_comparison.csv
โ”œโ”€โ”€ Absolute vs predicted codon usage
โ”œโ”€โ”€ Enrichment/depletion statistics
โ”œโ”€โ”€ Translational bias comparisons
โ””โ”€โ”€ Predicted-over-absolute enrichment metrics

fgs_predicted.{ffn,faa,out,gff}
โ”œโ”€โ”€ Raw FragGeneScanRs outputs
โ”œโ”€โ”€ Predicted nucleotide ORFs (.ffn)
โ”œโ”€โ”€ Predicted proteins (.faa)
โ”œโ”€โ”€ Gene annotations (.gff)
โ””โ”€โ”€ Raw model output/log files

plot_length_histogram.png
โ”œโ”€โ”€ Contig/scaffold size distribution
โ””โ”€โ”€ Publication-ready histogram visualization

plot_gc_distribution.png
โ”œโ”€โ”€ GC variability across sequences
โ””โ”€โ”€ Detects compositional heterogeneity

plot_gc_vs_length.png
โ”œโ”€โ”€ GC% versus sequence length
โ”œโ”€โ”€ Detects assembly structure patterns
โ””โ”€โ”€ Useful for MAG/metagenome exploration

plot_codon_usage_bar.png
โ”œโ”€โ”€ Genome-wide codon abundance plots
โ”œโ”€โ”€ Absolute vs predicted codon usage
โ””โ”€โ”€ Translational preference visualization

plot_codon_heatmap_by_frame.png
โ”œโ”€โ”€ 6-frame codon density heatmap
โ”œโ”€โ”€ Frame-aware codon visualization
โ””โ”€โ”€ High-dimensional codon pattern analysis

plot_codon_enrichment.png
โ”œโ”€โ”€ Codon enrichment/depletion analysis
โ”œโ”€โ”€ Predicted vs absolute codon shifts
โ””โ”€โ”€ Translational bias visualization

report.html
โ”œโ”€โ”€ Fully self-contained interactive report
โ”œโ”€โ”€ All plots embedded inline
โ”œโ”€โ”€ Metric summaries + tables
โ”œโ”€โ”€ Portable single-file visualization dashboard
โ””โ”€โ”€ Shareable publication-ready report
```

---

# ๐ŸŒ Analyze Multiple Assemblies

```bash
rustyomestats genome \
    -f assemblies/ \
    -o out/ \
    -t 32
```

---

# ๐Ÿง  U50 / UG50 Assembly Metrics

RustyOmeStats implements the modern metrics proposed in:

> [Castro et al. 2017]https://journals.sagepub.com/doi/abs/10.1089/cmb.2017.0013. Castro CJ, Ng TFF. U50: A New Metric for Measuring Assembly Output Based on Non-Overlapping, Target-Specific Contigs. J Comput Biol. 2017 24(11):1071-1080.

Including:

* U50
* UL50
* UG50
* ULG50
* Gap-aware assembly evaluation
* Overlap-aware assembly evaluation

---

# ๐Ÿ”ฌ Example U50 Workflow

```bash
rustyomestats u50 \
    --reference ref.fa \
    --bed contigs.sorted.bed \
    --outdir out/
```

Generate figures:

```bash
python scripts/plot_stats.py -d out/
```

---

# ๐Ÿ“Š Generated Visualizations

<div align="center">

| Plot                | Description                     |
| ------------------- | ------------------------------- |
| ๐Ÿ“ˆ GC Distribution  | GC variability across sequences |
| ๐Ÿ”ฅ Codon Heatmap    | Frame-specific codon usage      |
| ๐Ÿ“‰ Length Histogram | Assembly contig distributions   |
| ๐Ÿงฌ Coverage Plot    | Reference coverage structure    |
| ๐Ÿ“Š U50 Summary      | Modern assembly metric overview |

</div>

---

# ๐Ÿ Interactive HTML Reports

RustyOmeStats automatically generates:

โœ… Self-contained HTML reports
โœ… Inline PNG visualizations
โœ… Portable single-file reports
โœ… Publication-ready figures

Open directly in your browser:

```bash
firefox report.html
```

---

# ๐Ÿ“š Library Usage

RustyOmeStats can also be embedded as a Rust crate.

```rust
use rustyomestats::{io_utils, stats, u50};
use std::path::Path;

// genome stats
let files  = io_utils::collect_fasta_files(Path::new("genome.fna"))?;
let recs   = io_utils::load_all_records(&files)?;
let basic  = stats::compute_basic(&recs);

println!("{} sequences", basic.num_seq);

// U50 stats
let res = u50::compute_u50(
    Path::new("ref.fa"),
    Path::new("contigs.bed"),
    Path::new("out")
)?;

println!("UG50 = {}", res.ug50);
```

---

# ๐Ÿงช Testing

```bash
cargo test
```

Covers:

* N50/U50 correctness
* Greedy masking
* BED deduplication
* Reverse complements
* 6-frame codon indexing
* Hand-validated toy assemblies

---

# ๐Ÿ“„ License

**Creative Commons Attribution-NonCommercial (CC BY-NC 4.0)**

See the `LICENSE` file for details.

---

# ๐Ÿ“– Citation

If you use **RustyOmeStats** in published work, please cite:

```text
White III RA et al.
RustyOmeStats: High-performance genome and metagenome assembly statistics in Rust.
```

---

# ๐Ÿค Contributing

We welcome:

* ๐Ÿงฌ New assembly metrics
* โšก Performance optimizations
* ๐Ÿ“Š Visualization improvements
* ๐Ÿ Python plotting extensions
* ๐Ÿฆ€ Rust ecosystem integrations

Pull requests and issues are encouraged.

---

# ๐Ÿ“ž Support

* ๐Ÿ› GitHub Issues:
  - **Issues:** [RustyOmeStats Issues]https://github.com/raw937/rustyomestats/issues

* ๐Ÿ“ง Contact:
  - **Email:** [Dr. Richard Allen White III]mailto:rwhit101@uncc.edu
  - If you have any questions or feedback, please feel free to get in touch by email.  </br>

---

<div align="center">

# ๐Ÿฆ€ RustyOmeStats

### *Fast. Parallel. Modern Bioinformatics .*

Built with โค๏ธ in Rust.

</div>