public static void TestPsmHeader() { DigestionParams digestionParams = new DigestionParams(); PeptideWithSetModifications pepWithSetMods = new Protein( "MQQQQQQQ", "accession1", "org", new List <Tuple <string, string> > { new Tuple <string, string>("geneNameType", "geneName") }, new Dictionary <int, List <Modification> > { { 2, new List <Modification> { new Modification("mod", "mod") } } }, name: "name", full_name: "fullName", sequenceVariations: new List <SequenceVariation> { new SequenceVariation(2, "P", "Q", "changed this sequence") }) .Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); MsDataFile myMsDataFile = new TestDataFile(pepWithSetMods, "quadratic"); MsDataScan scann = myMsDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null); PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods.CompactPeptide(TerminusType.None), 1, 2, 3, scan, digestionParams); var t = psm.ToString(); var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { pepWithSetMods.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pepWithSetMods } } }; psm.MatchToProteinLinkedPeptides(matching); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); List <ProductType> lp = new List <ProductType> { ProductType.B }; new LocalizationEngine(new List <PeptideSpectralMatch> { psm }, lp, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), new List <string>()).Run(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 6, 0, 0, 0, true); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); }
public static void TestPsmHeader() { CommonParameters commonParameters = new CommonParameters(); PeptideWithSetModifications pepWithSetMods = new Protein( "MQQQQQQQ", "accession1", "org", new List <Tuple <string, string> > { new Tuple <string, string>("geneNameType", "geneName") }, new Dictionary <int, List <Modification> > { { 2, new List <Modification> { new Modification("mod", "mod") } } }, name: "name", fullName: "fullName", sequenceVariations: new List <SequenceVariation> { new SequenceVariation(2, "P", "Q", "changed this sequence") }) .Digest(commonParameters.DigestionParams, new List <Modification>(), new List <Modification>()).First(); MsDataFile myMsDataFile = new TestDataFile(pepWithSetMods, "quadratic"); MsDataScan scann = myMsDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null, new CommonParameters()); var theoreticalIons = new List <Product>(); pepWithSetMods.Fragment(DissociationType.HCD, FragmentationTerminus.Both, theoreticalIons); var matchedIons = MetaMorpheusEngine.MatchFragmentIons(scan, theoreticalIons, new CommonParameters()); PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods, 1, 2, 3, scan, commonParameters, matchedIons); psm.ResolveAllAmbiguities(); var t = psm.ToString(); var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); new LocalizationEngine(new List <PeptideSpectralMatch> { psm }, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), null, new List <string>()).Run(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 0, 0, 0); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); }
public static void TestPsmHeader() { DigestionParams digestionParams = new DigestionParams(); PeptideWithSetModifications pepWithSetMods = new Protein("MQQQQQQQ", "accession1").Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile = new TestDataFile(pepWithSetMods, "quadratic"); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > scann = myMsDataFile.GetOneBasedScan(2) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null); PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods.CompactPeptide(TerminusType.None), 1, 2, 3, scan); var t = psm.ToString(); var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { pepWithSetMods.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pepWithSetMods } } }; psm.MatchToProteinLinkedPeptides(matching); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); List <ProductType> lp = new List <ProductType> { ProductType.B }; new LocalizationEngine(new List <PeptideSpectralMatch> { psm }, lp, myMsDataFile, fragmentTolerance, new List <string>(), false).Run(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 6, 0, 0, 0, false); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); }
public static void ResolveModificationsTest() { double mass = 12.0 + new PeptideWithSetModifications(new Protein("LNLDLDND", "prot1"), new DigestionParams(), 1, 8, CleavageSpecificity.Full, "", 0, new Dictionary <int, Modification>(), 0, null).MonoisotopicMass.ToMz(1); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[, ] { }), 0, 0, true, Polarity.Positive, 0, new MzLibUtil.MzRange(0, 0), "", MZAnalyzerType.FTICR, 0, null, null, ""), mass, 1, "", new CommonParameters()); ModificationMotif.TryGetMotif("N", out ModificationMotif motif1); Dictionary <DissociationType, List <double> > NeutralLosses = new Dictionary <DissociationType, List <double> >(); NeutralLosses.Add(DissociationType.HCD, new List <double> { 0 }); Modification modFormula_C1 = new Modification(_originalId: "modC", _accession: "", _modificationType: "mt", _featureType: "", _target: motif1, _locationRestriction: "Anywhere.", _chemicalFormula: new ChemicalFormula(ChemicalFormula.ParseFormula("C1")), null, null, null, null, _neutralLosses: NeutralLosses, null, null); Modification modFormula_H1 = new Modification(_originalId: "modH", _accession: "", _modificationType: "mt", _featureType: "", _target: motif1, _locationRestriction: "Anywhere.", _chemicalFormula: new ChemicalFormula(ChemicalFormula.ParseFormula("H1")), null, null, null, null, _neutralLosses: NeutralLosses, null, null); IDictionary <int, List <Modification> > oneBasedModifications = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { modFormula_C1, modFormula_H1 } }, }; Protein protein1 = new Protein("MNLDLDNDL", "prot1", oneBasedModifications: oneBasedModifications); Dictionary <int, Modification> allModsOneIsNterminus1 = new Dictionary <int, Modification> { { 2, modFormula_C1 }, }; PeptideWithSetModifications pwsm1 = new PeptideWithSetModifications(protein1, new DigestionParams(), 2, 9, CleavageSpecificity.Unknown, null, 0, allModsOneIsNterminus1, 0); Dictionary <int, Modification> allModsOneIsNterminus2 = new Dictionary <int, Modification> { { 2, modFormula_H1 }, }; PeptideWithSetModifications pwsm2 = new PeptideWithSetModifications(protein1, new DigestionParams(), 2, 9, CleavageSpecificity.Unknown, null, 0, allModsOneIsNterminus2, 0); CommonParameters CommonParameters = new CommonParameters(digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1), scoreCutoff: 1); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); List <MatchedFragmentIon> mfi = new List <MatchedFragmentIon>(); //we're adding a neutral loss of 5 to the product to make sure we hit the right spot in the unit test to add that loss to the product ion string Product p = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 5); mfi.Add(new MatchedFragmentIon(ref p, 1, 1, 1)); PeptideSpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), mfi); myPsm.AddOrReplace(pwsm2, 10, 0, true, mfi, 10); myPsm.ResolveAllAmbiguities(); //Here we have a situation where there are two mods at the same position with different chemical formuala. They cannot be resolved and so the return value is null. Assert.IsNull(myPsm.ModsChemicalFormula); string myPsmString = myPsm.ToString(); string[] myPsmStringSplit = myPsmString.Split('\t'); string ppmErrorString = myPsmStringSplit[23]; //The two different mods produce two separate mass errors, which are both then reported Assert.AreEqual("0.00|11801.30", ppmErrorString); //Make sure we see produt ion neutral losses in the output. string matchedIonSeries = myPsmStringSplit[38]; Assert.AreEqual("[(b1-5.00)+1]", matchedIonSeries); //removing one of the peptides to reset for the next test myPsm.RemoveThisAmbiguousPeptide(0, pwsm2); PeptideWithSetModifications pwsm3 = new PeptideWithSetModifications(protein1, new DigestionParams(), 2, 9, CleavageSpecificity.Unknown, null, 0, allModsOneIsNterminus1, 0); myPsm.AddOrReplace(pwsm3, 10, 0, true, mfi, 10); myPsm.ResolveAllAmbiguities(); //Now we have removed one of the peptides with a different chemical formual and replaced it with a mod that has the same chemical formula as the remaining original best peptide //Here we have a situation where there are two mods at the same position have the same chemical formuala and they can be resolved and so the return value the chemical formual of the mod. Assert.AreEqual("C", myPsm.ModsChemicalFormula.Formula.ToString()); myPsmString = myPsm.ToString(); myPsmStringSplit = myPsmString.Split('\t'); ppmErrorString = myPsmStringSplit[23]; Assert.AreEqual("0.00", ppmErrorString); }