/// <summary> /// Basic overview of how peptides can be used and modified /// </summary> private static void PeptideExamples() { Console.WriteLine("**Peptide Examples**"); // Simple Peptide creation Peptide peptide1 = new Peptide("ACDEFGHIKLMNPQRSTVWY"); WritePeptideToConsole(peptide1); // Fragmenting a peptide is simple, you can include as many fragment types as you want Console.WriteLine("{0,-4} {1,-20} {2,-10} {3,-10} {4,-5}", "Type", "Formula", "Mass", "m/z +1", "Sequence"); foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y)) { WriteFragmentToConsole(fragment); } // Modifications can be applied to any residue or termini Console.WriteLine("Lets add some Iron to our peptide..."); peptide1.SetModification(new ChemicalFormula("Fe"), Terminus.C | Terminus.N); WritePeptideToConsole(peptide1); // A chemicalmodification is a simple wrapper for a chemical formula. You can name your mods if you want Console.WriteLine("Add a modification of Oxygen with the name \"Oxidation\" to all Methionines"); ChemicalFormulaModification oxMod = new ChemicalFormulaModification("O", "Oxidation"); peptide1.SetModification(oxMod, 'M'); WritePeptideToConsole(peptide1); // If you fragment a modified peptide, the modifications stay part of the fragments Console.WriteLine("{0,-4} {1,-20} {2,-20} {3,-5}", "Type", "Formula", "Mass", "m/z +1"); foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y, 2)) { WriteFragmentToConsole(fragment); } }
public void WriteMzmlTest() { var peptide = new Peptide("GPEAPPPALPAGAPPPCTAVTSDHLNSLLGNILR"); ChemicalFormulaModification carbamidomethylationOfCMod = new ChemicalFormulaModification("H3C2NO", "carbamidomethylation of C", ModificationSites.C); peptide.AddModification(carbamidomethylationOfCMod); DefaultMzSpectrum MS1 = createSpectrum(peptide.GetChemicalFormula(), 300, 2000, 1); DefaultMzSpectrum MS2 = createMS2spectrum(peptide.Fragment(FragmentTypes.b | FragmentTypes.y, true), 100, 1500); MsDataScan <IMzSpectrum <MzPeak> >[] Scans = new MsDataScan <IMzSpectrum <MzPeak> > [2]; Scans[0] = new MsDataScan <IMzSpectrum <MzPeak> >(1, MS1.newSpectrumApplyFunctionToX(b => b + 0.000001 * b + 0.000001), "spectrum 1", 1, false, Polarity.Positive, 1.0, new MzRange(300, 2000), "FTMS first spectrum", MZAnalyzerType.Unknown, 1, MS1.SumOfAllY); Scans[1] = new MsDataScan <IMzSpectrum <MzPeak> >(2, MS2.newSpectrumApplyFunctionToX(b => b + 0.00001 * b + 0.00001), "spectrum 2", 2, false, Polarity.Positive, 2.0, new MzRange(100, 1500), "FTMS second spectrum", MZAnalyzerType.Unknown, 1, MS2.SumOfAllY, "spectrum 1", 1134.26091302033, 3, 0.141146966879759, 1134.3, 1, DissociationType.Unknown, 1, 0.141146966879759, 1134.26091302033); var myMsDataFile = new FakeMsDataFile(@"myFakeFile.mzML", Scans); MzmlMethods.CreateAndWriteMyIndexedMZmlwithCalibratedSpectra(myMsDataFile, Path.Combine(Path.GetDirectoryName(myMsDataFile.FilePath), Path.GetFileNameWithoutExtension(myMsDataFile.FilePath)) + ".mzML"); Mzml okay = new Mzml(@"myFakeFile.mzML"); okay.Open(); okay.GetScan(2); Assert.AreEqual(1, okay.GetSpectrumNumber(1)); Assert.AreEqual(2, okay.GetSpectrumNumber(2)); }
public override PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide, FragmentTypes fragmentTypes, Tolerance productMassTolerance) { double[] eMasses = massSpectrum.MassSpectrum.GetMasses(); double[] eIntenisties = massSpectrum.MassSpectrum.GetIntensities(); double tic = massSpectrum.MassSpectrum.GetTotalIonCurrent(); PeptideSpectralMatch psm = new PeptideSpectralMatch(DefaultPsmScoreType) {Peptide = peptide}; double[] tMasses = peptide.Fragment(fragmentTypes).Select(frag => Mass.MzFromMass(frag.MonoisotopicMass, 1)).OrderBy(val => val).ToArray(); double score = Search(eMasses, eIntenisties, tMasses, productMassTolerance, tic); psm.Score = score; return psm; }
public void TestMultipleModificationsAtSingleResidue() { Peptide a = new Peptide("ACDEFGHIKLMNPQRSTVWY"); a.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("O"), ModificationSites.D)); a.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H"), ModificationSites.D)); var products = a.Fragment(FragmentTypes.b | FragmentTypes.y, true); foreach (Fragment fragment in products) { } foreach (IHasChemicalFormula fragment in products) { } }
private void GenerateMzFeatures() { // add precursor to mzFeatures in case Anji is interested in tracking it this.mzFeatures.Add(new MzFeature(this.peptide, this.precursorCharge)); // fragment peptide in-silico to determine all theoretical peptide fragments; var peptideFragments = peptide.Fragment(FragmentTypes.b | FragmentTypes.y).ToList(); foreach (var fragment in peptideFragments) { for (var charge = maxFragmentCharge; charge > 0; charge--) { this.mzFeatures.Add(new MzFeature(fragment, charge)); } } }
public void WriteMzmlTest() { var peptide = new Peptide("GPEAPPPALPAGAPPPCTAVTSDHLNSLLGNILR"); OldSchoolChemicalFormulaModification carbamidomethylationOfCMod = new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H3C2NO"), "carbamidomethylation of C", ModificationSites.C); peptide.AddModification(carbamidomethylationOfCMod); MzmlMzSpectrum MS1 = CreateSpectrum(peptide.GetChemicalFormula(), 300, 2000, 1); MzmlMzSpectrum MS2 = CreateMS2spectrum(peptide.Fragment(FragmentTypes.b | FragmentTypes.y, true), 100, 1500); IMzmlScan[] Scans = new IMzmlScan[2]; Scans[0] = new MzmlScan(1, MS1, 1, true, Polarity.Positive, 1.0, new MzRange(300, 2000), " first spectrum", MZAnalyzerType.Unknown, MS1.SumOfAllY, 1, "scan=1"); Scans[1] = new MzmlScanWithPrecursor(2, MS2, 2, true, Polarity.Positive, 2.0, new MzRange(100, 1500), " second spectrum", MZAnalyzerType.Unknown, MS2.SumOfAllY, 1134.26091302033, 3, 0.141146966879759, 1134.3, 1, DissociationType.Unknown, 1, 1134.26091302033, 1, "scan=2"); var myMsDataFile = new FakeMsDataFile(Scans); var oldFirstValue = myMsDataFile.GetOneBasedScan(1).MassSpectrum.FirstX; var secondScan = myMsDataFile.GetOneBasedScan(2) as IMsDataScanWithPrecursor <MzmlMzSpectrum>; Assert.AreEqual(1, secondScan.IsolationRange.Maximum - secondScan.IsolationRange.Minimum); MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, "argh.mzML", false); Mzml okay = Mzml.LoadAllStaticData(@"argh.mzML"); okay.GetOneBasedScan(2); Assert.AreEqual(1, okay.GetClosestOneBasedSpectrumNumber(1)); Assert.AreEqual(2, okay.GetClosestOneBasedSpectrumNumber(2)); var newFirstValue = okay.GetOneBasedScan(1).MassSpectrum.FirstX; Assert.AreEqual(oldFirstValue.Value, newFirstValue.Value, 1e-9); var secondScan2 = okay.GetOneBasedScan(2) as IMsDataScanWithPrecursor <MzmlMzSpectrum>; Assert.AreEqual(1, secondScan2.IsolationRange.Maximum - secondScan2.IsolationRange.Minimum); secondScan2.MassSpectrum.ReplaceXbyApplyingFunction((a) => 44); Assert.AreEqual(44, secondScan2.MassSpectrum.LastX); }
public override PeptideSpectralMatch Search(IMassSpectrum massSpectrum, Peptide peptide, FragmentTypes fragmentTypes, Tolerance productMassTolerance) { double[] eMasses = massSpectrum.MassSpectrum.GetMasses(); double[] eIntenisties = massSpectrum.MassSpectrum.GetIntensities(); double tic = massSpectrum.MassSpectrum.GetTotalIonCurrent(); PeptideSpectralMatch psm = new PeptideSpectralMatch(DefaultPsmScoreType) { Peptide = peptide }; double[] tMasses = peptide.Fragment(fragmentTypes).Select(frag => Mass.MzFromMass(frag.MonoisotopicMass, 1)).OrderBy(val => val).ToArray(); double score = Search(eMasses, eIntenisties, tMasses, productMassTolerance, tic); psm.Score = score; return(psm); }
public void TestClearModifications() { Peptide a = new Peptide("ACDEFGHIKLMNPQRSTVWY"); a.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("O"), ModificationSites.D)); a.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H"), ModificationSites.E)); Assert.AreEqual(2, a.ModificationCount()); a.ClearModifications(); Assert.AreEqual(0, a.ModificationCount()); a.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("O"), ModificationSites.NTerminus)); a.AddModification(new OldSchoolModification(1), ModificationSites.TerminusC); Assert.AreEqual(2, a.ModificationCount()); a.Fragment(FragmentTypes.y); Peptide peptide = new Peptide("[C2H3NO]-LLL-[C2H3NO]"); ModificationSites ff = ModificationSites.NPep | ModificationSites.PepC; peptide.ClearModifications(ff); Assert.AreEqual("LLL", peptide.GetSequenceWithModifications()); }
public void TestFormulaTerminusMods() { var pep1 = new Peptide("ACDEFG"); pep1.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H"), ModificationSites.NTerminus)); Assert.IsTrue(pep1.Fragment(FragmentTypes.b, true).First() is IHasChemicalFormula); var pep2 = new Peptide("ACDEFG"); pep2.AddModification(new OldSchoolModification(2, "haha", ModificationSites.NTerminus)); Assert.IsFalse(pep2.Fragment(FragmentTypes.b, true).First() is IHasChemicalFormula); var pep3 = new Peptide("ACDEFG"); pep3.AddModification(new OldSchoolModification(3, "haha", ModificationSites.D)); var list = pep3.Fragment(FragmentTypes.b, true).ToList(); Assert.IsTrue(list[0] is IHasChemicalFormula); Assert.IsFalse(list[2] is IHasChemicalFormula); }
public void Setup() { Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; UsefulProteomicsDatabases.Loaders.LoadElements(); double[] mz = { 328.73795, 329.23935, 447.73849, 448.23987, 482.23792, 482.57089, 482.90393, 500.95358, 501.28732, 501.62131, 611.99377, 612.32806, 612.66187, 722.85217, 723.35345 }; double[] intensities = { 81007096.0, 28604418.0, 78353512.0, 39291696.0, 122781408.0, 94147520.0, 44238040.0, 71198680.0, 54184096.0, 21975364.0, 44514172.0, 43061628.0, 23599424.0, 56022696.0, 41019144.0 }; _mzSpectrumA = new MzSpectrum(mz, intensities, false); var peptide = new Peptide("KQEEQMETEQQNKDEGK"); MzSpectrum MS1 = CreateSpectrum(peptide.GetChemicalFormula(), 300, 2000, 1); MzSpectrum MS2 = CreateMS2spectrum(peptide.Fragment(FragmentTypes.b | FragmentTypes.y, true), 100, 1500); MsDataScan[] Scans = new MsDataScan[2]; Scans[0] = new MsDataScan(MS1, 1, 1, false, Polarity.Positive, 1.0, new MzRange(300, 2000), "first spectrum", MZAnalyzerType.Unknown, MS1.SumOfAllY, 1, null, "scan=1"); Scans[1] = new MsDataScan(MS2, 2, 2, false, Polarity.Positive, 2.0, new MzRange(100, 1500), "second spectrum", MZAnalyzerType.Unknown, MS2.SumOfAllY, 1, null, "scan=2", 693.9892, 3, .3872, 693.99, 1, DissociationType.Unknown, 1, 693.6550); myMsDataFile = new FakeMsDataFile(Scans); }
public void FragmentNumberToLow() { Assert.Throws <IndexOutOfRangeException>(() => _mockPeptideEveryAminoAcid.Fragment(FragmentTypes.b, 0).ToList()); }
/// <summary> /// Basic overview of how peptides can be used and modified /// </summary> private static void PeptideExamples() { Console.WriteLine("**Peptide Examples**"); // Simple Peptide creation Peptide peptide1 = new Peptide("ACDEFGHIKLMNPQRSTVWY"); WritePeptideToConsole(peptide1); // Fragmenting a peptide is simple, you can include as many fragment types as you want Console.WriteLine("{0,-4} {1,-20} {2,-10} {3,-10} {4,-5}", "Type", "Formula", "Mass", "m/z +1", "Sequence"); foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y)) { WriteFragmentToConsole(fragment); } // Modifications can be applied to any residue or termini Console.WriteLine("Lets add some Iron to our peptide..."); peptide1.SetModification(new ChemicalFormula("Fe"), Terminus.C | Terminus.N); WritePeptideToConsole(peptide1); // A chemicalmodification is a simple wrapper for a chemical formula. You can name your mods if you want Console.WriteLine("Add a modification of Oxygen with the name \"Oxidation\" to all Methionines"); ChemicalFormulaModification oxMod = new ChemicalFormulaModification("O", "Oxidation"); peptide1.SetModification(oxMod, 'M'); WritePeptideToConsole(peptide1); // If you fragment a modified peptide, the modifications stay part of the fragments Console.WriteLine("{0,-4} {1,-20} {2,-20} {3,-5}", "Type", "Formula", "Mass", "m/z +1"); foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y, 2)) { WriteFragmentToConsole(fragment); } }