Rust Library
RustQC is published on crates.io as both a
binary and a library. The CLI (rustqc rna ...) is the primary interface, but
the same analysis modules are also exposed as a library so they can be embedded
into other Rust programs.
Full API reference: docs.rs/rustqc.
Adding RustQC as a dependency
Section titled “Adding RustQC as a dependency”[dependencies]rustqc = "0.2.1" # Or whatever the latest release isrust-htslib is linked statically and a small C++ component (used by the preseq
tool) is built from source, so a working C/C++ toolchain (cc, c++) is
required when building. No runtime dependencies are added beyond what the binary
already needs.
What’s in the library
Section titled “What’s in the library”The crate exposes these modules:
| Module | Contents |
|---|---|
gtf | GTF gene-annotation parsing. Gene, Transcript, Exon, parse_gtf. |
io | Transparent gzip-aware reader, FNV-1a hashing, number formatters. |
config | Configuration types mirroring the CLI’s YAML config file. |
summary | Serializable types for the JSON run summary. |
cpu | CPU feature detection and binary-target identification. |
rna | RNA-Seq analyses: dupradar, featurecounts, qualimap, preseq, rseqc. |
Strandedness lives at the crate root because it is used
across most analysis modules.
Quick examples
Section titled “Quick examples”Parse a GTF file:
use rustqc::gtf;
let genes = gtf::parse_gtf("genes.gtf", &[])?;println!("{} genes parsed", genes.len());for (gene_id, gene) in genes.iter().take(3) { println!("{gene_id}: {} transcripts", gene.transcripts.len());}# Ok::<(), anyhow::Error>(())Open a possibly-gzipped annotation or output file with one call:
use std::io::BufRead;use rustqc::io::open_reader;
let reader = open_reader("counts.tsv.gz")?;for line in reader.lines() { println!("{}", line?);}# Ok::<(), anyhow::Error>(())Use the Strandedness enum (it derives serde::Deserialize and clap’s
ValueEnum, so it integrates with both YAML configs and CLI parsers):
use rustqc::Strandedness;
let s = Strandedness::Reverse;assert_eq!(s.to_string(), "reverse");Stability
Section titled “Stability”The library is at 0.2.x and the public surface is intentionally small. Expect
breaking changes in minor releases until 1.0. Module visibility may be
narrowed in future versions if internal types are inadvertently exposed.