public void ChemicalForulaMyTest() { ChemicalFormula formula = new ChemicalFormula(); formula.Add(ChemicalFormula.ParseFormula("C3H5NO")); Assert.AreEqual(PeriodicTable.GetElement("C").PrincipalIsotope.AtomicMass * 3 + PeriodicTable.GetElement("H").PrincipalIsotope.AtomicMass * 5 + PeriodicTable.GetElement("N").PrincipalIsotope.AtomicMass + PeriodicTable.GetElement("O").PrincipalIsotope.AtomicMass, formula.MonoisotopicMass); }
public void ChemicalForulaIsSubSet() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO"); Assert.IsTrue(formulaA.IsSubsetOf(formulaB)); }
public void ChemicalForulaIsNotSuperSet() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO2"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO"); Assert.IsFalse(formulaB.IsSupersetOf(formulaA)); }
public void FormulaValueInequality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("NC1OH3"); Assert.AreNotEqual(formulaA, formulaB); }
public static void ChemicalFormulaIsSuperSet() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO"); Assert.IsTrue(formulaB.IsSupersetOf(formulaA)); }
public static void TestCompactPeptideMasses_nTerminalModifiedPeptide_NeutralLoss_DissociationTypes_CID_and_HCD()//there should be no added neutral losses in this case becuase the allowed dissociation type doesn't match the dissociation type used in the experiment { Protein p = new Protein("PET", "accession"); ModificationMotif.TryGetMotif("P", out ModificationMotif motif); Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > { { MassSpectrometry.DissociationType.CID, new List <double> { 0, ChemicalFormula.ParseFormula("H3O4P1").MonoisotopicMass } } }); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2); var aPeptideWithSetModifications = p.Digest(digestionParams, new List <Modification> { phosphorylation }, new List <Modification>()).First(); var aCompactPeptide = aPeptideWithSetModifications.CompactPeptide(FragmentationTerminus.Both); //evaluate N-terminal masses var nTerminalMasses = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.N); HashSet <int> expectedNTerminalMasses = new HashSet <int> { 177, 306 }; Assert.That(expectedNTerminalMasses.SetEquals(nTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1)))); //evaluate C-terminal masses var cTerminalMasses = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.C); HashSet <int> expectedCTerminalMasses = new HashSet <int> { 101, 230, 407 }; Assert.That(expectedCTerminalMasses.SetEquals(cTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1)))); }
public void TerminusModification() { Peptide pepA = new Peptide("DERLEK"); pepA.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("SO")), Terminus.N); Assert.AreEqual("[OS]-DERLEK", pepA.ToString()); }
public static void FormulaAlmostEquality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C{12}2H3NO"); Assert.AreNotEqual(formulaA, formulaB); }
public void Test_FragmentationModNeutralLoss() { // Now we'll check the mass of modified peptide with no neutral losses ModificationMotif.TryGetMotif("T", out ModificationMotif motif); Modification mod = new Modification(_originalId: "phospho", _modificationType: "testModType", _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("H1 O3 P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > { { DissociationType.HCD, new List <double> { ChemicalFormula.ParseFormula("H3 O4 P1").MonoisotopicMass } } }, _locationRestriction: "Anywhere."); List <Modification> modlist = new List <Modification> { mod }; DigestionParams digestionParams = new DigestionParams( protease: "trypsin", maxMissedCleavages: 0, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); var prot = new Protein("PEPTIDE", null, oneBasedModifications: new Dictionary <int, List <Modification> > { { 4, modlist } }); var ye = prot.Digest(digestionParams, new List <Modification>(), new List <Modification>()).ToList(); var peptideWithNeutralMassMod = ye.Where(v => v.AllModsOneIsNterminus.Count > 0).First(); var myModFragments = peptideWithNeutralMassMod.Fragment(DissociationType.HCD, FragmentationTerminus.Both).ToList(); HashSet <int> neutralMasses = new HashSet <int>(myModFragments.Select(m => (int)m.NeutralMass.ToMz(1)).ToList()); HashSet <int> expectedMasses = new HashSet <int> { 98, 227, 324, 407, 520, 635, 505, 618, 733, //b-ions with and without neutral loss 148, 263, 376, 459, 556, 685, 557, 654, 783, //y-ions with and without neutral loss 782 }; //molecular ion with neutral loss Assert.That(neutralMasses.SetEquals(expectedMasses)); }
public static void HashCodeEquality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("H3C2NO"); Assert.AreEqual(formulaA.GetHashCode(), formulaB.GetHashCode()); }
public static void FormulaValueEquality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("NC2OH3"); Assert.AreEqual(formulaA, formulaB); }
public static void TestCompactPeptideMasses_internallyModifiedPeptide_NeutralLoss() { Protein p = new Protein("PET", "accession"); ModificationMotif.TryGetMotif("E", out ModificationMotif motif); Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > { { MassSpectrometry.DissociationType.HCD, new List <double> { 0, ChemicalFormula.ParseFormula("H3O4P1").MonoisotopicMass } } }); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2); var aPeptideWithSetModifications = p.Digest(digestionParams, new List <Modification> { phosphorylation }, new List <Modification>()).First(); var aCompactPeptide = aPeptideWithSetModifications.CompactPeptide(FragmentationTerminus.Both); var allFragmentNeutralMasses = aPeptideWithSetModifications.Fragment(DissociationType.HCD, FragmentationTerminus.Both); //evaluate N-terminal masses var n = allFragmentNeutralMasses.Where(f => f.TerminusFragment.Terminus == FragmentationTerminus.N).ToList(); HashSet <int> expectedNTerminalMasses = new HashSet <int> { 97, 306, 208 }; Assert.That(expectedNTerminalMasses.SetEquals(n.Select(v => (int)Math.Round(v.NeutralMass, 1)))); //evaluate C-terminal masses var c = allFragmentNeutralMasses.Where(f => f.TerminusFragment.Terminus == FragmentationTerminus.C).ToList(); HashSet <int> expectedCTerminalMasses = new HashSet <int> { 119, 328, 230 }; Assert.That(expectedCTerminalMasses.SetEquals(c.Select(v => (int)Math.Round(v.NeutralMass, 1)))); }
public static void FormulaValueInequalityHeavyIsotope() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("CC{13}H3NO"); Assert.AreNotEqual(formulaA, formulaB); }
public static void CopyConstructorReferenceInequality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = new ChemicalFormula(formulaA); Assert.AreNotSame(formulaA, formulaB); }
public static void CopyConstructorValueEquality() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = new ChemicalFormula(formulaA); Assert.AreEqual(formulaA, formulaB); }
public static void HashCodeCheck() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("Al"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("Al{27}"); Assert.AreNotEqual(formulaA.GetHashCode(), formulaB.GetHashCode()); }
public static void ParsingFormulaNoNumbers() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CCHHHNO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO"); Assert.AreEqual(formulaA, formulaB); }
public static void ParsingFormulaWithSpaces() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula(" C2 H3 N O "); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO"); Assert.AreEqual(formulaA, formulaB); }
public static void TestReplaceIsotopes() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CC{13}2H3NO"); formulaA.Replace(PeriodicTable.GetElement("C")[13], PeriodicTable.GetElement("C")[12]); Assert.AreEqual("CC{12}2H3NO", formulaA.Formula); }
public static void ChemicalFormulaIsNotSubSet() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H2NO"); Assert.IsFalse(formulaA.IsSubsetOf(formulaB)); }
public static void ParsingFormulaRepeatedElementsCancelEachOther() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NOC-2"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("H3NO"); Assert.AreEqual(formulaA, formulaB); }
public static void IsSuperSetOf() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CH3NO{17}C"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("CHNO{16}"); Assert.IsFalse(formulaA.IsSupersetOf(formulaB)); }
public static void ParsingFormulaRepeatedElements() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CH3NOC"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO"); Assert.AreEqual(formulaA, formulaB); }
public static void ParsingFormulaNoNumbersRandomOrder() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("OCHHCHN"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO"); Assert.AreEqual(formulaA, formulaB); }
public static void ClearFormula() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); formulaA.Clear(); Assert.AreEqual(formulaA, new ChemicalFormula()); }
public static void TestIsotopicDistribution() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); var a = IsotopicDistribution.GetDistribution(formulaA); Assert.True(Math.Abs(formulaA.MonoisotopicMass - a.Masses.ToArray()[Array.IndexOf(a.Intensities.ToArray(), a.Intensities.Max())]) < 1e-9); }
public static void ContainsIsotopesOf() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("O{16}"); Assert.IsTrue(formulaA.ContainsIsotopesOf("O")); Assert.IsTrue(formulaA.ContainsSpecificIsotope("O", 16)); Assert.AreEqual(1, formulaA.CountSpecificIsotopes("O", 16)); }
public void PeptideMassTryptic() { ChemicalFormula formula = new ChemicalFormula(ChemicalFormula.ParseFormula("C37H66N12O21")); ChemicalFormula formula2; formula2 = _mockTrypticPeptide.GetChemicalFormula(); Assert.AreEqual(formula, formula2); }
public void SetCTerminusModStringRepresentationofChemicalModification() { IHasChemicalFormula formula = new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("Fe"), "Test"); _mockPeptideEveryAminoAcid.SetModification(formula, Terminus.C); Assert.AreEqual("ACDEFGHIKLMNPQRSTVWY-[Test]", _mockPeptideEveryAminoAcid.ToString()); }
public static void NotEqual() { ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C15O15H15S15N15"); ChemicalFormula formulaA = ChemicalFormula.ParseFormula("N15S15H15O15C15"); Assert.AreEqual(formulaA, formulaB); Assert.IsTrue(Math.Abs(formulaA.MonoisotopicMass - formulaB.MonoisotopicMass) < 1e-9); }