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

rust-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.

The crate exposes these modules:

ModuleContents
gtfGTF gene-annotation parsing. Gene, Transcript, Exon, parse_gtf.
ioTransparent gzip-aware reader, FNV-1a hashing, number formatters.
configConfiguration types mirroring the CLI’s YAML config file.
summarySerializable types for the JSON run summary.
cpuCPU feature detection and binary-target identification.
rnaRNA-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.