use isospec::{Iso, OrderedGenerator, Threshold, ThresholdGenerator};
fn main() -> Result<(), isospec::Error> {
let iso = Iso::from_formula("C100H202S2")?;
println!("The five most probable isotopologues:");
for peak in OrderedGenerator::new(iso.clone())?.into_iter().take(5) {
println!(" {:.6} Da p = {:.6}", peak.mass, peak.prob);
}
println!("Isotopologues within 1% of the most probable, with their isotopes:");
let mut generator = ThresholdGenerator::new(iso, 0.01, Threshold::Relative)?;
while let Some(peak) = generator.advance()? {
let conf = generator.conf().expect("positioned on an isotopologue");
println!(" {:.6} Da p = {:.6} {:?}", peak.mass, peak.prob, conf);
}
Ok(())
}