Skip to main content

Crate koth_ms

Crate koth_ms 

Source
Expand description

koth_ff: A high-performance LC-MS feature finder for timsTOF and mzML data.

The in-memory detection stages live in the koth_core crate, which has no file I/O or native dependencies. They are re-exported here at their original paths (koth_ms::hills, koth_ms::models, koth_ms::config::KothConfig, koth_ms::run_features, …); this crate adds the mzML, Bruker .d and Thermo .raw readers, the output writers, cross-run alignment and LFQ, and the koth_ff / koth_align executables.

§Pipeline

  1. Hill detection – groups MS1 peaks across scans into chromatographic hills
  2. Feature finding – groups hills into isotope envelopes with charge state assignment
  3. Scoring – scores isotope pattern quality using the averagine model

§Quick start

use std::path::Path;
use koth_ms::{run_hills, run_features, run_scoring, config::KothConfig};

let config = KothConfig::default();
let input = Path::new("data.mzML");

let spectra = koth_ms::read_spectra(input, &config.file).unwrap();
let hills = run_hills(&spectra, &config.hills, &config.file);
let features = run_features(&hills, &config.features, &config.file).unwrap();
let scored = run_scoring(&features, &config.scoring, &config.features, config.file.polarity);

Re-exports§

pub use pipeline::run_pipeline;
pub use pipeline::run_pipeline_streaming;
pub use pipeline::run_pipeline_with_ms2;

Modules§

alignment
config
Configuration. The koth_ff detection settings ([file], [hills], [hills_ms2], [features], [scoring], [output] and KothConfig) live in koth-core and are re-exported here at their original paths; this module adds the koth_align configuration.
error
features
hills
input
io
lfq
mem
models
output
pipeline
In-process / streaming feature-finding API.
scoring
stats
Small shared numeric helpers.

Structs§

Feature
A detected isotope feature: a group of hills forming an isotope envelope.
FeatureFindingOutput
Owned, in-memory result of a full run — the convenience shape for consumers (like uno) that just want the final lists rather than a streaming callback.
Hill
A finalized chromatographic hill (elution peak for a single m/z trace).
IsolationWindow
Precursor isolation window for an MS2 spectrum (mzML coordinates).
PipelineOptions
Knobs that mirror the koth_ff binary’s optional stages. Everything else is taken from the KothConfig passed in explicitly.
ScoredFeature
Feature with isotope pattern scoring applied.
Spectrum
A single mass spectrum with all its peaks.

Enums§

Polarity
Ion polarity: which way the charge-carrying adduct shifts m/z, and so which way to undo it when recovering a neutral mass.

Constants§

VERSION
Crate version with the git commit it was built from, e.g. 0.1.0 (a1b2c3d4e5f6), or 0.1.0 (a1b2c3d4e5f6-dirty) when the working tree had uncommitted changes.

Traits§

PipelineSink
A consumer notified as pipeline stages finalize.

Functions§

group_ms2_hills_by_window
Group a finalized MS2 hill set by its precursor isolation window, in a deterministic order (sorted by IsolationWindow::key).
read_spectra
Read MS1 spectra from an mzML file or Bruker .d directory.
run_features
Stage 2: Detect isotope features from hills.
run_hills
Stage 1: Detect chromatographic hills from MS1 spectra.
run_hills_streaming
Stage 1 (streaming): Detect hills from mzML, Bruker .d, or Thermo .raw using bounded spectrum buffers. Completed hills are retained for assembly; native readers also retain scan metadata. Decoy shuffling and optional TIC normalization still collect spectra. Gzipped mzML is decompressed as it is parsed, never held whole in memory.
run_ms2_hills_streaming
Stage 1 (MS2): Detect MS2 hills partitioned by the precursor isolation window of each MS2 spectrum (DIA channels).
run_pipeline_from_spectra
Convenience: run the pipeline from an in-memory spectrum iterator and collect all hills and features into owned vectors.
run_pipeline_streaming_from_spectra
Run the full pipeline from an in-memory iterator of spectra, streaming results to sink. No files are written and no Vec<Spectrum> is retained (unless hills.tic_norm_window > 0 or file.decoy_mode, which inherently need the whole set — matching the binary).
run_scoring
Stage 3: Score isotope features using the averagine model.