protected override void DoTest() { RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("ImportHighPrecTranList.sky"))); RunUI(() => SkylineWindow.ImportMassList(TestFilesDir.GetTestPath("ThermoTransitionList.csv"))); var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true)); RunUI(() => documentGrid.ChooseView("PeptideModSeqFullNames")); VerifyExpectedPeptides(documentGrid); AssertEx.VerifyModifiedSequences(SkylineWindow.Document); Assert.AreNotEqual(0, SkylineWindow.Document.PeptideCount); RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); }); Assert.AreEqual(0, SkylineWindow.Document.PeptideCount); // TODO(nicksh): Try importing SciEx transition list. }
private void TestDeleteUndo(TreeNode expectedSelNode) { if (_expectedSelNodes.Count > 0) { // Test delete nodes, copying the exepcted selection to temporary variables. RunUI(() => SkylineWindow.EditDelete()); var tempSelNodes = new Identity[_expectedSelNodes.Count]; _expectedSelNodes.CopyTo(tempSelNodes, 0); ClearExpectedSelection(); Identity tempSelNode = _expectedSelNode; var srmNode = expectedSelNode as SrmTreeNode; _expectedSelNode = srmNode != null ? srmNode.Model.Id : SequenceTree.NODE_INSERT_ID; ExpectedSelNodesAddRemove(expectedSelNode, true); CheckSelectedNodes(); // Testing Undo, check that selection has been properly restored, including expansion. RunUI(() => { SkylineWindow.SequenceTree.CollapseAll(); SkylineWindow.Undo(); }); ClearExpectedSelection(); foreach (Identity i in tempSelNodes) { _expectedSelNodes.Add(i); } ICollection <TreeNodeMS> seqTreeNodes = null; RunUI(() => seqTreeNodes = SkylineWindow.SequenceTree.SelectedNodes); foreach (TreeNodeMS node in seqTreeNodes) { bool expanded = false; TreeNodeMS ms = node; RunUI(() => expanded = ms.IsExpanded || ms.Nodes.Count == 0); Assert.IsTrue(expanded); } _expectedSelNode = tempSelNode; CheckSelectedNodes(); } }
private void TestInsertNode() { // Insert node cannot be deleted. // Insert node becomes new anchor for range select following delete. TreeNode node = null; RunUI(() => { SkylineWindow.SequenceTree.CollapseAll(); node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 2]; }); ExpectedSelNodesAddRemove(node, true); TestSelectNode(node, null); RunUI(() => node = node.NextNode); ExpectedSelNodesAddRemove(node, true); TestSelectNode(node, Keys.Shift); ClearExpectedSelection(); ExpectedSelNodesAddRemove(node, true); RunUI(() => { SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.EditDelete(); node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 2]; }); ExpectedSelNodesAddRemove(node, true); TestSelectNode(node, Keys.Shift); ClearExpectedSelection(); RunUI(() => { SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.SequenceTree.SelectedNode = null; }); }
protected override void DoTest() { // Skyline Targeted Method Refinement var folderMethodRefine = UseRawFiles ? "MethodRefine" : "MethodRefineMzml"; // Not L10N // Results Data, p. 2 var doc = SkylineWindow.Document; RunUI(() => SkylineWindow.OpenFile(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\WormUnrefined.sky"))); // Not L10N WaitForDocumentChangeLoaded(doc); RunUI(() => { // Adjust font sizes for better screen shots Settings.Default.ChromatogramFontSize = 14; Settings.Default.SpectrumFontSize = 14; SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; SkylineWindow.AutoZoomBestPeak(); // TODO: Mention this in the tutorial SkylineWindow.Size = new Size(1160, 660); Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode.Text, "YLGAYLLATLGGNASPSAQDVLK"); // Not L10N }); PauseForScreenShot("Main window", 2); // TODO: Update tutorial to view b-ions. RunUI(() => SkylineWindow.GraphSpectrumSettings.ShowBIons = true); // Unrefined Methods, p. 3 { var exportDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List)); RunUI(() => { exportDlg.ExportStrategy = ExportStrategy.Buckets; exportDlg.MethodType = ExportMethodType.Standard; exportDlg.OptimizeType = ExportOptimize.NONE; exportDlg.MaxTransitions = 59; }); PauseForScreenShot("Export Transition List form", 3); // Not L10N OkDialog(exportDlg, () => exportDlg.OkDialog(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm"))); // Not L10N } for (int i = 1; i < 10; i++) { Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_000" + i + TextUtil.EXT_CSV))); // Not L10N } for (int i = 10; i < 40; i++) { Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_00" + i + TextUtil.EXT_CSV))); // Not L10N } // Importing Multiple Injection Data, p. 4 Assert.IsTrue(SkylineWindow.Document.Settings.HasResults); RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg => { manageResultsDlg.RemoveReplicates(); Assert.AreEqual(manageResultsDlg.Chromatograms.ToArray().Length, 0); manageResultsDlg.OkDialog(); }); RunUI(() => SkylineWindow.SaveDocument()); Assert.IsFalse(SkylineWindow.Document.Settings.HasResults); const string replicateName = "Unrefined"; // Not L10N RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg => { importResultsDlg.RadioAddNewChecked = true; var namedPathSets = DataSourceUtil.GetDataSourcesInSubdirs(TestFilesDirs[0].FullPath).ToArray(); importResultsDlg.NamedPathSets = new[] { new KeyValuePair <string, MsDataFileUri[]>(replicateName, namedPathSets[0].Value.Take(15).ToArray()) }; importResultsDlg.OkDialog(); }); WaitForOpenForm <AllChromatogramsGraph>(); // To make the AllChromatogramsGraph form accessible to the SkylineTester forms tab PauseForScreenShot <AllChromatogramsGraph>("Loading Chromatograms: Take screenshot at about 25% loaded...", 5); WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes Assert.IsTrue(SkylineWindow.Document.Settings.HasResults); Assert.AreEqual(15, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length); RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg => { importResultsDlg.RadioAddExistingChecked = true; var namedPathSets = DataSourceUtil.GetDataSourcesInSubdirs(TestFilesDirs[0].FullPath).ToArray(); importResultsDlg.NamedPathSets = new[] { new KeyValuePair <string, MsDataFileUri[]>(replicateName, namedPathSets[0].Value.Skip(15).ToArray()) }; importResultsDlg.OkDialog(); }); WaitForCondition(20 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes Assert.AreEqual(39, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length); RunUI(SkylineWindow.AutoZoomNone); RestoreViewOnScreen(7); PauseForScreenShot("Chromatogram graph metafile", 7); // Simple Manual Refinement, p. 6 int startingNodeCount = SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false); Assert.AreEqual("YLGAYLLATLGGNASPSAQDVLK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); // Not L10N RunUI(() => { SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; SkylineWindow.AutoZoomNone(); SkylineWindow.AutoZoomBestPeak(); SkylineWindow.EditDelete(); SkylineWindow.ShowRTLinearRegressionGraph(); }); Assert.AreEqual(SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false), startingNodeCount - 1); Assert.AreEqual("VLEAGGLDCDMENANSVVDALK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); // Not L10N PauseForScreenShot("Retention Times Regression plot metafile", 8); RunDlg <RegressionRTThresholdDlg>(SkylineWindow.ShowRegressionRTThresholdDlg, rtThresholdDlg => { rtThresholdDlg.Threshold = 0.95; rtThresholdDlg.OkDialog(); }); WaitForConditionUI(() => SkylineWindow.RTGraphController.RegressionRefined != null); WaitForGraphs(); PauseForScreenShot("Retention Times Regression plot metafile with 0.95 threshold", 9); // Not L10N TestRTResidualsSwitch(); RunDlg <EditRTDlg>(SkylineWindow.CreateRegression, editRTDlg => editRTDlg.OkDialog()); RunUI(() => SkylineWindow.ShowGraphRetentionTime(false)); RunUI(SkylineWindow.AutoZoomNone); PauseForScreenShot("Chromatogram graph metafile zoomed out", 10); // Not L10N // Missing Data, p. 10 RunUI(() => { SkylineWindow.RTGraphController.SelectPeptide(SkylineWindow.Document.GetPathTo(1, 163)); Assert.AreEqual("YLAEVASEDR", SkylineWindow.SequenceTree.SelectedNode.Text); // Not L10N }); RestoreViewOnScreen(11); // Restoring the view changes the selection RunUI(SkylineWindow.CollapsePeptides); FindNode("YLAEVASEDR"); RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[153]); PauseForScreenShot("Targets view clipped from the main window", 11); RunUI(() => { var nodePep = (PeptideDocNode)((SrmTreeNode)SkylineWindow.SequenceTree.SelectedNode).Model; Assert.AreEqual(null, nodePep.GetPeakCountRatio( SkylineWindow.SequenceTree.GetDisplayResultsIndex(nodePep))); SkylineWindow.SequenceTree.SelectedPath = SkylineWindow.Document.GetPathTo(1, 157); Assert.AreEqual("VTVVDDQSVILK", SkylineWindow.SequenceTree.SelectedNode.Text); }); WaitForGraphs(); RunUI(() => { SkylineWindow.ActivateReplicate("Unrefined"); SkylineWindow.AutoZoomNone(); }); PauseForScreenShot("Unrefined chromatogram graph page clipped from main window", 12); // Not L10N // foreach (var peptideDocNode in SkylineWindow.Document.Peptides) // { // var nodeGroup = ((TransitionGroupDocNode)peptideDocNode.Children[0]); // Console.WriteLine("{0} - {1}", peptideDocNode.Peptide.Sequence, // nodeGroup.GetDisplayText(SkylineWindow.SequenceTree.GetDisplaySettings(peptideDocNode))); // } // Console.WriteLine("---------------------------------"); RunUI(() => { var graphChrom = SkylineWindow.GetGraphChrom("Unrefined"); // Not L10N Assert.AreEqual(2, graphChrom.Files.Count); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0]; // Picking Measurable Peptides and Transitions, p. 12 SkylineWindow.ExpandPeptides(); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; }); RunUI(SkylineWindow.AutoZoomBestPeak); RestoreViewOnScreen(13); RunUI(() => SkylineWindow.ShowGraphSpectrum(false)); PauseForScreenShot("Targets view clipped from the main window and chromatogram graph metafile", 13); RunUI(() => SkylineWindow.ShowGraphSpectrum(true)); PauseForScreenShot("Library Match plot metafile", 14); RunUI(() => { SkylineWindow.ShowGraphSpectrum(false); SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 0); SkylineWindow.SelectedNode.Expand(); SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0); }); PauseForScreenShot("Targetes view clipped from the main window", 14); // Not L10N RunUI(() => { double dotpExpect = Math.Round(Statistics.AngleToNormalizedContrastAngle(0.78), 2); // 0.57 AssertEx.Contains(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text, dotpExpect.ToString(LocalizationHelper.CurrentCulture)); SkylineWindow.EditDelete(); dotpExpect = 0.34; // Math.Round(Statistics.AngleToNormalizedContrastAngle(0.633), 2); // 0.44 SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; AssertEx.Contains(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text, dotpExpect.ToString(LocalizationHelper.CurrentCulture)); SkylineWindow.EditDelete(); PeptideTreeNode nodePep; for (int i = 0; i < 2; i++) { nodePep = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[i]; nodePep.ExpandAll(); foreach (TransitionTreeNode nodeTran in nodePep.Nodes[0].Nodes) { TransitionDocNode nodeTranDoc = (TransitionDocNode)nodeTran.Model; Assert.AreEqual((int)SequenceTree.StateImageId.peak, TransitionTreeNode.GetPeakImageIndex(nodeTranDoc, (PeptideDocNode)nodePep.Model, SkylineWindow.SequenceTree)); var resultsIndex = SkylineWindow.SequenceTree.GetDisplayResultsIndex(nodePep); var rank = nodeTranDoc.GetPeakRank(resultsIndex); if (rank == null || rank > 3) { SkylineWindow.SequenceTree.SelectedNode = nodeTran; } SkylineWindow.SequenceTree.KeysOverride = Keys.Control; } } nodePep = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[2]; nodePep.ExpandAll(); foreach (TransitionTreeNode nodeTran in nodePep.Nodes[0].Nodes) { TransitionDocNode nodeTranDoc = (TransitionDocNode)nodeTran.Model; Assert.AreEqual((int)SequenceTree.StateImageId.peak, TransitionTreeNode.GetPeakImageIndex(nodeTranDoc, (PeptideDocNode)nodePep.Model, SkylineWindow.SequenceTree)); var name = ((TransitionDocNode)nodeTran.Model).FragmentIonName; if (!(name == "y11" || name == "y13" || name == "y14")) // Not L10N { SkylineWindow.SequenceTree.SelectedNode = nodeTran; } SkylineWindow.SequenceTree.KeysOverride = Keys.Control; } SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.EditDelete(); for (int i = 0; i < 3; i++) { Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Nodes[i].Nodes[0].Nodes.Count == 3); } SkylineWindow.AutoZoomNone(); SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 5); SkylineWindow.Size = new Size(722, 449); }); RunUI(SkylineWindow.AutoZoomBestPeak); RestoreViewOnScreen(15); PauseForScreenShot("Targetes view clipped from main window and chromatogram graph metafile", 15); // Automated Refinement, p. 16 RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg => { refineDlg.MaxTransitionPeakRank = 3; refineDlg.PreferLargerIons = true; refineDlg.RemoveMissingResults = true; refineDlg.RTRegressionThreshold = 0.95; refineDlg.DotProductThreshold = Statistics.AngleToNormalizedContrastAngle(0.95); // Convert from original cos(angle) dot-product refineDlg.OkDialog(); }); WaitForCondition(() => SkylineWindow.Document.PeptideCount < 73); // foreach (var peptideDocNode in SkylineWindow.Document.Peptides) // { // var nodeGroup = ((TransitionGroupDocNode) peptideDocNode.Children[0]); // Console.WriteLine("{0} - {1}", peptideDocNode.Peptide.Sequence, // nodeGroup.GetDisplayText(SkylineWindow.SequenceTree.GetDisplaySettings(peptideDocNode))); // } RunUI(() => { Assert.AreEqual(72, SkylineWindow.Document.PeptideCount); Assert.AreEqual(216, SkylineWindow.Document.PeptideTransitionCount); SkylineWindow.CollapsePeptides(); SkylineWindow.Undo(); }); RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg => { refineDlg.MaxTransitionPeakRank = 6; refineDlg.RemoveMissingResults = true; refineDlg.RTRegressionThreshold = 0.90; refineDlg.DotProductThreshold = Statistics.AngleToNormalizedContrastAngle(0.90); // Convert from original cos(angle) dot-product refineDlg.OkDialog(); }); WaitForCondition(() => SkylineWindow.Document.PeptideCount < 120); RunUI(() => { Assert.AreEqual(113, SkylineWindow.Document.PeptideCount); // Scheduling for Efficient Acquisition, p. 17 SkylineWindow.Undo(); }); RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, mResults => { Assert.AreEqual(1, mResults.Chromatograms.Count()); mResults.SelectedChromatograms = SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Where( set => Equals("Unrefined", set.Name)); // Not L10N mResults.RemoveReplicates(); Assert.AreEqual(0, mResults.Chromatograms.Count()); mResults.OkDialog(); }); var importResultsDlg0 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults); RunUI(() => { SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0]; importResultsDlg0.RadioCreateMultipleMultiChecked = true; importResultsDlg0.NamedPathSets = DataSourceUtil.GetDataSourcesInSubdirs(Path.Combine(TestFilesDirs[1].FullPath, Path.GetFileName(TestFilesDirs[1].FullPath) ?? string.Empty)).ToArray(); }); var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg0.OkDialog); RunUI(importResultsNameDlg.NoDialog); WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes var docCurrent = SkylineWindow.Document; RunUI(SkylineWindow.RemoveMissingResults); WaitForDocumentChange(docCurrent); Assert.AreEqual(86, SkylineWindow.Document.PeptideCount); Assert.AreEqual(255, SkylineWindow.Document.PeptideTransitionCount); TestRTResidualsSwitch(); // Measuring Retention Times, p. 17 { var exportDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List)); RunUI(() => exportDlg.MaxTransitions = 130); PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 18); OkDialog(exportDlg, () => exportDlg.OkDialog(TestFilesDirs[1].FullPath + "\\unscheduled")); // Not L10N } /////////////////////// // Reviewing Retention Time Runs, p. 18 RunUI(() => { SkylineWindow.ShowGraphSpectrum(false); SkylineWindow.ArrangeGraphsTiled(); SkylineWindow.AutoZoomNone(); SkylineWindow.AutoZoomBestPeak(); }); FindNode("FWEVISDEHGIQPDGTFK"); RunUI(() => SkylineWindow.Size = new Size(1060, 550)); RestoreViewOnScreen(19); PauseForScreenShot("Main window", 19); // Not L10N RunUI(() => SkylineWindow.ShowRTSchedulingGraph()); WaitForCondition(() => SkylineWindow.GraphRetentionTime != null); PauseForScreenShot("Retention Times - Scheduling graph metafile", 19); RestoreViewOnScreen(20); // Creating a Scheduled Transition List, p. 20 { var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Prediction; peptideSettingsUI.TimeWindow = 4; }); PauseForScreenShot <PeptideSettingsUI.PredictionTab>("Peptide Settings - Prediction tab", 21); OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); // Not L10N } var exportMethodDlg1 = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List)); RunUI(() => { exportMethodDlg1.ExportStrategy = ExportStrategy.Single; exportMethodDlg1.MethodType = ExportMethodType.Scheduled; }); // TODO: Update tutorial to mention the scheduling options dialog. PauseForScreenShot("Export Transition List form", 22); // Not L10N RunDlg <SchedulingOptionsDlg>(() => exportMethodDlg1.OkDialog(TestFilesDirs[1].FullPath + "\\scheduled"), // Not L10N schedulingOptionsDlg => schedulingOptionsDlg.OkDialog()); WaitForClosedForm(exportMethodDlg1); // Reviewing Multi-Replicate Data, p. 22 RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg => { manageResultsDlg.RemoveAllReplicates(); manageResultsDlg.OkDialog(); }); var importResultsDlg1 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults); RunDlg <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets = importResultsDlg1.GetDataSourcePathsFile(null), openDataSourceDialog => { openDataSourceDialog.SelectAllFileType(ExtThermoRaw); openDataSourceDialog.Open(); }); RunDlg <ImportResultsNameDlg>(importResultsDlg1.OkDialog, importResultsNameDlg0 => { importResultsNameDlg0.Prefix = "Scheduled_"; // Not L10N importResultsNameDlg0.YesDialog(); }); WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes Assert.AreEqual(5, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden)); RunUI(() => { SkylineWindow.RemoveMissingResults(); SkylineWindow.ArrangeGraphsTiled(); SkylineWindow.ShowGraphRetentionTime(false); }); WaitForCondition(() => SkylineWindow.GraphRetentionTime.IsHidden); RunUI(() => { SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; SkylineWindow.ShowRTReplicateGraph(); SkylineWindow.ShowPeakAreaReplicateComparison(); SkylineWindow.CollapsePeptides(); SkylineWindow.ShowChromatogramLegends(false); SkylineWindow.Size = new Size(1024, 768); }); RestoreViewOnScreen(24); WaitForGraphs(); PauseForScreenShot("Main window", 24); // Not L10N RunUI(() => SkylineWindow.SaveDocument()); RunUI(SkylineWindow.NewDocument); }
protected override void DoTest() { const int numStandardPeps = 11; const int numLibraryPeps = 18; const string irtCalc = "iRT-C18"; const string ssrCalc = "SSRCalc 3.0 (300A)"; var testFilesDir = new TestFilesDir(TestContext, TestFilesZip); string databasePath = testFilesDir.GetTestPath("irt-c18.irtdb"); string documentPath = testFilesDir.GetTestPath("iRT Test.sky"); RunUI(() => SkylineWindow.OpenFile(documentPath)); var peptideSettingsDlg1 = ShowDialog <PeptideSettingsUI>( () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction)); var editRT1 = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression); var irtDlg1 = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator); RunUI(() => { irtDlg1.CalcName = irtCalc; irtDlg1.CreateDatabase(databasePath); }); var calibratePeptides = new List <MeasuredPeptide>(); /* * Check several error handling cases * Check the peptide choosing algorithm for sanity (correct # peptides) * Check that the info dialog comes up when too many are requested * Check the peptide linear transformation for sanity * Check that the peptides get passed back to EditIrtCalcDlg */ var calibrateDlg = ShowDialog <CalibrateIrtDlg>(irtDlg1.Calibrate); //Check the peptide choosing algorithm int peptideCount = SkylineWindow.Document.PeptideCount; //29 peptides in the document //Use the dialog box UI var countDlg = ShowDialog <AddIrtStandardsDlg>(calibrateDlg.UseResults); RunUI(() => countDlg.StandardCount = CalibrateIrtDlg.MIN_STANDARD_PEPTIDES - 1); RunDlg <MessageDlg>(countDlg.OkDialog, messageDlg => messageDlg.OkDialog()); RunUI(() => { countDlg.StandardCount = peptideCount; countDlg.OkDialog(); }); WaitForClosedForm(countDlg); Assert.AreEqual(peptideCount, calibrateDlg.StandardPeptideCount); //Bypass the UI foreach (int i in new[] { peptideCount, peptideCount / 2, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES *2, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES }) { int j = i; RunUI(() => { calibratePeptides = calibrateDlg.Recalculate(SkylineWindow.Document, j); Assert.AreEqual(calibratePeptides.Count, j); Assert.IsNull(FindOpenForm <MessageDlg>()); }); } RunUI(() => { calibrateDlg.Recalculate(SkylineWindow.Document, 11); //After closing this dialog, there should be 3 iRT values below 0 //and 3 above 100 calibrateDlg.SetFixedPoints(3, 7); calibrateDlg.OkDialog(); }); WaitForClosedForm(calibrateDlg); //Now check that the peptides were passed to the EditIrtCalcDlg RunUI(() => { Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount); //And that there are 3 below 0 and 3 above 100 Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt < 0)); Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt > 100)); irtDlg1.ClearStandardPeptides(); }); /* * Test pasting into EditIrtCalcDlg * Test that the dialog requires the whole standard to be in the document * Test that add results gets everything in the document besides the standard * Test that there were no errors along the way */ //Now paste in iRT with each peptide truncated by one amino acid var standard = new[] { BuildMeasuredPeptide("LGGNEQVTR", -24.92), BuildMeasuredPeptide("GAGSSEPVTGLDAK", 0.00), BuildMeasuredPeptide("VEATFGVDESNAK", 12.39), BuildMeasuredPeptide("YILAGVENSK", 19.79), BuildMeasuredPeptide("TPVISGGPYEYR", 28.71), BuildMeasuredPeptide("TPVITGAPYEYR", 33.38), BuildMeasuredPeptide("DGLDAASYYAPVR", 42.26), BuildMeasuredPeptide("ADVTPADFSEWSK", 54.62), BuildMeasuredPeptide("GTFIIDPGGVIR", 70.52), BuildMeasuredPeptide("GTFIIDPAAVIR", 87.23), BuildMeasuredPeptide("LFLQFGAQGSPFLK", 100.00), }; RunUI(() => { string standardText = BuildStandardText(standard, seq => seq.Substring(0, seq.Length - 1)); SetClipboardText(standardText); irtDlg1.DoPasteStandard(); }); // Cannot add results because standard peptides are not in the document RunDlg <AddIrtPeptidesDlg>(irtDlg1.AddResults, messageDlg => messageDlg.OkDialog()); // Paste Biognosys-provided values RunUI(() => { string standardText = BuildStandardText(standard, seq => seq); SetClipboardText(standardText); irtDlg1.ClearStandardPeptides(); irtDlg1.DoPasteStandard(); //Check count Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount); }); //Add results var addPeptidesDlg1 = ShowDialog <AddIrtPeptidesDlg>(irtDlg1.AddResults); var recalibrateDlg1 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg1.OkDialog); OkDialog(recalibrateDlg1, recalibrateDlg1.Btn1Click); RunUI(() => Assert.AreEqual(numLibraryPeps, irtDlg1.LibraryPeptideCount)); // Recalibrate const int shift = 100; const int skew = 10; RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg => { recalDlg.MinIrt = standard[1].RetentionTime + shift; recalDlg.MaxIrt = standard[standard.Length - 1].RetentionTime * skew + shift; recalDlg.FixedPoint1 = standard[1].Sequence; recalDlg.FixedPoint2 = standard[standard.Length - 1].Sequence; recalDlg.OkDialog(); }); RunUI(() => { for (int i = 0; i < irtDlg1.StandardPeptideCount; i++) { Assert.AreEqual(standard[i].RetentionTime * skew + shift, irtDlg1.StandardPeptides.Skip(i).First().Irt); } }); RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg => { recalDlg.FixedPoint1 = standard[2].Sequence; recalDlg.FixedPoint2 = standard[standard.Length - 2].Sequence; recalDlg.MinIrt = standard[2].RetentionTime; recalDlg.MaxIrt = standard[standard.Length - 2].RetentionTime; recalDlg.OkDialog(); }); // Change peptides var changePeptides = irtDlg1.LibraryPeptides.Where((p, i) => i % 2 == 0).ToArray(); var resetPeptides = irtDlg1.StandardPeptides.ToArray(); RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg => { changeDlg.Peptides = changePeptides; changeDlg.OkDialog(); }); Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Target).ToArray(), irtDlg1.StandardPeptides.Select(p => p.Target).ToArray())); Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Irt).ToArray(), irtDlg1.StandardPeptides.Select(p => p.Irt).ToArray())); RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg => { changeDlg.Peptides = resetPeptides; changeDlg.OkDialog(); }); OkDialog(irtDlg1, irtDlg1.OkDialog); Assert.IsNull(FindOpenForm <MessageDlg>()); /* * Check that the database was created successfully * Check that it has the correct numbers of standard and library peptides */ IrtDb db = IrtDb.GetIrtDb(databasePath, null); Assert.AreEqual(numStandardPeps, db.StandardPeptideCount); Assert.AreEqual(numLibraryPeps, db.LibraryPeptideCount); /* * Make sure that loading the database brings back up the right numbers of peptides */ //Rather than rigging SettingsListComboDriver, just create a new one and load var irtDlg1A = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator); RunDlg <MessageDlg>(() => irtDlg1A.OpenDatabase(testFilesDir.GetTestPath("bogus.irtdb")), messageDlg => messageDlg.OkDialog()); //There was a _bug_ where opening a path and then clicking OK would save all the peptides //twice, doubling the size of the database. So check that that is fixed. EditIrtCalcDlgPepCountTest(irtDlg1A, numStandardPeps, numLibraryPeps, databasePath, false); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, false); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, true); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, false); /* * Create a regression based on the new calculator * Create a regression based on SSRCalc * Open the graph * Switch to new calculator, verify r = 1.00 and graph is labeled iRT-C18 * Switch to SSRCalc, verify graph label changes */ RunUI(() => { editRT1.SetRegressionName("iRT Regression"); editRT1.AddResults(); editRT1.ChooseCalculator(irtCalc); editRT1.OkDialog(); }); WaitForClosedForm(editRT1); var editRT1A = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression); RunUI(() => { editRT1A.SetRegressionName("SSRCalc Regression"); editRT1A.AddResults(); editRT1A.ChooseCalculator(ssrCalc); }); RunDlg <RTDetails>(editRT1A.ShowDetails, detailsDlg => detailsDlg.Close()); OkDialog(editRT1A, editRT1A.OkDialog); RunUI(peptideSettingsDlg1.CancelButton.PerformClick); WaitForClosedForm(peptideSettingsDlg1); var docPeptides = new List <MeasuredRetentionTime>(); RunUI(() => { var document = Program.ActiveDocumentUI; foreach (var docPepNode in document.Peptides) { docPeptides.Add(new MeasuredRetentionTime(document.Settings.GetModifiedSequence(docPepNode), docPepNode.AverageMeasuredRetentionTime ?? 0)); } }); RetentionTimeStatistics stats = null; RegressionLineElement line = null; RunUI(() => SkylineWindow.ShowRTRegressionGraphScoreToRun()); WaitForRegression(); RunUI(() => { SkylineWindow.SetupCalculatorChooser(); SkylineWindow.ChooseCalculator(irtCalc); }); WaitForRegression(); RunUI(() => { stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null); line = SkylineWindow.RTGraphController.RegressionRefined.Conversion as RegressionLineElement; }); Assert.IsNotNull(stats); Assert.IsTrue(stats.R > 0.999); Assert.IsNotNull(line); //These values were taken from the graph, which shows values to 2 decimal places, so the real values must //be +/- 0.01 from these values Assert.IsTrue(Math.Abs(line.Intercept - 14.17) < 0.01); Assert.IsTrue(Math.Abs(line.Slope - 0.15) < 0.01); RunUI(() => SkylineWindow.ChooseCalculator(ssrCalc)); WaitForRegression(); RunUI(() => stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null)); Assert.IsNotNull(stats); Assert.IsTrue(Math.Abs(stats.R - 0.97) < 0.01); /* * Delete all peptides except the standard * Create a new calculator with the document standard (instead of pasting) * Create a regression with that calculator * Export a transition list using measured retention times * Export a method using predicted retention times * Test that they are identical */ //Delete from the document all but the last protein, which has all the standard peptides RunUI(() => { SkylineWindow.CollapseProteins(); var seqTree = SkylineWindow.SequenceTree; seqTree.SelectedNode = seqTree.Nodes[0]; seqTree.KeysOverride = Keys.Shift; seqTree.SelectedNode = seqTree.Nodes[17]; SkylineWindow.EditDelete(); }); //Peptide settings dialog -> Add a regression var peptideSettingsDlg2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); var editRT2 = ShowDialog <EditRTDlg>(peptideSettingsDlg2.AddRTRegression); //Set regression name RunUI(() => editRT2.SetRegressionName("iRT Document Regression")); //Regression dialog -> add a calculator var irtDlg2 = ShowDialog <EditIrtCalcDlg>(editRT2.AddCalculator); //Set calc name, database RunUI(() => { irtDlg2.CalcName = "iRT Document Calculator"; irtDlg2.CreateDatabase(testFilesDir.GetTestPath("irt-doc.irtdb")); }); //Calc dialog -> calibrate standard RunDlg <CalibrateIrtDlg>(irtDlg2.Calibrate, calibrateDlg2 => { //Get 11 peptides from the document (all of them) and go back to calculator dialog calibrateDlg2.Recalculate(SkylineWindow.Document, 11); calibrateDlg2.OkDialog(); }); Assert.AreEqual(11, irtDlg2.StandardPeptideCount); Assert.AreEqual(0, irtDlg2.LibraryPeptideCount); // Close dialog to save calculator OkDialog(irtDlg2, irtDlg2.OkDialog); // Test adding irt calculator { var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator); var addDlg = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase); // Check error messages RunUI(() => addDlg.Source = IrtCalculatorSource.file); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = "not_irtdb.docx"); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { AssertEx.AreComparableStrings(Resources.AddIrtCalculatorDlg_OkDialog_The_file__0__is_not_an_iRT_database, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = "not_exist.irtdb"); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { AssertEx.AreComparableStrings(TextUtil.LineSeparate( Resources.AddIrtCalculatorDlgOkDialogThe_file__0__does_not_exist, Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database), messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.CalculatorName = "noexist"); PauseForScreenShot(); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_choose_the_iRT_calculator_you_would_like_to_add, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = databasePath); var addPepDlg = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog); var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog); OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click); Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount); OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick); } // Add from existing calculator { var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator); var addDlg = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase); RunUI(() => addDlg.CalculatorName = irtCalc); var addPepDlg = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog); var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog); OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click); Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount); OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick); } var docIrtBefore = SkylineWindow.Document; OkDialog(editRT2, editRT2.OkDialog); OkDialog(peptideSettingsDlg2, peptideSettingsDlg2.OkDialog); WaitForClosedForm(peptideSettingsDlg2); var docIrt = VerifyIrtStandards(docIrtBefore, true); RunUI(() => { // Select 3 of the standards and delete them SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0); SkylineWindow.SequenceTree.KeysOverride = Keys.Shift; SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 2); SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.EditDelete(); }); // Should still have iRT peptides docIrt = VerifyIrtStandards(docIrt, true); // Remove one more and standards should be cleared RunUI(SkylineWindow.Cut); docIrt = VerifyIrtStandards(docIrt, false); RunUI(SkylineWindow.Paste); docIrt = VerifyIrtStandards(docIrt, true); // Repeat without results RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg => { dlg.RemoveAllReplicates(); dlg.OkDialog(); }); docIrt = VerifyIrtStandards(docIrt, true); RunUI(SkylineWindow.EditDelete); docIrt = VerifyIrtStandards(docIrt, false); RunUI(SkylineWindow.Paste); VerifyIrtStandards(docIrt, true); //Restore the document to contain all 29 peptides RunUI(() => SkylineWindow.UndoRestore(7)); //Open peptide settings var peptideSettingsDlg3 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunDlg <EditListDlg <SettingsListBase <RetentionTimeRegression>, RetentionTimeRegression> >(peptideSettingsDlg3.EditRegressionList, dlg => { dlg.SelectLastItem(); dlg.RemoveItem(); dlg.OkDialog(); }); //Add a new regression var editRT3 = ShowDialog <EditRTDlg>(peptideSettingsDlg3.AddRTRegression); RunUI(() => editRT3.SetRegressionName("iRT Document Regression")); //Edit the calculator list var editCalculator = ShowDialog <EditListDlg <SettingsListBase <RetentionScoreCalculatorSpec>, RetentionScoreCalculatorSpec> >( editRT3.EditCalculatorList); RunUI(() => editCalculator.SelectItem("iRT Document Calculator")); //Edit the document-based calculator var irtDlg3 = ShowDialog <EditIrtCalcDlg>(editCalculator.EditItem); //Add the 18 non-standard peptides to the calculator, then OkDialog back to Skyline var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(irtDlg3.AddResults); var recalibrateDlg2 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog); OkDialog(recalibrateDlg2, recalibrateDlg2.Btn1Click); RunUI(() => { Assert.AreEqual(18, irtDlg3.LibraryPeptideCount); irtDlg3.OkDialog(); }); WaitForClosedForm(irtDlg3); RunUI(editCalculator.OkDialog); WaitForClosedForm(editCalculator); RunUI(() => { editRT3.AddResults(); editRT3.ChooseCalculator("iRT Document Calculator"); editRT3.SetTimeWindow(2.0); editRT3.OkDialog(); }); WaitForClosedForm(editRT3); //Then choose the new, document-based regression and turn off prediction RunUI(() => { peptideSettingsDlg3.ChooseRegression("iRT Document Regression"); peptideSettingsDlg3.IsUseMeasuredRT = true; peptideSettingsDlg3.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg3); Assert.IsNull(FindOpenForm <MessageDlg>()); //Export the measurement-based transition list ExportMethod(testFilesDir.GetTestPath("EmpiricalTL.csv")); //Turn on prediction for scheduling var peptideSettingsDlg4 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { peptideSettingsDlg4.IsUseMeasuredRT = false; peptideSettingsDlg4.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg4); //Export the prediction-based transition list ExportMethod(testFilesDir.GetTestPath("PredictionTL.csv")); //Now open both files and compare AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")), File.ReadAllText(testFilesDir.GetTestPath("PredictionTL.csv"))); // Close and re-open, and try again RunUI(() => { Assert.IsTrue(SkylineWindow.SaveDocument()); SkylineWindow.NewDocument(); Assert.IsTrue(SkylineWindow.OpenFile(documentPath)); }); WaitForDocumentLoaded(); ExportMethod(testFilesDir.GetTestPath("PredictionTL_reopen.csv")); AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")), File.ReadAllText(testFilesDir.GetTestPath("PredictionTL_reopen.csv"))); /* * Rename the database * Switch to the calculator in EditRTDlg and check for an error * Go to edit the calculator and check for an error * Try to export a transition list and check for an error * Switch to the calculator in the graph and check for an error */ var stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb")); stream.Close(); File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"), testFilesDir.GetTestPath("backup.irtdb")); // The database renaming doesn't break usage anymore, since // the iRT databases are loaded into memory during initialization. // So, create a new calculator with a bogus path. const string irtCalcMissing = "iRT-C18-missing"; Settings.Default.RTScoreCalculatorList.SetValue(new RCalcIrt(irtCalcMissing, testFilesDir.GetTestPath("irt-c18-missing.irtdb"))); var peptideSettingsDlg5 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); var editRT5 = ShowDialog <EditRTDlg>(peptideSettingsDlg5.AddRTRegression); //Add results and switch to a calculator whose database is not connected: error RunDlg <MessageDlg>(() => { editRT5.AddResults(); editRT5.ChooseCalculator(irtCalcMissing); }, errorMessage => errorMessage.OkDialog()); //Go to add a new calculator var irtDlg5 = ShowDialog <EditIrtCalcDlg>(editRT5.AddCalculator); //Try to open a file that does not exist: error RunDlg <MessageDlg>(() => irtDlg5.OpenDatabase(databasePath), messageDlg => messageDlg.OkDialog()); RunUI(() => irtDlg5.CancelButton.PerformClick()); WaitForClosedForm(irtDlg5); //In order to export a transition list, we have to set the RT regression to have the iRT Calc. //This means that the iRT calc must have its database connected - else the dialog will not let //the user choose it. So here we will restore the file so we can choose the calculator. //Then once that dialog is closed and the regression is saved, switch the file back again. stream = File.Create(databasePath); stream.Close(); File.Replace(testFilesDir.GetTestPath("irt-c18-copy.irtdb"), databasePath, testFilesDir.GetTestPath("backup.irtdb")); RunUI(() => { editRT5.SetRegressionName("iRT Test Regression"); editRT5.AddResults(); editRT5.ChooseCalculator(irtCalc); editRT5.OkDialog(); }); WaitForClosedForm(editRT5); RunUI(() => { peptideSettingsDlg5.ChooseRegression("iRT Test Regression"); peptideSettingsDlg5.IsUseMeasuredRT = false; //Use prediction peptideSettingsDlg5.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg5); RunUI(() => SkylineWindow.SaveDocument()); //Switch the file back to the copy, destroying the original stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb")); stream.Close(); File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"), testFilesDir.GetTestPath("backup.irtdb")); var exportTransList = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg); // Used to cause a message box, but should work now, because iRT databases get loaded once RunUI(() => exportTransList.SetMethodType(ExportMethodType.Scheduled)); RunUI(() => exportTransList.CancelButton.PerformClick()); WaitForClosedForm(exportTransList); // Used to cause a message box, but should work now, because iRT databases get loaded once RunUI(() => SkylineWindow.ChooseCalculator(irtCalc)); /* * Now clean up by deleting all these calculators. If we don't, then the next functional test * will fail because it will try to use a calculator from settings which will not have its * database. */ RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsDlg6 => { peptideSettingsDlg6.ChooseRegression(Resources.SettingsList_ELEMENT_NONE_None); peptideSettingsDlg6.OkDialog(); }); // Finally, close and re-open the document to see MissingFileDlg int pepCount = SkylineWindow.Document.PeptideCount; RunUI(() => SkylineWindow.NewDocument(true)); Assert.AreEqual(0, SkylineWindow.Document.PeptideCount); RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath), dlg => dlg.OkDialog()); Assert.AreEqual(pepCount, SkylineWindow.Document.PeptideCount); RunUI(() => SkylineWindow.NewDocument(true)); RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath), dlg => dlg.CancelDialog()); Assert.AreEqual(0, SkylineWindow.Document.PeptideCount); // Make sure no message boxes are left open Assert.IsNull(FindOpenForm <MessageDlg>()); }
protected override void DoTest() { OpenDocument(TestFilesDir.GetTestPath(@"DIA-TTOF-tutorial.sky")); WaitForDocumentLoaded(); RunUI(() => { SkylineWindow.ShowDetectionsReplicateComparisonGraph(); }); WaitForGraphs(); GraphSummary graph = SkylineWindow.DetectionsPlot; var toolbar = graph.Toolbar as DetectionsToolbar; Assert.IsNotNull(toolbar); RunUI(() => { toolbar.CbLevel.SelectedItem = DetectionsGraphController.TargetType.PRECURSOR; }); WaitForGraphs(); DetectionsPlotPane pane; Assert.IsTrue(graph.TryGetGraphPane(out pane)); Assert.IsTrue(pane.HasToolbar); //use properties dialog to update the q-value var propDialog = ShowDialog <DetectionToolbarProperties>(() => { toolbar.pbProperties_Click(graph.GraphControl, new EventArgs()); }); //verify data correct for 2 q-values RunUI(() => { propDialog.SetQValueTo(0.003f); propDialog.OkDialog(); }); WaitForClosedForm(propDialog); WaitForCondition(() => (DetectionsGraphController.Settings.QValueCutoff == 0.003f)); AssertDataCorrect(pane, 0, 0.003f); //use properties dialog to update the q-value propDialog = ShowDialog <DetectionToolbarProperties>(() => { toolbar.pbProperties_Click(graph.GraphControl, new EventArgs()); }); RunUI(() => { propDialog.SetQValueTo(0.001f); propDialog.OkDialog(); }); WaitForClosedForm(propDialog); WaitForCondition(() => (DetectionsGraphController.Settings.QValueCutoff == 0.001f)); AssertDataCorrect(pane, 2, 0.001f); //verify the number of the bars on the plot RunUI(() => { Assert.IsTrue( pane.CurveList[0].IsBar && pane.CurveList[0].Points.Count == REF_DATA[0].Length); }); string[] tipText = { Resources.DetectionPlotPane_Tooltip_Replicate + TextUtil.SEPARATOR_TSV_STR + @"2_SW-B", string.Format(Resources.DetectionPlotPane_Tooltip_Count, DetectionsGraphController.TargetType.PRECURSOR) + TextUtil.SEPARATOR_TSV_STR + 118.ToString(CultureInfo.CurrentCulture), Resources.DetectionPlotPane_Tooltip_CumulativeCount + TextUtil.SEPARATOR_TSV_STR + 123.ToString(CultureInfo.CurrentCulture), Resources.DetectionPlotPane_Tooltip_AllCount + TextUtil.SEPARATOR_TSV_STR + 115.ToString(CultureInfo.CurrentCulture), Resources.DetectionPlotPane_Tooltip_QMedian + TextUtil.SEPARATOR_TSV_STR + (6.0d).ToString(@"F1", CultureInfo.CurrentCulture) }; RunUI(() => { Assert.IsNotNull(pane.ToolTip); pane.PopulateTooltip(1); //verify the tooltip text CollectionAssert.AreEqual(tipText, pane.ToolTip.TipLines); }); //test the data correct after a doc change (delete peptide) RunUI(() => { SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 12); SkylineWindow.EditDelete(); }); WaitForGraphs(); WaitForConditionUI(() => DetectionPlotData.GetDataCache().Datas.Any((dat) => ReferenceEquals(SkylineWindow.DocumentUI, dat.Document) && DetectionsGraphController.Settings.QValueCutoff == dat.QValueCutoff), "Cache is not updated on document change."); //verify that the cache is purged after the document update RunUI(() => { Assert.IsTrue(DetectionPlotData.GetDataCache().Datas.All((dat) => ReferenceEquals(SkylineWindow.DocumentUI, dat.Document))); }); AssertDataCorrect(pane, 4, 0.001f); RunUI(() => { SkylineWindow.ShowDetectionsHistogramGraph(); }); WaitForGraphs(); DetectionsHistogramPane paneHistogram; var graphHistogram = SkylineWindow.DetectionsPlot; Assert.IsTrue(graphHistogram.TryGetGraphPane(out paneHistogram), "Cannot get histogram pane."); //display and hide tooltip string[] histogramTipText = { Resources.DetectionHistogramPane_Tooltip_ReplicateCount + TextUtil.SEPARATOR_TSV_STR + 5.ToString(CultureInfo.CurrentCulture), String.Format(Resources.DetectionHistogramPane_Tooltip_Count, DetectionsGraphController.TargetType.PRECURSOR) + TextUtil.SEPARATOR_TSV_STR + 102.ToString(CultureInfo.CurrentCulture), }; RunUI(() => { Assert.IsNotNull(paneHistogram.ToolTip, "No tooltip found."); paneHistogram.PopulateTooltip(5); //verify the tooltip text CollectionAssert.AreEqual(histogramTipText, paneHistogram.ToolTip.TipLines); }); RunUI(() => { graph.Close(); graphHistogram.Close(); }); WaitForGraphs(); }
/// <summary> /// Test tree state restoration from a persistent string. Tests for proper expansion and /// selection of nodes, and correct vertical scrolling /// </summary> protected override void DoTest() { // tests for a blank document RunUI(() => { SkylineWindow.NewDocument(); SetCurrentState(); SkylineWindow.SaveDocument(TestContext.GetTestPath("blank.sky")); // reload file from persistent string SkylineWindow.OpenFile(TestContext.GetTestPath("blank.sky")); CompareStates(); }); _documentFile = TestFilesDir.GetTestPath("Study7_0-7.sky"); // tests for a fully collapsed tree RunUI(() => { SkylineWindow.OpenFile(_documentFile); SkylineWindow.CollapseProteins(); CheckStateMaintained(); }); // tests for a fully expanded tree and scrolling RunUI(() => { SkylineWindow.OpenFile(_documentFile); SkylineWindow.ExpandPrecursors(); CheckStateMaintained(); SkylineWindow.SelectAll(); CheckStateMaintained(); // select last node in tree for scrolling test SelectNode(SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1], null); CheckStateMaintained(); }); // tests for expansion RunUI(() => { SkylineWindow.OpenFile(_documentFile); SkylineWindow.CollapseProteins(); SelectNode(SkylineWindow.SequenceTree.TopNode, null); CheckStateMaintained(); TestExpansion(); }); // tests for selection RunUI(() => { SkylineWindow.OpenFile(_documentFile); TestSingleSelect(); TestSelectLastNode(); TestRangeSelect(); TestDisjointSelect(); TestCombinedRangeDisjoint(); }); // tests that Skyline will not crash when there is a mismatch between stored data in the // .sky.view file and that in the tree RunUI(() => { SelectNode(SkylineWindow.SequenceTree.Nodes[1], null); SkylineWindow.SaveDocument(_documentFile); System.IO.File.Copy(SkylineWindow.GetViewFile(_documentFile), _documentFile + ".copy"); SkylineWindow.EditDelete(); CheckStateMaintained(); System.IO.File.Delete(SkylineWindow.GetViewFile(_documentFile)); System.IO.File.Copy(_documentFile + ".copy", SkylineWindow.GetViewFile(_documentFile)); SkylineWindow.OpenFile(_documentFile); }); }
/// <summary> /// Test Skyline document sharing with libraries. /// </summary> protected override void DoTest() { // The transition list produced by the special test nodes doesn't parse as peptides, which this test expects TestSmallMolecules = false; // Open the .sky file string documentPath = TestFilesDir.GetTestPath(DOCUMENT_NAME); RunUI(() => SkylineWindow.OpenFile(documentPath)); // Delete the last protein because its peptide has an explicit modification // which just gets in the way for this test. SelectNode(SrmDocument.Level.MoleculeGroups, SkylineWindow.Document.PeptideGroupCount - 1); RunUI(SkylineWindow.EditDelete); // Select the first precursor and inspect its graph SelectNode(SrmDocument.Level.TransitionGroups, 0); WaitForLibraries(); WaitForGraphs(); int ionCount = 0; RunUI(() => ionCount = SkylineWindow.GraphSpectrum.PeaksMatchedCount); RunUI(() => SkylineWindow.GraphSpectrumSettings.ShowPrecursorIon = true); WaitForGraphs(); RunUI(() => Assert.AreEqual(ionCount + 1, SkylineWindow.GraphSpectrum.PeaksMatchedCount)); string precursorPrefix = IonType.precursor.GetLocalizedString(); string precursorLabel = precursorPrefix + Transition.GetChargeIndicator(2); SrmDocument docCurrent = SkylineWindow.Document; var pickList0 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest); RunUI(() => { Assert.IsFalse(pickList0.ItemNames.Contains(name => name.StartsWith(precursorPrefix))); pickList0.ApplyFilter(false); Assert.IsTrue(pickList0.ItemNames.Contains(name => name.StartsWith(precursorPrefix))); pickList0.ToggleFind(); pickList0.SearchString = precursorPrefix; pickList0.SetItemChecked(0, true); pickList0.OnOk(); }); WaitForDocumentChange(docCurrent); docCurrent = SkylineWindow.Document; Assert.AreEqual(IonType.precursor, new List <TransitionDocNode>(docCurrent.PeptideTransitions)[0].Transition.IonType, "First transition is not precursor type."); SelectNode(SrmDocument.Level.Transitions, 0); VerifySelectedIon(precursorLabel); SelectNode(SrmDocument.Level.TransitionGroups, 2); // Charge 3 docCurrent = SkylineWindow.Document; var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest); RunUI(() => { pickList1.ApplyFilter(false); pickList1.SetItemChecked(0, true); pickList1.OnOk(); }); WaitForDocumentChange(docCurrent); RunUI(() => SkylineWindow.SaveDocument()); RunUI(SkylineWindow.NewDocument); RunUI(() => SkylineWindow.OpenFile(documentPath)); Assert.AreEqual(2, GetPrecursorTranstionCount()); // Export a transition list string tranListPath = TestFilesDir.GetTestPath("TransitionList.csv"); var exportDialog = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List)); RunUI(() => { exportDialog.ExportStrategy = ExportStrategy.Single; exportDialog.MethodType = ExportMethodType.Standard; exportDialog.OkDialog(tranListPath); }); WaitForCondition(() => File.Exists(tranListPath)); // Save a copy of the current document docCurrent = SkylineWindow.Document; // Delete remaining 2 proteins SelectNode(SrmDocument.Level.MoleculeGroups, 0); RunUI(() => { SkylineWindow.EditDelete(); SkylineWindow.EditDelete(); }); // Paste the transition list SetClipboardTextUI(File.ReadAllText(tranListPath)); RunUI(() => SkylineWindow.Paste()); Assert.AreEqual(2, GetPrecursorTranstionCount()); Assert.AreEqual(docCurrent.PeptideTransitionCount, SkylineWindow.Document.PeptideTransitionCount); Assert.AreEqual(IonType.precursor, new List <TransitionDocNode>(docCurrent.PeptideTransitions)[0].Transition.IonType, "First transition is not precursor type."); SelectNode(SrmDocument.Level.Transitions, 0); VerifySelectedIon(precursorLabel); }
protected override void DoTest() { // Creating a MS/MS Spectral Library, p. 1 PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunDlg <BuildLibraryDlg>(peptideSettingsUI.ShowBuildLibraryDlg, buildLibraryDlg => { buildLibraryDlg.LibraryPath = TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\"); // Not L10N buildLibraryDlg.LibraryName = YEAST_ATLAS; buildLibraryDlg.LibraryCutoff = 0.95; buildLibraryDlg.LibraryAuthority = "peptideatlas.org"; // Not L10N buildLibraryDlg.OkWizardPage(); IList <string> inputPaths = new List <string> { TestFilesDirs[0].GetTestPath(@"MethodEdit\Yeast_atlas\interact-prob.pep.xml") // Not L10N }; buildLibraryDlg.AddInputFiles(inputPaths); buildLibraryDlg.OkWizardPage(); }); PeptideSettingsUI peptideSettingsUI1 = peptideSettingsUI; RunUI(() => { peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Library; peptideSettingsUI1.PickedLibraries = new[] { YEAST_ATLAS }; }); WaitForOpenForm <PeptideSettingsUI>(); // To show Library tab for Forms testing PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 4); // Not L10N RunUI(() => peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Digest); WaitForOpenForm <PeptideSettingsUI>(); // To show Digestion tab for Forms testing // Creating a Background Proteome File, p. 3 FileEx.SafeDelete(TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast" + ProteomeDb.EXT_PROTDB)); // Not L10N var buildBackgroundProteomeDlg = ShowDialog <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg); RunUI(() => { buildBackgroundProteomeDlg.BackgroundProteomePath = TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast"); // Not L10N buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast"; // Not L10N buildBackgroundProteomeDlg.AddFastaFile( TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\sgd_yeast.fasta")); // Not L10N }); PauseForScreenShot <BuildBackgroundProteomeDlg>("Edit Background Proteome form", 5); // Not L10N OkDialog(buildBackgroundProteomeDlg, buildBackgroundProteomeDlg.OkDialog); PauseForScreenShot <PeptideSettingsUI.DigestionTab>("Peptide Settings - Digestion tab", 6); // Not L10N var docB = SkylineWindow.Document; OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); WaitForDocumentChange(docB); if (!TryWaitForCondition(() => SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded && SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0)) { Assert.Fail("Timed out loading libraries: libCount={0}, NotLoadedExplained={1}", SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count, SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsNotLoadedExplained ?? "<null>"); } WaitForCondition(() => { var peptideSettings = SkylineWindow.Document.Settings.PeptideSettings; var backgroundProteome = peptideSettings.BackgroundProteome; return(backgroundProteome.HasDigestion(peptideSettings)); }, "backgroundProteome.HasDigestion"); // Wait a bit in case web access is turned on and backgroundProteome is actually resolving protein metadata int millis = (AllowInternetAccess ? 300 : 60) * 1000; WaitForCondition(millis, () => !SkylineWindow.Document.Settings.PeptideSettings.BackgroundProteome.NeedsProteinMetadataSearch, "backgroundProteome.NeedsProteinMetadataSearch"); // Pasting FASTA Sequences, p. 5 RunUI(() => SetClipboardFileText(@"MethodEdit\FASTA\fasta.txt")); // Not L10N // New in v0.7 : Skyline asks about removing empty proteins. using (new CheckDocumentState(35, 25, 25, 75)) { var emptyProteinsDlg = ShowDialog <EmptyProteinsDlg>(SkylineWindow.Paste); RunUI(() => emptyProteinsDlg.IsKeepEmptyProteins = true); OkDialog(emptyProteinsDlg, emptyProteinsDlg.OkDialog); WaitForCondition(millis, () => SkylineWindow.SequenceTree.Nodes.Count > 4); } RunUI(() => { SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[3].Nodes[0]; }); RestoreViewOnScreen(07); PauseForScreenShot("Main window", 7); // Not L10N RunUI(() => { Settings.Default.ShowBIons = true; SkylineWindow.SequenceTree.SelectedNode.Expand(); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes[1]; }); PauseForScreenShot("Main window showing effect of selection on Library Match graph", 8); // Not L10N CheckTransitionCount("VDIIANDQGNR", 3); // Not L10N using (new CheckDocumentState(35, 28, 31, 155)) { var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter; transitionSettingsUI.PrecursorCharges = "2, 3"; // Not L10N transitionSettingsUI.ProductCharges = "1"; // Not L10N transitionSettingsUI.FragmentTypes = "y, b"; // Not L10N }); WaitForOpenForm <TransitionSettingsUI>(); // To show Filter tab for Forms testing PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 9); // Not L10N RunUI(() => { transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Library; transitionSettingsUI.IonCount = 5; }); PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab", 10); // Not L10N OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog); } PauseForScreenShot("Targets tree clipped from main window", 11); // Not L10N CheckTransitionCount("VDIIANDQGNR", 5); // Not L10N // Using a Public Spectral Library, p. 9 peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); var editListUI = ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList); var addLibUI = ShowDialog <EditLibraryDlg>(editListUI.AddItem); RunUI(() => addLibUI.LibrarySpec = new BiblioSpecLibSpec(YEAST_GPM, TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\yeast_cmp_20.hlf"))); // Not L10N OkDialog(addLibUI, addLibUI.OkDialog); WaitForClosedForm(addLibUI); OkDialog(editListUI, editListUI.OkDialog); // Limiting Peptides per Protein, p. 11 using (new CheckDocumentState(35, 182, 219, 1058)) { RunUI(() => { peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Library; peptideSettingsUI.PickedLibraries = new[] { YEAST_ATLAS, YEAST_GPM }; }); PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 12); // Not L10N OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); Assert.IsTrue(WaitForCondition( () => SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded && SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0)); } using (new CheckDocumentState(35, 47, 47, 223, 2, true)) // Wait for change loaded, and expect 2 document revisions. { RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUI2 => { peptideSettingsUI2.PickedLibraries = new[] { YEAST_GPM }; peptideSettingsUI2.LimitPeptides = true; peptideSettingsUI2.RankID = XHunterLibSpec.PEP_RANK_EXPECT; peptideSettingsUI2.PeptidesPerProtein = 3; peptideSettingsUI2.OkDialog(); }); } using (new CheckDocumentState(19, 47, 47, 223)) { RunUI(() => { var refinementSettings = new RefinementSettings { MinPeptidesPerProtein = 1 }; SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine); // Not L10N }); } // Inserting a Protein List, p. 11 using (new CheckDocumentState(36, 58, 58, 278)) { PasteDlg pasteProteinsDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg); RunUI(() => { var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; SkylineWindow.SequenceTree.SelectedNode = node; SetClipboardFileText(@"MethodEdit\FASTA\Protein list.txt"); // Not L10N pasteProteinsDlg.SelectedPath = SkylineWindow.SequenceTree.SelectedPath; pasteProteinsDlg.PasteProteins(); }); PauseForScreenShot <PasteDlg.ProteinListTab>("Insert Protein List - For Screenshot, select last (empty) item in list", 14); // Not L10N OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog); } using (new CheckDocumentState(24, 58, 58, 278)) { RunUI(() => { var refinementSettings = new RefinementSettings { MinPeptidesPerProtein = 1 }; SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine); // Not L10N }); } // Inserting a Peptide List, p. 13 using (new CheckDocumentState(25, 70, 70, 338)) { RunUI(() => { SetClipboardFileText(@"MethodEdit\FASTA\Peptide list.txt"); // Not L10N SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0]; SkylineWindow.Paste(); // ReSharper disable LocalizableElement SkylineWindow.SequenceTree.Nodes[0].Text = "Primary Peptides"; // Not L10N // ReSharper restore LocalizableElement }); FindNode("TLTAQSMQNSTQSAPNK"); // Not L10N PauseForScreenShot("Main window", 16); // Not L10N } using (new CheckDocumentState(35, 70, 70, 338)) { RunUI(() => SkylineWindow.Undo()); PasteDlg pastePeptidesDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg); RunUI(pastePeptidesDlg.PastePeptides); PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List - For screenshot, select last (empty) line in list", 17); // Not L10N OkDialog(pastePeptidesDlg, pastePeptidesDlg.OkDialog); } // Simple Refinement, p. 16 var findPeptideDlg = ShowDialog <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg); RunUI(() => findPeptideDlg.SearchString = "IPEE"); // Not L10N OkDialog(findPeptideDlg, () => { findPeptideDlg.FindNext(); findPeptideDlg.Close(); }); PauseForScreenShot <GraphSpectrum>("Library Match graph metafile", 18); // Not L10N using (new CheckDocumentState(35, 64, 64, 320)) { RefineDlg refineDlg = ShowDialog <RefineDlg>(SkylineWindow.ShowRefineDlg); RunUI(() => refineDlg.MinTransitions = 5); OkDialog(refineDlg, refineDlg.OkDialog); PauseForScreenShot("29/35 prot 50/64 pep 50/64 prec 246/320 tran", 18); // Not L10N } // Checking Peptide Uniqueness, p. 18 RunUI(() => { var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 3 : 2)]; SkylineWindow.SequenceTree.SelectedNode = node; }); using (new CheckDocumentState(34, 63, 63, 315)) { var uniquePeptidesDlg = ShowDialog <UniquePeptidesDlg>(SkylineWindow.ShowUniquePeptidesDlg); WaitForConditionUI(() => uniquePeptidesDlg.GetDataGridView().RowCount == 1); RunUI(() => { Assert.AreEqual(1, uniquePeptidesDlg.GetDataGridView().RowCount); Assert.AreEqual(7, uniquePeptidesDlg.GetDataGridView().ColumnCount); }); PauseForScreenShot <UniquePeptidesDlg>("Unique Peptides form", 19); // Not L10N OkDialog(uniquePeptidesDlg, uniquePeptidesDlg.OkDialog); RunUI(() => SkylineWindow.EditDelete()); } // Protein Name Auto-Completion PauseForScreenShot("(fig. 1): For screenshot, click at bottom of document tree, type 'ybl087' and see the autocomplete text. Make sure to undo this new entry before proceeding.", 20); // Not L10N TestAutoComplete("ybl087", 0); // Not L10N var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups); Assert.AreEqual("YBL087C", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N // Protein Description Auto-Completion PauseForScreenShot("(fig. 2): For screenshot, click at bottom of document tree, type 'eft2' and see the autocomplete text, then down-arrow twice. Make sure to undo this new entry before proceeding.", 20); // Not L10N TestAutoComplete("eft2", 0); // Sorting logic puts this at the 0th entry in the list - Not L10N peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups); Assert.AreEqual("YDR385W", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N // Peptide Sequence Auto-Completion, p. 21 TestAutoComplete("IQGP", 0); // Not L10N var peptides = new List <PeptideDocNode>(Program.ActiveDocument.Peptides); Assert.AreEqual("K.AYLPVNESFGFTGELR.Q [769, 784]", peptides[peptides.Count - 1].Peptide.ToString()); // Not L10N PauseForScreenShot("(fig. 1) - For screenshot, click at the bottom of the document tree", 21); // Not L10N // Pop-up Pick-Lists, p. 21 using (new CheckDocumentState(36, 71, 71, 355)) { RunUI(() => { var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 4 : 3)]; SkylineWindow.SequenceTree.SelectedNode = node; }); var pickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest); RunUI(() => { pickList.ApplyFilter(false); pickList.SetItemChecked(8, true); pickList.AutoManageChildren = false; // TODO: Because calling SetItemChecked does not do this }); PauseForScreenShot <PopupPickList>("(fig. 2) - YBL087C Peptides picklist", 21); // Not L10N RunUI(pickList.OnOk); } using (new CheckDocumentState(36, 71, 71, 355)) { RunUI(() => { SkylineWindow.SequenceTree.Nodes[34].ExpandAll(); var node = SkylineWindow.SequenceTree.Nodes[34].Nodes[0].Nodes[0]; SkylineWindow.SequenceTree.SelectedNode = node; }); var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest); RunUI(() => { pickList1.SearchString = "y"; // Not L10N pickList1.SetItemChecked(0, false); pickList1.SetItemChecked(1, false); pickList1.ApplyFilter(false); pickList1.ToggleFind(); pickList1.SearchString = "b ++"; // Not L10N pickList1.SetItemChecked(4, true); pickList1.SetItemChecked(6, true); }); PauseForScreenShot <PopupPickList>("b ++ filtered picklist", 22); // Not L10N RunUI(pickList1.OnOk); } // Bigger Picture, p. 22. Drag and Drop, p. 23 RunUI(() => { ITipProvider nodeTip = SkylineWindow.SequenceTree.SelectedNode as ITipProvider; Assert.IsTrue(nodeTip != null && nodeTip.HasTip); var nodeName = SkylineWindow.SequenceTree.Nodes[1].Name; IdentityPath selectPath; SkylineWindow.ModifyDocument("Drag and drop", // Not L10N doc => doc.MoveNode(SkylineWindow.Document.GetPathTo(0, 1), SkylineWindow.Document.GetPathTo(0, 0), out selectPath)); Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Name == nodeName); }); FindNode(string.Format("L [b5] - {0:F04}+", 484.3130)); // Not L10N - may be localized " (rank 3)" PauseForScreenShot("For Screenshots, First hover over YBL087C, then over 672.671+++", 23); // Not L10N // Preparing to Measure, p. 25 RunDlg <TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Prediction), transitionSettingsUI => { transitionSettingsUI.RegressionCE = Settings.Default.GetCollisionEnergyByName("ABI 4000 QTrap"); // Not L10N transitionSettingsUI.RegressionDP = Settings.Default.GetDeclusterPotentialByName("ABI"); // Not L10N transitionSettingsUI.InstrumentMaxMz = 1800; transitionSettingsUI.OkDialog(); }); RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath("MethodEdit Tutorial.sky"))); // Not L10N var exportDialog = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List)); RunUI(() => { exportDialog.ExportStrategy = ExportStrategy.Buckets; exportDialog.MethodType = ExportMethodType.Standard; exportDialog.OptimizeType = ExportOptimize.NONE; exportDialog.IgnoreProteins = true; exportDialog.MaxTransitions = 75; }); PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 25); // Not L10N const string basename = "Yeast_list"; // Not L10N OkDialog(exportDialog, () => exportDialog.OkDialog(TestFilesDirs[0].GetTestPath(basename))); // write Yeast_list_000n.csv // check the output files for (int n = 0; n++ < 5;) { var csvname = String.Format("{0}_{1}.csv", basename, n.ToString("D4")); // Not L10N // AssertEx.FieldsEqual is hard-coded with CultureInfo.InvariantCulture, but so is transition list CSV export, so OK using (TextReader actual = new StreamReader(TestFilesDirs[0].GetTestPath(csvname))) using (TextReader target = new StreamReader(TestFilesDirs[1].GetTestPath(csvname))) { AssertEx.FieldsEqual(target, actual, 6, null, true, TestSmallMolecules ? 3 : 0); } } }
protected override void DoTest() { RunUI(() => { SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SimpleRatiosTest.sky")); SkylineWindow.ExpandPrecursors(); }); Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Quantification.SimpleRatios); Assert.AreEqual(new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy), SkylineWindow.Document.Settings.PeptideSettings.Quantification.NormalizationMethod); PeptideTreeNode peptideTreeNode = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; TransitionGroupTreeNode lightTreeNode = (TransitionGroupTreeNode)peptideTreeNode.Nodes[0]; TransitionGroupTreeNode heavyTreeNode = (TransitionGroupTreeNode)peptideTreeNode.Nodes[1]; var lightTransitionAreas = lightTreeNode.DocNode.Transitions.Select(tran => tran.Results[0][0].Area).ToList(); Assert.AreEqual(4, lightTransitionAreas.Count); var heavyTransitionAreas = heavyTreeNode.DocNode.Transitions.Select(tran => tran.Results[0][0].Area).ToList(); Assert.AreEqual(2, heavyTransitionAreas.Count); // Verify that only the first two transition areas in both precursors contribute to the displayed ratio var expectedRatio = lightTransitionAreas.Take(2).Sum() / heavyTransitionAreas.Sum(); StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio)); RunUI(() => { SkylineWindow.ShowResultsGrid(true); SkylineWindow.SelectedPath = peptideTreeNode.Path; }); var resultsGridForm = FindOpenForm <LiveResultsGrid>(); WaitForConditionUI(() => resultsGridForm.IsComplete); RunDlg <ViewEditor>(resultsGridForm.DataboundGridControl.NavBar.CustomizeView, viewEditor => { viewEditor.ChooseColumnsTab.AddColumn(propertyPathNormalizedArea); viewEditor.ViewName = "PeptideResultsWithNormalizedArea"; viewEditor.OkDialog(); }); VerifyExpectedRatio(resultsGridForm, expectedRatio); RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUi => { peptideSettingsUi.SimpleRatios = true; peptideSettingsUi.OkDialog(); }); Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Quantification.SimpleRatios); // When SimpleRatios is true, verify that all transitions contribute to the ratio expectedRatio = lightTransitionAreas.Sum() / heavyTransitionAreas.Sum(); StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio)); VerifyExpectedRatio(resultsGridForm, expectedRatio); // Verify that deleting a transition from the light precursor does not affect the heavy precursor Assert.AreEqual(4, lightTreeNode.DocNode.TransitionCount); Assert.AreEqual(2, heavyTreeNode.DocNode.TransitionCount); RunUI(() => { SkylineWindow.SequenceTree.SelectedPaths = new[] { SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 0) }; SkylineWindow.EditDelete(); }); Assert.AreEqual(3, lightTreeNode.DocNode.TransitionCount); Assert.AreEqual(2, heavyTreeNode.DocNode.TransitionCount); expectedRatio = lightTransitionAreas.Skip(1).Sum() / heavyTransitionAreas.Sum(); StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio)); RunUI(() => SkylineWindow.SelectedPath = peptideTreeNode.Path); VerifyExpectedRatio(resultsGridForm, expectedRatio); }
private void TestModificationMatching() { var phosphoLossMod = new StaticMod("Phospho Loss", "S, T", null, true, "HPO3", LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), }); Settings.Default.StaticModList.Clear(); Settings.Default.StaticModList.Add(phosphoLossMod.ChangeExplicit(false)); var phosphoNotVariable = SkylineWindow.Document.Settings.ChangePeptideModifications( mods => mods.ChangeStaticModifications(new[] { phosphoLossMod.ChangeExplicit(false) })); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(phosphoNotVariable))); RelaunchLibExplorer(false, PHOSPHO_LIB); // Test doesn't find variable match if implicit match exists in doc WaitForConditionUI(() => !_viewLibUI.HasUnmatchedPeptides); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 4, 4, 12)) { RunDlg <MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides, msgDlg => msgDlg.Btn1Click()); } Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod))); Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && mod.IsVariable)); RunUI(SkylineWindow.Undo); // Test creates variable mod if implicit match exists in globals var pepModsNoMods1 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods1))); RelaunchLibExplorer(false, PHOSPHO_LIB); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 4, 4, 12)) { RunDlg <MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides, msgDlg => msgDlg.Btn1Click()); } Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && mod.IsVariable)); Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications .Contains(mod => mod.Equivalent(phosphoLossMod) && !mod.IsVariable)); // Test implicit mods only created if safe to do so RunUI(() => SkylineWindow.Undo()); RunDlg <MultiButtonMsgDlg>(() => _libComboBox.SelectedIndex = 4, msgDlg => msgDlg.Btn1Click()); WaitForConditionUI(() => _pepList.SelectedIndex != -1); WaitForConditionUI(() => _viewLibUI.HasMatches); RunDlg <MultiButtonMsgDlg>(() => _viewLibUI.CheckLibraryInSettings(), msgDlg => msgDlg.Btn0Click()); var fmpDlg0 = ShowDialog <FilterMatchedPeptidesDlg>(() => _viewLibUI.AddAllPeptides()); RunUI(() => fmpDlg0.AddFiltered = true); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 82, 96, TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 279 : 282)) { RunDlg <MultiButtonMsgDlg>(fmpDlg0.OkDialog, msgDlg => msgDlg.Btn1Click()); } // Implicit mod is created because there are no conflicting peptides in the current document. Assert.IsTrue( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => !mod.IsExplicit && !mod.IsVariable)); var nodeRemoved = ""; RunUI(() => { Settings.Default.EditFindText = "C"; SkylineWindow.FindNext(false); nodeRemoved = ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode.Peptide.Sequence; SkylineWindow.EditDelete(); }); Assert.IsFalse( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => mod.IsExplicit)); var pepModsNoMods2 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods2))); RelaunchLibExplorer(false, YEAST); RunUI(() => { _viewLibUI.ChangeSelectedPeptide(nodeRemoved.Replace("C", "C[+57.0]")); _viewLibUI.AddPeptide(); }); // Explicit mod is created because an implicit mod conflicts with current document settings. Assert.IsFalse( SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Contains(mod => !mod.IsExplicit)); Assert.IsTrue(SkylineWindow.Document.Peptides.Contains(nodePep => nodePep.Peptide.Sequence == nodeRemoved && nodePep.HasExplicitMods)); // Implicit modifications only added to document if they apply to the added peptide RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); }); var pepModsNoMods3 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods3))); Settings.Default.StaticModList.Clear(); RelaunchLibExplorer(true, ANL_COMBINED); RunUI(() => _viewLibUI.AddPeptide()); Assert.AreEqual(0, Settings.Default.StaticModList.Count); // Variable mods not added if conflict with existing peptides. RunUI(() => { _pepList.SelectedIndex = 1; _viewLibUI.AddPeptide(); }); Assert.IsFalse(SkylineWindow.Document.Peptides.Contains(nodePep => nodePep.HasExplicitMods && nodePep.ExplicitMods.IsVariableStaticMods)); // Test removing mod from globals affects matches var pepModsNoMods4 = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(Settings.Default.StaticModList.GetDefaults().ToArray())); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNoMods4))); Settings.Default.StaticModList.Clear(); Settings.Default.StaticModList.AddRange(Settings.Default.StaticModList.GetDefaults()); RelaunchLibExplorer(false, YEAST); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); // Test removing mod from doc does not remove matches Settings.Default.StaticModList.Clear(); var pepModsNone = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0])); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsNone))); RunUI(SkylineWindow.Activate); RunUI(_viewLibUI.Activate); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); // Relaunch explorer without modification matching RunUI(() => _viewLibUI.CancelDialog()); WaitForClosedForm(_viewLibUI); _viewLibUI = ShowDialog <ViewLibraryDlg>(() => SkylineWindow.OpenLibraryExplorer(YEAST)); var matchedPepModsDlg = WaitForOpenForm <MultiButtonMsgDlg>(); RunUI(matchedPepModsDlg.BtnCancelClick); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsTrue(_viewLibUI.HasUnmatchedPeptides); // Test adding mod to doc affects matches Settings.Default.StaticModList.AddRange(Settings.Default.StaticModList.GetDefaults()); var pepModsDefault = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(Settings.Default.StaticModList.Select(mod => mod.ChangeExplicit(false)).ToArray())); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(pepModsDefault))); RunUI(SkylineWindow.Activate); RunUI(_viewLibUI.Activate); WaitForConditionUI(() => _pepList.Items.Count == 96); WaitForConditionUI(() => _pepList.SelectedIndex != -1); Assert.IsFalse(_viewLibUI.HasUnmatchedPeptides); RunUI(() => _viewLibUI.CancelDialog()); WaitForClosedForm(_viewLibUI); }
private void TestBasicFunctionality() { // Launch the Library Explorer dialog _viewLibUI = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries); // Ensure the appropriate default library is selected ComboBox libComboBox = null; ListBox pepList = null; string libSelected = null; RunUI(() => { libComboBox = (ComboBox)_viewLibUI.Controls.Find("comboLibrary", true)[0]; Assert.IsNotNull(libComboBox); libSelected = libComboBox.SelectedItem.ToString(); // Find the peptides list control pepList = (ListBox)_viewLibUI.Controls.Find("listPeptide", true)[0]; Assert.IsNotNull(pepList); }); Assert.AreEqual(_testLibs[0].Name, libSelected); // Initially, peptide with index 0 should be selected WaitForConditionUI(() => pepList.SelectedIndex != -1); var modDlg = WaitForOpenForm <MultiButtonMsgDlg>(); RunUI(modDlg.Btn1Click); ViewLibraryPepInfo previousPeptide = new ViewLibraryPepInfo(); int peptideIndex = -1; RunUI(() => { previousPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; peptideIndex = pepList.SelectedIndex; }); Assert.IsNotNull(previousPeptide); Assert.AreEqual(0, peptideIndex); Assert.AreEqual(3, previousPeptide.Charge, "Expected charge 3 on " + previousPeptide.DisplayString); // Now try to select a different peptide and check to see if the // selection changes const int selectPeptideIndex = 1; RunUI(() => { pepList.SelectedIndex = selectPeptideIndex; }); ViewLibraryPepInfo selPeptide = new ViewLibraryPepInfo(); RunUI(() => { Assert.AreEqual(selectPeptideIndex, pepList.SelectedIndex); // Did selection change work? selPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; }); Assert.IsNotNull(selPeptide); if (Equals(previousPeptide, selPeptide)) { Assert.AreNotEqual(previousPeptide.DisplayString, selPeptide.DisplayString); } Assert.AreEqual(2, selPeptide.Charge, "Expected charge 2 on " + selPeptide.DisplayString); // Click the "Next" link RunUI(() => { var nextLink = (IButtonControl)_viewLibUI.Controls.Find("NextLink", true)[0]; Assert.IsNotNull(nextLink); nextLink.PerformClick(); }); RunUI(() => { previousPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; }); // Click "Previous" link and ensure the peptide selected changes RunUI(() => { var previousLink = (IButtonControl)_viewLibUI.Controls.Find("PreviousLink", true)[0]; Assert.IsNotNull(previousLink); previousLink.PerformClick(); }); RunUI(() => { selPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; }); Assert.AreNotEqual(previousPeptide, selPeptide); // Test valid peptide search TextBox pepTextBox = null; RunUI(() => { pepTextBox = (TextBox)_viewLibUI.Controls.Find("textPeptide", true)[0]; Assert.IsNotNull(pepTextBox); pepTextBox.Focus(); pepTextBox.Text = _testLibs[0].UniquePeptide; }); int pepsCount = 0; RunUI(() => { selPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; pepsCount = pepList.Items.Count; }); Assert.AreEqual(_testLibs[0].UniquePeptide, selPeptide.DisplayString); Assert.AreEqual(1, pepsCount); // Test invalid peptide search RunUI(() => { pepTextBox.Focus(); pepTextBox.Text = INVALID_SEARCH; }); RunUI(() => { pepsCount = pepList.Items.Count; }); Assert.AreEqual(0, pepsCount); // Test clearing invalid peptide search RunUI(() => { pepTextBox.Focus(); pepTextBox.Text = ""; }); selPeptide = new ViewLibraryPepInfo(); RunUI(() => { selPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; pepsCount = pepList.Items.Count; }); Assert.IsNotNull(selPeptide); Assert.AreNotEqual(0, pepsCount); // Test selecting a different library previousPeptide = selPeptide; RunDlg <MultiButtonMsgDlg>(() => libComboBox.SelectedIndex = 1, dlg => dlg.Btn1Click()); RunUI(() => { libComboBox.SelectedIndex = 1; }); RunUI(() => { libSelected = libComboBox.SelectedItem.ToString(); }); Assert.AreEqual(libSelected, _testLibs[1].Name); RunUI(() => { selPeptide = (ViewLibraryPepInfo)pepList.SelectedItem; }); Assert.IsNotNull(selPeptide); Assert.AreNotEqual(previousPeptide, selPeptide); // If the library is not in the document settings, offer to add the library to the settings. // If the user declines, add the peptides anyways, but strip them so they do not appear to be // connected to any library. RunDlg <MultiButtonMsgDlg>(_viewLibUI.AddPeptide, msgDlg => msgDlg.Btn1Click()); Assert.AreEqual(1, SkylineWindow.Document.PeptideCount); Assert.IsFalse(SkylineWindow.Document.Peptides.Contains(nodePep => nodePep.HasLibInfo)); RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); }); // Test adding peptides offers to add library if not already in settings. // Test add single peptide. using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 1, 1, 3)) { RunDlg <MultiButtonMsgDlg>(_viewLibUI.AddPeptide, msgDlg => msgDlg.Btn0Click()); } RunUI(SkylineWindow.EditDelete); // Test unmatched peptides are correct. // One unmatched because its precursor m/z is outside the instrument measurement range AddAllPeptides(1, 4, 3); // Verify that everything matches, given a wide enough mass range RunUI(() => SkylineWindow.ModifyDocument("Change m/z range", doc => doc.ChangeSettings(doc.Settings.ChangeTransitionInstrument(inst => inst.ChangeMaxMz(TransitionInstrument.MAX_MEASURABLE_MZ))))); WaitForConditionUI(() => !_viewLibUI.HasUnmatchedPeptides); RunUI(() => SkylineWindow.ModifyDocument("Change m/z range", doc => doc.ChangeSettings(doc.Settings.ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1500))))); WaitForConditionUI(() => _viewLibUI.HasUnmatchedPeptides); // Test library peptides are merged without duplicates. TestForDuplicatePeptides(); // Test library peptides only get added to the document once. var docOriginal = SkylineWindow.Document; RunDlg <MessageDlg>(_viewLibUI.AddPeptide, msgDlg => msgDlg.OkDialog()); var filterMatchedPeptidesDlg5 = ShowDialog <FilterMatchedPeptidesDlg>(_viewLibUI.AddAllPeptides); RunDlg <MessageDlg>(filterMatchedPeptidesDlg5.OkDialog, msgDlg => msgDlg.OkDialog()); Assert.AreSame(docOriginal, SkylineWindow.Document); // Test missing peptides added. RunUI(() => { var sequenceTree = SkylineWindow.SequenceTree; var nodePeps = sequenceTree.Nodes[0].Nodes; sequenceTree.SelectedNode = nodePeps[0]; sequenceTree.KeysOverride = Keys.Control; for (int i = 2; i < 10; i += 2) { sequenceTree.SelectedNode = nodePeps[i]; } sequenceTree.KeysOverride = Keys.None; SkylineWindow.EditDelete(); }); AddAllPeptides(); var docAddBack = SkylineWindow.Document; // Peptides will be added back in a different order AssertEx.IsDocumentState(docAddBack, null, docOriginal.PeptideGroupCount, docOriginal.PeptideCount, docOriginal.PeptideTransitionGroupCount, docOriginal.PeptideTransitionCount); TestSamePeptides(docOriginal.Peptides); // Test missing transition groups added correctly. RunUI(() => { var sequenceTree = SkylineWindow.SequenceTree; sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0].Nodes[0]; sequenceTree.KeysOverride = Keys.Control; for (int x = 0; x < 5; x++) { var nodePep = sequenceTree.Nodes[0].Nodes[x]; var nodeGroups = nodePep.Nodes; for (int i = 0; i < nodeGroups.Count; i += 2) { sequenceTree.SelectedNode = nodeGroups[i]; } } SkylineWindow.EditDelete(); }); AddAllPeptides(); var docAddBackGroups = SkylineWindow.Document; // Check all precursor charges present. foreach (PeptideDocNode nodePep in docOriginal.Peptides) { var key = nodePep.Key; foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { var charge = nodeGroup.TransitionGroup.PrecursorCharge; Assert.IsTrue(docAddBackGroups.Peptides.Contains(nodePepDoc => Equals(key, nodePepDoc.Key) && nodePepDoc.HasChildCharge(charge))); } } // Check no duplicate TransitionGroups added. TestForDuplicateTransitionGroups(); // Test peptides get heavy label modifications. List <StaticMod> heavyMods15N = new List <StaticMod> { new StaticMod("15N", null, null, null, LabelAtoms.N15, null, null) }; RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); var settings = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications, new[] { new TypedModifications(IsotopeLabelType.heavy, heavyMods15N) })); SkylineWindow.ModifyDocument("Change heavy modifications", doc => doc.ChangeSettings(settings)); }); AddAllPeptides(); // All peptides should have a heavy label transition group. // There should be no peptide whose children do not contain a transition group with heavy label type. Assert.IsFalse(SkylineWindow.Document.Peptides.Contains(nodePep => !nodePep.Children.Contains(nodeGroup => ((TransitionGroupDocNode)nodeGroup).TransitionGroup.LabelType.Equals(IsotopeLabelType.heavy)))); // Test peptide setting changes update the library explorer. RunUI(() => SkylineWindow.ModifyDocument("Change static modifications", doc => doc.ChangeSettings(SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new List <StaticMod>()))))); AddAllPeptides(1, 8, 3); // Along with Heavy 15N added earlier in the test, adding this modification means that all library peptides // will match to the document settings. StaticMod varMetOxidized = new StaticMod("Methionine Oxidized", "M", null, true, "O", LabelAtoms.None, RelativeRT.Matching, null, null, null); var metOxidizedSettings = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new[] { varMetOxidized })); RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(metOxidizedSettings)); }); // Switch to ANL_Combined library RunDlg <MultiButtonMsgDlg>(() => { libComboBox.SelectedIndex = 2; }, msgDlg => msgDlg.BtnCancelClick()); // User prompted to add library since not in current settings. RunDlg <MultiButtonMsgDlg>(() => _viewLibUI.CheckLibraryInSettings(), msgDlg => msgDlg.Btn0Click()); // Add single peptide to the document. RunUI(_viewLibUI.AddPeptide); WaitForProteinMetadataBackgroundLoaderCompletedUI(); var nodePepAdded = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; // Because document settings match the library, no duplicates should be found. AddAllPeptides(0); // Even though there are two matches in the library for the the nodePep we just added // to the document (one with light modifications and one with heavy), the two spectrum // both have the same charge. In this case, both spectrum should be ignored when Add All // is called. Assert.AreEqual(nodePepAdded, SkylineWindow.SequenceTree.Nodes[0].Nodes[0]); Assert.AreEqual(3, SkylineWindow.Document.PeptideCount); // Switch to the Phospho Loss Library RunDlg <MultiButtonMsgDlg>(() => libComboBox.SelectedIndex = 3, msgDlg => msgDlg.Btn1Click()); // Add modifications to the document matching the settings of the library. var phosphoLossMod = new StaticMod("Phospho Loss", "S, T", null, true, "HPO3", LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), }); var phosphoLossSettings = SkylineWindow.Document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new[] { phosphoLossMod })); RunUI(() => SkylineWindow.ModifyDocument("Change static mods", doc => doc.ChangeSettings(phosphoLossSettings))); RunDlg <MultiButtonMsgDlg>(() => _viewLibUI.CheckLibraryInSettings(), msgDlg => msgDlg.Btn0Click()); // Again, we should be able to match all peptides since the document settings match use the peptides found // in the library. RunDlg <MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides, msgDlg => { Assert.AreEqual(0, (int)msgDlg.Tag); msgDlg.Btn1Click(); }); // Test losses are being displayed in the graph, indicating that the spectrum have been matched correctly. WaitForConditionUI(() => _viewLibUI.GraphItem.IonLabels.Contains(str => str.Contains("98"))); Assert.IsTrue(_viewLibUI.GraphItem.IonLabels.Contains(str => str.Contains("98"))); // Associate yeast background proteome var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunDlg <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg, buildBackgroundProteomeDlg => { buildBackgroundProteomeDlg.BackgroundProteomePath = TestFilesDir.GetTestPath("yeast_mini.protdb"); buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast"; buildBackgroundProteomeDlg.OkDialog(); }); RunUI(peptideSettingsUI.OkDialog); WaitForCondition(() => { var peptideSettings = Program.ActiveDocument.Settings.PeptideSettings; var backgroundProteome = peptideSettings.BackgroundProteome; return(backgroundProteome.HasDigestion(peptideSettings)); }); WaitForDocumentLoaded(); // Give background loader a chance to get the protein metadata too RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, transitionSettingsUI => { transitionSettingsUI.PrecursorCharges = "1,2,3"; transitionSettingsUI.OkDialog(); }); // Test add all with the yeast background proteome connected. RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); // Switch to yeast library. libComboBox.SelectedIndex = 4; _viewLibUI.AssociateMatchingProteins = true; }); var addLibraryDlg = ShowDialog <MultiButtonMsgDlg>(_viewLibUI.AddAllPeptides); // Add the library to the document. var filterMatchedPeptidesDlg = ShowDialog <FilterMatchedPeptidesDlg>(addLibraryDlg.Btn0Click); RunUI(() => filterMatchedPeptidesDlg.AddUnmatched = false); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(4, 10, 13, 39)) { RunDlg <MultiButtonMsgDlg>(filterMatchedPeptidesDlg.OkDialog, messageDlg => messageDlg.Btn1Click()); } Assert.IsFalse(SkylineWindow.Document.Peptides.Contains(nodePep => !nodePep.HasLibInfo)); // Test adding a single peptide that matches two different proteins using keep all. RunUI(() => { SkylineWindow.Undo(); _viewLibUI.ChangeSelectedPeptide("ADTGIAVEGATDAAR+"); }); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(2, 2, 2, 6)) { RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => filterMatchedPeptideDlg.OkDialog()); } // Test adding a second charge state for that peptide. RunUI(() => _viewLibUI.ChangeSelectedPeptide("ADTGIAVEGATDAAR++")); using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(2, 2, 4, 12)) { RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => filterMatchedPeptideDlg.OkDialog()); } RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => filterMatchedPeptideDlg.OkDialog()); // Test adding a second charge state - No Duplicates. RunUI(() => SkylineWindow.Undo()); var docPrev = WaitForDocumentLoaded(); RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => { filterMatchedPeptideDlg.DuplicateProteinsFilter = BackgroundProteome.DuplicateProteinsFilter.NoDuplicates; filterMatchedPeptideDlg.OkDialog(); }); Assert.AreEqual(docPrev, WaitForDocumentLoaded()); // Test adding a second charge state - First Only. using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(2, 2, 3, 9)) { RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => { filterMatchedPeptideDlg.DuplicateProteinsFilter = BackgroundProteome.DuplicateProteinsFilter.FirstOccurence; filterMatchedPeptideDlg.OkDialog(); }); } RunUI(() => { SkylineWindow.Undo(); SkylineWindow.Undo(); // Add doubly charged state, no protein association. _viewLibUI.AssociateMatchingProteins = false; _viewLibUI.AddPeptide(); _viewLibUI.AssociateMatchingProteins = true; }); // Add doubly charged state with protein assocation. RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => filterMatchedPeptideDlg.OkDialog()); // First only // Select singly charged state RunUI(() => _viewLibUI.ChangeSelectedPeptide("ADTGIAVEGATDAAR+")); // Test adding peptide associated with the background proteome does not affect any matching peptides that are // in peptide lists. using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(2, 2, 3, 9)) { RunDlg <FilterMatchedPeptidesDlg>(_viewLibUI.AddPeptide, filterMatchedPeptideDlg => filterMatchedPeptideDlg.OkDialog()); // First only } var peptideGroups = SkylineWindow.Document.PeptideGroups.ToArray(); int index = peptideGroups.IndexOf(nodeGroup => nodeGroup.IsPeptideList); Assert.IsTrue(peptideGroups[index].Children.Count == 1); // Test selecting no duplicates prevents any peptide from appearing twice in the document. RunUI(() => SkylineWindow.Undo()); RunUI(() => SkylineWindow.Undo()); var filterMatchedPeptidesDlg1 = ShowDialog <FilterMatchedPeptidesDlg>(_viewLibUI.AddAllPeptides); RunUI(() => filterMatchedPeptidesDlg1.DuplicateProteinsFilter = BackgroundProteome.DuplicateProteinsFilter.NoDuplicates); RunDlg <MultiButtonMsgDlg>(filterMatchedPeptidesDlg1.OkDialog, messageDlg => messageDlg.Btn1Click()); TestForDuplicatePeptides(); // Test selecting first occurence prevents any peptide from appearing twice in the document. RunUI(() => SkylineWindow.Undo()); var filterMatchedPeptidesDlg2 = ShowDialog <FilterMatchedPeptidesDlg>(_viewLibUI.AddAllPeptides); RunUI(() => filterMatchedPeptidesDlg2.DuplicateProteinsFilter = BackgroundProteome.DuplicateProteinsFilter.FirstOccurence); RunDlg <MultiButtonMsgDlg>(filterMatchedPeptidesDlg2.OkDialog, messageDlg => messageDlg.Btn1Click()); TestForDuplicatePeptides(); // Test peptides are added to "Library Peptides" peptide list if this peptide group already exists. using (new CheckDocumentStateWithPossibleProteinMetadataBackgroundUpdate(1, 2, 3, 9)) { RunUI(() => { SkylineWindow.Undo(); _viewLibUI.AssociateMatchingProteins = false; _viewLibUI.AddPeptide(); _viewLibUI.ChangeSelectedPeptide("AAAP"); _viewLibUI.AddPeptide(); }); } RunUI(() => { SkylineWindow.SelectAll(); SkylineWindow.EditDelete(); }); // Close the Library Explorer dialog OkDialog(_viewLibUI, _viewLibUI.CancelDialog); }