Skip to content

Commit

Permalink
Fix AtomicComposition
Browse files Browse the repository at this point in the history
  • Loading branch information
david-bouyssie committed Nov 10, 2023
1 parent 4b79f58 commit 3789dad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions mzcore-rs/src/chemistry/composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ use crate::chemistry::atom::AtomIsotopicVariant;

#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
pub struct AtomicComposition {
/// Save all constituent parts as the element in question, the isotope (or 0 for natural distribution), and the number of this part
pub atoms: Vec<AtomIsotopicVariant>,
pub atoms: Vec<(AtomIsotopicVariant, f32)>,
/// Any additional mass, defined to be monoisotopic
pub additional_mass: f64,
}
Expand Down
6 changes: 3 additions & 3 deletions mzcore-rs/src/chemistry/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ impl AtomTable {
}

pub fn elemental_to_atomic_composition(&self, el_comp: ElementalComposition) -> Result<AtomicComposition> {
let atoms_res: Result<Vec<AtomIsotopicVariant>> = el_comp.element_counts.iter().map(|&elc| {
let atoms_res: Result<Vec<(AtomIsotopicVariant, f32)>> = el_comp.element_counts.iter().map(|&elc| {
match self.atom_by_element.get(&elc.element) {
Some(atom) => {
match atom.isotopes.get(elc.isotope_index as usize) {
Some(isotope) => {
Ok(AtomIsotopicVariant::new(atom.to_owned(), isotope.to_owned()))
Ok((AtomIsotopicVariant::new(atom.to_owned(), isotope.to_owned()), elc.count))
}
None => Err(anyhow!("wrong isotope index {}", elc.isotope_index)),
}
Expand All @@ -59,7 +59,7 @@ impl AtomTable {
}).collect();

Ok(AtomicComposition {
atoms: atoms_res?,
atoms: atoms_res?,
additional_mass:el_comp.additional_mass
})
}
Expand Down

0 comments on commit 3789dad

Please sign in to comment.