//Calculate if crosslink amino acid exist and return its position based on compactPeptide public static List <int> XlPosCal(CompactPeptide compactPeptide, string crosslinkerModSites) { Tolerance tolerance = new PpmTolerance(1); List <int> xlpos = new List <int>(); foreach (char item in crosslinkerModSites) { if (tolerance.Within(compactPeptide.NTerminalMasses[0], Residue.GetResidue(item).MonoisotopicMass)) { xlpos.Add(0); } for (int i = 1; i < compactPeptide.NTerminalMasses.Length; i++) { if (tolerance.Within(compactPeptide.NTerminalMasses[i] - compactPeptide.NTerminalMasses[i - 1], Residue.GetResidue(item).MonoisotopicMass)) { xlpos.Add(i); } } if (tolerance.Within(compactPeptide.CTerminalMasses[0], Residue.GetResidue(item).MonoisotopicMass)) { xlpos.Add(compactPeptide.NTerminalMasses.Length); } } xlpos.Sort(); return(xlpos); }
public void Residue_Equality() { Residue first = Residue.GetResidue('V'); Residue second = Residue.GetResidue('V'); Assert.AreEqual(first, second); }
public void SetAminoAcidModification() { var Asparagine = Residue.GetResidue("N"); _mockPeptideEveryAminoAcid.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("Fe")), Asparagine); Assert.AreEqual("ACDEFGHIKLMN[Fe]PQRSTVWY", _mockPeptideEveryAminoAcid.ToString()); }
public static void XlTestXlPosCal() { var prot = new Protein("MNNNKQQQQ", null); Protease protease = new Protease("New Custom Protease", new List <Tuple <string, TerminusType> > { new Tuple <string, TerminusType>("K", TerminusType.C) }, new List <Tuple <string, TerminusType> >(), CleavageSpecificity.Full, null, null, null); ProteaseDictionary.Dictionary.Add(protease.Name, protease); DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var ye = prot.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pep = ye[0]; Assert.AreEqual(pep.BaseSequence, "MNNNK"); CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(CrosslinkerType.DSS); Assert.AreEqual(crosslinker.CrosslinkerModSites, "K"); Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, 128.09496301518999, 1e-9); var n = pep.CompactPeptide(TerminusType.None).NTerminalMasses; var c = pep.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n.Count(), 4); Assert.AreEqual(c.Count(), 4); Assert.AreEqual(c[0], 128.09496301518999, 1e-6); var x = PsmCross.XlPosCal(pep.CompactPeptide(TerminusType.None), crosslinker.CrosslinkerModSites).ToArray(); Assert.AreEqual(x[0], 4); var pep2 = ye[2]; Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); var n2 = pep2.CompactPeptide(TerminusType.None).NTerminalMasses; var c2 = pep2.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n2.Count(), 8); Assert.AreEqual(c2.Count(), 8); Assert.AreEqual(n2[4] - n2[3], 128.09496301518999, 1e-6); var x2 = PsmCross.XlPosCal(pep2.CompactPeptide(TerminusType.None), crosslinker.CrosslinkerModSites).ToArray(); Assert.AreEqual(x2[0], 4); //Test crosslinker with multiple types of mod var protSTC = new Protein("GASTACK", null); var peps = protSTC.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pepSTC = peps[0]; Assert.AreEqual(pepSTC.BaseSequence, "GASTACK"); CrosslinkerTypeClass crosslinker2 = new CrosslinkerTypeClass("ST", "C", "crosslinkerSTC", false, -18.01056, 0, 0, 0, 0, 0, 0); string crosslinkerModSitesAll = new string((crosslinker2.CrosslinkerModSites + crosslinker2.CrosslinkerModSites2).ToCharArray().Distinct().ToArray()); Assert.AreEqual(crosslinkerModSitesAll, "STC"); }
public static void XlTestXlPosCal() { var prot = new Protein("MNNNKQQQQ", null); List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("New Custom Protease", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); List <Modification> variableModifications = new List <Modification>(); var ye = prot.Digest(digestionParams, new List <Modification>(), variableModifications).ToList(); var pep = ye[0]; Assert.AreEqual(pep.BaseSequence, "MNNNK"); Crosslinker crosslinker = GlobalVariables.Crosslinkers.Where(p => p.CrosslinkerName == "DSS").First(); Assert.AreEqual(crosslinker.CrosslinkerModSites, "K"); Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, 128.09496301518999, 1e-9); var n = pep.Fragment(DissociationType.HCD, FragmentationTerminus.N); var c = pep.Fragment(DissociationType.HCD, FragmentationTerminus.C); Assert.AreEqual(n.Count(), 4); Assert.AreEqual(c.Count(), 4); Assert.AreEqual(c.First().NeutralMass, 146.10552769899999, 1e-6); var x = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep).ToArray(); Assert.AreEqual(x[0], 5); var pep2 = ye[2]; Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); var n2 = pep2.Fragment(DissociationType.HCD, FragmentationTerminus.N); var c2 = pep2.Fragment(DissociationType.HCD, FragmentationTerminus.C); Assert.AreEqual(n2.Count(), 8); Assert.AreEqual(c2.Count(), 8); var x2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep2).ToArray(); Assert.AreEqual(x2[0], 5); //Test crosslinker with multiple types of mod var protSTC = new Protein("GASTACK", null); var peps = protSTC.Digest(digestionParams, new List <Modification>(), variableModifications).ToList(); var pepSTC = peps[0]; Assert.AreEqual(pepSTC.BaseSequence, "GASTACK"); Crosslinker crosslinker2 = new Crosslinker("ST", "C", "crosslinkerSTC", false, -18.01056, 0, 0, 0, 0, 0, 0); string crosslinkerModSitesAll = new string((crosslinker2.CrosslinkerModSites + crosslinker2.CrosslinkerModSites2).ToCharArray().Distinct().ToArray()); Assert.AreEqual(crosslinkerModSitesAll, "STC"); }
public void TestLeucineSequence() { Assert.AreEqual("ACDEFGHLKLMNPQRSTVWY", _mockPeptideEveryAminoAcid.GetSequenceWithModifications(true)); Assert.AreEqual(20, _mockPeptideEveryAminoAcid.ResidueCount()); Assert.AreEqual(7, _mockTrypticPeptide.ResidueCount('S')); Assert.AreEqual(7, _mockTrypticPeptide.ResidueCount(Residue.GetResidue('S'))); Assert.AreEqual(2, _mockTrypticPeptide.ResidueCount(Residue.GetResidue('S'), 2, 3)); Assert.AreEqual(3, _mockTrypticPeptide.ResidueCount('S', 2, 4)); Peptide peptide = new Peptide("III-[C2H3NO]"); Assert.AreEqual("LLL-[C2H3NO]", peptide.GetSequenceWithModifications(true)); }
public static void XlTestXlPosCal() { var prot = new Protein("MNNNKQQQQ", null); var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); DigestionParams digestionParams = new DigestionParams { InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain, MaxMissedCleavages = 2, Protease = protease, MinPeptideLength = 1 }; List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var ye = prot.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pep = ye[0]; Assert.AreEqual(pep.BaseSequence, "MNNNK"); CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(CrosslinkerType.DSS); Assert.AreEqual(crosslinker.CrosslinkerModSite, 'K'); Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSite).MonoisotopicMass, 128.09496301518999, 1e-9); var n = pep.CompactPeptide(TerminusType.None).NTerminalMasses; var c = pep.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n.Count(), 4); Assert.AreEqual(c.Count(), 4); Assert.AreEqual(c[0], 128.09496301518999, 1e-6); var x = PsmCross.XlPosCal(pep.CompactPeptide(TerminusType.None), crosslinker).ToArray(); Assert.AreEqual(x[0], 4); var pep2 = ye[2]; Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); var n2 = pep2.CompactPeptide(TerminusType.None).NTerminalMasses; var c2 = pep2.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n2.Count(), 8); Assert.AreEqual(c2.Count(), 8); Assert.AreEqual(n2[4] - n2[3], 128.09496301518999, 1e-6); var x2 = PsmCross.XlPosCal(pep2.CompactPeptide(TerminusType.None), crosslinker).ToArray(); Assert.AreEqual(x2[0], 4); }
public static void TestSilacWhenProteinIsMissing() { //make heavy residue and add to search task Residue heavyLysine = new Residue("a", 'a', "a", Chemistry.ChemicalFormula.ParseFormula("C{13}6H12N{15}2O"), ModificationSites.All); //+8 lysine Residue lightLysine = Residue.GetResidue('K'); SearchTask task = new SearchTask { SearchParameters = new SearchParameters { SilacLabels = new List <SilacLabel> { new SilacLabel(lightLysine.Letter, heavyLysine.Letter, heavyLysine.ThisChemicalFormula.Formula, heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass) }, NoOneHitWonders = true //The NoOneHitWonders=true doesn't really seem like a SILAC test, but we're testing that there's no crash if a quantified peptide's proteinGroup isn't quantified //This happens if somebody messed with parsimony (picked TDS) or from requiring two peptides per protein (and we're only finding one). We're testing the second case here. } }; PeptideWithSetModifications lightPeptide = new PeptideWithSetModifications("PEPTIDEK", new Dictionary <string, Modification>()); List <double> massDifferences = new List <double> { heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass }; MsDataFile myMsDataFile1 = new TestDataFile(lightPeptide, massDifferences); string mzmlName = @"silac.mzML"; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); string xmlName = "SilacDb.xml"; Protein theProtein = new Protein("PEPTIDEK", "accession1"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein }, xmlName); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSilac"); Directory.CreateDirectory(outputFolder); var theStringResult = task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1").ToString(); }
public void TestChemicalFormula() { Residue.GetResidue('A'); Peptide A = new Peptide("A"); Residue.GetResidue('A'); ChemicalFormula ok = new ChemicalFormula(Residue.GetResidue('A').ThisChemicalFormula); ok.Add(new ChemicalFormulaTerminus(ChemicalFormula.ParseFormula("OH"))); ok.Add(new ChemicalFormulaTerminus(ChemicalFormula.ParseFormula("H"))); Residue.GetResidue('A'); Residue.GetResidue('A'); Assert.AreEqual(ok, A.GetChemicalFormula()); }
//Calculate if crosslink amino acid exist and return its position based on compactPeptide public static List <int> XlPosCal(CompactPeptide compactPeptide, CrosslinkerTypeClass crosslinker) { Tolerance tolerance = new PpmTolerance(1); List <int> xlpos = new List <int>(); if (tolerance.Within(compactPeptide.NTerminalMasses[0], Residue.GetResidue(crosslinker.CrosslinkerModSite).MonoisotopicMass)) { xlpos.Add(0); } for (int i = 1; i < compactPeptide.NTerminalMasses.Length; i++) { if (tolerance.Within(compactPeptide.NTerminalMasses[i] - compactPeptide.NTerminalMasses[i - 1], Residue.GetResidue(crosslinker.CrosslinkerModSite).MonoisotopicMass)) { xlpos.Add(i); } } if (tolerance.Within(compactPeptide.CTerminalMasses[0], Residue.GetResidue(crosslinker.CrosslinkerModSite).MonoisotopicMass)) { xlpos.Add(compactPeptide.NTerminalMasses.Length); } return(xlpos); }
public void GetResidueByCharacterString() { Residue aa = Residue.GetResidue("A"); Assert.AreEqual(aa.Name, "Alanine"); }
public void SilacLabelTest() { Protein originalProtein = new Protein("ACDEFGHIKAKAK", "TEST"); List <PeptideWithSetModifications> originalDigest = originalProtein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).ToList(); //Multiple SILAC labels Residue lysine = Residue.GetResidue('K'); Residue arginine = Residue.GetResidue('R'); Residue heavyLabel = new Residue("heavy", 'a', "aaa", ChemicalFormula.ParseFormula("C{13}6H12N2O"), ModificationSites.All); //Lysine +6 Residue heavierLabel = new Residue("heavier", 'b', "bbb", ChemicalFormula.ParseFormula("C{13}6H12N{15}2O"), ModificationSites.All); //Lysine +8 Residue heavyArginine = new Residue("heavyR", 'c', "ccc", ChemicalFormula.ParseFormula("C{13}6H5N{15}4O"), ModificationSites.All); //Arginine +10 List <Residue> residuesToAdd = new List <Residue> { heavyLabel, heavierLabel, heavyArginine }; Residue.AddNewResiduesToDictionary(residuesToAdd); List <SilacLabel> silacLabels = new List <SilacLabel> { new SilacLabel('K', 'a', heavyLabel.ThisChemicalFormula.Formula, heavyLabel.MonoisotopicMass - lysine.MonoisotopicMass), new SilacLabel('K', 'b', heavierLabel.ThisChemicalFormula.Formula, heavierLabel.MonoisotopicMass - lysine.MonoisotopicMass) }; List <PeptideWithSetModifications> silacDigest = originalProtein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>(), silacLabels).ToList(); Assert.IsTrue(originalDigest.Count * 3 == silacDigest.Count); //check that each peptide now has a light, heavy, and heavier compliment double silacPeptideLightMonoisotopicMass = silacDigest.Where(x => x.BaseSequence.Contains("K")).First().MonoisotopicMass; double silacPeptideHeavyMonoisotopicMass = silacDigest.Where(x => x.BaseSequence.Contains("a")).First().MonoisotopicMass; double silacPeptideHeavierMonoisotopicMass = silacDigest.Where(x => x.BaseSequence.Contains("b")).First().MonoisotopicMass; Assert.IsTrue(silacPeptideLightMonoisotopicMass != double.NaN); //if both NaN, then the mass comparison statements will always be true, because NaN + double = NaN Assert.IsTrue(silacPeptideHeavyMonoisotopicMass != double.NaN); //if both NaN, then the mass comparison statements will always be true, because NaN + double = NaN Assert.IsTrue(silacPeptideHeavierMonoisotopicMass != double.NaN); //if both NaN, then the mass comparison statements will always be true, because NaN + double = NaN Assert.IsTrue(Math.Round(silacPeptideLightMonoisotopicMass + heavyLabel.MonoisotopicMass, 5).Equals(Math.Round(silacPeptideHeavyMonoisotopicMass + lysine.MonoisotopicMass, 5))); //check that the residue masses were succesfully added Assert.IsTrue(Math.Round(silacPeptideHeavyMonoisotopicMass + heavierLabel.MonoisotopicMass, 5).Equals(Math.Round(silacPeptideHeavierMonoisotopicMass + heavyLabel.MonoisotopicMass, 5))); //check that the residue masses were succesfully added //code coverage SilacLabel testParameterlessConstructorForTomlsWithoutAnyRealTestAndMoreJustForCodeCoverage = new SilacLabel(); Assert.IsTrue(testParameterlessConstructorForTomlsWithoutAnyRealTestAndMoreJustForCodeCoverage != null); Assert.IsTrue(silacLabels[0].AdditionalLabels == null); //The zero index label is K to a with a mass diff of 6 //the one index label is K to b with a mass diff of 8 silacLabels[0].AddAdditionalSilacLabel(new SilacLabel('D', 'c', heavyLabel.ThisChemicalFormula.Formula, heavyLabel.MonoisotopicMass - lysine.MonoisotopicMass - 1)); Assert.IsTrue(silacLabels[0].AdditionalLabels.Count == 1); silacLabels[0].AddAdditionalSilacLabel(new SilacLabel('E', 'd', heavyLabel.ThisChemicalFormula.Formula, heavyLabel.MonoisotopicMass - lysine.MonoisotopicMass + 1)); Assert.IsTrue(silacLabels[0].AdditionalLabels.Count == 2); silacDigest = originalProtein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>(), silacLabels).ToList(); Assert.IsTrue(silacDigest.Count == 9); //Turnover silacLabels = new List <SilacLabel> { new SilacLabel('K', 'b', heavierLabel.ThisChemicalFormula.Formula, heavierLabel.MonoisotopicMass - lysine.MonoisotopicMass) }; silacDigest = originalProtein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>(), silacLabels, (null, silacLabels[0])).ToList(); Assert.IsTrue(silacDigest.Count == 14); silacDigest = originalProtein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>(), silacLabels, (silacLabels[0], null)).ToList(); Assert.IsTrue(silacDigest.Count == 14); silacLabels = new List <SilacLabel> { new SilacLabel('K', 'a', heavyLabel.ThisChemicalFormula.Formula, heavyLabel.MonoisotopicMass - lysine.MonoisotopicMass), new SilacLabel('K', 'b', heavierLabel.ThisChemicalFormula.Formula, heavierLabel.MonoisotopicMass - lysine.MonoisotopicMass) }; silacDigest = originalProtein.Digest(new DigestionParams(generateUnlabeledProteinsForSilac: false), new List <Modification>(), new List <Modification>(), silacLabels, (silacLabels[1], silacLabels[0])).ToList(); Assert.IsTrue(silacDigest.Count == 14); originalProtein = new Protein("ACDEFGHIKARAK", "TEST"); silacLabels[1].AddAdditionalSilacLabel(new SilacLabel('R', 'c', heavyArginine.ThisChemicalFormula.Formula, heavyArginine.MonoisotopicMass - arginine.MonoisotopicMass)); silacDigest = originalProtein.Digest(new DigestionParams(generateUnlabeledProteinsForSilac: false), new List <Modification>(), new List <Modification>(), silacLabels, (silacLabels[1], silacLabels[0])).ToList(); Assert.IsTrue(silacDigest.Count == 14); silacLabels = new List <SilacLabel> { new SilacLabel('K', 'a', heavyLabel.ThisChemicalFormula.Formula, heavyLabel.MonoisotopicMass - lysine.MonoisotopicMass), new SilacLabel('K', 'b', heavierLabel.ThisChemicalFormula.Formula, heavierLabel.MonoisotopicMass - lysine.MonoisotopicMass) }; silacLabels[0].AddAdditionalSilacLabel(new SilacLabel('R', 'c', heavyArginine.ThisChemicalFormula.Formula, heavyArginine.MonoisotopicMass - arginine.MonoisotopicMass)); silacDigest = originalProtein.Digest(new DigestionParams(generateUnlabeledProteinsForSilac: false), new List <Modification>(), new List <Modification>(), silacLabels, (silacLabels[1], silacLabels[0])).ToList(); Assert.IsTrue(silacDigest.Count == 14); }
public void Invalid_Symbol_Retrieval() { Residue res; Assert.ThrowsException <ArgumentException>(() => res = Residue.GetResidue('X')); }
public void Valid_Symbol_Retrieval() { Residue valine = Residue.GetResidue('V'); }
public static void TestSilacMultipleModsPerCondition() { //The concern with multiple mods per label is the conversions back and forth between "light" and "heavy" labels Residue heavyLysine = new Residue("a", 'a', "a", Chemistry.ChemicalFormula.ParseFormula("C{13}6H12N{15}2O"), ModificationSites.All); //+8 lysine Residue heavyArginine = new Residue("b", 'b', "b", Chemistry.ChemicalFormula.ParseFormula("C{13}6H12N4O"), ModificationSites.All); //+6 arginine Residue lightLysine = Residue.GetResidue('K'); Residue lightArginine = Residue.GetResidue('R'); SilacLabel krLabel = new SilacLabel(lightLysine.Letter, heavyLysine.Letter, heavyLysine.ThisChemicalFormula.Formula, heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass); krLabel.AddAdditionalSilacLabel(new SilacLabel(lightArginine.Letter, heavyArginine.Letter, heavyArginine.ThisChemicalFormula.Formula, heavyArginine.MonoisotopicMass - lightArginine.MonoisotopicMass)); SearchTask task = new SearchTask { SearchParameters = new SearchParameters { SilacLabels = new List <SilacLabel> { krLabel } }, CommonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 2)) }; PeptideWithSetModifications lightPeptide = new PeptideWithSetModifications("SEQENEWITHAKANDANR", new Dictionary <string, Modification>()); List <double> massDifferences = new List <double> { (heavyLysine.MonoisotopicMass + heavyArginine.MonoisotopicMass) - (lightLysine.MonoisotopicMass + lightArginine.MonoisotopicMass) }; MsDataFile myMsDataFile1 = new TestDataFile(lightPeptide, massDifferences); string mzmlName = @"silac.mzML"; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); string xmlName = "SilacDb.xml"; Protein theProtein = new Protein("MPRTEINRSEQENEWITHAKANDANRANDSMSTFF", "accession1"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein }, xmlName); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSilac"); Directory.CreateDirectory(outputFolder); task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1"); //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllProteinGroups.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[0].Contains("Intensity_silac\tIntensity_silac(K+8.014 & R+6.020)")); //test that two files were made Assert.IsTrue(output[1].Contains("875000\t437500")); //test the heavy intensity is half that of the light (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[1].Contains("SEQENEWITHAKANDANR\taccession1\t")); //test the sequence and accession were not modified Assert.IsTrue(output[1].Contains("875000")); //test intensity Assert.IsFalse(output[1].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)")); //test the sequence was not doubled modified Assert.IsTrue(output[1].Contains("437500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); Assert.AreEqual(output.Length, 3); Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[2].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[1].Contains("SEQENEWITHAKANDANR\t")); //test light sequence was not modified Assert.IsTrue(output[2].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") Assert.IsTrue(output[1].Contains("2111.96")); //test light mass Assert.IsTrue(output[2].Contains("2125.99")); //test heavy mass Assert.IsTrue(output[2].Contains("accession1")); //test heavy accesssion is light in output ///Test for when an additional label is the only label on a peptide ///Usually crashes in mzId //Delete old files File.Delete(mzmlName); Directory.Delete(outputFolder, true); lightPeptide = new PeptideWithSetModifications("ANDANR", new Dictionary <string, Modification>()); //has the additional, but not the original massDifferences = new List <double> { (heavyArginine.MonoisotopicMass) - (lightArginine.MonoisotopicMass) }; myMsDataFile1 = new TestDataFile(lightPeptide, massDifferences, true); mzmlName = @"silac.mzML"; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); Directory.CreateDirectory(outputFolder); task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1"); //Clear the old files Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); }
public void TestAApolymerContains() { Assert.IsFalse(_mockTrypticPeptide.Contains('A')); Assert.IsTrue(_mockTrypticPeptide.Contains(Residue.GetResidue('T'))); }
public static void TestSilacNoLightProtein() { //The concern with multiple mods per label is the conversions back and forth between "light" and "heavy" labels Residue heavyArginine = new Residue("c", 'c', "c", Chemistry.ChemicalFormula.ParseFormula("C6H12N{15}4O"), ModificationSites.All); //+4 arginine Residue heavierArginine = new Residue("d", 'd', "d", Chemistry.ChemicalFormula.ParseFormula("C{13}6H12N{15}4O"), ModificationSites.All); //+10 arginine Residue.AddNewResiduesToDictionary(new List <Residue> { heavyArginine }); //These should be added in the search task, but we need to add this one earlier so that we can create a heavy pwsm Residue lightArginine = Residue.GetResidue('R'); SilacLabel heavyLabel = new SilacLabel(lightArginine.Letter, heavyArginine.Letter, heavyArginine.ThisChemicalFormula.Formula, heavyArginine.MonoisotopicMass - lightArginine.MonoisotopicMass); SilacLabel heavierLabel = new SilacLabel(lightArginine.Letter, heavierArginine.Letter, heavierArginine.ThisChemicalFormula.Formula, heavierArginine.MonoisotopicMass - lightArginine.MonoisotopicMass); SearchTask task = new SearchTask { SearchParameters = new SearchParameters { SilacLabels = new List <SilacLabel> { heavyLabel, heavierLabel } }, CommonParameters = new CommonParameters(digestionParams: new DigestionParams(generateUnlabeledProteinsForSilac: false)) //this is the important part of the unit test }; PeptideWithSetModifications heavyPeptide = new PeptideWithSetModifications("PEPTIDEc", new Dictionary <string, Modification>()); List <double> massDifferences = new List <double> { heavierArginine.MonoisotopicMass - heavyArginine.MonoisotopicMass }; MsDataFile myMsDataFile1 = new TestDataFile(heavyPeptide, massDifferences); string mzmlName = @"silac.mzML"; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); string xmlName = "SilacDb.xml"; Protein theProtein = new Protein("PEPTIDER", "accession1"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein }, xmlName); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSilac"); Directory.CreateDirectory(outputFolder); var theStringResult = task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1").ToString(); //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllProteinGroups.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[0].Contains("Modification Info List\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test that two files were made and no light file Assert.IsTrue(output[1].Contains("875000\t437500")); //test the heavier intensity is half that of the heavy (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[0].Contains("Organism\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test the two files were made and no light file Assert.IsTrue(output[1].Contains("875000\t437500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); Assert.AreEqual(output.Length, 3); Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[2].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[1].Contains("PEPTIDER(+3.988)\t")); //test light sequence was not modified Assert.IsTrue(output[2].Contains("PEPTIDER(+10.008)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") Assert.IsTrue(output[1].Contains("959.44")); //test light mass Assert.IsTrue(output[2].Contains("965.46")); //test heavy mass //test PSMs output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); Assert.IsTrue(output[1].Contains("959.44")); //test the correct monoisotopic mass Assert.IsTrue(output[1].Contains("PEPTIDER(+3.988)")); //test the correct psm Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) //Clear the old files Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); }
public void ResidueMonoisotopicMassTest() { Assert.AreEqual(Residue.ResidueMonoisotopicMass['A'], Residue.GetResidue('A').MonoisotopicMass, 1e-9); }
public void GetResidueByName() { Residue aa = Residue.GetResidue("Alanine"); Assert.AreEqual("Alanine", aa.Name); }
public static void TestSilacQuantification() { //make heavy residue and add to search task Residue heavyLysine = new Residue("a", 'a', "a", Chemistry.ChemicalFormula.ParseFormula("C{13}6H12N{15}2O"), ModificationSites.All); //+8 lysine Residue lightLysine = Residue.GetResidue('K'); SearchTask task = new SearchTask { SearchParameters = new SearchParameters { SilacLabels = new List <SilacLabel> { new SilacLabel(lightLysine.Letter, heavyLysine.Letter, heavyLysine.ThisChemicalFormula.Formula, heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass) } } }; PeptideWithSetModifications lightPeptide = new PeptideWithSetModifications("PEPTIDEK", new Dictionary <string, Modification>()); List <double> massDifferences = new List <double> { heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass }; MsDataFile myMsDataFile1 = new TestDataFile(lightPeptide, massDifferences); string mzmlName = @"silac.mzML"; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); string xmlName = "SilacDb.xml"; Protein theProtein = new Protein("PEPTIDEK", "accession1"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein }, xmlName); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSilac"); Directory.CreateDirectory(outputFolder); var theStringResult = task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1").ToString(); Assert.IsTrue(theStringResult.Contains("All target PSMS within 1% FDR: 1")); //it's not a psm, it's a MBR feature ///Normal Peptide //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllProteinGroups.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[0].Contains("Intensity_silac\tIntensity_silac(K+8.014)")); //test that two files were made Assert.IsTrue(output[1].Contains("875000\t437500")); //test the heavy intensity is half that of the light (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.AreEqual(output.Length, 2); Assert.IsTrue(output[1].Contains("PEPTIDEK\taccession1\t")); //test the sequence and accession were not modified Assert.IsTrue(output[1].Contains("875000")); //test intensity Assert.IsFalse(output[1].Contains("PEPTIDEK(+8.014)")); //test the sequence was not doubled modified Assert.IsTrue(output[1].Contains("437500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); Assert.AreEqual(output.Length, 3); Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[2].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[1].Contains("PEPTIDEK\t")); //test light sequence was not modified Assert.IsTrue(output[2].Contains("PEPTIDEK(+8.014)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") Assert.IsTrue(output[1].Contains("927.45")); //test light mass Assert.IsTrue(output[2].Contains("935.46")); //test heavy mass ///Ambiguous base sequence peptide //Clear the old files Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); //make a heavy peptide massDifferences = new List <double> { heavyLysine.MonoisotopicMass - lightLysine.MonoisotopicMass }; myMsDataFile1 = new TestDataFile(lightPeptide, massDifferences, true); IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); //make an ambiguous database Protein theProtein2 = new Protein("PEPTLDEKPEPTIDEK", "accession2"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein, theProtein2 }, xmlName); Directory.CreateDirectory(outputFolder); theStringResult = task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) Assert.IsTrue(output[1].Contains("PEPTIDEK(+8.014)|PEPTLDEK(+8.014)|PEPTIDEK(+8.014)") || output[1].Contains("PEPTIDEK(+8.014)|PEPTIDEK(+8.014)|PEPTLDEK(+8.014)") || output[1].Contains("PEPTLDEK(+8.014)|PEPTIDEK(+8.014)|PEPTIDEK(+8.014)")); //test the heavy ambiguous peptides were all found //Need the options, because output isn't consistent as of 3/26/19 ///Ambiguous proteinGroup //Clear the old files Directory.Delete(outputFolder, true); File.Delete(xmlName); //make an ambiguous database theProtein2 = new Protein("PEPTIDEK", "accession2"); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { theProtein, theProtein2 }, xmlName); Directory.CreateDirectory(outputFolder); theStringResult = task.RunTask(outputFolder, new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); Assert.IsTrue(output[1].Contains("accession1|accession2") || output[1].Contains("accession2|accession1")); //test the heavy ambiguous peptides were all found //Need the options, because output isn't consistent as of 3/26/19 Assert.IsTrue(output[1].Contains("\tPEPTIDEK(+8.014)\t")); //test the heavy ambiguous peptides were all found //delete files Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); }
public void GetResidueByCharacter() { Residue aa = Residue.GetResidue('A'); Assert.AreEqual("Alanine", aa.Name); }