public void TestSortByMassIsotopePattern() { var spExp = new IsotopePattern(new[] { new IsotopeContainer(157.07503, 0.0002), new IsotopeContainer(156.07770, 2), new IsotopeContainer(158.08135, 0.004), new IsotopeContainer(157.08059, 0.0006), }); spExp.MonoIsotope = spExp.Isotopes[1]; spExp.Charge = 1; var isoNorma = IsotopePatternManipulator.SortByMass(spExp); var listISO = isoNorma.Isotopes; Assert.AreEqual(156.07770, isoNorma.MonoIsotope.Mass, 0.001); Assert.AreEqual(156.07770, listISO[0].Mass, 0.00001); Assert.AreEqual(157.07503, listISO[1].Mass, 0.00001); Assert.AreEqual(157.08059, listISO[2].Mass, 0.00001); Assert.AreEqual(158.08135, listISO[3].Mass, 0.00001); Assert.AreEqual(2, isoNorma.MonoIsotope.Intensity, 0.001); Assert.AreEqual(2, listISO[0].Intensity, 0.001); Assert.AreEqual(0.0002, listISO[1].Intensity, 0.00001); Assert.AreEqual(0.0006, listISO[2].Intensity, 0.00001); Assert.AreEqual(0.004, listISO[3].Intensity, 0.00001); Assert.AreEqual(1, isoNorma.Charge, 0.001); }
/// <summary> /// Get all combinatorial chemical isotopes given a structure. /// </summary> /// <param name="molFor">The IMolecularFormula to start</param> /// <returns>A IsotopePattern object containing the different combinations</returns> public IsotopePattern GetIsotopes(IMolecularFormula molFor) { if (builder == null) { try { isoFactory = CDK.IsotopeFactory; builder = molFor.Builder; } catch (Exception e) { Console.WriteLine(e.StackTrace); } } var mf = MolecularFormulaManipulator.GetString(molFor, true); var molecularFormula = MolecularFormulaManipulator.GetMajorIsotopeMolecularFormula(mf, builder); IsotopePattern abundance_Mass = null; foreach (var isos in molecularFormula.Isotopes) { var elementSymbol = isos.Symbol; var atomCount = molecularFormula.GetCount(isos); // Generate possible isotope containers for the current atom's // these will then me 'multiplied' with the existing patten var additional = new List <IsotopeContainer>(); foreach (var isotope in isoFactory.GetIsotopes(elementSymbol)) { double mass = isotope.ExactMass.Value; double abundance = isotope.Abundance.Value; if (abundance <= 0.000000001) { continue; } IsotopeContainer container = new IsotopeContainer(mass, abundance); if (storeFormula) { container.Formula = AsFormula(isotope); } additional.Add(container); } for (int i = 0; i < atomCount; i++) { abundance_Mass = CalculateAbundanceAndMass(abundance_Mass, additional); } } var isoP = IsotopePatternManipulator.SortAndNormalizedByIntensity(abundance_Mass); isoP = CleanAbundance(isoP, minIntensity); var isoPattern = IsotopePatternManipulator.SortByMass(isoP); return(isoPattern); }