예제 #1
0
        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);
        }
예제 #2
0
        public void ChemicalForulaIsSubSet()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO");

            Assert.IsTrue(formulaA.IsSubsetOf(formulaB));
        }
예제 #3
0
        public void ChemicalForulaIsNotSuperSet()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO2");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO");

            Assert.IsFalse(formulaB.IsSupersetOf(formulaA));
        }
예제 #4
0
        public void FormulaValueInequality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("NC1OH3");

            Assert.AreNotEqual(formulaA, formulaB);
        }
예제 #5
0
        public static void ChemicalFormulaIsSuperSet()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H3NO");

            Assert.IsTrue(formulaB.IsSupersetOf(formulaA));
        }
예제 #6
0
        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))));
        }
예제 #7
0
        public void TerminusModification()
        {
            Peptide pepA = new Peptide("DERLEK");

            pepA.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("SO")), Terminus.N);
            Assert.AreEqual("[OS]-DERLEK", pepA.ToString());
        }
예제 #8
0
        public static void FormulaAlmostEquality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C{12}2H3NO");

            Assert.AreNotEqual(formulaA, formulaB);
        }
예제 #9
0
        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));
        }
예제 #10
0
        public static void HashCodeEquality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("H3C2NO");

            Assert.AreEqual(formulaA.GetHashCode(), formulaB.GetHashCode());
        }
예제 #11
0
        public static void FormulaValueEquality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("NC2OH3");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #12
0
        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))));
        }
예제 #13
0
        public static void FormulaValueInequalityHeavyIsotope()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("CC{13}H3NO");

            Assert.AreNotEqual(formulaA, formulaB);
        }
예제 #14
0
        public static void CopyConstructorReferenceInequality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula(formulaA);

            Assert.AreNotSame(formulaA, formulaB);
        }
예제 #15
0
        public static void CopyConstructorValueEquality()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula(formulaA);

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #16
0
        public static void HashCodeCheck()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("Al");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("Al{27}");

            Assert.AreNotEqual(formulaA.GetHashCode(), formulaB.GetHashCode());
        }
예제 #17
0
        public static void ParsingFormulaNoNumbers()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CCHHHNO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #18
0
        public static void ParsingFormulaWithSpaces()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("  C2 H3 N O  ");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #19
0
        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);
        }
예제 #20
0
        public static void ChemicalFormulaIsNotSubSet()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C3H2NO");

            Assert.IsFalse(formulaA.IsSubsetOf(formulaB));
        }
예제 #21
0
        public static void ParsingFormulaRepeatedElementsCancelEachOther()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NOC-2");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("H3NO");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #22
0
        public static void IsSuperSetOf()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CH3NO{17}C");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("CHNO{16}");

            Assert.IsFalse(formulaA.IsSupersetOf(formulaB));
        }
예제 #23
0
        public static void ParsingFormulaRepeatedElements()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("CH3NOC");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #24
0
        public static void ParsingFormulaNoNumbersRandomOrder()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("OCHHCHN");
            ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3NO");

            Assert.AreEqual(formulaA, formulaB);
        }
예제 #25
0
        public static void ClearFormula()
        {
            ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO");

            formulaA.Clear();
            Assert.AreEqual(formulaA, new ChemicalFormula());
        }
예제 #26
0
        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);
        }
예제 #27
0
        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));
        }
예제 #28
0
        public void PeptideMassTryptic()
        {
            ChemicalFormula formula = new ChemicalFormula(ChemicalFormula.ParseFormula("C37H66N12O21"));
            ChemicalFormula formula2;

            formula2 = _mockTrypticPeptide.GetChemicalFormula();
            Assert.AreEqual(formula, formula2);
        }
예제 #29
0
        public void SetCTerminusModStringRepresentationofChemicalModification()
        {
            IHasChemicalFormula formula = new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("Fe"), "Test");

            _mockPeptideEveryAminoAcid.SetModification(formula, Terminus.C);

            Assert.AreEqual("ACDEFGHIKLMNPQRSTVWY-[Test]", _mockPeptideEveryAminoAcid.ToString());
        }
예제 #30
0
        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);
        }