private SrmDocument ConnectLibrarySpecs(SrmDocument document, string documentPath) { string docLibFile = null; if (!string.IsNullOrEmpty(documentPath) && document.Settings.PeptideSettings.Libraries.HasDocumentLibrary) { docLibFile = BiblioSpecLiteSpec.GetLibraryFileName(documentPath); if (!File.Exists(docLibFile)) { Assert.Fail(Resources.CommandLine_ConnectLibrarySpecs_Error__Could_not_find_the_spectral_library__0__for_this_document_, docLibFile); } } var settings = document.Settings.ConnectLibrarySpecs((library, librarySpec) => { string name = library != null ? library.Name : librarySpec.Name; LibrarySpec spec; if (Settings.Default.SpectralLibraryList.TryGetValue(name, out spec)) { if (File.Exists(spec.FilePath)) { return(spec); } } string fileName = library != null ? library.FileNameHint : Path.GetFileName(librarySpec.FilePath); if (fileName != null) { // First look for the file name in the document directory string pathLibrary = PathEx.FindExistingRelativeFile(documentPath, fileName); if (pathLibrary != null) { return(CreateLibrarySpec(library, librarySpec, pathLibrary, true)); } // In the user's default library directory pathLibrary = Path.Combine(Settings.Default.LibraryDirectory, fileName); if (File.Exists(pathLibrary)) { return(CreateLibrarySpec(library, librarySpec, pathLibrary, false)); } } Assert.Fail(Resources.CommandLine_ConnectLibrarySpecs_Warning__Could_not_find_the_spectral_library__0_, name); return(CreateLibrarySpec(library, librarySpec, null, false)); }, docLibFile); if (ReferenceEquals(settings, document.Settings)) { return(document); } // If the libraries were moved to disconnected state, then avoid updating // the document tree for this change, or it will strip all the library // information off the document nodes. if (settings.PeptideSettings.Libraries.DisconnectedLibraries != null) { return(document.ChangeSettingsNoDiff(settings)); } return(document.ChangeSettings(settings)); }
public BiblioSpecLiteBuilder GetLibBuilder(SrmDocument doc, string docFilePath, bool includeAmbiguousMatches) { string outputPath = BiblioSpecLiteSpec.GetLibraryFileName(docFilePath); // Check to see if the library is already there, and if it is, // "Append" instead of "Create" bool libraryExists = File.Exists(outputPath); var libraryBuildAction = LibraryBuildAction.Create; if (libraryExists) { if (doc.Settings.HasDocumentLibrary) { libraryBuildAction = LibraryBuildAction.Append; } else { // If the document does not have a document library, then delete the one that we have found // CONSIDER: it may be that user is trying to re-import, in which case this file is probably in use FileEx.SafeDelete(outputPath); FileEx.SafeDelete(Path.ChangeExtension(outputPath, BiblioSpecLiteSpec.EXT_REDUNDANT)); } } string name = Path.GetFileNameWithoutExtension(docFilePath); return(new BiblioSpecLiteBuilder(name, outputPath, SearchFilenames) { Action = libraryBuildAction, KeepRedundant = true, CutOffScore = CutoffScore, Id = Helpers.MakeId(name), IncludeAmbiguousMatches = includeAmbiguousMatches }); }
private bool VerifyDocumentLibrary() { string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(DocumentPath); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(DocumentPath); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; return(File.Exists(docLibPath) && File.Exists(redundantDocLibPath) && librarySettings.HasDocumentLibrary); }
private void VerifyDocumentLibraryBuilt(string path) { // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(GetTestPath(path)); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); }
private void Testit( bool useDriftTimes, // If false, don't use any drift information in chromatogram extraction ref LibraryIonMobilityInfo driftInfoExplicitDT ) { bool CCSonly = driftInfoExplicitDT != null; // If true, force conversion from CCS to DT var ext = useDriftTimes ? (CCSonly ? "CCS" : "DT") : "train"; string skyfile = TestFilesDir.GetTestPath("test_" + ext + ".sky"); RunUI(() => { SkylineWindow.NewDocument(true); SkylineWindow.SaveDocument(skyfile); }); Stopwatch loadStopwatch = new Stopwatch(); loadStopwatch.Start(); // Enable use of drift times in spectral library var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { // ReSharper disable once ConditionIsAlwaysTrueOrFalse peptideSettingsUI.IsUseSpectralLibraryDriftTimes = useDriftTimes; peptideSettingsUI.SpectralLibraryDriftTimeResolvingPower = 50; }); OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); // Launch import peptide search wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); var basename = _testCase == 1 ? "40minG_WBP_wide_z2-3_mid_BSA_5pmol_01" : "09_BSAtrypticdigest_5uL_IMQTOF_AltFramesdtramp_dAJS009"; var nextFile = _testCase == 1 ? null : "10_BSAtrypticdigest_5uL_IMQTOF_AltFramesdtramp_dAJS010.d"; var searchResults = GetTestPath(basename + ".pep.xml"); var doc = SkylineWindow.Document; if (CCSonly || !useDriftTimes) { // Hide the drift time info provided by SpectrumMill, so we have to convert from CCS var mzxmlFile = searchResults.Replace("pep.xml", "mzXML"); var fileContents = File.ReadAllText(mzxmlFile); fileContents = fileContents.Replace(" DT=", " xx="); if (!useDriftTimes) { fileContents = fileContents.Replace(" CCS=", " xxx="); } File.WriteAllText(mzxmlFile, fileContents); } var searchResultsList = new[] { searchResults }; RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchResultsList); importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95; importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = false; }); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); doc = WaitForDocumentChange(doc); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(skyfile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // We're on the "Extract Chromatograms" page of the wizard. // All the files should be found, and we should // just be able to move to the next page. RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page)); RunUI(() => { var importResultsControl = (ImportResultsControl)importPeptideSearchDlg.ImportResultsControl; importResultsControl.ExcludeSpectrumSourceFiles = true; importResultsControl.UpdateResultsFiles(new [] { TestFilesDirs[0].PersistentFilesDir }, true); // Go look in the persistent files dir }); if (searchResultsList.Length > 1) { // Deal with the common name start dialog var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); RunUI(() => { importResultsNameDlg.NoDialog(); }); WaitForClosedForm(importResultsNameDlg); } else { RunUI(() => importPeptideSearchDlg.ClickNextButtonNoCheck()); } // Modifications are already set up, so that page should get skipped. RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges = new [] { 2, 3, 4, 5 }); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof); RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings // We're on the "Import FASTA" page of the wizard. RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page); importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("SwissProt.bsa-mature")); }); var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog); WaitForClosedForm(importPeptideSearchDlg); var doc1 = WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes if (_testCase == 1) { AssertEx.IsDocumentState(doc1, null, 1, 34, 45, 135); } else { AssertEx.IsDocumentState(doc1, null, 1, 36, 43, 129); } loadStopwatch.Stop(); DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds); var errmsg = ""; if (!useDriftTimes) { // Inspect the loaded data directly to derive DT and CCS // Verify ability to extract predictions from raw data var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>( () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction)); // Simulate user picking Edit Current from the Drift Time Predictor combo control var driftTimePredictorDlg = ShowDialog <EditDriftTimePredictorDlg>(peptideSettingsDlg.AddDriftTimePredictor); RunUI(() => { driftTimePredictorDlg.SetPredictorName("test"); driftTimePredictorDlg.SetResolvingPower(50); driftTimePredictorDlg.GetDriftTimesFromResults(); driftTimePredictorDlg.OkDialog(); }); WaitForClosedForm(driftTimePredictorDlg); RunUI(() => { peptideSettingsDlg.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg); var document = SkylineWindow.Document; var measuredDTs = document.Settings.PeptideSettings.Prediction.IonMobilityPredictor.MeasuredMobilityIons; Assert.IsNotNull(driftInfoExplicitDT, "driftInfoExplicitDT != null"); var explicitDTs = driftInfoExplicitDT.GetIonMobilityDict(); string errMsgAll = string.Empty; // A handful of peptides that really should have been trained on a clean sample // CONSIDER: or are they multiple conformers? They have multiple hits with distinct IM in the pepXML var expectedDiffs = LibKeyMap <double> .FromDictionary(new Dictionary <LibKey, double> { { new PeptideLibraryKey("LC[+57.0]VLHEK", 2), 18.09 }, { new PeptideLibraryKey("EC[+57.0]C[+57.0]DKPLLEK", 3), 7.0 }, { new PeptideLibraryKey("SHC[+57.0]IAEVEK", 3), 6.0 }, { new PeptideLibraryKey("DDPHAC[+57.0]YSTVFDK", 2), 24.0 } }).AsDictionary(); foreach (var pair in doc1.PeptidePrecursorPairs) { string errMsg = string.Empty; var key = new LibKey(pair.NodePep.ModifiedSequence, pair.NodeGroup.PrecursorAdduct); double tolerCCS = 5; if (expectedDiffs.ContainsKey(key)) { tolerCCS = expectedDiffs[key] + .1; } if (!explicitDTs.ContainsKey(key)) { errMsg += "Could not locate explicit IMS info for " + key + "\n"; } var given = explicitDTs[key][0]; var measured = measuredDTs[key]; var msg = CheckDeltaPct(given.CollisionalCrossSectionSqA ?? 0, measured.CollisionalCrossSectionSqA ?? 0, tolerCCS, "measured CCS", key.ToString()); if (!string.IsNullOrEmpty(msg)) { errMsg += msg + CheckDeltaPct(given.IonMobility.Mobility.Value, measured.IonMobility.Mobility.Value, -1, "measured drift time", key.ToString()); } else { errMsg += CheckDelta(given.IonMobility.Mobility.Value, measured.IonMobility.Mobility.Value, 10.0, "measured drift time", key.ToString()); } errMsg += CheckDelta(given.HighEnergyIonMobilityValueOffset, measured.HighEnergyIonMobilityValueOffset, 2.0, "measured drift time high energy offset", key.ToString()); if (!string.IsNullOrEmpty(errMsg)) { errMsgAll += "\n" + errMsg; } } if (!string.IsNullOrEmpty(errMsgAll)) { Assert.Fail(errMsgAll); } return; } LibraryIonMobilityInfo libraryIonMobilityInfo; doc1.Settings.PeptideSettings.Libraries.Libraries.First().TryGetIonMobilityInfos(doc1.MoleculeLibKeys.ToArray(), 0, out libraryIonMobilityInfo); if (driftInfoExplicitDT == null) { driftInfoExplicitDT = libraryIonMobilityInfo; } else { var instrumentInfo = new DataFileInstrumentInfo(new MsDataFileImpl(GetTestPath(basename + ".d"))); var dictExplicitDT = driftInfoExplicitDT.GetIonMobilityDict(); foreach (var pep in doc1.Peptides) { foreach (var nodeGroup in pep.TransitionGroups) { double windowDT; var calculatedDriftTime = doc1.Settings.GetIonMobility( pep, nodeGroup, null, libraryIonMobilityInfo, instrumentInfo, 0, out windowDT); var libKey = new LibKey(pep.ModifiedSequence, nodeGroup.PrecursorAdduct); IonMobilityAndCCS[] infoValueExplicitDT; if (!dictExplicitDT.TryGetValue(libKey, out infoValueExplicitDT)) { errmsg += "No driftinfo value found for " + libKey + "\n"; } else { var ionMobilityInfo = infoValueExplicitDT[0]; var delta = Math.Abs(ionMobilityInfo.IonMobility.Mobility.Value - calculatedDriftTime.IonMobility.Mobility.Value); var acceptableDelta = (libKey.Sequence.StartsWith("DDPHAC") || libKey.Sequence.EndsWith("VLHEK")) ? 3: 1; // These were ambiguous matches if (delta > acceptableDelta) { errmsg += String.Format("calculated DT ({0}) and explicit DT ({1}, CCS={4}) do not agree (abs delta = {2}) for {3}\n", calculatedDriftTime.IonMobility, ionMobilityInfo.IonMobility, delta, libKey, ionMobilityInfo.CollisionalCrossSectionSqA ?? 0); } } } } } float tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance; double maxHeight = 0; var results = doc1.Settings.MeasuredResults; var numPeaks = _testCase == 1 ? new[] { 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 10, 7, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 10, 10, 8, 10, 10, 10, 10, 10 } : new[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; int npIndex = 0; foreach (var pair in doc1.PeptidePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); foreach (var chromGroup in chromGroupInfo) { if (numPeaks[npIndex] != chromGroup.NumPeaks) { errmsg += String.Format("unexpected peak count {0} instead of {1} in chromatogram {2}\r\n", chromGroup.NumPeaks, numPeaks[npIndex], npIndex); } npIndex++; foreach (var tranInfo in chromGroup.TransitionPointSets) { maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity); } } } Assert.IsTrue(errmsg.Length == 0, errmsg); Assert.AreEqual(_testCase == 1 ? 2265204 : 1326442, maxHeight, 1); // Does CCS show up in reports? var expectedDtWindow = _testCase == 1 ? 0.74 : 0.94; TestReports(doc1, 0, expectedDtWindow); if (nextFile != null) { // Verify that we can use library generated for one file as the default for another without its own library ImportResults(nextFile); TestReports(SkylineWindow.Document, 1, expectedDtWindow); } // And verify roundtrip of ion mobility AssertEx.RoundTrip(SkylineWindow.Document); RunUI(() => { SkylineWindow.SaveDocument(skyfile); SkylineWindow.NewDocument(true); SkylineWindow.OpenFile(skyfile); }); TestReports(SkylineWindow.Document, 1, expectedDtWindow); // Watch for problem with reimport after changed DT window var docResolvingPower = SkylineWindow.Document; var peptideSettingsUI2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { // ReSharper disable once ConditionIsAlwaysTrueOrFalse peptideSettingsUI2.IsUseSpectralLibraryDriftTimes = useDriftTimes; peptideSettingsUI2.SpectralLibraryDriftTimeResolvingPower = 40; }); OkDialog(peptideSettingsUI2, peptideSettingsUI2.OkDialog); var docReimport = WaitForDocumentChangeLoaded(docResolvingPower); // Reimport data for a replicate RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg => { var chromatograms = docReimport.Settings.MeasuredResults.Chromatograms; dlg.SelectedChromatograms = new[] { chromatograms[0] }; dlg.ReimportResults(); dlg.OkDialog(); }); WaitForDocumentChangeLoaded(docReimport); var expectedDtWindow0 = _testCase == 2 ? 1.175 : 0.92; var expectedDtWindow1 = _testCase == 2 ? 0.94 : 0.92; TestReports(SkylineWindow.Document, 0, expectedDtWindow0, string.Format(" row {0} case {1} ccsOnly {2}", 0, _testCase, CCSonly)); TestReports(SkylineWindow.Document, 1, expectedDtWindow1, string.Format(" row {0} case {1} ccsOnly {2}", 1, _testCase, CCSonly)); }
public bool BuildPeptideSearchLibrary(CancelEventArgs e) { // Nothing to build, if now search files were specified if (!SearchFilenames.Any()) { var libraries = SkylineWindow.Document.Settings.PeptideSettings.Libraries; if (!libraries.HasLibraries) { return(false); } var libSpec = libraries.LibrarySpecs.FirstOrDefault(s => s.IsDocumentLibrary); return(libSpec != null && LoadPeptideSearchLibrary(libSpec)); } double cutOffScore; MessageBoxHelper helper = new MessageBoxHelper(WizardForm); if (!helper.ValidateDecimalTextBox(textCutoff, 0, 1.0, out cutOffScore)) { e.Cancel = true; return(false); } ImportPeptideSearch.CutoffScore = cutOffScore; BiblioSpecLiteBuilder builder; try { builder = ImportPeptideSearch.GetLibBuilder(SkylineWindow.Document, SkylineWindow.DocumentFilePath, cbIncludeAmbiguousMatches.Checked); } catch (FileEx.DeleteException de) { MessageDlg.ShowException(this, de); return(false); } using (var longWaitDlg = new LongWaitDlg { Text = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_Peptide_Search_Library, Message = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_document_library_for_peptide_search_, }) { // Disable the wizard, because the LongWaitDlg does not try { ImportPeptideSearch.ClosePeptideSearchLibraryStreams(SkylineWindow.DocumentUI); var status = longWaitDlg.PerformWork(WizardForm, 800, monitor => LibraryManager.BuildLibraryBackground(SkylineWindow, builder, monitor, new LibraryManager.BuildState(null, null))); if (status.IsError) { MessageDlg.ShowException(WizardForm, status.ErrorException); return(false); } } catch (Exception x) { MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Failed_to_build_the_library__0__, Path.GetFileName(BiblioSpecLiteSpec.GetLibraryFileName(SkylineWindow.DocumentFilePath))), x.Message), x); return(false); } } var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true); Settings.Default.SpectralLibraryList.Insert(0, docLibSpec); // Go ahead and load the library - we'll need it for // the modifications and chromatograms page. if (!LoadPeptideSearchLibrary(docLibSpec)) { return(false); } var selectedIrtStandard = comboStandards.SelectedItem as IrtStandard; var addedIrts = false; if (selectedIrtStandard != null && selectedIrtStandard != IrtStandard.NULL) { addedIrts = AddIrtLibraryTable(docLibSpec.FilePath, selectedIrtStandard); } var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(SkylineWindow.Document, docLibSpec); if (docNew == null) { return(false); } if (addedIrts) { docNew = ImportPeptideSearch.AddRetentionTimePredictor(docNew, docLibSpec); } SkylineWindow.ModifyDocument(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Add_document_spectral_library, doc => docNew); if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage)) { MessageDlg.Show(WizardForm, builder.AmbiguousMatchesMessage); } return(true); }
private bool BuildPeptideSearchLibrary(CancelEventArgs e) { // Nothing to build, if now search files were specified if (!SearchFilenames.Any()) { var libraries = DocumentContainer.Document.Settings.PeptideSettings.Libraries; if (!libraries.HasLibraries) { return(false); } var libSpec = libraries.LibrarySpecs.FirstOrDefault(s => s.IsDocumentLibrary); return(libSpec != null && LoadPeptideSearchLibrary(libSpec)); } double cutOffScore; MessageBoxHelper helper = new MessageBoxHelper(WizardForm); if (!helper.ValidateDecimalTextBox(textCutoff, 0, 1.0, out cutOffScore)) { e.Cancel = true; return(false); } ImportPeptideSearch.CutoffScore = cutOffScore; BiblioSpecLiteBuilder builder; try { builder = ImportPeptideSearch.GetLibBuilder(DocumentContainer.Document, DocumentContainer.DocumentFilePath, cbIncludeAmbiguousMatches.Checked); builder.PreferEmbeddedSpectra = PreferEmbeddedSpectra; } catch (FileEx.DeleteException de) { MessageDlg.ShowException(this, de); return(false); } bool retry = false; do { using (var longWaitDlg = new LongWaitDlg { Text = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_Peptide_Search_Library, Message = Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Building_document_library_for_peptide_search_, }) { // Disable the wizard, because the LongWaitDlg does not try { ImportPeptideSearch.ClosePeptideSearchLibraryStreams(DocumentContainer.Document); var status = longWaitDlg.PerformWork(WizardForm, 800, monitor => LibraryManager.BuildLibraryBackground(DocumentContainer, builder, monitor, new LibraryManager.BuildState(null, null))); if (status.IsError) { // E.g. could not find external raw data for MaxQuant msms.txt; ask user if they want to retry with "prefer embedded spectra" option if (BiblioSpecLiteBuilder.IsLibraryMissingExternalSpectraError(status.ErrorException)) { var response = ShowLibraryMissingExternalSpectraError(WizardForm, status.ErrorException); if (response == UpdateProgressResponse.cancel) { return(false); } else if (response == UpdateProgressResponse.normal) { builder.PreferEmbeddedSpectra = true; } retry = true; } else { MessageDlg.ShowException(WizardForm, status.ErrorException); return(false); } } } catch (Exception x) { MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_BuildPeptideSearchLibrary_Failed_to_build_the_library__0__, Path.GetFileName(BiblioSpecLiteSpec.GetLibraryFileName(DocumentContainer.DocumentFilePath))), x.Message), x); return(false); } } } while (retry); var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true); Settings.Default.SpectralLibraryList.Insert(0, docLibSpec); // Go ahead and load the library - we'll need it for // the modifications and chromatograms page. if (!LoadPeptideSearchLibrary(docLibSpec)) { return(false); } var selectedIrtStandard = comboStandards.SelectedItem as IrtStandard; var addedIrts = false; if (selectedIrtStandard != null && selectedIrtStandard != IrtStandard.EMPTY) { addedIrts = AddIrtLibraryTable(docLibSpec.FilePath, selectedIrtStandard); } var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(DocumentContainer.Document, docLibSpec); if (docNew == null) { return(false); } if (addedIrts) { docNew = ImportPeptideSearch.AddRetentionTimePredictor(docNew, docLibSpec); } DocumentContainer.ModifyDocumentNoUndo(doc => docNew); if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage)) { MessageDlg.Show(WizardForm, builder.AmbiguousMatchesMessage); } return(true); }
protected override void DoTest() { string skyfile = TestFilesDir.GetTestPath("test_pasef_mascot.sky"); RunUI(() => { SkylineWindow.NewDocument(true); SkylineWindow.SaveDocument(skyfile); }); Stopwatch loadStopwatch = new Stopwatch(); loadStopwatch.Start(); // Enable use of drift times in spectral library var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { // ReSharper disable once ConditionIsAlwaysTrueOrFalse peptideSettingsUI.IsUseSpectralLibraryDriftTimes = true; peptideSettingsUI.SpectralLibraryDriftTimeResolvingPower = 50; }); OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); // Launch import peptide search wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); var nextFile = "FZGC A 100 ng_Slot1-46_01_440.d"; var searchResults = GetTestPath("F264099.dat"); var doc = SkylineWindow.Document; var searchResultsList = new[] { searchResults }; RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchResultsList); importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95; importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = false; }); var ambiguousDlg = ShowDialog <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); // Expect the ambiguous matches dialog OkDialog(ambiguousDlg, ambiguousDlg.OkDialog); doc = WaitForDocumentChange(doc); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(skyfile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // We're on the "Extract Chromatograms" page of the wizard. // All the files should be found, and we should // just be able to move to the next page. RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page)); RunUI(() => { var importResultsControl = (ImportResultsControl)importPeptideSearchDlg.ImportResultsControl; importResultsControl.ExcludeSpectrumSourceFiles = false; importResultsControl.UpdateResultsFiles(new [] { TestFilesDirs[0].PersistentFilesDir }, true); // Go look in the persistent files dir }); if (searchResultsList.Length > 1) { // Deal with the common name start dialog var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); RunUI(() => { importResultsNameDlg.NoDialog(); }); WaitForClosedForm(importResultsNameDlg); } else { RunUI(() => importPeptideSearchDlg.ClickNextButtonNoCheck()); } // Modifications are already set up, so that page should get skipped. RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges = new [] { 2, 3, 4, 5 }); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.UseSpectralLibraryIonMobilityValuesControl.SetUseSpectralLibraryDriftTimes(true)); // Verify error handling in ion mobility control RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.UseSpectralLibraryIonMobilityValuesControl.SetResolvingPowerText("fish")); var errDlg = ShowDialog <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); RunUI(() => errDlg.OkDialog()); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.UseSpectralLibraryIonMobilityValuesControl.SetResolvingPower(40)); RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings // We're on the "Import FASTA" page of the wizard. RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page); importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("human_and_yeast.fasta")); }); var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); WaitForConditionUI(() => peptidesPerProteinDlg.DocumentFinalCalculated); OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog); WaitForClosedForm(importPeptideSearchDlg); var doc1 = WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes AssertEx.IsDocumentState(doc1, null, 7906, 28510, 28510, 85530); loadStopwatch.Stop(); DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds); var errmsg = ""; LibraryIonMobilityInfo libraryIonMobilityInfo; doc1.Settings.PeptideSettings.Libraries.Libraries.First().TryGetIonMobilityInfos(0, out libraryIonMobilityInfo); var driftInfoExplicitDT = libraryIonMobilityInfo; var instrumentInfo = new DataFileInstrumentInfo(new MsDataFileImpl(GetTestPath(nextFile))); var dictExplicitDT = driftInfoExplicitDT.GetIonMobilityDict(); foreach (var pep in doc1.Peptides) { foreach (var nodeGroup in pep.TransitionGroups) { double windowDT; var calculatedDriftTime = doc1.Settings.GetIonMobility( pep, nodeGroup, libraryIonMobilityInfo, instrumentInfo, 0, out windowDT); var libKey = new LibKey(pep.ModifiedSequence, nodeGroup.PrecursorAdduct); IonMobilityAndCCS[] infoValueExplicitDT; if (!dictExplicitDT.TryGetValue(libKey, out infoValueExplicitDT)) { errmsg += "No ionMobility value found for " + libKey + "\n"; } else { var ionMobilityInfo = infoValueExplicitDT[0]; var delta = Math.Abs(ionMobilityInfo.IonMobility.Mobility.Value - calculatedDriftTime.IonMobility.Mobility.Value); var acceptableDelta = 1; if (delta > acceptableDelta) { errmsg += String.Format("calculated DT ({0}) and explicit DT ({1}, CCS={4}) do not agree (abs delta = {2}) for {3}\n", calculatedDriftTime.IonMobility, ionMobilityInfo.IonMobility, delta, libKey, ionMobilityInfo.CollisionalCrossSectionSqA ?? 0); } } } } float tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance; double maxHeight = 0; var results = doc1.Settings.MeasuredResults; foreach (var pair in doc1.PeptidePrecursorPairs) { Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out var chromGroupInfo)); foreach (var chromGroup in chromGroupInfo) { foreach (var tranInfo in chromGroup.TransitionPointSets) { maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity); } } } Assert.IsTrue(errmsg.Length == 0, errmsg); Assert.AreEqual(1093425, maxHeight, 1); // Does CCS show up in reports? TestReports(doc1); }
protected override void DoTest() { string skyfile = TestFilesDir.GetTestPath("Mix1_SkylineIMS_Test-reimport_RP50.sky"); RunUI(() => SkylineWindow.OpenFile(skyfile)); var doc0 = WaitForDocumentLoaded(); AssertEx.IsDocumentState(doc0, null, 4, 218, 429, 3176); Stopwatch loadStopwatch = new Stopwatch(); loadStopwatch.Start(); // Launch import peptide search wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); const string ID12692Base = "ID12692_01_UCA168_3727_040714"; string ID12692Search = GetTestPath(ID12692Base + "_IA_final_fragment.csv"); string[] searchFiles = { ID12692Search }; var doc = SkylineWindow.Document; RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles); importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95; importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = true; }); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); doc = WaitForDocumentChange(doc); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(skyfile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // We're on the "Extract Chromatograms" page of the wizard. // All the files should be found, and we should // just be able to move to the next page. RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page)); RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Modifications are already set up, so that page should get skipped. RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings /* No lockmass correction for IMS data due to Waters DLL limitations as of Nov 2015 * var lockmassDlg = ShowDialog<ImportResultsLockMassDlg>(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings, lockmass correction dialog should appear * RunUI(() => * { * var mz = 785.8426; // Glu-Fib ESI 2+, per Will T * lockmassDlg.LockmassPositive = mz; * lockmassDlg.LockmassNegative = mz; * lockmassDlg.LockmassTolerance = 10.0; * }); * RunUI(lockmassDlg.OkDialog); * WaitForClosedForm<ImportResultsLockMassDlg>(); */ // Add FASTA also skipped because filter for document peptides was chosen. WaitForClosedForm(importPeptideSearchDlg); WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes var doc1 = WaitForDocumentLoaded(400000); AssertEx.IsDocumentState(doc1, null, 4, 63, 6, 42); // Was 4, 63, 4, 30 before drift time based charge state detection was added to final_fragments reader loadStopwatch.Stop(); DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds); float tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance; double maxHeight = 0; var results = doc1.Settings.MeasuredResults; var numPeaks = new[] { 8, 10, 10, 10, 10, 10, 10 }; int npIndex = 0; var errmsg = ""; foreach (var pair in doc1.PeptidePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); foreach (var chromGroup in chromGroupInfo) { if (numPeaks[npIndex] != chromGroup.NumPeaks) { errmsg += String.Format("unexpected peak count {0} instead of {1} in chromatogram {2}\r\n", chromGroup.NumPeaks, numPeaks[npIndex], npIndex); } npIndex++; foreach (var tranInfo in chromGroup.TransitionPointSets) { maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity); } } } Assert.IsTrue(errmsg.Length == 0, errmsg); Assert.AreEqual(3617.529, maxHeight, 1); }
protected override void DoTest() { TestSmallMolecules = false; // The presence of the extra test node without any results is incompatible with what's being tested here. // Clean-up before running the test RunUI(() => SkylineWindow.ModifyDocument("Set default settings", d => d.ChangeSettings(SrmSettingsList.GetDefault()))); SrmDocument doc = SkylineWindow.Document; const string documentBaseName = "Ms1FilterTutorial"; string documentFile = GetTestPath(documentBaseName + SrmDocument.EXT); RunUI(() => SkylineWindow.SaveDocument(documentFile)); // show the empty Transition Setting dialog var transitionSettingsDlg = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => transitionSettingsDlg.SelectedTab = TransitionSettingsUI.TABS.FullScan); PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan tab nothing set", 2); OkDialog(transitionSettingsDlg, transitionSettingsDlg.OkDialog); // Launch the wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); // We're on the "Build Spectral Library" page of the wizard. // Add the test xml file to the search files list and try to // build the document library. string[] searchFiles = { GetTestPath("100803_0001_MCF7_TiB_L.group.xml"), // Not L10N GetTestPath("100803_0005b_MCF7_TiTip3.group.xml") // Not L10N }; PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library empty page", 3); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles); }); PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", 4); var ambiguousDlg = ShowDialog <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); OkDialog(ambiguousDlg, ambiguousDlg.OkDialog); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(documentFile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // We're on the "Extract Chromatograms" page of the wizard. // All the test results files are in the same directory as the // document file, so all the files should be found, and we should // just be able to move to the next page. WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page); PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search - Extract Chromatograms page", 5); var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(() => importPeptideSearchDlg.ClickNextButton()); PauseForScreenShot <ImportResultsNameDlg>("Import Results - Common prefix form", 6); OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog); // Wait for the "Add Modifications" page of the wizard. WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.match_modifications_page); List <string> modsToCheck = new List <string> { "Phospho (ST)", "Phospho (Y)", "Oxidation (M)" }; // Not L10N RunUI(() => { importPeptideSearchDlg.MatchModificationsControl.CheckedModifications = modsToCheck; }); PauseForScreenShot <ImportPeptideSearchDlg.MatchModsPage>("Import Peptide Search - Add Modifications page", 7); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); // We're on the "Configure MS1 Full-Scan Settings" page of the wizard. RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page); importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges = new[] { 2, 3, 4 }; importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof; importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes = 10 * 1000; Assert.AreEqual(importPeptideSearchDlg.FullScanSettingsControl.PrecursorIsotopesCurrent, FullScanPrecursorIsotopes.Count); Assert.AreEqual(FullScanMassAnalyzerType.tof, importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer); Assert.AreEqual(10 * 1000, importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes); Assert.AreEqual(3, importPeptideSearchDlg.FullScanSettingsControl.Peaks); Assert.AreEqual(RetentionTimeFilterType.ms2_ids, importPeptideSearchDlg.FullScanSettingsControl.RetentionTimeFilterType); Assert.AreEqual(5, importPeptideSearchDlg.FullScanSettingsControl.TimeAroundMs2Ids); }); PauseForScreenShot <ImportPeptideSearchDlg.Ms1FullScanPage>("Import Peptide Search - Configure MS1 Full-Scan Settings page", 8); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); // Last page of wizard - Import Fasta. string fastaPath = GetTestPath("12_proteins.062011.fasta"); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page); Assert.AreEqual("Trypsin [KR | P]", importPeptideSearchDlg.ImportFastaControl.Enzyme.GetKey()); importPeptideSearchDlg.ImportFastaControl.MaxMissedCleavages = 2; importPeptideSearchDlg.ImportFastaControl.SetFastaContent(fastaPath); Assert.IsFalse(importPeptideSearchDlg.ImportFastaControl.DecoyGenerationEnabled); }); PauseForScreenShot <ImportPeptideSearchDlg.FastaPage>("Import Peptide Search - Import FASTA page", 10); var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(() => importPeptideSearchDlg.ClickNextButton()); WaitForCondition(() => peptidesPerProteinDlg.DocumentFinalCalculated); RunUI(() => { int proteinCount, peptideCount, precursorCount, transitionCount; peptidesPerProteinDlg.NewTargetsAll(out proteinCount, out peptideCount, out precursorCount, out transitionCount); Assert.AreEqual(11, proteinCount); Assert.AreEqual(51, peptideCount); Assert.AreEqual(52, precursorCount); Assert.AreEqual(156, transitionCount); peptidesPerProteinDlg.NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount); Assert.AreEqual(11, proteinCount); Assert.AreEqual(51, peptideCount); Assert.AreEqual(52, precursorCount); Assert.AreEqual(156, transitionCount); }); OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog); PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 11); WaitForDocumentChangeLoaded(doc, 8 * 60 * 1000); // 10 minutes var libraryExplorer = ShowDialog <ViewLibraryDlg>(() => SkylineWindow.OpenLibraryExplorer(documentBaseName)); var matchedPepModsDlg = WaitForOpenForm <AddModificationsDlg>(); PauseForScreenShot <MultiButtonMsgDlg>("Add mods alert", 12); RunUI(() => { Assert.AreEqual(13, matchedPepModsDlg.NumMatched); Assert.AreEqual(0, matchedPepModsDlg.NumUnmatched); matchedPepModsDlg.CancelDialog(); }); RunUI(() => { libraryExplorer.GraphSettings.ShowBIons = true; libraryExplorer.GraphSettings.ShowYIons = true; libraryExplorer.GraphSettings.ShowCharge1 = true; libraryExplorer.GraphSettings.ShowCharge2 = true; libraryExplorer.GraphSettings.ShowPrecursorIon = true; }); PauseForScreenShot <ViewLibraryDlg>("Spectral Library Explorer", 13); RunUI(() => { const string sourceFirst = "100803_0005b_MCF7_TiTip3.wiff"; const double timeFirst = 35.2128; Assert.AreEqual(sourceFirst, libraryExplorer.SourceFile); Assert.AreEqual(timeFirst, libraryExplorer.RetentionTime, 0.0001); libraryExplorer.SelectedIndex++; Assert.AreNotEqual(sourceFirst, libraryExplorer.SourceFile); Assert.AreNotEqual(timeFirst, libraryExplorer.RetentionTime, 0.0001); }); OkDialog(libraryExplorer, libraryExplorer.CancelDialog); const int TIB_L = 0; // index for Tib_L const int TIP3 = 1; // index for Tip3 AssertEx.IsDocumentState(SkylineWindow.Document, null, 11, 51, 52, 156); AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIB_L]), 51, 52, 0, 156, 0); AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIP3]), 51, 52, 0, 156, 0); string Tib_LFilename = searchFiles[TIB_L].Replace(".group.xml", PreferedExtAbWiff); string Tip3Filename = searchFiles[TIP3].Replace(".group.xml", PreferedExtAbWiff); // Select the first transition group. RunUI(() => { SkylineWindow.SequenceTree.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0); SkylineWindow.GraphSpectrumSettings.ShowAIons = true; SkylineWindow.GraphSpectrumSettings.ShowBIons = true; SkylineWindow.GraphSpectrumSettings.ShowYIons = true; SkylineWindow.GraphSpectrumSettings.ShowPrecursorIon = true; SkylineWindow.ExpandPrecursors(); SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR); }); RunDlg <SpectrumChartPropertyDlg>(SkylineWindow.ShowSpectrumProperties, dlg => { dlg.FontSize = GraphFontSize.NORMAL; dlg.OkDialog(); }); RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg => { dlg.FontSize = GraphFontSize.NORMAL; dlg.OkDialog(); }); RunUI(() => { // Make window screenshot size if (IsPauseForScreenShots && SkylineWindow.WindowState != FormWindowState.Maximized) { SkylineWindow.Width = 1160; SkylineWindow.Height = 792; } }); RestoreViewOnScreen(13); PauseForScreenShot("Main window with imported data", 14); // RunUIWithDocumentWait(() => // { // SkylineWindow.ToggleIntegrateAll(); // TODO: No longer necessary. Change in tutorial // }); RunUI(() => { SkylineWindow.ShowGraphPeakArea(true); SkylineWindow.ShowPeakAreaReplicateComparison(); SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.none); Settings.Default.ShowDotProductPeakArea = true; Settings.Default.ShowLibraryPeakArea = true; }); PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view (show context menu)", 16); RestoreViewOnScreen(15); RunUI(() => { SkylineWindow.AutoZoomBestPeak(); SkylineWindow.ArrangeGraphsTiled(); SkylineWindow.ShowChromatogramLegends(false); }); PauseForScreenShot("Main window layout", 17); int atest = 0; CheckAnnotations(TIB_L, 0, atest++); int pepIndex = 3; RunUI(() => SkylineWindow.CollapsePeptides()); RunUI(() => SkylineWindow.ShowAlignedPeptideIDTimes(true)); ChangePeakBounds(TIB_L, pepIndex, 38.79, 39.385); PauseForScreenShot("Chromatogram graphs clipped from main window", 19); CheckAnnotations(TIB_L, pepIndex, atest++); var alignmentForm = ShowDialog <AlignmentForm>(() => SkylineWindow.ShowRetentionTimeAlignmentForm()); RunUI(() => { alignmentForm.Width = 711; alignmentForm.Height = 561; alignmentForm.ComboAlignAgainst.SelectedIndex = 0; // to match what's in the tutorial doc }); PauseForScreenShot <AlignmentForm>("Retention time alignment form", 20); OkDialog(alignmentForm, alignmentForm.Close); PauseForScreenShot("Status bar clipped from main window - 4/51 pep 4/52 prec 10/156 tran", 21); pepIndex = JumpToPeptide("SSKASLGSLEGEAEAEASSPK"); RunUI(() => SkylineWindow.ShowChromatogramLegends(true)); Assert.IsTrue(8 == pepIndex); PauseForScreenShot("Chromatogram graph metafiles for 9th peptide", 21); CheckAnnotations(TIB_L, pepIndex, atest++); ZoomSingle(TIP3, 32.6, 41.4); // simulate the wheel scroll described in tutorial PauseForScreenShot("Chromatogram graph metafile showing all peaks for 1_MCF_TiB_L", 22); CheckAnnotations(TIB_L, pepIndex, atest++); // current TIB_L peak should have idotp .87 and ppm -6.9 Assert.AreEqual(0.87, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005); Assert.AreEqual(-10.8, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05); ChangePeakBounds(TIB_L, pepIndex, 36.5, 38.0); // now current TIB_L peak should have idotp .9 and ppm -6.5 Assert.AreEqual(0.9, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005); Assert.AreEqual(-9.4, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05); CheckAnnotations(TIB_L, pepIndex, atest++); var undoIndex = SkylineWindow.Document.RevisionIndex; // preserve for simulating ctrl-z PickPeakBoth(pepIndex, 40.471035, 40.8134); // select peak for both chromatograms at these respective retention times PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 23); int[] m1Thru4 = { 1, 2, 3, 4, 5 }; PickTransitions(pepIndex, m1Thru4, "Transition pick list filtered", 24, "Transition pick list unfiltered", 24); // turn on chromatograms PickPeakBoth(pepIndex, 36.992836, 37.3896027); // select peak for both chromatograms at these respective retention times ZoomSingle(TIP3, 32.4, 39.6); // set the view for screenshot PauseForScreenShot("Chromatogram graph metafile comparing 33 and 37 minute peaks", 25); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); RevertDoc(undoIndex); // undo changes pepIndex = JumpToPeptide("ASLGSLEGEAEAEASSPKGK"); // Not L10N Assert.IsTrue(10 == pepIndex); PauseForScreenShot("Chhromatogram graph meta files for peptide ASLGSLEGEAEAEASSPKGK", 26); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); PickTransitions(pepIndex, m1Thru4); // turn on M+3 and M+4 ChangePeakBounds(TIP3, pepIndex, 37.35, 38.08); ZoomSingle(TIP3, 36.65, 39.11); // simulate the wheel scroll described in tutorial PauseForScreenShot("upper - Chromatogram graph metafile for peptide ASLGSLEGEAEAEASSPKGK with adjusted integration", 27); CheckAnnotations(TIP3, pepIndex, atest++); RevertDoc(undoIndex); // undo changes pepIndex = JumpToPeptide("AEGEWEDQEALDYFSDKESGK"); // Not L10N PauseForScreenShot("lower - Chromatogram graph metafiles for peptide AEGEWEDQEALDYFSDKESGK", 27); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); int[] m1Thru5 = { 1, 2, 3, 4, 5, 6 }; PickTransitions(pepIndex, m1Thru5); // turn on M+3 M+4 and M+5 PauseForScreenShot("Chromatogram graph metafiles with M+3, M+4 and M+5 added", 28); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); JumpToPeptide("ALVEFESNPEETREPGSPPSVQR"); // Not L10N PauseForScreenShot("Chromatogram graph metafiles for peptide ALVEFESNPEETREPGSPPSVQR", 29); pepIndex = JumpToPeptide("YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR"); // Not L10N PauseForScreenShot("upper - Peak Areas graph metafile for peptide YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR", 30); int[] m1Thru7 = { 1, 2, 3, 4, 5, 6, 7, 8 }; PickTransitions(pepIndex, m1Thru7); // enable [M+3] [M+4] [M+5] [M+6] [M+7] PauseForScreenShot("lower - Peak Areas graph metafile with M+3 through M+7 added", 30); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); // page 32 zooming setup RunUI(() => { SkylineWindow.SynchronizeZooming(true); SkylineWindow.LockYChrom(false); SkylineWindow.AlignToFile = SkylineWindow.GraphChromatograms.ToArray()[TIP3].GetChromFileInfoId(); // align to Tip3 }); ZoomBoth(36.5, 39.5, 1600); // simulate the wheel scroll described in tutorial RunUI(() => SkylineWindow.ShowChromatogramLegends(false)); PauseForScreenShot("Chromatogram graphs clipped from main window with synchronized zooming", 32); RestoreViewOnScreen(33); // float the Library Match window TODO this causes a crash at next call to ChangePeakBounds, in pwiz.Skyline.Controls.Graphs.GraphChromatogram.ChromGroupInfos.get() Line 492 , why? RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tip3Filename), 37.6076f))); // set the Library Match view PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 5b_MCF7_TiTip3 (37.61 Min)", 33); RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tib_LFilename), 37.0335f))); // set the Library Match view PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 1_MCF_TiB_L (37.03 min)", 33); RestoreViewOnScreen(34); // back to normal view pepIndex = JumpToPeptide("GVVDSEDLPLNISR"); // Not L10N RunUI(() => SkylineWindow.ShowChromatogramLegends(true)); PauseForScreenShot("upper - Chromatogram graph metafiles for peptide GVVDSEDLPLNISR", 34); ZoomBoth(35.05, 36.9, 480); PauseForScreenShot("lower - Chromatogram graph metafile - effect of zoom ", 34); ChangePeakBounds(TIP3, pepIndex, 35.7, 36.5); // adjust integration per tutorial CheckAnnotations(TIP3, pepIndex, atest++); // check the new idotp values /* pepIndex = */ JumpToPeptide("DQVANSAFVER"); // Not L10N PauseForScreenShot("Chromatogram graph metafiles for peptide DQVANSAFVER", 35); // int[] m1 = {2}; // PickTransitions(pepIndex, m1); // enable [M+1] only // // Measured times in TIB_L are different from displayed times, because of alignment // ChangePeakBounds(TIB_L, pepIndex, 23.99, 25.29); // ChangePeakBounds(TIP3, pepIndex, 23.81, 25.21); // // First transition selected for screenshot // RunUI(() => // { // var pathPep = SkylineWindow.SelectedPath; // var nodePep = ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode; // var nodeGroup = nodePep.TransitionGroups.First(); // var nodeTran = nodeGroup.Transitions.First(); // SkylineWindow.SelectedPath = new IdentityPath( // new IdentityPath(pathPep, nodeGroup.TransitionGroup), nodeTran.Transition); // }); // PauseForScreenShot("page 36 - M+1 only, with adjusted integration"); // CheckAnnotations(TIB_L, pepIndex, atest++); // CheckAnnotations(TIP3, pepIndex, EXPECTED_ANNOTATIONS[atest]); var docAfter = WaitForProteinMetadataBackgroundLoaderCompletedUI(); // Minimizing a chromatogram cache file. RunUI(SkylineWindow.CollapsePeptides); for (int i = 0; i < 5; i++) // just do the first 5 { int iPeptide = i; var path = docAfter.GetPathTo((int)SrmDocument.Level.Molecules, iPeptide); RunUI(() => { SkylineWindow.SelectedPath = path; }); WaitForGraphs(); } // Eliminate extraneous chromatogram data. doc = WaitForProteinMetadataBackgroundLoaderCompletedUI(); var minimizedFile = GetTestPath("Ms1FilteringTutorial-2min.sky"); // Not L10N var cacheFile = Path.ChangeExtension(minimizedFile, ChromatogramCache.EXT); { // TODO: Figure out why the minimize fails to unlock the .skyd file, if not minimized to current file RunUI(() => SkylineWindow.SaveDocument(minimizedFile)); var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults); var minimizeResultsDlg = ShowDialog <MinimizeResultsDlg>(manageResultsDlg.MinimizeResults); RunUI(() => { minimizeResultsDlg.LimitNoiseTime = true; minimizeResultsDlg.NoiseTimeRange = 2; // Not L10N }); PauseForScreenShot <MinimizeResultsDlg>("Minimize Results form (percentages vary slightly)", 36); // old p. 23 OkDialog(minimizeResultsDlg, () => minimizeResultsDlg.MinimizeToFile(minimizedFile)); WaitForCondition(() => File.Exists(cacheFile)); WaitForClosedForm(manageResultsDlg); } WaitForDocumentChange(doc); // Inclusion list method export for MS1 filtering doc = SkylineWindow.Document; RunDlg <PeptideSettingsUI>(() => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction), dlg => { dlg.IsUseMeasuredRT = true; dlg.TimeWindow = 10; dlg.OkDialog(); }); WaitForDocumentChangeLoaded(doc); // Now deviating from the tutorial script for a moment to make sure we can choose a Scheduled export method. RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, dlg => { dlg.MinPeptides = 1; // Not L10N const double minPeakFoundRatio = 0.1; dlg.MinPeakFoundRatio = minPeakFoundRatio; dlg.OkDialog(); }); // Ready to export, although we will just cancel out of the dialog. var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method)); RunUI(() => { exportMethodDlg.InstrumentType = ExportInstrumentType.ABI_TOF; // Not L10N exportMethodDlg.MethodType = ExportMethodType.Scheduled; exportMethodDlg.CancelButton.PerformClick(); }); WaitForClosedForm(exportMethodDlg); RunUI(() => SkylineWindow.SaveDocument()); RunUI(SkylineWindow.NewDocument); }
protected override void DoTest() { string skyfile = TestFilesDir.GetTestPath("test.sky"); RunUI(() => SkylineWindow.SaveDocument(skyfile)); Stopwatch loadStopwatch = new Stopwatch(); loadStopwatch.Start(); // Launch import peptide search wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); string lo = GetTestPath("40minG_WBP_wide_z2-3_low_BSA_5pmol_02.pep.xml"); string mid = GetTestPath("40minG_WBP_wide_z2-3_mid_BSA_5pmol_01.pep.xml"); string up = GetTestPath("40minG_WBP_wide_z2-3_up_BSA_5pmol_02.pep.xml"); string[] searchFiles = { lo, mid, up }; var doc = SkylineWindow.Document; RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles); importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95; importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = false; }); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); doc = WaitForDocumentChange(doc); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(skyfile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // We're on the "Extract Chromatograms" page of the wizard. // All the files should be found, and we should // just be able to move to the next page. RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page)); RunUI(() => { var importResultsControl = (ImportResultsControl)importPeptideSearchDlg.ImportResultsControl; importResultsControl.ExcludeSpectrumSourceFiles = true; }); var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); RunUI(() => { importResultsNameDlg.NoDialog(); }); WaitForClosedForm(importResultsNameDlg); // Modifications are already set up, so that page should get skipped. RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges = new [] { 2, 3, 4, 5 }); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof); // Enable use of drift times in spectral library Assume.IsTrue(importPeptideSearchDlg.FullScanSettingsControl.IonMobilityFiltering.Visible); Assume.IsTrue(importPeptideSearchDlg.FullScanSettingsControl.IonMobilityFiltering.Enabled); var useDriftTimes = true; // For debugging convenience, if you want to see how this works without IM filtering // ReSharper disable once ConditionIsAlwaysTrueOrFalse RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.IonMobilityFiltering.IsUseSpectralLibraryIonMobilities = useDriftTimes); RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.IonMobilityFiltering.IonMobilityFilterResolvingPower = 50); RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings // We're on the "Import FASTA" page of the wizard. RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page); importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("SwissProt.bsa-mature")); }); var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck); OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog); WaitForClosedForm(importPeptideSearchDlg); WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes var doc1 = WaitForDocumentLoaded(400000); AssertEx.IsDocumentState(doc1, null, 1, 40, 54, 162); loadStopwatch.Stop(); DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds); float tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance; double maxHeight = 0; var results = doc1.Settings.MeasuredResults; foreach (var pair in doc1.PeptidePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); foreach (var chromGroup in chromGroupInfo) { foreach (var tranInfo in chromGroup.TransitionPointSets) { maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity); } } } // ReSharper disable once ConditionIsAlwaysTrueOrFalse Assert.AreEqual(useDriftTimes ? 972186 : 1643104, maxHeight, 1); }
protected override void DoTest() { // Clean-up before running the test RunUI(() => SkylineWindow.ModifyDocument("Set default settings", d => d.ChangeSettings(SrmSettingsList.GetDefault()))); SrmDocument doc = SkylineWindow.Document; const string documentBaseName = "Ms1FilterTutorial"; string documentFile = GetTestPath(documentBaseName + SrmDocument.EXT); RunUI(() => SkylineWindow.SaveDocument(documentFile)); // Launch the wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); // We're on the "Build Spectral Library" page of the wizard. // Add the test xml file to the search files list and try to // build the document library. string[] searchFiles = { GetTestPath("100803_0001_MCF7_TiB_L.group.xml"), // Not L10N GetTestPath("100803_0005b_MCF7_TiTip3.group.xml") // Not L10N }; foreach (var searchFile in searchFiles) { Assert.IsTrue(File.Exists(searchFile), string.Format("File {0} does not exist.", searchFile)); } PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library empty page", 3); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles); // Sanity check here, because of failure getting both files for results import below var searchNames = importPeptideSearchDlg.BuildPepSearchLibControl.SearchFilenames; Assert.AreEqual(searchFiles.Length, searchNames.Length, PathsMessage("Unexpected search files found.", searchNames)); var builder = importPeptideSearchDlg.BuildPepSearchLibControl.ImportPeptideSearch.GetLibBuilder( SkylineWindow.DocumentUI, SkylineWindow.DocumentFilePath, false); Assert.IsTrue(ArrayUtil.EqualsDeep(searchFiles, builder.InputFiles), PathsMessage("Unexpected BlibBuild input files.", builder.InputFiles)); importPeptideSearchDlg.BuildPepSearchLibControl.DebugMode = true; }); PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", 4); WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled); var ambiguousDlg = ShowDialog <MessageDlg>(() => importPeptideSearchDlg.ClickNextButton()); RunUI(() => AssertEx.Contains(ambiguousDlg.Message, Resources.BiblioSpecLiteBuilder_AmbiguousMatches_The_library_built_successfully__Spectra_matching_the_following_peptides_had_multiple_ambiguous_peptide_matches_and_were_excluded_)); OkDialog(ambiguousDlg, ambiguousDlg.OkDialog); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(documentFile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); // Verify input paths sent to BlibBuild string buildArgs = importPeptideSearchDlg.BuildPepSearchLibControl.LastBuildCommandArgs; string buildOutput = importPeptideSearchDlg.BuildPepSearchLibControl.LastBuildOutput; var argLines = buildArgs.Split(new[] { Environment.NewLine }, StringSplitOptions.None); var dirCommon = PathEx.GetCommonRoot(searchFiles); var searchLines = searchFiles.Select(f => PathEx.RemovePrefix(f, dirCommon)).ToArray(); Assert.IsTrue(ArrayUtil.EqualsDeep(searchLines, argLines.Skip(1).ToArray()), buildArgs); // Verify resulting .blib file contains the expected files var docLib = librarySettings.Libraries[0]; int expectedFileCount = searchFiles.Length; int expectedRedundantSpectra = 813; // 446 with TiTip only int expectedSpectra = 552; // 428 with TiTip3 only if (expectedFileCount != docLib.FileCount) { var searchFileNames = searchFiles.Select(Path.GetFileName).ToArray(); using (var blibDbRedundant = BlibDb.OpenBlibDb(redundantDocLibPath)) { VerifyLib(searchFileNames, expectedRedundantSpectra, blibDbRedundant.GetIdFilePaths(), blibDbRedundant.GetSpectraCount(), "redundant library", buildArgs, buildOutput); } using (var blibDb = BlibDb.OpenBlibDb(docLibPath)) { VerifyLib(searchFileNames, expectedSpectra, blibDb.GetIdFilePaths(), blibDb.GetSpectraCount(), "SQLite library", buildArgs, buildOutput); } VerifyLib(searchFileNames, expectedSpectra, docLib.LibraryDetails.DataFiles.Select(d => d.IdFilePath).ToArray(), docLib.SpectrumCount, "in memory", buildArgs, buildOutput); } // We're on the "Extract Chromatograms" page of the wizard. // All the test results files are in the same directory as the // document file, so all the files should be found, and we should // just be able to move to the next page. WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page && importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count > 0 && importPeptideSearchDlg.IsNextButtonEnabled); // Wait for extra for both source files in the list TryWaitForConditionUI(10 * 1000, () => importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count == searchFiles.Length); RunUI(() => { // Check for missing files var missingFiles = importPeptideSearchDlg.ImportResultsControl.MissingResultsFiles.ToArray(); Assert.AreEqual(0, missingFiles.Length, PathsMessage("Unexpected missing file found.", missingFiles)); // Check for expected results files var resultsNames = importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Select(f => f.Name).ToArray(); Assert.AreEqual(searchFiles.Length, importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count, PathsMessage("Unexpected results files found.", resultsNames)); // Check for expected common prefix var commonPrefix = ImportResultsDlg.GetCommonPrefix(resultsNames); Assert.IsFalse(string.IsNullOrEmpty(commonPrefix), PathsMessage("File names do not have a common prefix.", resultsNames)); Assert.AreEqual("100803_000", commonPrefix); }); PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search - Extract Chromatograms page", 6); var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(() => importPeptideSearchDlg.ClickNextButton()); PauseForScreenShot <ImportResultsNameDlg>("Import Results - Common prefix form", 7); OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog); // Wait for the "Add Modifications" page of the wizard. WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.match_modifications_page); List <string> modsToCheck = new List <string> { "Phospho (ST)", "Phospho (Y)", "Oxidation (M)" }; // Not L10N RunUI(() => { importPeptideSearchDlg.MatchModificationsControl.CheckedModifications = modsToCheck; }); PauseForScreenShot <ImportPeptideSearchDlg.MatchModsPage>("Import Peptide Search - Add Modifications page", 8); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); // We're on the "Configure MS1 Full-Scan Settings" page of the wizard. RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page); importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges = new[] { 2, 3, 4 }; importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof; importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes = 10 * 1000; Assert.AreEqual(importPeptideSearchDlg.FullScanSettingsControl.PrecursorIsotopesCurrent, FullScanPrecursorIsotopes.Count); Assert.AreEqual(FullScanMassAnalyzerType.tof, importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer); Assert.AreEqual(10 * 1000, importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes); Assert.AreEqual(3, importPeptideSearchDlg.FullScanSettingsControl.Peaks); Assert.AreEqual(RetentionTimeFilterType.ms2_ids, importPeptideSearchDlg.FullScanSettingsControl.RetentionTimeFilterType); Assert.AreEqual(5, importPeptideSearchDlg.FullScanSettingsControl.TimeAroundMs2Ids); }); PauseForScreenShot <ImportPeptideSearchDlg.Ms1FullScanPage>("Import Peptide Search - Configure MS1 Full-Scan Settings page", 9); RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton())); // Last page of wizard - Import Fasta. string fastaPath = GetTestPath("12_proteins.062011.fasta"); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page); Assert.AreEqual("Trypsin [KR | P]", importPeptideSearchDlg.ImportFastaControl.Enzyme.GetKey()); importPeptideSearchDlg.ImportFastaControl.MaxMissedCleavages = 2; importPeptideSearchDlg.ImportFastaControl.SetFastaContent(fastaPath); Assert.IsFalse(importPeptideSearchDlg.ImportFastaControl.DecoyGenerationEnabled); }); PauseForScreenShot <ImportPeptideSearchDlg.FastaPage>("Import Peptide Search - Import FASTA page", 12); var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(() => importPeptideSearchDlg.ClickNextButton()); WaitForCondition(() => peptidesPerProteinDlg.DocumentFinalCalculated); RunUI(() => { int proteinCount, peptideCount, precursorCount, transitionCount; peptidesPerProteinDlg.NewTargetsAll(out proteinCount, out peptideCount, out precursorCount, out transitionCount); Assert.AreEqual(11, proteinCount); Assert.AreEqual(51, peptideCount); Assert.AreEqual(52, precursorCount); Assert.AreEqual(156, transitionCount); peptidesPerProteinDlg.NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount); Assert.AreEqual(11, proteinCount); Assert.AreEqual(51, peptideCount); Assert.AreEqual(52, precursorCount); Assert.AreEqual(156, transitionCount); }); OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog); var allChromGraph = WaitForOpenForm <AllChromatogramsGraph>(); RunUI(() => { allChromGraph.Left = SkylineWindow.Right + 20; allChromGraph.Activate(); }); PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 13); WaitForDocumentChangeLoaded(doc, 8 * 60 * 1000); // 10 minutes var libraryExplorer = ShowDialog <ViewLibraryDlg>(() => SkylineWindow.OpenLibraryExplorer(documentBaseName)); var matchedPepModsDlg = WaitForOpenForm <AddModificationsDlg>(); PauseForScreenShot <AddModificationsDlg>("Add mods alert", 14); RunUI(() => { Assert.AreEqual(13, matchedPepModsDlg.NumMatched); Assert.AreEqual(0, matchedPepModsDlg.NumUnmatched); matchedPepModsDlg.CancelDialog(); }); RunUI(() => { libraryExplorer.GraphSettings.ShowBIons = true; libraryExplorer.GraphSettings.ShowYIons = true; libraryExplorer.GraphSettings.ShowCharge1 = true; libraryExplorer.GraphSettings.ShowCharge2 = true; libraryExplorer.GraphSettings.ShowPrecursorIon = true; }); PauseForScreenShot <ViewLibraryDlg>("Spectral Library Explorer", 15); RunUI(() => { const string sourceFirst = "100803_0005b_MCF7_TiTip3.wiff"; const double timeFirst = 35.2128; Assert.AreEqual(sourceFirst, libraryExplorer.SourceFile); Assert.AreEqual(timeFirst, libraryExplorer.RetentionTime, 0.01); libraryExplorer.SelectedIndex++; Assert.AreNotEqual(sourceFirst, libraryExplorer.SourceFile); Assert.AreNotEqual(timeFirst, libraryExplorer.RetentionTime, 0.01); }); OkDialog(libraryExplorer, libraryExplorer.CancelDialog); const int TIB_L = 0; // index for Tib_L const int TIP3 = 1; // index for Tip3 AssertEx.IsDocumentState(SkylineWindow.Document, null, 11, 51, 52, 156); AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIB_L]), 51, 52, 0, 156, 0); AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIP3]), 51, 52, 0, 156, 0); string Tib_LFilename = searchFiles[TIB_L].Replace(".group.xml", PreferedExtAbWiff); string Tip3Filename = searchFiles[TIP3].Replace(".group.xml", PreferedExtAbWiff); // Select the first transition group. RunUI(() => { SkylineWindow.SequenceTree.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0); SkylineWindow.GraphSpectrumSettings.ShowAIons = true; SkylineWindow.GraphSpectrumSettings.ShowBIons = true; SkylineWindow.GraphSpectrumSettings.ShowYIons = true; SkylineWindow.GraphSpectrumSettings.ShowPrecursorIon = true; SkylineWindow.ExpandPrecursors(); SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR); }); RunDlg <SpectrumChartPropertyDlg>(SkylineWindow.ShowSpectrumProperties, dlg => { dlg.FontSize = GraphFontSize.NORMAL; dlg.OkDialog(); }); RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg => { dlg.FontSize = GraphFontSize.NORMAL; dlg.OkDialog(); }); const int skylineWindowWidth = 1160; const int skylineWindowHeight = 792; RunUI(() => { // Make window screenshot size if (IsPauseForScreenShots && SkylineWindow.WindowState != FormWindowState.Maximized) { SkylineWindow.Width = skylineWindowWidth; SkylineWindow.Height = skylineWindowHeight; } }); RestoreViewOnScreen(13); PauseForScreenShot("Main window with imported data", 16); // RunUIWithDocumentWait(() => // { // SkylineWindow.ToggleIntegrateAll(); // TODO: No longer necessary. Change in tutorial // }); RunUI(() => { SkylineWindow.ShowGraphPeakArea(true); SkylineWindow.ShowPeakAreaReplicateComparison(); SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.NONE); Settings.Default.ShowDotProductPeakArea = true; Settings.Default.ShowLibraryPeakArea = true; }); RunUI(() => { SkylineWindow.Width = 500; var peakAreas = SkylineWindow.GraphPeakArea; var peakAreasFloating = peakAreas.Parent.Parent; peakAreasFloating.Left = SkylineWindow.Right + 20; peakAreasFloating.Top = SkylineWindow.Top; peakAreasFloating.Size = new Size(504, 643); }); PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view (show context menu)", 18); RunUI(() => SkylineWindow.Width = skylineWindowWidth); RestoreViewOnScreen(15); RunUI(() => { SkylineWindow.AutoZoomBestPeak(); SkylineWindow.ArrangeGraphsTiled(); SkylineWindow.ShowChromatogramLegends(false); }); PauseForScreenShot("Main window layout", 19); int atest = 0; CheckAnnotations(TIB_L, 0, atest++); int pepIndex = 3; RunUI(() => SkylineWindow.CollapsePeptides()); RunUI(() => SkylineWindow.ShowAlignedPeptideIDTimes(true)); ChangePeakBounds(TIB_L, pepIndex, 38.79, 39.385); PauseForScreenShot("Chromatogram graphs clipped from main window", 21); CheckAnnotations(TIB_L, pepIndex, atest++); var alignmentForm = ShowDialog <AlignmentForm>(() => SkylineWindow.ShowRetentionTimeAlignmentForm()); const int skylineWindowNarrowWidth = 788; RunUI(() => { SkylineWindow.Width = skylineWindowNarrowWidth; alignmentForm.Width = 660; alignmentForm.Height = 561; alignmentForm.Left = SkylineWindow.Right + 20; alignmentForm.Splitter.SplitterDistance = 75; alignmentForm.ComboAlignAgainst.SelectedIndex = 0; // to match what's in the tutorial doc }); PauseForScreenShot <AlignmentForm>("Retention time alignment form", 22); OkDialog(alignmentForm, alignmentForm.Close); PauseForScreenShot("Status bar clipped from main window - 4/51 pep 4/52 prec 10/156 tran", 23); const string TIP_NAME = "5b_MCF7_TiTip3"; if (IsCoverShotMode) { RestoreCoverViewOnScreen(); ClickChromatogram(TIP_NAME, 34.5, 366); TreeNode selectedNode = null; RunUI(() => selectedNode = SkylineWindow.SequenceTree.SelectedNode); RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0]); WaitForGraphs(); RunUI(() => SkylineWindow.SequenceTree.SelectedNode = selectedNode); TakeCoverShot(); return; } pepIndex = JumpToPeptide("SSKASLGSLEGEAEAEASSPK"); RunUI(() => SkylineWindow.ShowChromatogramLegends(true)); Assert.IsTrue(8 == pepIndex); PauseForScreenShot("Chromatogram graph metafiles for 9th peptide", 24); CheckAnnotations(TIB_L, pepIndex, atest++); ZoomSingle(TIP3, 31.8, 42.2, 280); // simulate the wheel scroll described in tutorial PauseForScreenShot("Chromatogram graph metafile showing all peaks for 1_MCF_TiB_L", 24); CheckAnnotations(TIB_L, pepIndex, atest++); // current TIB_L peak should have idotp .87 and ppm -6.9 Assert.AreEqual(0.87, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005); Assert.AreEqual(-10.8, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05); ChangePeakBounds(TIB_L, pepIndex, 36.5, 38.0); // now current TIB_L peak should have idotp .9 and ppm -6.5 Assert.AreEqual(0.9, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005); Assert.AreEqual(-9.4, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05); CheckAnnotations(TIB_L, pepIndex, atest++); var undoIndex = SkylineWindow.Document.RevisionIndex; // preserve for simulating ctrl-z RunUI(() => SkylineWindow.Width = skylineWindowWidth); PickPeakBoth(pepIndex, 40.471035, 40.8134); // select peak for both chromatograms at these respective retention times PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 25); int[] m1Thru4 = { 1, 2, 3, 4, 5 }; PickTransitions(pepIndex, m1Thru4, "Transition pick list filtered", 26, "Transition pick list unfiltered", 26); // turn on chromatograms PickPeakBoth(pepIndex, 36.992836, 37.3896027); // select peak for both chromatograms at these respective retention times ZoomSingle(TIP3, 32.4, 42.2, 520); // set the view for screenshot RunUI(() => { SkylineWindow.Height = 550; SkylineWindow.ArrangeGraphsTabbed(); }); ActivateReplicate(TIP_NAME); PauseForScreenShot("Chromatogram graph metafile comparing 33 and 37 minute peaks", 27); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); RevertDoc(undoIndex); // undo changes ActivateReplicate(TIP_NAME); ClickChromatogram(TIP_NAME, 37.3, 142); PauseForScreenShot("MS1 spectrum graph 37.32 minutes", 28); ClickChromatogram(TIP_NAME, 33.2, 328.1); PauseForScreenShot("MS1 spectrum graph 33.19 minutes", 29); RunUI(() => SkylineWindow.HideFullScanGraph()); RunUI(() => { SkylineWindow.Width = skylineWindowNarrowWidth; SkylineWindow.Height = skylineWindowHeight; SkylineWindow.ArrangeGraphs(DisplayGraphsType.Column); }); pepIndex = JumpToPeptide("ASLGSLEGEAEAEASSPKGK"); // Not L10N Assert.IsTrue(10 == pepIndex); PauseForScreenShot("Chromatogram graph meta files for peptide ASLGSLEGEAEAEASSPKGK", 30); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); PickTransitions(pepIndex, m1Thru4); // turn on M+3 and M+4 ChangePeakBounds(TIP3, pepIndex, 37.35, 38.08); ZoomSingle(TIP3, 36.65, 39.11, 300); // simulate the wheel scroll described in tutorial PauseForScreenShot("upper - Chromatogram graph metafile for peptide ASLGSLEGEAEAEASSPKGK with adjusted integration", 31); CheckAnnotations(TIP3, pepIndex, atest++); RevertDoc(undoIndex); // undo changes pepIndex = JumpToPeptide("AEGEWEDQEALDYFSDKESGK"); // Not L10N PauseForScreenShot("lower - Chromatogram graph metafiles for peptide AEGEWEDQEALDYFSDKESGK", 31); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); int[] m1Thru5 = { 1, 2, 3, 4, 5, 6 }; PickTransitions(pepIndex, m1Thru5); // turn on M+3 M+4 and M+5 PauseForScreenShot("Chromatogram graph metafiles with M+3, M+4 and M+5 added", 32); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); JumpToPeptide("ALVEFESNPEETREPGSPPSVQR"); // Not L10N PauseForScreenShot("Chromatogram graph metafiles for peptide ALVEFESNPEETREPGSPPSVQR", 33); pepIndex = JumpToPeptide("YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR"); // Not L10N if (IsPauseForScreenShots) { RestoreViewOnScreen(34); PauseForScreenShot("upper - Peak Areas graph metafile for peptide YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR", 34); } int[] m1Thru7 = { 1, 2, 3, 4, 5, 6, 7, 8 }; PickTransitions(pepIndex, m1Thru7); // enable [M+3] [M+4] [M+5] [M+6] [M+7] PauseForScreenShot("lower - Peak Areas graph metafile with M+3 through M+7 added", 34); CheckAnnotations(TIB_L, pepIndex, atest++); CheckAnnotations(TIP3, pepIndex, atest++); RunUI(() => SkylineWindow.ShowGraphPeakArea(false)); // page 36 zooming setup RunUI(() => { SkylineWindow.SynchronizeZooming(true); SkylineWindow.LockYChrom(false); SkylineWindow.AlignToFile = GetGraphChromatogram(TIP3).GetChromFileInfoId(); // align to Tip3 }); ZoomBoth(36.5, 39.5, 1600); // simulate the wheel scroll described in tutorial RunUI(() => { SkylineWindow.ShowChromatogramLegends(false); SkylineWindow.Width = skylineWindowWidth; SkylineWindow.Height = 720; }); PauseForScreenShot("Chromatogram graphs clipped from main window with synchronized zooming", 35); ClickChromatogram(TIP_NAME, 37.5, 1107.3); PauseForScreenShot("MS1 spectrum graph 37.50 minutes", 36); RunUI(() => SkylineWindow.HideFullScanGraph()); RunUI(() => { SkylineWindow.ShowChromatogramLegends(true); SkylineWindow.Width = skylineWindowNarrowWidth; SkylineWindow.Height = skylineWindowHeight; }); RestoreViewOnScreen(36); // float the Library Match window RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tip3Filename), 37.6076f))); // set the Library Match view PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 5b_MCF7_TiTip3 (37.61 Min)", 37); RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tib_LFilename), 37.0335f))); // set the Library Match view PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 1_MCF_TiB_L (37.03 min)", 37); RestoreViewOnScreen(37); // back to normal view /* pepIndex = */ JumpToPeptide("DQVANSAFVER"); // Not L10N PauseForScreenShot("Chromatogram graph metafiles for peptide DQVANSAFVER", 38); // int[] m1 = {2}; // PickTransitions(pepIndex, m1); // enable [M+1] only // // Measured times in TIB_L are different from displayed times, because of alignment // ChangePeakBounds(TIB_L, pepIndex, 23.99, 25.29); // ChangePeakBounds(TIP3, pepIndex, 23.81, 25.21); // // First transition selected for screenshot // RunUI(() => // { // var pathPep = SkylineWindow.SelectedPath; // var nodePep = ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode; // var nodeGroup = nodePep.TransitionGroups.First(); // var nodeTran = nodeGroup.Transitions.First(); // SkylineWindow.SelectedPath = new IdentityPath( // new IdentityPath(pathPep, nodeGroup.TransitionGroup), nodeTran.Transition); // }); // PauseForScreenShot("page 36 - M+1 only, with adjusted integration"); // CheckAnnotations(TIB_L, pepIndex, atest++); // CheckAnnotations(TIP3, pepIndex, EXPECTED_ANNOTATIONS[atest]); var docAfter = WaitForProteinMetadataBackgroundLoaderCompletedUI(); // Minimizing a chromatogram cache file. RunUI(SkylineWindow.CollapsePeptides); for (int i = 0; i < 5; i++) // just do the first 5 { int iPeptide = i; var path = docAfter.GetPathTo((int)SrmDocument.Level.Molecules, iPeptide); RunUI(() => { SkylineWindow.SelectedPath = path; }); WaitForGraphs(); } // Eliminate extraneous chromatogram data. doc = WaitForProteinMetadataBackgroundLoaderCompletedUI(); var minimizedFile = GetTestPath("Ms1FilteringTutorial-2min.sky"); // Not L10N var cacheFile = Path.ChangeExtension(minimizedFile, ChromatogramCache.EXT); { // TODO: Figure out why the minimize fails to unlock the .skyd file, if not minimized to current file RunUI(() => SkylineWindow.SaveDocument(minimizedFile)); var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults); var minimizeResultsDlg = ShowDialog <MinimizeResultsDlg>(manageResultsDlg.MinimizeResults); RunUI(() => { minimizeResultsDlg.LimitNoiseTime = true; minimizeResultsDlg.NoiseTimeRange = 2; // Not L10N }); PauseForScreenShot <MinimizeResultsDlg>("Minimize Results form (percentages vary slightly)", 39); // old p. 23 OkDialog(minimizeResultsDlg, () => minimizeResultsDlg.MinimizeToFile(minimizedFile)); WaitForCondition(() => File.Exists(cacheFile)); WaitForClosedForm(manageResultsDlg); } WaitForDocumentChange(doc); // Inclusion list method export for MS1 filtering doc = SkylineWindow.Document; RunDlg <PeptideSettingsUI>(() => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction), dlg => { dlg.IsUseMeasuredRT = true; dlg.TimeWindow = 10; dlg.OkDialog(); }); doc = WaitForDocumentChangeLoaded(doc); // Now deviating from the tutorial script for a moment to make sure we can choose a Scheduled export method. // CONSIDER: This refinement seems to be a no-op. Not sure why it is here. RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, dlg => { dlg.MinPeptides = 1; // This would get rid of proteins with no peptides (none exist) const double minPeakFoundRatio = 0.1; dlg.MinPeakFoundRatio = minPeakFoundRatio; // This would get rid of undetected transitions (none exist) dlg.OkDialog(); // Will not change the document or add an Undo entry }); // Nothing should have changed on the UI thread RunUI(() => Assert.AreSame(doc, SkylineWindow.DocumentUI)); // Ready to export, although we will just cancel out of the dialog. var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method)); RunUI(() => { exportMethodDlg.InstrumentType = ExportInstrumentType.ABI_TOF; // Not L10N exportMethodDlg.MethodType = ExportMethodType.Scheduled; exportMethodDlg.CancelButton.PerformClick(); }); WaitForClosedForm(exportMethodDlg); // Because this was showing up in the nightly test failures WaitForConditionUI(() => exportMethodDlg.IsDisposed); RunUI(() => SkylineWindow.SaveDocument()); RunUI(SkylineWindow.NewDocument); }
private void LowResTest() { string documentFile = GetTestPath(@"Low Res\BSA_Protea_label_free_meth3.sky"); WaitForCondition(() => File.Exists(documentFile)); RunUI(() => SkylineWindow.OpenFile(documentFile)); bool AsSmallMolecules = AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.none; const int expectedMoleculeCount = 9; int expectedTransitionGroupCount = 10; int expectedTransitionCount = 78; var document = SkylineWindow.Document; if (AsSmallMolecules) { ConvertDocumentToSmallMolecules(AsSmallMoleculesTestMode); document = SkylineWindow.Document; Assert.AreEqual(document.PeptideTransitionGroupCount, 0); Assert.AreEqual(document.MoleculeTransitionGroupCount, expectedTransitionGroupCount); Assert.AreEqual(document.PeptideTransitionCount, 0); Assert.AreEqual(document.MoleculeTransitionCount, expectedTransitionCount); } AssertEx.IsDocumentState(document, null, 3, expectedMoleculeCount, expectedTransitionGroupCount, expectedTransitionCount); // p. 3 Select first peptide RunUI(() => SkylineWindow.SelectedPath = document.GetPathTo((int)SrmDocument.Level.Molecules, 0)); PauseForScreenShot("Main window", 3); // p. 4 Configure Document for Thermo raw files { var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan); PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Peptide Settings - Full-Scan tab blank", 5); RunUI(() => { transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count; transitionSettingsUI.PrecursorMassAnalyzer = FullScanMassAnalyzerType.qit; transitionSettingsUI.AcquisitionMethod = FullScanAcquisitionMethod.Targeted; }); PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Peptide Settings - Full-Scan tab low res", 6); RunUI(() => { transitionSettingsUI.SetRetentionTimeFilter(RetentionTimeFilterType.ms2_ids, 2); // p.6 - library ion match tolerance same as extraction window transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Library; transitionSettingsUI.IonMatchTolerance = 0.7; }); PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab match tolerance same as MS/MS resolution", 8); RunUI(() => { // p.6 transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter; transitionSettingsUI.FragmentTypes += ", p"; }); PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 9); OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog); var docFullScan = WaitForDocumentChange(document); var tranSettingsFullScan = docFullScan.Settings.TransitionSettings; Assert.AreEqual(FullScanPrecursorIsotopes.Count, tranSettingsFullScan.FullScan.PrecursorIsotopes); Assert.AreEqual(FullScanMassAnalyzerType.qit, tranSettingsFullScan.FullScan.PrecursorMassAnalyzer); Assert.AreEqual(FullScanAcquisitionMethod.Targeted, tranSettingsFullScan.FullScan.AcquisitionMethod); Assert.IsTrue(ArrayUtil.EqualsDeep(new[] { IonType.y, IonType.b, IonType.precursor }, tranSettingsFullScan.Filter.IonTypes)); } RunUI(() => SkylineWindow.ExpandPrecursors()); // Check all the precursors on picklists bool pausedForScreenShot = false; foreach (PeptideGroupTreeNode node in SkylineWindow.SequenceTree.GetSequenceNodes()) { foreach (TreeNode child in node.Nodes) { foreach (SrmTreeNodeParent grandChild in child.Nodes) { // Because of RunUI must copy to local variable first. SrmTreeNodeParent child1 = grandChild; RunUI(() => SkylineWindow.SequenceTree.SelectedNode = child1); var picklist = ShowDialog <PopupPickList>(() => SkylineWindow.SequenceTree.ShowPickList(false)); RunUI(() => { picklist.SetItemChecked(0, true); Assert.IsTrue(picklist.GetItemLabel(0).Contains(IonType.precursor.GetLocalizedString())); Assert.IsTrue(picklist.GetItemChecked(0)); }); if (!pausedForScreenShot) { PauseForScreenShot <PopupPickList>("Transitions popup pick-list", 10); pausedForScreenShot = true; } OkDialog(picklist, picklist.OnOk); } } } WaitForDocumentLoaded(); if (!AsSmallMolecules) // No libraries for small molecules, yet { foreach (var nodeGroup in SkylineWindow.Document.MoleculeTransitionGroups) { Assert.IsFalse(nodeGroup.HasLibInfo && nodeGroup.Transitions.All(nodeTran => !nodeTran.HasLibInfo)); } } // All transition groups should now have a precursor transition foreach (var nodeGroup in SkylineWindow.Document.MoleculeTransitionGroups) { Assert.AreEqual(IonType.precursor, nodeGroup.Transitions.First().Transition.IonType); } // p.8 ExportMethodDlg exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method)); RunUI(() => { exportMethodDlg.SetInstrument("Thermo LTQ"); Assert.AreEqual("Thermo LTQ", exportMethodDlg.InstrumentType); exportMethodDlg.SetMethodType(ExportMethodType.Standard); exportMethodDlg.SetTemplateFile(GetTestPath(@"Low Res\TargetedMSMS_template.meth")); }); PauseForScreenShot <ExportMethodDlg.MethodView>("Export Method form", 11); // p. 10 Ok the error box. { var messageDlg = ShowDialog <MessageDlg>(() => exportMethodDlg.OkDialog(GetTestPath(@"Low Res\TargetedMSMS_BSA_Protea.meth"))); PauseForScreenShot <MessageDlg>("Error message (expected)", 12); OkDialog(messageDlg, messageDlg.OkDialog); } // Making a report by hand p.11 ExportLiveReportDlg exportReportDlg = ShowDialog <ExportLiveReportDlg>(() => SkylineWindow.ShowExportReportDialog()); var editReportListDlg = ShowDialog <ManageViewsForm>(exportReportDlg.EditList); var viewEditor = ShowDialog <ViewEditor>(editReportListDlg.AddView); RunUI(() => { Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(PropertyPath.Parse("Proteins!*.Name"))); viewEditor.ChooseColumnsTab.AddSelectedColumn(); Assert.AreEqual(1, viewEditor.ChooseColumnsTab.ColumnCount); var columnsToAdd = new[] { PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.ModifiedSequence"), PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Charge"), PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Mz"), }; foreach (var id in columnsToAdd) { Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(id), "Unable to select {0}", id); viewEditor.ChooseColumnsTab.AddSelectedColumn(); } Assert.AreEqual(4, viewEditor.ChooseColumnsTab.ColumnCount); }); PauseForScreenShot <ViewEditor>("Edit Report form", 13); { var previewReportDlg = ShowDialog <DocumentGridForm>(viewEditor.ShowPreview); var expectedRows = 10 + (TestSmallMolecules ? 1 : 0); WaitForConditionUI(() => previewReportDlg.IsComplete && previewReportDlg.RowCount == expectedRows); RunUI(() => { Assert.AreEqual(4, previewReportDlg.ColumnCount); var precursors = SkylineWindow.Document.MoleculeTransitionGroups.ToArray(); const int precursorIndex = 3; for (int i = 0; i < expectedRows; i++) { Assert.AreEqual(precursors[i].PrecursorMz, double.Parse(previewReportDlg.DataGridView.Rows[i].Cells[precursorIndex].Value.ToString()), 0.000001); } var precursorMzCol = previewReportDlg.DataGridView.Columns[precursorIndex]; Assert.IsNotNull(precursorMzCol); previewReportDlg.DataGridView.Sort(precursorMzCol, ListSortDirection.Ascending); }); PauseForScreenShot <DocumentGridForm>("Preview New Report window", 14); OkDialog(previewReportDlg, previewReportDlg.Close); } // Press the Esc key until all forms have been dismissed. RunUI(() => { viewEditor.Close(); editReportListDlg.Close(); exportReportDlg.CancelClick(); }); WaitForClosedForm(viewEditor); WaitForClosedForm(editReportListDlg); WaitForClosedForm(exportReportDlg); //p. 12 Import Full-Scan Data // Launch import peptide search wizard var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg); RunUI(() => importPeptideSearchDlg.BuildPepSearchLibControl.WorkflowType = ImportPeptideSearchDlg.Workflow.prm); PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search Build Spectral Library blank page", 15); const int prefixLen = 35; const string lowResDir = "Low Res"; const string searchDir = "search"; const string lowRes20Base = "klc_20100329v_Protea_Peptide_Curve_20fmol_uL_tech1"; string lowRes20File = GetTestPath(Path.Combine(lowResDir, lowRes20Base + ExtThermoRaw)); string lowRes20FileRaw = Path.ChangeExtension(lowRes20File, ExtThermoRaw); string lowRes20Search = GetTestPath(Path.Combine(lowResDir, Path.Combine(searchDir, lowRes20Base + BiblioSpecLiteBuilder.EXT_PERCOLATOR))); string shortLowRes20FileName = (Path.GetFileNameWithoutExtension(lowRes20File) ?? "").Substring(prefixLen); const string lowRes80Base = "klc_20100329v_Protea_Peptide_Curve_80fmol_uL_tech1"; string lowRes80File = GetTestPath(Path.Combine(lowResDir, lowRes80Base + ExtThermoRaw)); string lowRes80Search = GetTestPath(Path.Combine(lowResDir, Path.Combine(searchDir, lowRes80Base + BiblioSpecLiteBuilder.EXT_PERCOLATOR))); string shortLowRes80FileName = (Path.GetFileNameWithoutExtension(lowRes80File) ?? "").Substring(prefixLen); string[] searchFiles = { lowRes20Search, lowRes80Search }; var doc = SkylineWindow.Document; RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles); importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.99; importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = true; }); PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search Build Spectral Library with files page", 16); RunDlg <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck, dlg => dlg.OkDialog()); doc = WaitForDocumentChangeLoaded(doc); // Verify document library was built string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(documentFile); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath)); var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries; Assert.IsTrue(librarySettings.HasDocumentLibrary); PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search Extract Chromatograms page", 17); // We're on the "Extract Chromatograms" page of the wizard. // All the test results files are in the same directory as the // document file, so all the files should be found, and we should // just be able to move to the next page. TryWaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page); var correctPage = false; ImportPeptideSearchDlg.Pages currentPage = 0; RunUI(() => correctPage = ImportPeptideSearchDlg.Pages.chromatograms_page == (currentPage = importPeptideSearchDlg.CurrentPage)); if (!correctPage) { WaitForConditionUI(1, // Immediate timeout - just want the richer error message that WaitForConditionUI provides () => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page, string.Format("Expected to be on chromatograms_page, on {0} instead", currentPage)); } var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(() => importPeptideSearchDlg.ClickNextButton()); OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog); // Modifications are already set up, so that page should get skipped. // We're on the "Configure Transition Settings" page of the wizard. // We've already set up these settings, so just click next. WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.transition_settings_page); Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()); }); // We're on the "Configure Full-Scan Settings" page of the wizard. // We've already set up these settings, so just click next. WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled); RunUI(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page); Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()); }); doc = WaitForDocumentChange(doc); // Add FASTA also skipped because filter for document peptides was chosen. WaitForClosedForm(importPeptideSearchDlg); PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 18); WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes WaitForClosedAllChromatogramsGraph(); expectedTransitionGroupCount = 10; // Expect this many with results expectedTransitionCount = 87; // Expect this many with results AssertResult.IsDocumentResultsState(SkylineWindow.Document, shortLowRes20FileName, expectedMoleculeCount, expectedTransitionGroupCount, 0, expectedTransitionCount, 0); AssertResult.IsDocumentResultsState(SkylineWindow.Document, shortLowRes80FileName, expectedMoleculeCount, expectedTransitionGroupCount, 0, expectedTransitionCount, 0); RunUI(() => { Assert.IsTrue(SkylineWindow.IsGraphSpectrumVisible); SkylineWindow.ArrangeGraphsTiled(); SkylineWindow.CollapsePrecursors(); SkylineWindow.Width = 1070; }); // Select the first precursor. if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { FindNode(AsSmallMolecules ? "LVNELTEFAK" : "K.LVNELTEFAK.T [65, 74]"); } else { FindNode(document.MoleculeTransitionGroups.First().CustomIon.DisplayName); } // Ensure Graphs look like p17. (checked) WaitForGraphs(); RestoreViewOnScreen(18); PauseForScreenShot("Main window with data imported", 19); const double minDotp = 0.9; foreach (var nodeGroup in SkylineWindow.Document.PeptideTransitionGroups) { double dotp = nodeGroup.Results[0][0].LibraryDotProduct ?? 0; Assert.IsTrue(Math.Round(dotp, 2) >= minDotp, string.Format("Library dot-product {0} found below {1}", dotp, minDotp)); } RunUI(() => SkylineWindow.AutoZoomBestPeak()); // Ensure Graphs look like p18. (checked) WaitForGraphs(); PauseForScreenShot("Chromatogram graphs clipped from main window with zoomed peaks", 20); RestoreViewOnScreen(21); RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(lowRes20FileRaw, 77.7722))); PauseForScreenShot <GraphSpectrum>("Library Match view clipped from main window with noisy spectrum", 21); RunUI(() => { SkylineWindow.ShowGraphSpectrum(false); Assert.IsFalse(SkylineWindow.IsGraphSpectrumVisible); SkylineWindow.ShowPeptideIDTimes(false); }); RunUI(() => { var chromGraphs = SkylineWindow.GraphChromatograms.ToArray(); Assert.AreEqual(2, chromGraphs.Length); Assert.AreEqual(46.8, chromGraphs[0].GraphItems.First().BestPeakTime, 0.05); Assert.AreEqual(46.8, chromGraphs[1].GraphItems.First().BestPeakTime, 0.05); SkylineWindow.ShowPeakAreaReplicateComparison(); SkylineWindow.ShowProductTransitions(); }); WaitForCondition(() => !SkylineWindow.GraphPeakArea.IsHidden); if (!AsSmallMolecules) // No libraries (yet?) { WaitForDotProducts(); } RunUI(() => { // Graph p.15 Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count()); Assert.AreEqual(6, SkylineWindow.GraphPeakArea.CurveCount); }); PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile", 22); if (!AsSmallMolecules) // No libraries (yet?) { VerifyDotProducts(0.99, 0.98); } // Check graph p15. (checked) RunUI(() => { SkylineWindow.ShowAllTransitions(); SkylineWindow.ShowSplitChromatogramGraph(true); }); // p. 16 screenshot of full 5-point dilution curve // Select precursor if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { FindNode(AsSmallMolecules ? "DRVYIHPF" : "R.DRVYIHPF.- [34, 41]"); // May be localized " (missed 1)" } else { FindNode(Resources.CustomIon_DisplayName_Ion + " [1047"); } WaitForGraphs(); PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile with split graphs", 24); RunUI(() => { SkylineWindow.Size = new Size(990, 620); SkylineWindow.ShowGraphPeakArea(false); }); PauseForScreenShot("Chromatogram graphs clipped from main window with split graphs", 25); // PeakAreaGraph Normalize to total p.20. RunUI(() => { SkylineWindow.ShowGraphPeakArea(true); SkylineWindow.ShowProductTransitions(); SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view); }); // Ensure graph looks like p20. if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { FindNode(AsSmallMolecules ? "KNLQSLDPSH" : "R.IKNLQSLDPSH.- [80, 90]"); FindNode(AsSmallMolecules ? "KNLQSLDPSH" : "R.IKNLQSLDPSH.- [80, 90]"); // Phosphorylated } else { FindNode(Resources.CustomIon_DisplayName_Ion + " [1333"); } WaitForGraphs(); PauseForScreenShot <GraphSummary.AreaGraphView>("figure 1a - Area Replicate graph metafile for IKNLQSLDPSH", 26); RunUI(() => { Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count()); Assert.AreEqual(9, SkylineWindow.GraphPeakArea.CurveCount); }); if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { FindNode(AsSmallMolecules ? "HLVDEPQNLIK" : "K.HLVDEPQNLIK.Q [401, 411]"); } else { FindNode(Resources.CustomIon_DisplayName_Ion + " [1306"); } WaitForGraphs(); PauseForScreenShot("figure 1b - Area replicate graph metafile for HLVDEPQNLIK", 26); RunUI(() => { Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count()); Assert.AreEqual(7, SkylineWindow.GraphPeakArea.CurveCount); }); RunUI(() => SkylineWindow.ShowGraphPeakArea(false)); WaitForCondition(() => SkylineWindow.GraphPeakArea.IsHidden); RunUI(() => SkylineWindow.SaveDocument()); }