Skip to content

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.

[dependencies]
rustqc = "0.2.1" # Or whatever the latest release is

SAM/BAM/CRAM I/O is handled by the pure-Rust noodles crate and the plot fonts are bundled, so building it needs only a Rust toolchain: no C++ compiler, fontconfig, htslib or cmake. No runtime dependencies are added beyond what the binary already needs.

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.

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");

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.