use isospec::{Element, ElementSpec, Envelope, Iso};
fn main() -> Result<(), isospec::Error> {
let carbon = Element::from_symbol("C").expect("carbon");
let masses: Vec<f64> = carbon.isotopes().map(|i| i.mass).collect();
let mut labelled = Iso::from_formula("C1H12O6")?;
labelled.add_element(&ElementSpec::new(5, &masses, &[0.01, 0.99]))?;
let natural = Iso::from_formula("C6H12O6")?;
let mut a = Envelope::from_total_prob(&natural, 0.9999)?;
let mut b = Envelope::from_total_prob(&labelled, 0.9999)?;
a.normalize()?;
b.normalize()?;
println!("natural glucose: {:.4} Da on average", a.average_mass()?);
println!("labelled glucose: {:.4} Da on average", b.average_mass()?);
println!("Wasserstein distance: {:.4} Da", a.wasserstein(&mut b)?);
Ok(())
}