public static void TestMetaDrawReadCrossPsmFile() { XLSearchTask searchTask = new XLSearchTask(); searchTask.XlSearchParameters.Crosslinker = GlobalVariables.Crosslinkers.ToList()[1]; string myFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\BSA_DSS_23747.mzML"); string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\BSA.fasta"); string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestMetaDrawReadPsmFile"); DbForTask db = new DbForTask(myDatabase, false); Directory.CreateDirectory(folderPath); searchTask.RunTask(folderPath, new List <DbForTask> { db }, new List <string> { myFile }, "metadraw"); string psmFile = Directory.GetFiles(folderPath).First(f => f.Contains("XL_Intralinks.tsv")); List <PsmFromTsv> parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); Directory.Delete(folderPath, true); }
public static void WriteTsvTest() { string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlOutputTestFile"); string myFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\2017-11-21_XL_DSSO_Ribosome_RT60min_28800-28898.mzML"); string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\RibosomeGO.fasta"); Directory.CreateDirectory(outputFolder); XLSearchTask xLSearch = new XLSearchTask(); xLSearch.XlSearchParameters.CrosslinkAtCleavageSite = true; xLSearch.RunTask(outputFolder, new List <DbForTask> { new DbForTask(myDatabase, false) }, new List <string> { myFile }, "test"); var resultsPath = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Intralinks.tsv")); var sections = resultsPath[1].Split('\t'); Assert.That(resultsPath.Length > 1); Assert.That(sections.Length == 47); var resultsPath_Inter = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Interlinks.tsv")); Assert.That(resultsPath_Inter.Length > 1); var resultsPath_Deadend = File.ReadAllLines(Path.Combine(outputFolder, @"Deadends.tsv")); Assert.That(resultsPath_Deadend.Length > 1); var resultsPath_loop = File.ReadAllLines(Path.Combine(outputFolder, @"Looplinks.tsv")); Assert.That(resultsPath_loop.Length > 1); var resultsPath_single = File.ReadAllLines(Path.Combine(outputFolder, @"SinglePeptides.tsv")); Assert.That(resultsPath_single.Length > 1); Directory.Delete(outputFolder, true); }
public static void WriteTsvTest() { string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlOutputTest1"); string myFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\BSA_DSS_23747.mzML"); string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\BSA.fasta"); Directory.CreateDirectory(outputFolder); XLSearchTask xLSearch = new XLSearchTask(); xLSearch.RunTask(outputFolder, new List <DbForTask> { new DbForTask(myDatabase, false) }, new List <string> { myFile }, "test"); var resultsPath = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Interlinks.tsv")); var sections = resultsPath[1].Split('\t'); Assert.That(resultsPath.Length == 2); Assert.That(sections.Length == 45); Directory.Delete(outputFolder, true); }
public static void MetaDraw_XlSearchTaskWithChildScansTest() { string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"MetaDraw_XlSearchTaskTest"); string proteinDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\BSA.fasta"); string spectraFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"XlTestData\ms2mixed_bsa_xlink.mzML"); // run task CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.CID, ms2childScanDissociationType: DissociationType.ETD, trimMsMsPeaks: false); Directory.CreateDirectory(outputFolder); var xlSearchTask = new XLSearchTask() { CommonParameters = commonParameters }; xlSearchTask.RunTask(outputFolder, new List <DbForTask> { new DbForTask(proteinDatabase, false) }, new List <string> { spectraFile }, ""); //TODO: test other files (XL_Interlinks.tsv, Deadends.tsv, Looplinks.tsv, SinglePeptides.tsv) var csmFile = Path.Combine(outputFolder, @"XL_Intralinks.tsv"); // load results into metadraw var metadrawLogic = new MetaDrawLogic(); metadrawLogic.SpectraFilePaths.Add(spectraFile); metadrawLogic.PsmResultFilePaths.Add(csmFile); var errors = metadrawLogic.LoadFiles(true, true); Assert.That(!errors.Any()); Assert.That(metadrawLogic.FilteredListOfPsms.Any()); // test results filter MetaDrawSettings.QValueFilter = 0.01; MetaDrawSettings.ShowDecoys = false; metadrawLogic.FilterPsms(); Assert.That(metadrawLogic.FilteredListOfPsms.All(p => p.DecoyContamTarget == "T")); Assert.That(metadrawLogic.FilteredListOfPsms.All(p => p.QValue <= 0.01)); // test text search filter (filter by full sequence) string filterString = @"SLGKVGTR"; metadrawLogic.FilterPsmsByString(filterString); int c = 0; foreach (var filteredPsm in metadrawLogic.PeptideSpectralMatchesView) { var psmObj = (PsmFromTsv)filteredPsm; Assert.That(psmObj.FullSequence.Contains(filterString)); c++; } Assert.That(c > 0); // test text search filter (filter by MS2 scan number) filterString = @"2"; metadrawLogic.FilterPsmsByString(filterString); c = 0; foreach (var filteredPsm in metadrawLogic.PeptideSpectralMatchesView) { var psmObj = (PsmFromTsv)filteredPsm; Assert.That(psmObj.Ms2ScanNumber.ToString().Contains(filterString)); c++; } Assert.That(c > 0); // draw PSM var plotView = new OxyPlot.Wpf.PlotView(); var canvas = new Canvas(); var parentChildView = new ParentChildScanPlotsView(); var csm = metadrawLogic.FilteredListOfPsms.First(); metadrawLogic.DisplaySpectrumMatch(plotView, canvas, csm, parentChildView, out errors); Assert.That(errors == null || !errors.Any()); // test that plot was drawn var peak = (LineSeries)plotView.Model.Series[0]; // the first m/z peak var peakPoints = peak.Points; Assert.That(Math.Round(peakPoints[0].X, 2) == 142.12); // m/z Assert.That(Math.Round(peakPoints[1].X, 2) == 142.12); Assert.That((int)peakPoints[0].Y == 0); // intensity Assert.That((int)peakPoints[1].Y == 1114); var plotAxes = plotView.Model.Axes; Assert.That(plotAxes.Count == 2); // test that base sequence annotation was drawn Assert.That(canvas.Children.Count > 0); // test that the plots were drawn in the parent/child view Assert.That(parentChildView.Plots.Count == 2); // test parent scan var parentPlot = parentChildView.Plots[0]; Assert.That(parentPlot.SpectrumLabel == "Scan: 2 Dissociation Type: CID MsOrder: 2 Selected Mz: 492.02 Retention Time: 23.9"); int numAnnotatedResidues = csm.BaseSeq.Length; int numAnnotatedIons = csm.MatchedIons.Count(p => p.NeutralTheoreticalProduct.ProductType != ProductType.M); int numAnnotatedMods = csm.FullSequence.Count(p => p == '['); Assert.That(parentPlot.TheCanvas.Children.Count == numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods); peak = (LineSeries)parentPlot.Plot.Model.Series[0]; // the first m/z peak peakPoints = peak.Points; Assert.That(Math.Round(peakPoints[0].X, 2) == 142.12); // m/z Assert.That(Math.Round(peakPoints[1].X, 2) == 142.12); Assert.That((int)peakPoints[0].Y == 0); // intensity Assert.That((int)peakPoints[1].Y == 1114); // test child scan var childPlot = parentChildView.Plots[1]; Assert.That(childPlot.SpectrumLabel == "Scan: 3 Dissociation Type: ETD MsOrder: 2 Selected Mz: 492.02 RetentionTime: 23.9"); Assert.That(childPlot.TheCanvas.Children.Count > 0); numAnnotatedResidues = csm.BaseSeq.Length; numAnnotatedIons = csm.ChildScanMatchedIons[3].Concat(csm.BetaPeptideChildScanMatchedIons[3]) .Count(p => p.NeutralTheoreticalProduct.ProductType != ProductType.M); numAnnotatedMods = csm.FullSequence.Count(p => p == '['); Assert.That(childPlot.TheCanvas.Children.Count == numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods); peak = (LineSeries)childPlot.Plot.Model.Series[0]; // the first m/z peak peakPoints = peak.Points; Assert.That(Math.Round(peakPoints[0].X, 2) == 122.92); // m/z Assert.That(Math.Round(peakPoints[1].X, 2) == 122.92); Assert.That((int)peakPoints[0].Y == 0); // intensity Assert.That((int)peakPoints[1].Y == 857); // write pdf var psmsToExport = metadrawLogic.FilteredListOfPsms.Where(p => p.FullSequence == "SLGKVGTR(4)").ToList(); metadrawLogic.ExportToPdf(plotView, canvas, psmsToExport, parentChildView, outputFolder, out errors); // test that pdf exists Assert.That(File.Exists(Path.Combine(outputFolder, @"2_SLGKVGTR(4).pdf"))); // parent scan Assert.That(File.Exists(Path.Combine(outputFolder, @"3_SLGKVGTR(4).pdf"))); // child scan // clean up resources metadrawLogic.CleanUpResources(); Assert.That(!metadrawLogic.FilteredListOfPsms.Any()); Assert.That(!metadrawLogic.PsmResultFilePaths.Any()); Assert.That(!metadrawLogic.SpectraFilePaths.Any()); // delete output Directory.Delete(outputFolder, true); }