internal static void ConvertElementTableToFormula( ref clsElementIsotopes elemental_isotope_composition, Hashtable elementCounts, out DeconToolsV2.MolecularFormula formula) { var elements = elementCounts.Keys.GetEnumerator(); formula = new DeconToolsV2.MolecularFormula(); while (elements.MoveNext()) { // Get the next element symbol in the table var element = (string)elements.Current; // Put it in a character array var count = (int)elementCounts[element]; // find the index of the element in the AtomicInformation var index = elemental_isotope_composition.GetElementIndex(element); if (index == -1) { throw new ApplicationException(string.Concat("Unknown element ", element)); } var atomic_count = new DeconToolsV2.AtomicCount(index, count); var mono_mass = elemental_isotope_composition.ElementalIsotopesList[index].Isotopes[0].Mass * count; var avg_mass = elemental_isotope_composition.ElementalIsotopesList[index].AverageMass * count; formula.AddAtomicCount(atomic_count, mono_mass, avg_mass); } }
public void AddAtomicCount(AtomicCount cnt, double monoMass, double avgMass) { var numElements = ElementalComposition.Count; for (var elemNum = 0; elemNum < numElements; elemNum++) { if (ElementalComposition[elemNum].Index == cnt.Index) { ElementalComposition[elemNum].NumCopies += cnt.NumCopies; MonoisotopicMass += monoMass; AverageMass += avgMass; TotalAtomCount += cnt.NumCopies; return; } } ElementalComposition.Add(cnt); MonoisotopicMass += monoMass; AverageMass += avgMass; TotalAtomCount += cnt.NumCopies; }
public AtomicCount(AtomicCount ac) { Index = ac.Index; NumCopies = ac.NumCopies; }