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 GenerateDefaultTaskTomls(string folderLocation) { try { if (!Directory.Exists(folderLocation)) { Directory.CreateDirectory(folderLocation); } CalibrationTask c = new CalibrationTask(); Toml.WriteFile(c, Path.Combine(folderLocation, @"CalibrationTask.toml"), MetaMorpheusTask.tomlConfig); GptmdTask g = new GptmdTask(); Toml.WriteFile(g, Path.Combine(folderLocation, @"GptmdTask.toml"), MetaMorpheusTask.tomlConfig); SearchTask s = new SearchTask(); Toml.WriteFile(s, Path.Combine(folderLocation, @"SearchTask.toml"), MetaMorpheusTask.tomlConfig); XLSearchTask xl = new XLSearchTask(); Toml.WriteFile(xl, Path.Combine(folderLocation, @"XLSearchTask.toml"), MetaMorpheusTask.tomlConfig); GlycoSearchTask glyco = new GlycoSearchTask(); Toml.WriteFile(glyco, Path.Combine(folderLocation, @"GlycoSearchTask.toml"), MetaMorpheusTask.tomlConfig); } catch (Exception e) { throw new MetaMorpheusException("Default tomls could not be written: " + e.Message); } }
public XLSearchTaskWindow() { InitializeComponent(); PopulateChoices(); TheTask = new XLSearchTask(); UpdateFieldsFromTask(TheTask); this.saveButton.Content = "Add the XLSearch Task"; dataContextForSearchTaskWindow = new DataContextForSearchTaskWindow() { ExpanderTitle = string.Join(", ", SearchModesForThisTask.Where(b => b.Use).Select(b => b.Name)), //ModExpanderTitle = //"fixed: " //+ string.Join(",", ModFileListInWindow.Where(b => b.Fixed).Select(b => b.FileName)) //+ " variable: " //+ string.Join(",", ModFileListInWindow.Where(b => b.Variable).Select(b => b.FileName)) //+ " localize: " //+ string.Join(",", ModFileListInWindow.Where(b => b.Localize).Select(b => b.FileName)), AnalysisExpanderTitle = "Some analysis properties...", SearchModeExpanderTitle = "Some search properties..." }; this.DataContext = dataContextForSearchTaskWindow; }
public XLSearchTaskWindow(XLSearchTask task) { InitializeComponent(); PopulateChoices(); TheTask = task; UpdateFieldsFromTask(TheTask); DataContextForSearchTaskWindow = new DataContextForSearchTaskWindow() { ExpanderTitle = string.Join(", ", SearchModesForThisTask.Where(b => b.Use).Select(b => b.Name)), AnalysisExpanderTitle = "Some analysis properties...", SearchModeExpanderTitle = "Some search properties..." }; this.DataContext = DataContextForSearchTaskWindow; }
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 XLSearchTaskWindow(XLSearchTask task) { InitializeComponent(); PopulateChoices(); TheTask = task ?? new XLSearchTask(); UpdateFieldsFromTask(TheTask); if (task == null) { this.saveButton.Content = "Add the XLSearch Task"; } DataContextForSearchTaskWindow = new DataContextForSearchTaskWindow() { ExpanderTitle = string.Join(", ", SearchModesForThisTask.Where(b => b.Use).Select(b => b.Name)), AnalysisExpanderTitle = "Some analysis properties...", SearchModeExpanderTitle = "Some search properties..." }; this.DataContext = DataContextForSearchTaskWindow; SearchModifications.Timer.Tick += new EventHandler(TextChangeTimerHandler); base.Closing += this.OnClosing; }
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 XlTest_BSA_DSSO() { //Generate parameters var commonParameters = new CommonParameters(doPrecursorDeconvolution: false, cIons: true, zDotIons: true, scoreCutoff: 2, digestionParams: new DigestionParams(minPeptideLength: 5)); var xlSearchParameters = new XlSearchParameters { XlCharge_2_3_PrimeFragment = true }; //Create databases contain two protein. var proteinList = new List <Protein> { new Protein("EKVLTSSAR", "Fake01"), new Protein("LSQKFPK", "Fake02") }; ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); ModificationWithMass mod1 = new ModificationWithMass("Oxidation of M", "Common Variable", motif1, TerminusLocalization.Any, 15.99491461957); ModificationMotif.TryGetMotif("C", out ModificationMotif motif2); ModificationWithMass mod2 = new ModificationWithMass("Carbamidomethyl of C", "Common Fixed", motif2, TerminusLocalization.Any, 57.02146372068994); var variableModifications = new List <ModificationWithMass>() { mod1 }; var fixedModifications = new List <ModificationWithMass>() { mod2 }; var localizeableModifications = new List <ModificationWithMass>(); var lp = new List <ProductType> { ProductType.BnoB1ions, ProductType.Y, ProductType.C, ProductType.Zdot }; Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int i = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } //Generate digested peptide lists. List <PeptideWithSetModifications> digestedList = new List <PeptideWithSetModifications>(); foreach (var item in proteinList) { var digested = item.Digest(commonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); digestedList.AddRange(digested); } foreach (var fdfd in digestedList) { fdfd.CompactPeptide(TerminusType.None); } //Run index engine var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, lp, 1, DecoyType.Reverse, new List <DigestionParams> { commonParameters.DigestionParams }, commonParameters, 30000, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); var fragmentIndexCount = indexResults.FragmentIndex.Count(p => p != null); var fragmentIndexAll = indexResults.FragmentIndex.Select((s, j) => new { j, s }).Where(p => p.s != null).Select(t => t.j).ToList(); Assert.IsTrue(fragmentIndexAll.Count() > 0); //Get MS2 scans. var myMsDataFile = new XLTestDataFile(); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, commonParameters.DoPrecursorDeconvolution, commonParameters.UseProvidedPrecursorInfo, commonParameters.DeconvolutionIntensityRatio, commonParameters.DeconvolutionMaxAssumedChargeState, commonParameters.DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); //Generate crosslinker, which is DSSO here. CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(xlSearchParameters.CrosslinkerType); //TwoPassCrosslinkSearchEngine.Run(). List <PsmCross> newPsms = new List <PsmCross>(); new TwoPassCrosslinkSearchEngine(newPsms, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, lp, 0, commonParameters, false, xlSearchParameters.XlPrecusorMsTl, crosslinker, xlSearchParameters.CrosslinkSearchTop, xlSearchParameters.CrosslinkSearchTopNum, xlSearchParameters.XlQuench_H2O, xlSearchParameters.XlQuench_NH2, xlSearchParameters.XlQuench_Tris, xlSearchParameters.XlCharge_2_3, xlSearchParameters.XlCharge_2_3_PrimeFragment, new List <string> { }).Run(); var compactPeptideToProteinPeptideMatch = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); new CrosslinkAnalysisEngine(newPsms, compactPeptideToProteinPeptideMatch, proteinList, variableModifications, fixedModifications, lp, null, crosslinker, TerminusType.None, commonParameters, new List <string> { }).Run(); foreach (var item in newPsms) { item.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); } //Test newPsms Assert.AreEqual(newPsms.Count(), 3); //Test Output var task = new XLSearchTask(); task.WriteAllToTsv(newPsms, TestContext.CurrentContext.TestDirectory, "allPsms", new List <string> { }); task.WritePepXML_xl(newPsms, proteinList, null, variableModifications, fixedModifications, null, TestContext.CurrentContext.TestDirectory, "pep.XML", new List <string> { }); task.WriteSingleToTsv(newPsms.Where(p => p.CrossType == PsmCrossType.Singe).ToList(), TestContext.CurrentContext.TestDirectory, "singlePsms", new List <string> { }); //Test PsmCross.XlCalculateTotalProductMasses. var psmCrossAlpha = new PsmCross(digestedList[1].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0], commonParameters.DigestionParams); var psmCrossBeta = new PsmCross(digestedList[2].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0], commonParameters.DigestionParams); var linkPos = PsmCross.XlPosCal(psmCrossAlpha.compactPeptide, crosslinker.CrosslinkerModSites); var productMassesAlphaList = PsmCross.XlCalculateTotalProductMasses(psmCrossAlpha, psmCrossBeta.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, lp, true, false, linkPos); Assert.AreEqual(productMassesAlphaList[0].ProductMz.Length, 99); }
private void UpdateFieldsFromTask(XLSearchTask task) { //Crosslink search para //RbSearchCrosslink.IsChecked = !task.XlSearchParameters.SearchGlyco; //RbSearchGlyco.IsChecked = task.XlSearchParameters.SearchGlyco; cbCrosslinkers.SelectedItem = task.XlSearchParameters.Crosslinker; ckbXLTopNum.IsChecked = task.XlSearchParameters.RestrictToTopNHits; txtXLTopNum.Text = task.XlSearchParameters.CrosslinkSearchTopNum.ToString(CultureInfo.InvariantCulture); ckbCrosslinkAtCleavageSite.IsChecked = task.XlSearchParameters.CrosslinkAtCleavageSite; ckbQuenchH2O.IsChecked = task.XlSearchParameters.XlQuench_H2O; ckbQuenchNH2.IsChecked = task.XlSearchParameters.XlQuench_NH2; ckbQuenchTris.IsChecked = task.XlSearchParameters.XlQuench_Tris; cbbXLprecusorMsTl.SelectedIndex = task.CommonParameters.PrecursorMassTolerance is AbsoluteTolerance ? 0 : 1; XLPrecusorMsTlTextBox.Text = task.CommonParameters.PrecursorMassTolerance.Value.ToString(CultureInfo.InvariantCulture); trimMs1.IsChecked = task.CommonParameters.TrimMs1Peaks; trimMsMs.IsChecked = task.CommonParameters.TrimMsMsPeaks; TopNPeaksTextBox.Text = task.CommonParameters.NumberOfPeaksToKeepPerWindow == int.MaxValue || !task.CommonParameters.NumberOfPeaksToKeepPerWindow.HasValue ? "" : task.CommonParameters.NumberOfPeaksToKeepPerWindow.Value.ToString(CultureInfo.InvariantCulture); MinRatioTextBox.Text = task.CommonParameters.MinimumAllowedIntensityRatioToBasePeak == double.MaxValue || !task.CommonParameters.MinimumAllowedIntensityRatioToBasePeak.HasValue ? "" : task.CommonParameters.MinimumAllowedIntensityRatioToBasePeak.Value.ToString(CultureInfo.InvariantCulture); DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); if (task.CommonParameters.ChildScanDissociationType != DissociationType.Unknown) { ChildScanDissociationTypeComboBox.SelectedItem = task.CommonParameters.ChildScanDissociationType.ToString(); } checkBoxDecoy.IsChecked = task.XlSearchParameters.DecoyType != DecoyType.None; deconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; useProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; productMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); productMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); minScoreAllowed.Text = task.CommonParameters.ScoreCutoff.ToString(CultureInfo.InvariantCulture); numberOfDatabaseSearchesTextBox.Text = task.CommonParameters.TotalPartitions.ToString(CultureInfo.InvariantCulture); maxThreadsTextBox.Text = task.CommonParameters.MaxThreadsToUsePerFile.ToString(CultureInfo.InvariantCulture); CustomFragmentationWindow = new CustomFragmentationWindow(task.CommonParameters.CustomIons); ckbPercolator.IsChecked = task.XlSearchParameters.WriteOutputForPercolator; ckbPepXML.IsChecked = task.XlSearchParameters.WritePepXml; OutputFileNameTextBox.Text = task.CommonParameters.TaskDescriptor; foreach (var mod in task.CommonParameters.ListOfModsFixed) { var theModType = FixedModTypeForTreeViewObservableCollection.FirstOrDefault(b => b.DisplayName.Equals(mod.Item1)); if (theModType != null) { var theMod = theModType.Children.FirstOrDefault(b => b.ModName.Equals(mod.Item2)); if (theMod != null) { theMod.Use = true; } else { theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } else { theModType = new ModTypeForTreeView(mod.Item1, true); FixedModTypeForTreeViewObservableCollection.Add(theModType); theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } foreach (var mod in task.CommonParameters.ListOfModsVariable) { var theModType = VariableModTypeForTreeViewObservableCollection.FirstOrDefault(b => b.DisplayName.Equals(mod.Item1)); if (theModType != null) { var theMod = theModType.Children.FirstOrDefault(b => b.ModName.Equals(mod.Item2)); if (theMod != null) { theMod.Use = true; } else { theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } else { theModType = new ModTypeForTreeView(mod.Item1, true); VariableModTypeForTreeViewObservableCollection.Add(theModType); theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } foreach (var ye in VariableModTypeForTreeViewObservableCollection) { ye.VerifyCheckState(); } foreach (var ye in FixedModTypeForTreeViewObservableCollection) { ye.VerifyCheckState(); } }
private void UpdateFieldsFromTask(XLSearchTask task) { //Crosslink search para cbCrosslinker.SelectedIndex = (int)task.XlSearchParameters.CrosslinkerType; //cbFragmentation.SelectedIndex = (int)task.XlSearchParameters.FragmentationType; ckbXLTopNum.IsChecked = task.XlSearchParameters.CrosslinkSearchTop; txtXLTopNum.Text = task.XlSearchParameters.CrosslinkSearchTopNum.ToString(CultureInfo.InvariantCulture); ckbQuenchH2O.IsChecked = task.XlSearchParameters.XlQuench_H2O; ckbQuenchNH2.IsChecked = task.XlSearchParameters.XlQuench_NH2; ckbQuenchTris.IsChecked = task.XlSearchParameters.XlQuench_Tris; //ckbSearchWithXLAllBeta.IsChecked = task.XlSearchParameters.CrosslinkSearchWithAllBeta; txtUdXLKerName.Text = task.XlSearchParameters.UdXLkerName; ckbUdXLkerCleavable.IsChecked = task.XlSearchParameters.UdXLkerCleavable; txtUdXLkerTotalMs.Text = task.XlSearchParameters.UdXLkerTotalMass.HasValue ? task.XlSearchParameters.UdXLkerTotalMass.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerShortMass.Text = task.XlSearchParameters.UdXLkerShortMass.HasValue ? task.XlSearchParameters.UdXLkerShortMass.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerLongMass.Text = task.XlSearchParameters.UdXLkerLongMass.HasValue ? task.XlSearchParameters.UdXLkerLongMass.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerLoopMass.Text = task.XlSearchParameters.UdXLkerLoopMass.HasValue ? task.XlSearchParameters.UdXLkerLoopMass.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerAminoAcid.Text = task.XlSearchParameters.UdXLkerResidue.ToString(); txtUdXLkerDeadendH2O.Text = task.XlSearchParameters.UdXLkerDeadendMassH2O.HasValue ? task.XlSearchParameters.UdXLkerDeadendMassH2O.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerDeadendNH2.Text = task.XlSearchParameters.UdXLkerDeadendMassNH2.HasValue ? task.XlSearchParameters.UdXLkerDeadendMassNH2.Value.ToString(CultureInfo.InvariantCulture) : ""; txtUdXLkerDeadendTris.Text = task.XlSearchParameters.UdXLkerDeadendMassTris.HasValue ? task.XlSearchParameters.UdXLkerDeadendMassTris.Value.ToString(CultureInfo.InvariantCulture) : ""; cbbXLprecusorMsTl.SelectedIndex = task.XlSearchParameters.XlPrecusorMsTl is AbsoluteTolerance ? 0 : 1; txtXLPrecusorMsTl.Text = task.XlSearchParameters.XlPrecusorMsTl.Value.ToString(CultureInfo.InvariantCulture); //cbbXLBetaprecusorMsTl.SelectedIndex = task.XlSearchParameters.XlPrecusorMsTl is AbsoluteTolerance ? 0 : 1; //txtXLBetaPrecusorMsTl.Text = task.XlSearchParameters.XlPrecusorMsTl.Value.ToString(CultureInfo.InvariantCulture); trimMs1.IsChecked = task.CommonParameters.TrimMs1Peaks; trimMsMs.IsChecked = task.CommonParameters.TrimMsMsPeaks; TopNPeaksCheckBox.Text = task.CommonParameters.TopNpeaks.HasValue ? task.CommonParameters.TopNpeaks.Value.ToString(CultureInfo.InvariantCulture) : ""; MinRatioCheckBox.Text = task.CommonParameters.MinRatio.HasValue ? task.CommonParameters.MinRatio.Value.ToString(CultureInfo.InvariantCulture) : ""; ckbCharge_2_3.IsChecked = task.XlSearchParameters.XlCharge_2_3; ckbCharge_2_3_PrimeFragments.IsChecked = task.XlSearchParameters.XlCharge_2_3_PrimeFragment; checkBoxDecoy.IsChecked = task.XlSearchParameters.DecoyType != DecoyType.None; deconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; useProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); txtMinPeptideLength.Text = task.CommonParameters.DigestionParams.MinPeptideLength.HasValue ? task.CommonParameters.DigestionParams.MinPeptideLength.Value.ToString(CultureInfo.InvariantCulture) : ""; txtMaxPeptideLength.Text = task.CommonParameters.DigestionParams.MaxPeptideLength.HasValue ? task.CommonParameters.DigestionParams.MaxPeptideLength.Value.ToString(CultureInfo.InvariantCulture) : ""; proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; productMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); productMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; bCheckBox.IsChecked = task.CommonParameters.BIons; yCheckBox.IsChecked = task.CommonParameters.YIons; cCheckBox.IsChecked = task.CommonParameters.CIons; zdotCheckBox.IsChecked = task.CommonParameters.ZdotIons; minScoreAllowed.Text = task.CommonParameters.ScoreCutoff.ToString(CultureInfo.InvariantCulture); ckbAllResults.IsChecked = task.XlSearchParameters.XlOutAll; ckbPercolator.IsChecked = task.XlSearchParameters.XlOutPercolator; ckbCrosslink.IsChecked = task.XlSearchParameters.XlOutCrosslink; ckbPepXML.IsChecked = task.XlSearchParameters.XlOutPepXML; OutputFileNameTextBox.Text = task.CommonParameters.TaskDescriptor; foreach (var mod in task.CommonParameters.ListOfModsFixed) { var theModType = fixedModTypeForTreeViewObservableCollection.FirstOrDefault(b => b.DisplayName.Equals(mod.Item1)); if (theModType != null) { var theMod = theModType.Children.FirstOrDefault(b => b.DisplayName.Equals(mod.Item2)); if (theMod != null) { theMod.Use = true; } else { theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } else { theModType = new ModTypeForTreeView(mod.Item1, true); fixedModTypeForTreeViewObservableCollection.Add(theModType); theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } foreach (var mod in task.CommonParameters.ListOfModsVariable) { var theModType = variableModTypeForTreeViewObservableCollection.FirstOrDefault(b => b.DisplayName.Equals(mod.Item1)); if (theModType != null) { var theMod = theModType.Children.FirstOrDefault(b => b.DisplayName.Equals(mod.Item2)); if (theMod != null) { theMod.Use = true; } else { theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } else { theModType = new ModTypeForTreeView(mod.Item1, true); variableModTypeForTreeViewObservableCollection.Add(theModType); theModType.Children.Add(new ModForTreeView("UNKNOWN MODIFICATION!", true, mod.Item2, true, theModType)); } } localizeAllCheckBox.IsChecked = task.CommonParameters.LocalizeAll; if (task.CommonParameters.LocalizeAll) { foreach (var heh in localizeModTypeForTreeViewObservableCollection) { heh.Use = false; } } else { foreach (var heh in localizeModTypeForTreeViewObservableCollection) { if (task.CommonParameters.ListOfModTypesLocalize.Contains(heh.DisplayName)) { heh.Use = true; } else { heh.Use = false; } } } foreach (var ye in variableModTypeForTreeViewObservableCollection) { ye.VerifyCheckState(); } foreach (var ye in fixedModTypeForTreeViewObservableCollection) { ye.VerifyCheckState(); } }
public static void XlTest_BSA_DSSO() { //Generate parameters var commonParameters = new CommonParameters(doPrecursorDeconvolution: false, dissociationType: DissociationType.EThcD, scoreCutoff: 1, digestionParams: new DigestionParams(minPeptideLength: 5), precursorMassTolerance: new PpmTolerance(10)); var xlSearchParameters = new XlSearchParameters(); //Create databases contain two protein. var proteinList = new List <Protein> { new Protein("EKVLTSSAR", "Fake01"), new Protein("LSQKFPK", "Fake02") }; ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); Modification mod1 = new Modification(_originalId: "Oxidation of M", _modificationType: "Common Variable", _target: motif1, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.99491461957); ModificationMotif.TryGetMotif("C", out ModificationMotif motif2); Modification mod2 = new Modification(_originalId: "Carbamidomethyl of C", _modificationType: "Common Fixed", _target: motif2, _locationRestriction: "Anywhere.", _monoisotopicMass: 57.02146372068994); var variableModifications = new List <Modification>() { mod1 }; var fixedModifications = new List <Modification>() { mod2 }; var localizeableModifications = new List <Modification>(); //Run index engine var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.Reverse, commonParameters, 30000, false, new List <FileInfo>(), new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); var indexedFragments = indexResults.FragmentIndex.Where(p => p != null).SelectMany(v => v).ToList(); Assert.AreEqual(82, indexedFragments.Count); Assert.AreEqual(3, indexResults.PeptideIndex.Count); //Get MS2 scans. var myMsDataFile = new XLTestDataFile(); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //Generate crosslinker, which is DSSO here. Crosslinker crosslinker = GlobalVariables.Crosslinkers.Where(p => p.CrosslinkerName == "DSSO").First(); CrosslinkSpectralMatch[] possiblePsms = new CrosslinkSpectralMatch[listOfSortedms2Scans.Length]; new CrosslinkSearchEngine(possiblePsms, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, commonParameters, crosslinker, xlSearchParameters.RestrictToTopNHits, xlSearchParameters.CrosslinkSearchTopNum, xlSearchParameters.XlQuench_H2O, xlSearchParameters.XlQuench_NH2, xlSearchParameters.XlQuench_Tris, new List <string> { }).Run(); var newPsms = possiblePsms.Where(p => p != null).ToList(); foreach (var item in newPsms) { item.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); } //Test newPsms Assert.AreEqual(3, newPsms.Count); //Test Output var task = new XLSearchTask(); task.WritePepXML_xl(newPsms, proteinList, null, variableModifications, fixedModifications, null, TestContext.CurrentContext.TestDirectory, "pep.XML", new List <string> { }); //Test PsmCross.XlCalculateTotalProductMasses //var psmCrossAlpha = new CrosslinkSpectralMatch(digestedList[1], 0, 0, 0, listOfSortedms2Scans[0], commonParameters.DigestionParams, new List<MatchedFragmentIon>()); //var psmCrossBeta = new CrosslinkSpectralMatch(digestedList[2], 0, 0, 0, listOfSortedms2Scans[0], commonParameters.DigestionParams, new List<MatchedFragmentIon>()); //var linkPos = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), digestedList[1]); //var productMassesAlphaList = CrosslinkedPeptide.XlGetTheoreticalFragments(DissociationType.EThcD, false, crosslinker, linkPos, digestedList[2].MonoisotopicMass, digestedList[1]); //Assert.AreEqual(productMassesAlphaList.First().Value.Count, 50); //TO DO: The number here should be manually verified. File.Delete(@"singlePsms.tsv"); File.Delete(@"pep.XML.pep.xml"); File.Delete(@"allPsms.tsv"); }
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); }