public void TestCalculateIsotopesOrthinine() { // RESULTS ACCORDING PAGE: http://www2.sisweb.com/mstools/isotope.htm double[] massResults = { 133.097720, 134.094750, 134.101079, 134.103990, 135.101959, 135.104430 }; double[] abundResults = { 1.00, .006, .054, 0.002, 0.004, 0.001 }; IMolecularFormula molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("C"), 5); molFor.Add(builder.NewIsotope("H"), 13); molFor.Add(builder.NewIsotope("N"), 2); molFor.Add(builder.NewIsotope("O"), 2); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.0010); IsotopePattern isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(6, isoPattern.Isotopes.Count); Assert.AreEqual(massResults[0], isoPattern.Isotopes[0].Mass, 0.01); Assert.AreEqual(massResults[1], isoPattern.Isotopes[1].Mass, 0.01); Assert.AreEqual(massResults[2], isoPattern.Isotopes[2].Mass, 0.01); Assert.AreEqual(massResults[3], isoPattern.Isotopes[3].Mass, 0.01); Assert.AreEqual(massResults[4], isoPattern.Isotopes[4].Mass, 0.01); Assert.AreEqual(massResults[5], isoPattern.Isotopes[5].Mass, 0.01); Assert.AreEqual(abundResults[0], isoPattern.Isotopes[0].Intensity, 0.01); Assert.AreEqual(abundResults[1], isoPattern.Isotopes[1].Intensity, 0.01); Assert.AreEqual(abundResults[2], isoPattern.Isotopes[2].Intensity, 0.01); Assert.AreEqual(abundResults[3], isoPattern.Isotopes[3].Intensity, 0.01); Assert.AreEqual(abundResults[4], isoPattern.Isotopes[4].Intensity, 0.01); Assert.AreEqual(abundResults[5], isoPattern.Isotopes[5].Intensity, 0.01); }
public void TestDifferentIsotopes() { var ifac = BODRIsotopeFactory.Instance; IIsotope c = ifac.GetMajorIsotope("C"); var carbons = ifac.GetIsotopes("C"); IIsotope c13 = carbons.ElementAt(5); // 13 IIsotope h = ifac.GetMajorIsotope("H"); MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.AddIsotope(c, 0, 11); mfRange.AddIsotope(c13, 0, 10); mfRange.AddIsotope(h, 0, 10); double minMass = 54.04193 - 0.001; double maxMass = 54.04193 + 0.001; MolecularFormulaGenerator gen = new MolecularFormulaGenerator(builder, minMass, maxMass, mfRange); IMolecularFormulaSet mfSet = gen.GetAllFormulas(); Assert.IsNotNull(mfSet); Assert.AreEqual(1, mfSet.Count); IMolecularFormula trueFormula = new MolecularFormula(); // C3CH5 trueFormula.Add(c, 3); trueFormula.Add(c13, 1); trueFormula.Add(h, 5); Assert.AreEqual(trueFormula.IsotopesCount, mfSet[0].IsotopesCount); Assert.AreEqual(trueFormula.GetCount(c), mfSet[0].GetCount(c)); Assert.AreEqual(trueFormula.GetCount(c13), mfSet[0].GetCount(c13)); }
public void TestCalculateIsotopesMn() { IMolecularFormula molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("Mn"), 1); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.001); IsotopePattern isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(1, isoPattern.Isotopes.Count); }
/// <summary> /// Clones this <see cref="MolecularFormula"/> object and its content. I should integrate into ChemObject. /// </summary> /// <returns>The cloned object</returns> public object Clone() { MolecularFormula clone = new MolecularFormula(); foreach (var isotope_count in isotopes) { clone.isotopes.Add(isotope_count.Key, isotope_count.Value); } clone.Charge = Charge; return(clone); }
public void TestGetIsotopes1() { var molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("Br")); molFor.Add(builder.NewIsotope("Br")); var isotopeGe = new IsotopePatternGenerator(0.1); var isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(3, isoPattern.Isotopes.Count); }
public void TestIsValidSum_IMolecularFormula() { var formula = new MolecularFormula(); formula.Add(ifac.GetMajorIsotope("C"), 1); formula.Add(ifac.GetMajorIsotope("H"), 100); List <IRule> rules = new List <IRule> { new MMElementRule() }; MolecularFormulaChecker MFChecker = new MolecularFormulaChecker(rules); Assert.AreEqual(0.0, MFChecker.IsValidSum(formula), 0.001); }
public void TestIsValid_NOT() { var formula = new MolecularFormula(); formula.Add(ifac.GetMajorIsotope("C"), 1); formula.Add(ifac.GetMajorIsotope("H"), 100); List <IRule> rules = new List <IRule> { new MMElementRule() }; MolecularFormulaChecker MFChecker = new MolecularFormulaChecker(rules); IMolecularFormula formulaWith = MFChecker.IsValid(formula); Assert.AreEqual(0.0, formulaWith.GetProperty <double>((new MMElementRule()).GetType().ToString())); }
public void TestIsTheSame_IIsotope_IIsotope() { IIsotope carb = Builder.NewIsotope("C"); IIsotope anotherCarb = Builder.NewIsotope("C"); IIsotope h = Builder.NewIsotope("H"); carb.ExactMass = 12.0; anotherCarb.ExactMass = 12.0; h.ExactMass = 1.0; carb.Abundance = 34.0; anotherCarb.Abundance = 34.0; h.Abundance = 99.0; Assert.IsTrue(MolecularFormula.IsTheSame(carb, carb)); Assert.IsTrue(MolecularFormula.IsTheSame(carb, anotherCarb)); Assert.IsFalse(MolecularFormula.IsTheSame(carb, h)); }
public void TestCalculateIsotopesnCarbono() { // RESULTS ACCORDING PAGE: http://www2.sisweb.com/mstools/isotope.htm double[] massResults = { 120.000000, 121.003360, 122.006709 }; double[] abundResults = { 1.00, .108, 0.005 }; IMolecularFormula molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("C"), 10); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.0010); IsotopePattern isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(3, isoPattern.Isotopes.Count); Assert.AreEqual(massResults[0], isoPattern.Isotopes[0].Mass, 0.01); Assert.AreEqual(massResults[1], isoPattern.Isotopes[1].Mass, 0.01); Assert.AreEqual(massResults[2], isoPattern.Isotopes[2].Mass, 0.01); Assert.AreEqual(abundResults[0], isoPattern.Isotopes[0].Intensity, 0.01); Assert.AreEqual(abundResults[1], isoPattern.Isotopes[1].Intensity, 0.01); Assert.AreEqual(abundResults[2], isoPattern.Isotopes[2].Intensity, 0.01); }
public void TestCalculateIsotopesAllBromine() { // RESULTS ACCORDING PAGE: http://www2.sisweb.com/mstools/isotope.htm double[] massResults = { 157.836669, 159.834630, 161.832580 }; double[] abundResults = { .512, 1.00, .487 }; IMolecularFormula molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("Br")); molFor.Add(builder.NewIsotope("Br")); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(.1); IsotopePattern isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(3, isoPattern.Isotopes.Count); Assert.AreEqual(massResults[0], isoPattern.Isotopes[0].Mass, 0.01); Assert.AreEqual(massResults[1], isoPattern.Isotopes[1].Mass, 0.01); Assert.AreEqual(massResults[2], isoPattern.Isotopes[2].Mass, 0.01); Assert.AreEqual(abundResults[0], isoPattern.Isotopes[0].Intensity, 0.01); Assert.AreEqual(abundResults[1], isoPattern.Isotopes[1].Intensity, 0.01); Assert.AreEqual(abundResults[2], isoPattern.Isotopes[2].Intensity, 0.01); }
public void TestCalculateIsotopesIodemethylidyne() { // RESULTS ACCORDING PAGE: http://www2.sisweb.com/mstools/isotope.htm var massResults = new[] { 138.904480, 139.907839 }; var abundResults = new[] { 1.00, .011 }; var molFor = new MolecularFormula(); molFor.Add(builder.NewIsotope("C")); molFor.Add(builder.NewIsotope("I")); Assert.AreEqual(2, molFor.IsotopesCount); var isotopeGe = new IsotopePatternGenerator(.01); var isoPattern = isotopeGe.GetIsotopes(molFor); Assert.AreEqual(2, isoPattern.Isotopes.Count); Assert.AreEqual(massResults[0], isoPattern.Isotopes[0].Mass, 0.01); Assert.AreEqual(massResults[1], isoPattern.Isotopes[1].Mass, 0.01); Assert.AreEqual(abundResults[0], isoPattern.Isotopes[0].Intensity, 0.01); Assert.AreEqual(abundResults[1], isoPattern.Isotopes[1].Intensity, 0.01); }