diff --git a/pwiz_tools/Skyline/CommandLine.cs b/pwiz_tools/Skyline/CommandLine.cs index 12bf868eed..d32bc890f2 100644 --- a/pwiz_tools/Skyline/CommandLine.cs +++ b/pwiz_tools/Skyline/CommandLine.cs @@ -2323,6 +2323,7 @@ private IrtStandard GetIrtStandard(CommandArgs commandArgs) Equals(standard.Name, commandArgs.IrtStandardName)); if (irtStandard == null) { + // TODO: This should really be an Error that causes processing to stop rather than information treated like no iRT standard was specified _out.WriteLine(SkylineResources.CommandLine_ImportSearchInternal_The_iRT_standard_name___0___is_invalid_, commandArgs.IrtStandardName); return null; @@ -2351,7 +2352,10 @@ private bool ImportSearchInternal(CommandArgs commandArgs, ref SrmDocument doc) foreach (var file in commandArgs.SearchResultsFiles) _out.WriteLine(Path.GetFileName(file)); if (!builder.BuildLibrary(progressMonitor)) + { + _out.WriteLine(SkylineResources.CommandLine_ImportSearchInternal_Error__Failed_to_build_the_spectral_library_); return false; + } if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage)) _out.WriteLine(builder.AmbiguousMatchesMessage); @@ -2393,7 +2397,7 @@ private bool ImportSearchInternal(CommandArgs commandArgs, ref SrmDocument doc) import.IrtStandard = autoStandards[0]; break; default: - _out.WriteLine(SkylineResources.CommandLine_ImportSearchInternal_iRT_standard_set_to__0___but_multiple_iRT_standards_were_found__iRT_standard_must_be_set_explicitly_, + _out.WriteLine(SkylineResources.CommandLine_ImportSearchInternal_Error__iRT_standard_set_to__0___but_multiple_iRT_standards_were_found__iRT_standard_must_be_set_explicitly_, IrtStandard.AUTO.Name); return false; } diff --git a/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs b/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs index 8349574933..08ff89a054 100644 --- a/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs +++ b/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs @@ -351,7 +351,7 @@ private bool BuildPeptideSearchLibrary(CancelEventArgs e, bool showWarnings, boo return false; } - bool retry = false; + bool retry; do { using (var longWaitDlg = new LongWaitDlg()) @@ -379,10 +379,11 @@ private bool BuildPeptideSearchLibrary(CancelEventArgs e, bool showWarnings, boo var response = ShowLibraryMissingExternalSpectraError(WizardForm, status.ErrorException); if (response == UpdateProgressResponse.cancel) return false; - else if (response == UpdateProgressResponse.normal) - builder.PreferEmbeddedSpectra = true; + + builder.PreferEmbeddedSpectra = response == UpdateProgressResponse.normal; retry = true; + continue; } else { @@ -398,7 +399,10 @@ private bool BuildPeptideSearchLibrary(CancelEventArgs e, bool showWarnings, boo return false; } } - } while (retry) ; + + retry = false; + + } while (retry); var docLibSpec = builder.LibrarySpec; BuildLibrarySettings.LibraryName = docLibSpec.Name; @@ -418,7 +422,7 @@ private bool BuildPeptideSearchLibrary(CancelEventArgs e, bool showWarnings, boo return false; IrtStandard outStandard = null; - var addedIrts = !isFeatureDetection && LibraryBuildNotificationHandler.AddIrts(IrtRegressionType.DEFAULT, + var addedIrts = !isFeatureDetection && PeptideSettingsUI.AddIrts(IrtRegressionType.DEFAULT, ImportPeptideSearch.DocLib, docLibSpec, _driverStandards.SelectedItem, WizardForm, false, out outStandard); var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(DocumentContainer.Document, docLibSpec); @@ -477,6 +481,12 @@ private bool AddExistingLibrary(CancelEventArgs e) return false; } + if (DocumentContainer.Document.Settings.PeptideSettings.Libraries.LibrarySpecs.Contains(docLibSpec)) + { + // No further work necessary. + return true; + } + var docNew = ImportPeptideSearch.AddDocumentSpectralLibrary(DocumentContainer.Document, docLibSpec); if (docNew == null) return false; diff --git a/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs b/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs index 6bea2da109..038f3b6659 100644 --- a/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs +++ b/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs @@ -567,22 +567,37 @@ private void NextPage() { if (!BuildPepSearchLibControl.PerformDDASearch) { - HasPeakBoundaries = BuildPepSearchLibControl.SearchFilenames.All(f => f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)); - if (BuildPepSearchLibControl.SearchFilenames.Any(f => f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)) && !HasPeakBoundaries) - { - MessageDlg.Show(this, PeptideSearchResources.ImportPeptideSearchDlg_NextPage_Cannot_build_library_from_OpenSWATH_results_mixed_with_results_from_other_tools_); - return; - } + HasPeakBoundaries = BuildPepSearchLibControl.SearchFilenames.All(f => + f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)); + if (BuildPepSearchLibControl.SearchFilenames.Any(f => + f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)) && !HasPeakBoundaries) + { + MessageDlg.Show(this, + PeptideSearchResources + .ImportPeptideSearchDlg_NextPage_Cannot_build_library_from_OpenSWATH_results_mixed_with_results_from_other_tools_); + return; } } + } var eCancel = new CancelEventArgs(); if (!BuildPepSearchLibControl.PerformDDASearch && !BuildPeptideSearchLibrary(eCancel, IsFeatureDetectionWorkflow)) { - // Page shows error if (eCancel.Cancel) + { + // Page has shown an error and canceled further progress return; + } + // A failure has occurred + // CONSIDER(brendanx): This looks suspicious to me. It closes the entire wizard + // when BuildPeptideSearchLibrary has failed but eCancel.Cancel is not set, which + // makes it unclear if the user has seen an error message before the UI disappears. + // I am not ready to dig into this further as it has been this way for years, + // passing most tests. It is hard to imagine how the wizard could continue if + // it fails to create a library, and it is not performing a search. CloseWizard(DialogResult.Cancel); + // Not a good idea to continue once the wizard has been closed + return; } // The user had the option to finish right after diff --git a/pwiz_tools/Skyline/Model/Lib/BiblioSpecLiteBuilder.cs b/pwiz_tools/Skyline/Model/Lib/BiblioSpecLiteBuilder.cs index f0e750ef05..2d6f3c5a64 100644 --- a/pwiz_tools/Skyline/Model/Lib/BiblioSpecLiteBuilder.cs +++ b/pwiz_tools/Skyline/Model/Lib/BiblioSpecLiteBuilder.cs @@ -160,54 +160,41 @@ public bool BuildLibrary(IProgressMonitor progress) Charges = Charges, }; - bool retry = true; - do + try { - try + if (!blibBuilder.BuildLibrary(Action, progress, ref status, + out _buildCommandArgs, out _buildOutput, out _ambiguousMatches)) { - if (!blibBuilder.BuildLibrary(Action, progress, ref status, - out _buildCommandArgs, out _buildOutput, out _ambiguousMatches)) - { - return false; - } - - retry = false; - } - catch (IOException x) - { - if (IsLibraryMissingExternalSpectraError(x, out IList spectrumFilenames, out IList directoriesSearched, out string resultsFilepath)) - { - // replace the relative path to the results file (e.g. msms.txt) with the absolute path - string fullResultsFilepath = InputFiles.SingleOrDefault(o => o.EndsWith(resultsFilepath)) ?? - throw new InvalidDataException(@"no results filepath from BiblioSpec error message", x); - - // TODO: this will break if BiblioSpec output is translated to other languages - string messageWithFullFilepath = - x.Message.Replace(@"search results file '" + resultsFilepath, - @"search results file '" + fullResultsFilepath); - - var response = - progress.UpdateProgress( - status.ChangeErrorException(new IOException(messageWithFullFilepath, x))); - if (response == UpdateProgressResponse.cancel) - return false; - else if (response == UpdateProgressResponse.normal) - blibBuilder.PreferEmbeddedSpectra = true; - continue; - } - - progress.UpdateProgress(status.ChangeErrorException(x)); return false; } - catch (Exception x) + } + catch (IOException x) + { + if (IsLibraryMissingExternalSpectraError(x, out IList spectrumFilenames, out IList directoriesSearched, out string resultsFilepath)) { - Console.WriteLine(x.Message); - progress.UpdateProgress(status.ChangeErrorException( - new Exception(string.Format(LibResources.BiblioSpecLiteBuilder_BuildLibrary_Failed_trying_to_build_the_redundant_library__0__, - redundantLibrary), x))); - return false; + // replace the relative path to the results file (e.g. msms.txt) with the absolute path + string fullResultsFilepath = InputFiles.SingleOrDefault(o => o.EndsWith(resultsFilepath)); + if (fullResultsFilepath == null) + throw new InvalidDataException(@"no results filepath from BiblioSpec error message", x); + + // TODO: this will break if BiblioSpec output is translated to other languages + string messageWithFullFilepath = + x.Message.Replace(@"search results file '" + resultsFilepath, + @"search results file '" + fullResultsFilepath); + x = new IOException(messageWithFullFilepath, x); } - } while (retry); + + progress.UpdateProgress(status.ChangeErrorException(x)); + return false; + } + catch (Exception x) + { + Console.WriteLine(x.Message); + progress.UpdateProgress(status.ChangeErrorException( + new Exception(string.Format(LibResources.BiblioSpecLiteBuilder_BuildLibrary_Failed_trying_to_build_the_redundant_library__0__, + redundantLibrary), x))); + return false; + } var blibFilter = new BlibFilter(); status = new ProgressStatus(message); diff --git a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.Designer.cs b/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.Designer.cs deleted file mode 100644 index ac2e850c64..0000000000 --- a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.Designer.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace pwiz.Skyline.SettingsUI -{ - partial class BuildLibraryNotification - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BuildLibraryNotification)); - this.NotificationCloseButton = new System.Windows.Forms.Button(); - this.TextPanel = new System.Windows.Forms.Panel(); - this.NotificationMessage = new System.Windows.Forms.Label(); - this.LibraryNameLabel = new System.Windows.Forms.Label(); - this.ViewLibraryLink = new System.Windows.Forms.LinkLabel(); - this.TextPanel.SuspendLayout(); - this.SuspendLayout(); - // - // NotificationCloseButton - // - resources.ApplyResources(this.NotificationCloseButton, "NotificationCloseButton"); - this.NotificationCloseButton.FlatAppearance.BorderColor = System.Drawing.Color.Lavender; - this.NotificationCloseButton.FlatAppearance.BorderSize = 0; - this.NotificationCloseButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.CornflowerBlue; - this.NotificationCloseButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightSteelBlue; - this.NotificationCloseButton.ForeColor = System.Drawing.Color.Transparent; - this.NotificationCloseButton.Name = "NotificationCloseButton"; - this.NotificationCloseButton.UseVisualStyleBackColor = false; - this.NotificationCloseButton.Click += new System.EventHandler(this.NotificationCloseButton_Click); - // - // TextPanel - // - this.TextPanel.Controls.Add(this.NotificationMessage); - this.TextPanel.Controls.Add(this.LibraryNameLabel); - this.TextPanel.Controls.Add(this.ViewLibraryLink); - resources.ApplyResources(this.TextPanel, "TextPanel"); - this.TextPanel.Name = "TextPanel"; - // - // NotificationMessage - // - resources.ApplyResources(this.NotificationMessage, "NotificationMessage"); - this.NotificationMessage.ForeColor = System.Drawing.Color.Navy; - this.NotificationMessage.Name = "NotificationMessage"; - // - // LibraryNameLabel - // - resources.ApplyResources(this.LibraryNameLabel, "LibraryNameLabel"); - this.LibraryNameLabel.AutoEllipsis = true; - this.LibraryNameLabel.ForeColor = System.Drawing.Color.Navy; - this.LibraryNameLabel.Name = "LibraryNameLabel"; - // - // ViewLibraryLink - // - resources.ApplyResources(this.ViewLibraryLink, "ViewLibraryLink"); - this.ViewLibraryLink.AutoEllipsis = true; - this.ViewLibraryLink.Name = "ViewLibraryLink"; - this.ViewLibraryLink.TabStop = true; - this.ViewLibraryLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.ViewLibraryLink_LinkClicked); - // - // BuildLibraryNotification - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoValidate = System.Windows.Forms.AutoValidate.Disable; - this.BackColor = System.Drawing.Color.Lavender; - this.ControlBox = false; - this.Controls.Add(this.NotificationCloseButton); - this.Controls.Add(this.TextPanel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "BuildLibraryNotification"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.TopMost = true; - this.TextPanel.ResumeLayout(false); - this.TextPanel.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button NotificationCloseButton; - private System.Windows.Forms.Panel TextPanel; - private System.Windows.Forms.Label NotificationMessage; - private System.Windows.Forms.Label LibraryNameLabel; - private System.Windows.Forms.LinkLabel ViewLibraryLink; - } -} \ No newline at end of file diff --git a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.cs b/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.cs deleted file mode 100644 index 52031524d6..0000000000 --- a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.cs +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Original author: Tahmina Baker , - * UWPR, Department of Genome Sciences, UW - * - * Copyright 2010 University of Washington - Seattle, WA - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Linq; -using System.Threading; -using System.Windows.Forms; -using pwiz.Common.SystemUtil; -using pwiz.Skyline.Alerts; -using pwiz.Skyline.Controls; -using pwiz.Skyline.Model; -using pwiz.Skyline.Model.AuditLog; -using pwiz.Skyline.Model.DocSettings; -using pwiz.Skyline.Model.DocSettings.Extensions; -using pwiz.Skyline.Model.Irt; -using pwiz.Skyline.Model.Lib; -using pwiz.Skyline.Properties; -using pwiz.Skyline.SettingsUI.Irt; -using pwiz.Skyline.Util; -using pwiz.Skyline.Util.Extensions; -using Timer=System.Windows.Forms.Timer; - -namespace pwiz.Skyline.SettingsUI -{ - public partial class BuildLibraryNotification : FormEx - { - private const int ANIMATION_DURATION = 1000; - private const int DISPLAY_DURATION = 10000; - - private readonly Thread _thread; - private readonly ManualResetEvent _windowCreatedEvent; - private readonly FormAnimator _animator; - private readonly Timer _displayTimer; - private readonly String _libraryName; - - public event EventHandler ExploreLibrary; - public event EventHandler NotificationComplete; - - public BuildLibraryNotification(String libraryName) - { - InitializeComponent(); - - // WINDOWS 10 UPDATE HACK: Because Windows 10 update version 1803 causes unparented non-ShowInTaskbar windows to leak GDI and User handles - ShowInTaskbar = Program.FunctionalTest; - - _libraryName = libraryName; - LibraryNameLabel.Text = string.Format(SettingsUIResources.BuildLibraryNotification_BuildLibraryNotification_Library__0__, _libraryName); - - var showParams = new FormAnimator.AnimationParams( - FormAnimator.AnimationMethod.slide, - FormAnimator.AnimationDirection.up, - 0); - var hideParams = new FormAnimator.AnimationParams( - FormAnimator.AnimationMethod.blend, - FormAnimator.AnimationDirection.up, - 0); - _animator = new FormAnimator(this, showParams, hideParams) - {ShowParams = {Duration = ANIMATION_DURATION}}; - - // Not sure why this is necessary, but sometimes the form doesn't - // appear without it. - Opacity = 1; - - _thread = BackgroundEventThreads.CreateThreadForAction(Notify); - _thread.Name = @"BuildLibraryNotification"; - _thread.IsBackground = true; - - _windowCreatedEvent = new ManualResetEvent(false); - HandleCreated += Notification_HandleCreated; - - _displayTimer = new Timer(); - _displayTimer.Tick += OnDisplayTimerEvent; - _displayTimer.Interval = DISPLAY_DURATION; - } - - private void Notification_HandleCreated(object sender, EventArgs e) - { - _windowCreatedEvent.Set(); - } - - /// - /// Does not work with the way this form gets shown, but it is - /// here to prove it was tried. - /// - protected override bool ShowWithoutActivation - { - get { return true; } - } - - public void Start() - { - Assume.IsFalse(_thread.IsAlive); // Called only once - - _thread.Start(); - } - - public void Notify() - { - LocalizationHelper.InitThread(); - - // Start the timer that will count how long to display it - _displayTimer.Start(); - - // Start the message pump - // This call returns when ExitThread is called - Application.Run(this); - } - - public void Remove() - { - _windowCreatedEvent.WaitOne(); - - if (IsHandleCreated) - { - try - { - // Make sure this happens on the right thread. - if (InvokeRequired) - { - BeginInvoke((Action)OnRemove); - _thread.Join(); // Wait for the thread to complete - } - else - { - OnRemove(); - } - } - catch - { - // ignore - } - } - } - - public void OnRemove() - { - try - { - _displayTimer.Stop(); - _displayTimer.Dispose(); - _animator.Release(); - _windowCreatedEvent.Dispose(); - Close(); - Dispose(); - } - finally - { - Application.ExitThread(); - } - } - - private void CloseNotification(bool animate) - { - _displayTimer.Stop(); - _animator.HideParams.Duration = animate ? ANIMATION_DURATION : 0; - Hide(); - - if (NotificationComplete != null) - NotificationComplete.Invoke(this, new EventArgs()); - } - - private void OnDisplayTimerEvent(object sender, EventArgs e) - { - CloseNotification(true); - } - - private void NotificationCloseButton_Click(object sender, EventArgs e) - { - CloseNotification(false); - } - - private void ViewLibraryLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - CloseNotification(false); - if (ExploreLibrary != null) - ExploreLibrary.Invoke(this, new ExploreLibraryEventArgs(_libraryName)); - } - } - - public sealed class ExploreLibraryEventArgs : EventArgs - { - public ExploreLibraryEventArgs(string libraryName) - { - LibraryName = libraryName; - } - - public string LibraryName { get; private set; } - } - - public interface INotificationContainer - { - Point NotificationAnchor { get; } - } - - public interface ILibraryBuildNotificationContainer : INotificationContainer - { - LibraryManager LibraryManager { get; } - void ModifyDocument(string description, Func act, Func logFunc); - SrmDocument Document { get; } - } - - public sealed class LibraryBuildNotificationHandler - { - private const int PADDING = 8; - - public LibraryBuildNotificationHandler(Form notificationContainer) - { - notificationContainer.Closing += notificationContainerForm_Closing; - notificationContainer.Move += notifactionContainerForm_Move; - NotificationContainerForm = notificationContainer; - NotificationContainer = (ILibraryBuildNotificationContainer) notificationContainer; - } - - private Form NotificationContainerForm { get; set; } - private ILibraryBuildNotificationContainer NotificationContainer { get; set; } - - private BuildLibraryNotification _notification; - - private Point NotificationAnchor - { - get - { - Point anchor = NotificationContainer.NotificationAnchor; - anchor.X += PADDING; - anchor.Y -= PADDING; - return anchor; - } - } - - private void InvokeAction(Action action) - { - // Make sure the notification container form has not already been - // destroyed on its own thread, before trying to post a message to the - // thread. - try - { - NotificationContainerForm.Invoke(action); - } - catch (ObjectDisposedException) - { - // The main window may close during an attempt to activate it, - // and cause this exception. Hard to figure out anything to do - // but catch and ignore it. Would be lots nicer, if it were - // possible to show a .NET form without it activating itself. - // Again, using NativeWindow is too much for this feature right now. - // It does not help to test IsDisposed before calling Invoke. - } - } - - private void notification_ExploreLibrary(object sender, ExploreLibraryEventArgs e) - { - InvokeAction(() => ShowViewLibraryUI(e.LibraryName)); - } - - private void ShowViewLibraryUI(String libName) - { - var indexPepSetUI = Program.MainWindow.OwnedForms.IndexOf(form => form is PeptideSettingsUI); - if (indexPepSetUI != -1) - { - ((PeptideSettingsUI)Program.MainWindow.OwnedForms[indexPepSetUI]).ShowViewLibraryDlg(libName); - } - var indexViewLibDlg = Program.MainWindow.OwnedForms.IndexOf(form => form is ViewLibraryDlg); - if (indexViewLibDlg == -1) - { - var dlg = new ViewLibraryDlg(NotificationContainer.LibraryManager, libName, Program.MainWindow) - {Owner = Program.MainWindow}; - dlg.Show(Program.MainWindow); - } - else - { - ViewLibraryDlg viewLibDlg = (ViewLibraryDlg) Program.MainWindow.OwnedForms[indexViewLibDlg]; - viewLibDlg.Activate(); - viewLibDlg.ChangeSelectedLibrary(libName); - } - } - - private void notification_Activated(object sender, EventArgs e) - { - // Ugh. The library build notification form will activate itself. - // To do better, we would have to use a NativeWindow for the notification, - // like CustomTip, but that is just too much work for this. So, - // we just do our best to return activation to the topmost open form. - InvokeAction(TopMostApplicationForm.Activate); - } - - private void notification_Shown(object sender, EventArgs e) - { - Form form = (Form) sender; - // If the application is not active when the form is shown, then the form - // can end up underneath the application window. This hack fixes that issue. - form.TopMost = true; - - // Remove the activation hook, since it can cause problems after this. - form.Activated -= notification_Activated; - } - - private Form TopMostApplicationForm - { - get - { - return FormUtil.FindTopLevelOpenForm(f => f is BuildLibraryNotification) ?? - NotificationContainerForm; - } - } - - private void notification_NotificationComplete(object sender, EventArgs e) - { - RemoveLibraryBuildNotification(); - } - - private void notifactionContainerForm_Move(object sender, EventArgs e) - { - RemoveLibraryBuildNotification(); - } - - private void notificationContainerForm_Closing(object sender, CancelEventArgs e) - { - RemoveLibraryBuildNotification(); - } - - public void RemoveLibraryBuildNotification() - { - // Avoid blocking here, because notification.Remove() requires the form's - // event thread, which can result in a deadlock if the test thread tries to - // remove the form just before the event thread begins removing it. - // Unfortunately, this means the function cannot guarantee the form is - // actually removed when it returns. Just that the process of removing it - // has started. - var notification = Interlocked.Exchange(ref _notification, null); - if (notification != null) - { - notification.Shown -= notification_Shown; - notification.Activated -= notification_Activated; - notification.Remove(); - } - } - - public void LibraryBuildCompleteCallback(LibraryManager.BuildState buildState, bool success) - { - // Completion needs to happen on a separate thread because of the access to UI elements - // In order to make sure the thread handle is released, it needs to call Application.ThreadExit() - var threadComplete = BackgroundEventThreads.CreateThreadForAction(() => - { - if (success && NotificationContainerForm.IsHandleCreated) - { - // Only one form showing at a time - lock (this) - { - RemoveLibraryBuildNotification(); - - var frm = new BuildLibraryNotification(buildState.LibrarySpec.Name); - frm.Activated += notification_Activated; - frm.Shown += notification_Shown; - frm.ExploreLibrary += notification_ExploreLibrary; - frm.NotificationComplete += notification_NotificationComplete; - Point anchor = NotificationAnchor; - frm.Left = anchor.X; - frm.Top = anchor.Y - frm.Height; - NotificationContainerForm.BeginInvoke(new Action(() => - { - if (!string.IsNullOrEmpty(buildState.ExtraMessage)) - { - MessageDlg.Show(TopMostApplicationForm, buildState.ExtraMessage); - } - if (buildState.IrtStandard != null && !buildState.IrtStandard.IsEmpty) - { - // Load library - Library lib = null; - using (var longWait = new LongWaitDlg()) - { - longWait.Text = SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Loading_library; - var status = longWait.PerformWork(TopMostApplicationForm, 800, monitor => - { - lib = NotificationContainer.LibraryManager.TryGetLibrary(buildState.LibrarySpec) ?? - NotificationContainer.LibraryManager.LoadLibrary(buildState.LibrarySpec, () => new DefaultFileLoadMonitor(monitor)); - if (lib != null) - { - foreach (var stream in lib.ReadStreams) - stream.CloseStream(); - } - }); - if (status.IsCanceled) - lib = null; - if (status.IsError) - throw status.ErrorException; - } - // Add iRTs to library - if (AddIrts(IrtRegressionType.DEFAULT, lib, buildState.LibrarySpec, buildState.IrtStandard, NotificationContainerForm, true, out _)) - AddRetentionTimePredictor(buildState); - } - })); - frm.Start(); - Assume.IsNull(Interlocked.Exchange(ref _notification, frm)); - } - } - }); - threadComplete.Name = @"Library Build Completion"; - threadComplete.Start(); - } - - public static bool AddIrts(IrtRegressionType regressionType, Library lib, LibrarySpec libSpec, IrtStandard standard, Control parent, bool useTopMostForm, out IrtStandard outStandard) - { - outStandard = standard; - if (lib == null || !lib.IsLoaded || standard == null || standard.IsEmpty) - return false; - - Control GetParent() { return useTopMostForm ? FormUtil.FindTopLevelOpenForm(f => f is BuildLibraryNotification) ?? parent : parent; } - - IRetentionTimeProvider[] irtProviders = null; - var isAuto = standard.IsAuto; - List autoStandards = null; - var cirtPeptides = new DbIrtPeptide[0]; - - using (var longWait = new LongWaitDlg()) - { - longWait.Text = SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Loading_retention_time_providers; - var standard1 = standard; - var status = longWait.PerformWork(GetParent(), 800, monitor => - { - ImportPeptideSearch.GetLibIrtProviders(lib, standard1, monitor, out irtProviders, out autoStandards, out cirtPeptides); - }); - if (status.IsCanceled) - return false; - if (status.IsError) - throw status.ErrorException; - } - - int? numCirt = null; - if (cirtPeptides.Length >= RCalcIrt.MIN_PEPTIDES_COUNT) - { - using (var dlg = new AddIrtStandardsDlg(cirtPeptides.Length, - string.Format( - Resources.LibraryBuildNotificationHandler_AddIrts__0__distinct_CiRT_peptides_were_found__How_many_would_you_like_to_use_as_iRT_standards_, - cirtPeptides.Length))) - { - if (dlg.ShowDialog(GetParent()) != DialogResult.OK) - return false; - numCirt = dlg.StandardCount; - } - } - else if (isAuto) - { - switch (autoStandards.Count) - { - case 0: - standard = new IrtStandard(XmlNamedElement.NAME_INTERNAL, null, null, IrtPeptidePicker.Pick(irtProviders, 10)); - break; - case 1: - standard = autoStandards[0]; - break; - default: - using (var selectIrtStandardDlg = new SelectIrtStandardDlg(autoStandards)) - { - if (selectIrtStandardDlg.ShowDialog(GetParent()) != DialogResult.OK) - return false; - standard = selectIrtStandardDlg.Selected; - } - break; - } - } - - ProcessedIrtAverages processed = null; - using (var longWait = new LongWaitDlg()) - { - longWait.Text = SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Processing_retention_times; - try - { - var status = longWait.PerformWork(GetParent(), 800, monitor => - { - processed = ImportPeptideSearch.ProcessRetentionTimes(numCirt, irtProviders, - standard.Peptides.ToArray(), cirtPeptides, regressionType, monitor, - out var newStandardPeptides); - if (newStandardPeptides != null) - { - standard = new IrtStandard(XmlNamedElement.NAME_INTERNAL, null, null, newStandardPeptides); - } - }); - if (status.IsCanceled) - return false; - if (status.IsError) - throw status.ErrorException; - } - catch (Exception x) - { - MessageDlg.ShowWithException(GetParent(), - TextUtil.LineSeparate( - Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_while_processing_retention_times_, - x.Message), x); - return false; - } - } - - using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed)) - { - if (resultsDlg.ShowDialog(GetParent()) != DialogResult.OK) - return false; - } - - var recalibrate = false; - if (processed.CanRecalibrateStandards(standard.Peptides)) - { - using (var dlg = new MultiButtonMsgDlg( - TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_, - Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_), - MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false)) - { - recalibrate = dlg.ShowDialog(GetParent()) == DialogResult.Yes; - } - } - - if (!processed.DbIrtPeptides.Any()) - return false; - - using (var longWait = new LongWaitDlg()) - { - longWait.Text = SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Adding_iRTs_to_library; - try - { - var status = longWait.PerformWork(GetParent(), 800, monitor => - { - ImportPeptideSearch.CreateIrtDb(libSpec.FilePath, processed, standard.Peptides.ToArray(), recalibrate, regressionType, monitor); - }); - if (status.IsError) - throw status.ErrorException; - } - catch (Exception x) - { - MessageDlg.ShowWithException(GetParent(), - TextUtil.LineSeparate( - SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_An_error_occurred_trying_to_add_iRTs_to_the_library_, - x.Message), x); - return false; - } - } - outStandard = standard; - return true; - } - - private void AddRetentionTimePredictor(LibraryManager.BuildState buildState) - { - var predictorName = Helpers.GetUniqueName(buildState.LibrarySpec.Name, Settings.Default.RetentionTimeList.Select(rt => rt.Name).ToArray()); - using (var addPredictorDlg = new AddRetentionTimePredictorDlg(predictorName, buildState.LibrarySpec.FilePath, false)) - { - if (addPredictorDlg.ShowDialog(TopMostApplicationForm) == DialogResult.OK) - { - Settings.Default.RTScoreCalculatorList.Add(addPredictorDlg.Calculator); - Settings.Default.RetentionTimeList.Add(addPredictorDlg.Regression); - NotificationContainer.ModifyDocument(SettingsUIResources.LibraryBuildNotificationHandler_AddRetentionTimePredictor_Add_retention_time_predictor, - doc => doc.ChangeSettings(doc.Settings.ChangePeptidePrediction(predict => - predict.ChangeRetentionTime(addPredictorDlg.Regression))), AuditLogEntry.SettingsLogFunction); - } - } - } - } -} diff --git a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.ja.resx b/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.ja.resx deleted file mode 100644 index c8f52a3a4a..0000000000 --- a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.ja.resx +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - R0lGODlhDgAOAIcAAAAAAHgAAP////7Jyf+Pj/8AAMoAAGcAAP9iYgAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - ACH/C05FVFNDQVBFMi4wAwEBAAAh+QQBAAAAACwAAAAADgAOAAAIVwABCBxIsKDAAAYREgwgQOHBhgMD - DCBAQKHEAgYORCSAAMGBAwgwalzYsWOBAiMLBjCJ0uDBkCdTkjxJUyaAiygP1Iw4QKRAnQYyRhQ68ADR - ogZtuiwYEAA7 - - - - - Center - - - Flat - - - 137, 3 - - - 0, 0, 0, 0 - - - 16, 16 - - - - 2 - - - NotificationCloseButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - Left, Right - - - True - - - 0, 16 - - - 84, 13 - - - 7 - - - 構築完了。 - - - NotificationMessage - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 0 - - - Left, Right - - - 0, 0 - - - 118, 16 - - - 6 - - - メッセージプレースホルダー - - - LibraryNameLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 1 - - - Left, Right - - - Microsoft Sans Serif, 8.25pt - - - 0, 38 - - - 118, 16 - - - 5 - - - ライブラリを調べる... - - - ViewLibraryLink - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 2 - - - 24, 32 - - - 119, 53 - - - 3 - - - TextPanel - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - 6, 13 - - - 160, 94 - - - Manual - - - BuildLibraryNotification - - - pwiz.Skyline.Util.FormEx, Skyline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.resx b/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.resx deleted file mode 100644 index 7a077a516a..0000000000 --- a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.resx +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - R0lGODlhDgAOAIcAAAAAAHgAAP////7Jyf+Pj/8AAMoAAGcAAP9iYgAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - ACH/C05FVFNDQVBFMi4wAwEBAAAh+QQBAAAAACwAAAAADgAOAAAIVwABCBxIsKDAAAYREgwgQOHBhgMD - DCBAQKHEAgYORCSAAMGBAwgwalzYsWOBAiMLBjCJ0uDBkCdTkjxJUyaAiygP1Iw4QKRAnQYyRhQ68ADR - ogZtuiwYEAA7 - - - - - Center - - - Flat - - - 137, 3 - - - 0, 0, 0, 0 - - - 16, 16 - - - - 2 - - - NotificationCloseButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - Left, Right - - - True - - - 0, 16 - - - 84, 13 - - - 7 - - - build completed. - - - NotificationMessage - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 0 - - - Left, Right - - - 0, 0 - - - 118, 16 - - - 6 - - - message placeholder - - - LibraryNameLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 1 - - - Left, Right - - - Microsoft Sans Serif, 8.25pt - - - 0, 38 - - - 118, 16 - - - 5 - - - Explore library... - - - ViewLibraryLink - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 2 - - - 24, 32 - - - 119, 53 - - - 3 - - - TextPanel - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - 6, 13 - - - 160, 94 - - - Manual - - - BuildLibraryNotification - - - pwiz.Skyline.Util.FormEx, Skyline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.zh-CHS.resx b/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.zh-CHS.resx deleted file mode 100644 index dfea83c2d9..0000000000 --- a/pwiz_tools/Skyline/SettingsUI/BuildLibraryNotification.zh-CHS.resx +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - R0lGODlhDgAOAIcAAAAAAHgAAP////7Jyf+Pj/8AAMoAAGcAAP9iYgAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - ACH/C05FVFNDQVBFMi4wAwEBAAAh+QQBAAAAACwAAAAADgAOAAAIVwABCBxIsKDAAAYREgwgQOHBhgMD - DCBAQKHEAgYORCSAAMGBAwgwalzYsWOBAiMLBjCJ0uDBkCdTkjxJUyaAiygP1Iw4QKRAnQYyRhQ68ADR - ogZtuiwYEAA7 - - - - - Center - - - Flat - - - 137, 3 - - - 0, 0, 0, 0 - - - 16, 16 - - - - 2 - - - NotificationCloseButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - Left, Right - - - True - - - 0, 16 - - - 84, 13 - - - 7 - - - 完成建立。 - - - NotificationMessage - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 0 - - - Left, Right - - - 0, 0 - - - 118, 16 - - - 6 - - - 消息占位符 - - - LibraryNameLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 1 - - - Left, Right - - - Microsoft Sans Serif, 8.25pt - - - 0, 38 - - - 118, 16 - - - 5 - - - 搜索库… - - - ViewLibraryLink - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - TextPanel - - - 2 - - - 24, 32 - - - 119, 53 - - - 3 - - - TextPanel - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - 6, 13 - - - 160, 94 - - - Manual - - - BuildLibraryNotification - - - pwiz.Skyline.Util.FormEx, Skyline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/pwiz_tools/Skyline/SettingsUI/IonMobility/EditIonMobilityLibraryDlg.cs b/pwiz_tools/Skyline/SettingsUI/IonMobility/EditIonMobilityLibraryDlg.cs index 2b4d58f416..0662b885c2 100644 --- a/pwiz_tools/Skyline/SettingsUI/IonMobility/EditIonMobilityLibraryDlg.cs +++ b/pwiz_tools/Skyline/SettingsUI/IonMobility/EditIonMobilityLibraryDlg.cs @@ -745,12 +745,11 @@ public void ImportFromSpectralLibrary() public string ImportFromSpectralLibrary(LibrarySpec librarySpec, IList existing) { - var libraryManager = ((ILibraryBuildNotificationContainer)Program.MainWindow).LibraryManager; Library library = null; IEnumerable peptideCollisionalCrossSections = null; try { - library = libraryManager.TryGetLibrary(librarySpec); + library = Program.MainWindow.LibraryManager.TryGetLibrary(librarySpec); using (var longWait = new LongWaitDlg()) { longWait.Text = IonMobilityResources.CollisionalCrossSectionGridViewDriver_AddSpectralLibrary_Adding_Spectral_Library; diff --git a/pwiz_tools/Skyline/SettingsUI/Irt/EditIrtCalcDlg.cs b/pwiz_tools/Skyline/SettingsUI/Irt/EditIrtCalcDlg.cs index 03d37fbc96..5358187f47 100644 --- a/pwiz_tools/Skyline/SettingsUI/Irt/EditIrtCalcDlg.cs +++ b/pwiz_tools/Skyline/SettingsUI/Irt/EditIrtCalcDlg.cs @@ -999,12 +999,11 @@ public void AddSpectralLibrary() private void AddSpectralLibrary(LibrarySpec librarySpec) { - var libraryManager = ((ILibraryBuildNotificationContainer)Program.MainWindow).LibraryManager; Library library = null; ProcessedIrtAverages irtAverages = null; try { - library = libraryManager.TryGetLibrary(librarySpec); + library = Program.MainWindow.LibraryManager.TryGetLibrary(librarySpec); using (var longWait = new LongWaitDlg()) { longWait.Text = IrtResources.LibraryGridViewDriver_AddSpectralLibrary_Adding_Spectral_Library; diff --git a/pwiz_tools/Skyline/SettingsUI/PeptideSettingsUI.cs b/pwiz_tools/Skyline/SettingsUI/PeptideSettingsUI.cs index e96ddc0e5e..9315566939 100644 --- a/pwiz_tools/Skyline/SettingsUI/PeptideSettingsUI.cs +++ b/pwiz_tools/Skyline/SettingsUI/PeptideSettingsUI.cs @@ -26,17 +26,21 @@ using pwiz.Common.SystemUtil; using pwiz.Skyline.Alerts; using pwiz.Skyline.Controls; +using pwiz.Skyline.FileUI.PeptideSearch; using pwiz.Skyline.Model; using pwiz.Skyline.Model.DocSettings; using pwiz.Skyline.Model.DocSettings.AbsoluteQuantification; using pwiz.Skyline.Model.GroupComparison; +using pwiz.Skyline.Model.Irt; using pwiz.Skyline.Model.Lib; using pwiz.Skyline.Model.Lib.Midas; using pwiz.Skyline.Model.Proteome; using pwiz.Skyline.Model.Results.Scoring; using pwiz.Skyline.Properties; +using pwiz.Skyline.SettingsUI.Irt; using pwiz.Skyline.Util; using pwiz.Skyline.Util.Extensions; +using static pwiz.Skyline.Model.Lib.LibraryManager; namespace pwiz.Skyline.SettingsUI { @@ -728,65 +732,261 @@ public void ShowBuildLibraryDlg() // Libraries built for full-scan filtering can have important retention time information, // and the redundant libraries are more likely to be desirable for showing spectra. - using (var dlg = new BuildLibraryDlg(_parent)) + using var dlg = new BuildLibraryDlg(_parent); + dlg.LibraryKeepRedundant = _parent.DocumentUI.Settings.TransitionSettings.FullScan.IsEnabled; + if (dlg.ShowDialog(this) == DialogResult.OK) { - dlg.LibraryKeepRedundant = _parent.DocumentUI.Settings.TransitionSettings.FullScan.IsEnabled; - if (dlg.ShowDialog(this) == DialogResult.OK) + if (!string.IsNullOrEmpty(dlg.AddLibraryFile)) { - if (!string.IsNullOrEmpty(dlg.AddLibraryFile)) + using var editLibDlg = new EditLibraryDlg(Settings.Default.SpectralLibraryList); + editLibDlg.LibraryPath = dlg.AddLibraryFile; + if (editLibDlg.ShowDialog(this) == DialogResult.OK) { - using (var editLibDlg = new EditLibraryDlg(Settings.Default.SpectralLibraryList)) - { - editLibDlg.LibraryPath = dlg.AddLibraryFile; - if (editLibDlg.ShowDialog(this) == DialogResult.OK) - { - _driverLibrary.List.Add(editLibDlg.LibrarySpec); - _driverLibrary.LoadList(_driverLibrary.Chosen.Concat(new[] {editLibDlg.LibrarySpec}).ToArray()); - } - } - return; + _driverLibrary.List.Add(editLibDlg.LibrarySpec); + _driverLibrary.LoadList(_driverLibrary.Chosen.Concat(new[] {editLibDlg.LibrarySpec}).ToArray()); } - IsBuildingLibrary = true; + return; + } - var builder = dlg.Builder; + BuildLibrary(dlg.Builder); + } + } - // assume success and cleanup later - Settings.Default.SpectralLibraryList.Add(builder.LibrarySpec); - _driverLibrary.LoadList(); - var libraryIndex = listLibraries.Items.IndexOf(builder.LibrarySpec.Name); - if (libraryIndex >= 0) - listLibraries.SetItemChecked(libraryIndex, true); + private void BuildLibrary(ILibraryBuilder builder) + { + IsBuildingLibrary = true; - var currentForm = this; + var buildState = new BuildState(builder.LibrarySpec, _libraryManager.BuildLibraryBackground); - _libraryManager.BuildLibrary(_parent, builder, (buildState, success) => + bool retry; + do + { + using (var longWaitDlg = new LongWaitDlg(_parent)) + { + var status = longWaitDlg.PerformWork(_parent, 500, progressMonitor => + _libraryManager.BuildLibraryBackground(_parent, builder, progressMonitor, buildState)); + + if (status.IsError) { - _parent.LibraryBuildCompleteCallback(buildState, success); + if (ReportLibraryBuildFailure) + { + Console.WriteLine(@"Library {0} build failed", builder.LibrarySpec.Name); + } + + // E.g. could not find external raw data for MaxQuant msms.txt; ask user if they want to retry with "prefer embedded spectra" option + var builderLite = builder as BiblioSpecLiteBuilder; + if (builderLite != null && BiblioSpecLiteBuilder.IsLibraryMissingExternalSpectraError(status.ErrorException)) + { + var response = BuildPeptideSearchLibraryControl.ShowLibraryMissingExternalSpectraError(this, status.ErrorException); + if (response == UpdateProgressResponse.cancel) + return; + + builderLite.PreferEmbeddedSpectra = response == UpdateProgressResponse.normal; - if (!success) + retry = true; + continue; + } + else { - if (ReportLibraryBuildFailure) - Console.WriteLine(@"Library {0} build failed", builder.LibrarySpec.Name); + MessageDlg.ShowException(this, status.ErrorException); + } + } + retry = false; + } + } while (retry); + + CompleteLibraryBuild(buildState); + + Settings.Default.SpectralLibraryList.Add(builder.LibrarySpec); + _driverLibrary.LoadList(); + var libraryIndex = listLibraries.Items.IndexOf(builder.LibrarySpec.Name); + if (libraryIndex >= 0) + listLibraries.SetItemChecked(libraryIndex, true); + + IsBuildingLibrary = false; + } + + private static bool PerformLongWork(Control parent, string text, Action work) + { + using var longWait = new LongWaitDlg(); + longWait.Text = text; // CONSIDER: Should this really be the form title or should it be the starting Message? + var status = longWait.PerformWork(parent, 800, work); + // Note that we can't trust that the status not being complete has any useful meaning here + if (status.IsCanceled) + return false; + if (status.IsError) + { + MessageDlg.ShowException(parent, status.ErrorException); + return false; + } + return true; + } + + private static bool PerformLongWorkWithErrorMessage(Control parent, string text, string errorMessage, + Action work) + { + return PerformLongWork(parent, text, monitor => + { + try + { + work(monitor); + } + catch (Exception x) + { + throw new IOException(TextUtil.LineSeparate(errorMessage, x.Message), x); + } + }); + } + + public void CompleteLibraryBuild(BuildState buildState) + { + if (!string.IsNullOrEmpty(buildState.ExtraMessage)) + { + MessageDlg.Show(this, buildState.ExtraMessage); + } - _parent.Invoke(new Action(() => + if (buildState.IrtStandard != null && !buildState.IrtStandard.IsEmpty) + { + // Load library + Library lib = null; + if (!PerformLongWork(this, SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Loading_library, + monitor => + { + lib = _libraryManager.TryGetLibrary(buildState.LibrarySpec) ?? + _libraryManager.LoadLibrary(buildState.LibrarySpec, () => new DefaultFileLoadMonitor(monitor)); + if (lib != null) { - if (Settings.Default.SpectralLibraryList.Contains(builder.LibrarySpec)) - Settings.Default.SpectralLibraryList.Remove(builder.LibrarySpec); - })); - - // TODO: handle the case of cleaning up a PeptideSettingsUI form other than the one that launched this library build - if (ReferenceEquals(currentForm, this) && !IsDisposed && !Disposing) - currentForm.Invoke(new Action(() => - { - _driverLibrary.LoadList(); - listLibraries.Items.Remove(builder.LibrarySpec.Name); - })); + foreach (var stream in lib.ReadStreams) + stream.CloseStream(); + } + })) + { + return; + } + // Add iRTs to library + if (AddIrts(IrtRegressionType.DEFAULT, lib, buildState.LibrarySpec, buildState.IrtStandard, this, true, out _)) + AddRetentionTimePredictor(buildState); + } + } + + public static bool AddIrts(IrtRegressionType regressionType, Library lib, LibrarySpec libSpec, IrtStandard standard, Control parent, bool useTopMostForm, out IrtStandard outStandard) + { + outStandard = standard; + if (lib == null || !lib.IsLoaded || standard == null || standard.IsEmpty) + return false; + + IRetentionTimeProvider[] irtProviders = null; + var isAuto = standard.IsAuto; + List autoStandards = null; + var cirtPeptides = Array.Empty(); + + var standard1 = standard; + if (!PerformLongWork(parent, SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Loading_retention_time_providers, + monitor => + { + ImportPeptideSearch.GetLibIrtProviders(lib, standard1, monitor, + out irtProviders, out autoStandards, out cirtPeptides); + })) + { + return false; + } + + int? numCirt = null; + if (cirtPeptides.Length >= RCalcIrt.MIN_PEPTIDES_COUNT) + { + using var dlg = new AddIrtStandardsDlg(cirtPeptides.Length, + string.Format( + Resources.LibraryBuildNotificationHandler_AddIrts__0__distinct_CiRT_peptides_were_found__How_many_would_you_like_to_use_as_iRT_standards_, + cirtPeptides.Length)); + if (dlg.ShowDialog(parent) != DialogResult.OK) + return false; + numCirt = dlg.StandardCount; + } + else if (isAuto) + { + switch (autoStandards.Count) + { + case 0: + standard = new IrtStandard(XmlNamedElement.NAME_INTERNAL, null, null, IrtPeptidePicker.Pick(irtProviders, 10)); + break; + case 1: + standard = autoStandards[0]; + break; + default: + using (var selectIrtStandardDlg = new SelectIrtStandardDlg(autoStandards)) + { + if (selectIrtStandardDlg.ShowDialog(parent) != DialogResult.OK) + return false; + standard = selectIrtStandardDlg.Selected; } - IsBuildingLibrary = false; - }); + break; } } + + ProcessedIrtAverages processed = null; + if (!PerformLongWorkWithErrorMessage(parent, + SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Processing_retention_times, + Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_while_processing_retention_times_, + monitor => + { + processed = ImportPeptideSearch.ProcessRetentionTimes(numCirt, irtProviders, + standard.Peptides.ToArray(), cirtPeptides, regressionType, monitor, + out var newStandardPeptides); + if (newStandardPeptides != null) + { + standard = new IrtStandard(XmlNamedElement.NAME_INTERNAL, null, null, newStandardPeptides); + } + })) + { + return false; + } + + using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed)) + { + if (resultsDlg.ShowDialog(parent) != DialogResult.OK) + return false; + } + + var recalibrate = false; + if (processed.CanRecalibrateStandards(standard.Peptides)) + { + using var dlg = new MultiButtonMsgDlg( + TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_, + Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_), + MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false); + + recalibrate = dlg.ShowDialog(parent) == DialogResult.Yes; + } + + if (!processed.DbIrtPeptides.Any()) + return false; + + if (!PerformLongWorkWithErrorMessage(parent, + SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_Adding_iRTs_to_library, + SettingsUIResources.LibraryBuildNotificationHandler_AddIrts_An_error_occurred_trying_to_add_iRTs_to_the_library_, + monitor => + { + ImportPeptideSearch.CreateIrtDb(libSpec.FilePath, processed, standard.Peptides.ToArray(), + recalibrate, regressionType, monitor); + })) + { + return false; + } + outStandard = standard; + return true; + } + + private void AddRetentionTimePredictor(BuildState buildState) + { + var predictorName = Helpers.GetUniqueName(buildState.LibrarySpec.Name, Settings.Default.RetentionTimeList.Select(rt => rt.Name).ToArray()); + using var addPredictorDlg = new AddRetentionTimePredictorDlg(predictorName, buildState.LibrarySpec.FilePath, false); + if (addPredictorDlg.ShowDialog(this) == DialogResult.OK) + { + Settings.Default.RTScoreCalculatorList.Add(addPredictorDlg.Calculator); + Settings.Default.RetentionTimeList.Add(addPredictorDlg.Regression); + _driverRT.LoadList(addPredictorDlg.Regression.Name); + } } private void btnFilter_Click(object sender, EventArgs e) diff --git a/pwiz_tools/Skyline/Skyline.cs b/pwiz_tools/Skyline/Skyline.cs index 938c6bb620..f70399cb64 100644 --- a/pwiz_tools/Skyline/Skyline.cs +++ b/pwiz_tools/Skyline/Skyline.cs @@ -97,7 +97,6 @@ public partial class SkylineWindow IUndoable, IDocumentUIContainer, IProgressMonitor, - ILibraryBuildNotificationContainer, IToolMacroProvider, IModifyDocumentContainer, IRetentionScoreSource, @@ -119,7 +118,6 @@ public partial class SkylineWindow private readonly RetentionTimeManager _retentionTimeManager; private readonly IonMobilityLibraryManager _ionMobilityLibraryManager; private readonly LibraryManager _libraryManager; - private readonly LibraryBuildNotificationHandler _libraryBuildNotificationHandler; private readonly ChromatogramManager _chromatogramManager; private readonly AutoTrainManager _autoTrainManager; @@ -165,7 +163,6 @@ public SkylineWindow(string[] args = null) _libraryManager = new LibraryManager(); _libraryManager.ProgressUpdateEvent += UpdateProgress; _libraryManager.Register(this); - _libraryBuildNotificationHandler = new LibraryBuildNotificationHandler(this); _backgroundProteomeManager = new BackgroundProteomeManager(); _backgroundProteomeManager.ProgressUpdateEvent += UpdateProgress; @@ -4008,13 +4005,6 @@ private void ShowProgressErrorUI(ProgressUpdateEventArgs e) return; } - // TODO: replace this with more generic logic fed from IProgressMonitor - if (BiblioSpecLiteBuilder.IsLibraryMissingExternalSpectraError(x)) - { - e.Response = BuildPeptideSearchLibraryControl.ShowLibraryMissingExternalSpectraError(this, x); - return; - } - var message = ExceptionUtil.GetMessage(x); // Drill down to see if the innermost exception was an out-of-memory exception. @@ -4147,25 +4137,7 @@ private void buttonShowAllChromatograms_ButtonClick(object sender, EventArgs e) ShowAllChromatogramsGraph(); } - Point INotificationContainer.NotificationAnchor - { - get { return new Point(Left, statusStrip.Visible ? Bottom - statusStrip.Height : Bottom); } - } - - LibraryManager ILibraryBuildNotificationContainer.LibraryManager - { - get { return _libraryManager; } - } - - public Action LibraryBuildCompleteCallback - { - get { return _libraryBuildNotificationHandler.LibraryBuildCompleteCallback; } - } - - public void RemoveLibraryBuildNotification() - { - _libraryBuildNotificationHandler.RemoveLibraryBuildNotification(); - } + public LibraryManager LibraryManager => _libraryManager; public bool StatusContains(string format) { diff --git a/pwiz_tools/Skyline/Skyline.csproj b/pwiz_tools/Skyline/Skyline.csproj index aabe03b385..b224c787e5 100644 --- a/pwiz_tools/Skyline/Skyline.csproj +++ b/pwiz_tools/Skyline/Skyline.csproj @@ -2349,12 +2349,6 @@ EditLibraryDlg.cs - - Form - - - BuildLibraryNotification.cs - Form @@ -4294,12 +4288,6 @@ BuildLibraryDlg.cs - - BuildLibraryNotification.cs - - - BuildLibraryNotification.cs - CalculateIsolationSchemeDlg.cs @@ -6748,10 +6736,6 @@ BuildBackgroundProteomeDlg.cs Designer - - BuildLibraryNotification.cs - Designer - CalibrateIrtDlg.cs diff --git a/pwiz_tools/Skyline/SkylineResources.designer.cs b/pwiz_tools/Skyline/SkylineResources.designer.cs index 5b63bb8a4b..2fc507e439 100644 --- a/pwiz_tools/Skyline/SkylineResources.designer.cs +++ b/pwiz_tools/Skyline/SkylineResources.designer.cs @@ -949,12 +949,21 @@ public static string CommandLine_ImportSearch_Warning__Unable_to_locate_results_ } /// - /// Looks up a localized string similar to iRT standard set to {0}, but multiple iRT standards were found. iRT standard must be set explicitly.. + /// Looks up a localized string similar to Error: Failed to build the spectral library.. /// - public static string CommandLine_ImportSearchInternal_iRT_standard_set_to__0___but_multiple_iRT_standards_were_found__iRT_standard_must_be_set_explicitly_ { + public static string CommandLine_ImportSearchInternal_Error__Failed_to_build_the_spectral_library_ { get { - return ResourceManager.GetString("CommandLine_ImportSearchInternal_iRT_standard_set_to__0___but_multiple_iRT_standa" + - "rds_were_found__iRT_standard_must_be_set_explicitly_", resourceCulture); + return ResourceManager.GetString("CommandLine_ImportSearchInternal_Error__Failed_to_build_the_spectral_library_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Error: iRT standard set to {0}, but multiple iRT standards were found. iRT standard must be set explicitly.. + /// + public static string CommandLine_ImportSearchInternal_Error__iRT_standard_set_to__0___but_multiple_iRT_standards_were_found__iRT_standard_must_be_set_explicitly_ { + get { + return ResourceManager.GetString("CommandLine_ImportSearchInternal_Error__iRT_standard_set_to__0___but_multiple_iRT" + + "_standards_were_found__iRT_standard_must_be_set_explicitly_", resourceCulture); } } diff --git a/pwiz_tools/Skyline/SkylineResources.ja.resx b/pwiz_tools/Skyline/SkylineResources.ja.resx index 219434b779..2e1b053111 100644 --- a/pwiz_tools/Skyline/SkylineResources.ja.resx +++ b/pwiz_tools/Skyline/SkylineResources.ja.resx @@ -391,8 +391,8 @@ 警告: 結果ファイル'{0}'を特定できません - - iRT標準は{0}に設定されていますが、複数のiRT標準が見つかりました。iRT標準は明示的に設定される必要があります。 + + エラー:iRT標準は{0}に設定されていますが、複数のiRT標準が見つかりました。iRT標準は明示的に設定される必要があります。 iRT標準名「{0}」は無効です。 diff --git a/pwiz_tools/Skyline/SkylineResources.resx b/pwiz_tools/Skyline/SkylineResources.resx index 76fe11bcfc..97faadc257 100644 --- a/pwiz_tools/Skyline/SkylineResources.resx +++ b/pwiz_tools/Skyline/SkylineResources.resx @@ -385,8 +385,8 @@ Warning: Unable to locate results file '{0}' - - iRT standard set to {0}, but multiple iRT standards were found. iRT standard must be set explicitly. + + Error: iRT standard set to {0}, but multiple iRT standards were found. iRT standard must be set explicitly. The iRT standard name '{0}' is invalid. @@ -1186,4 +1186,7 @@ Do you want to save the document now? Error updating file '{0}'. + + Error: Failed to build the spectral library. + \ No newline at end of file diff --git a/pwiz_tools/Skyline/SkylineResources.zh-CHS.resx b/pwiz_tools/Skyline/SkylineResources.zh-CHS.resx index 21e0de6e45..5b07243bcc 100644 --- a/pwiz_tools/Skyline/SkylineResources.zh-CHS.resx +++ b/pwiz_tools/Skyline/SkylineResources.zh-CHS.resx @@ -391,7 +391,7 @@ 警告:无法找到结果文件“{0}” - + iRT 标准设置为 {0},但找到多个 iRT 标准。必须明确设置 iRT 标准。 diff --git a/pwiz_tools/Skyline/TestData/CommandLineImportTest.cs b/pwiz_tools/Skyline/TestData/CommandLineImportTest.cs index cd5b65c971..aa3d38fab8 100644 --- a/pwiz_tools/Skyline/TestData/CommandLineImportTest.cs +++ b/pwiz_tools/Skyline/TestData/CommandLineImportTest.cs @@ -147,6 +147,7 @@ public void ConsoleImportPeptideSearchTest() // only check the error message up to and including "In any of the following directories:" string externalSpectrumFileErrorPrefix = Regex.Replace(Resources.VendorIssueHelper_ShowLibraryMissingExternalSpectrumFileError, "\\{2\\}.*", "{2}", RegexOptions.Singleline); + AssertEx.Contains(output, SkylineResources.CommandLine_ImportSearchInternal_Error__Failed_to_build_the_spectral_library_); AssertEx.Contains(output, TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_, Path.GetFileName(searchFilePath))); AssertEx.Contains(output, string.Format(externalSpectrumFileErrorPrefix, searchFilePath, "wine yeast sampleA_2", "", BiblioSpecLiteBuilder.BiblioSpecSupportedFileExtensions)); diff --git a/pwiz_tools/Skyline/TestFunctional/BlibIrtTest.cs b/pwiz_tools/Skyline/TestFunctional/BlibIrtTest.cs index 3d296144a2..74a796d8cc 100644 --- a/pwiz_tools/Skyline/TestFunctional/BlibIrtTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/BlibIrtTest.cs @@ -17,11 +17,13 @@ * limitations under the License. */ using System.Linq; +using System.Windows.Forms; using Microsoft.VisualStudio.TestTools.UnitTesting; using pwiz.Skyline.Alerts; using pwiz.Skyline.Controls.Graphs; using pwiz.Skyline.FileUI.PeptideSearch; using pwiz.Skyline.Model.Irt; +using pwiz.Skyline.Properties; using pwiz.Skyline.SettingsUI; using pwiz.Skyline.SettingsUI.Irt; using pwiz.SkylineTestUtil; @@ -46,26 +48,12 @@ protected override void DoTest() var peptideSettings = ShowDialog(SkylineWindow.ShowPeptideSettingsUI); - // Library build - var buildLibrary = ShowDialog(peptideSettings.ShowBuildLibraryDlg); + RunUI(() => peptideSettings.SelectedTab = PeptideSettingsUI.TABS.Library); - RunUI(() => - { - buildLibrary.LibraryName = "iRT standard peptides test"; - buildLibrary.LibraryPath = outBlib; - buildLibrary.IrtStandard = IrtStandard.BIOGNOSYS_11; - //buildLibrary.PreferEmbeddedSpectra = true; - buildLibrary.OkWizardPage(); - - buildLibrary.InputFileNames = new[] {searchResults}; - }); - WaitForConditionUI(() => buildLibrary.Grid.ScoreTypesLoaded); - RunUI(() => buildLibrary.Grid.SetScoreThreshold(0.05)); - - OkDialog(buildLibrary, buildLibrary.OkWizardPage); - var preferEmbeddedDlg = WaitForOpenForm(); - OkDialog(preferEmbeddedDlg, preferEmbeddedDlg.BtnYesClick); - VerifyAddIrts(WaitForOpenForm()); + TestLibraryBuild(peptideSettings, outBlib, searchResults, DialogResult.Cancel); + TestLibraryBuild(peptideSettings, outBlib, searchResults, DialogResult.No); + // CONSIDER: Ideally, we would also test "Retry" by putting files in place to have it succeed + TestLibraryBuild(peptideSettings, outBlib, searchResults, DialogResult.Yes); // iRT calculator var editIrtCalc = ShowDialog(peptideSettings.AddCalculator); @@ -84,6 +72,35 @@ protected override void DoTest() // Import peptide search RunUI(() => SkylineWindow.SaveDocument(testFilesDir.GetTestPath("test.sky"))); + TestImportPeptideSearch(searchResults, DialogResult.Cancel); + TestImportPeptideSearch(searchResults, DialogResult.No); + // CONSIDER: Ideally, we would also test "Retry" by putting files in place to have it succeed + TestImportPeptideSearch(searchResults, DialogResult.Yes); + } + + private static void TestLibraryBuild(PeptideSettingsUI peptideSettings, string outBlib, string searchResults, DialogResult dialogResult) + { + // Library build + var buildLibrary = ShowDialog(peptideSettings.ShowBuildLibraryDlg); + + RunUI(() => + { + buildLibrary.LibraryName = "iRT standard peptides test"; + buildLibrary.LibraryPath = outBlib; + buildLibrary.IrtStandard = IrtStandard.BIOGNOSYS_11; + buildLibrary.OkWizardPage(); + + buildLibrary.InputFileNames = new[] {searchResults}; + }); + WaitForConditionUI(() => buildLibrary.Grid.ScoreTypesLoaded); + RunUI(() => buildLibrary.Grid.SetScoreThreshold(0.05)); + + OkDialog(buildLibrary, buildLibrary.OkWizardPage); + ChooseEmbedding(WaitForOpenForm(), dialogResult); + } + + private void TestImportPeptideSearch(string searchResults, DialogResult dialogResult) + { var import = ShowDialog(SkylineWindow.ShowImportPeptideSearchDlg); RunUI(() => { import.BuildPepSearchLibControl.AddSearchFiles(new[] { searchResults }); }); WaitForConditionUI(() => import.BuildPepSearchLibControl.Grid.ScoreTypesLoaded); @@ -91,11 +108,41 @@ protected override void DoTest() { import.BuildPepSearchLibControl.Grid.SetScoreThreshold(0.05); import.BuildPepSearchLibControl.IrtStandards = IrtStandard.BIOGNOSYS_11; - //import.BuildPepSearchLibControl.PreferEmbeddedSpectra = true; }); WaitForConditionUI(() => import.IsNextButtonEnabled); - VerifyAddIrts(ShowDialog(() => import.ClickNextButton())); - OkDialog(import, import.CancelDialog); + ChooseEmbedding(ShowDialog(() => import.ClickNextButton()), dialogResult); + if (dialogResult == DialogResult.Yes) + OkDialog(import, import.CancelDialog); + else + WaitForClosedForm(import); + } + + private static void ChooseEmbedding(MultiButtonMsgDlg preferEmbeddedDlg, DialogResult dialogResult) + { + RunUI(() => + { + AssertEx.AreComparableStrings(Resources.VendorIssueHelper_ShowLibraryMissingExternalSpectrumFilesError, + preferEmbeddedDlg.Message); + }); + + if (dialogResult == DialogResult.Cancel) + OkDialog(preferEmbeddedDlg, preferEmbeddedDlg.BtnCancelClick); + else + { + if (dialogResult == DialogResult.No) + { + // Click Retry once, and then Cancel + OkDialog(preferEmbeddedDlg, preferEmbeddedDlg.Btn1Click); // Retry + var preferEmbeddedRetry = WaitForOpenForm(); + Assert.AreNotSame(preferEmbeddedDlg, preferEmbeddedRetry); + OkDialog(preferEmbeddedRetry, preferEmbeddedRetry.BtnCancelClick); + } + else + { + OkDialog(preferEmbeddedDlg, preferEmbeddedDlg.BtnYesClick); + VerifyAddIrts(WaitForOpenForm()); + } + } } private static void VerifyAddIrts(AddIrtPeptidesDlg dlg) diff --git a/pwiz_tools/Skyline/TestFunctional/CleavableCrosslinkTest.cs b/pwiz_tools/Skyline/TestFunctional/CleavableCrosslinkTest.cs index e5a3ffc148..e6cd30ad54 100644 --- a/pwiz_tools/Skyline/TestFunctional/CleavableCrosslinkTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/CleavableCrosslinkTest.cs @@ -49,9 +49,10 @@ protected override void DoTest() }); // Library build var buildLibrary = ShowDialog(peptideSettingsUi.ShowBuildLibraryDlg); + const string libraryName = "MyLibrary"; RunUI(() => { - buildLibrary.LibraryName = "MyLibrary"; + buildLibrary.LibraryName = libraryName; buildLibrary.LibraryPath = TestFilesDir.GetTestPath("MyLibrary.blib"); buildLibrary.OkWizardPage(); @@ -59,6 +60,7 @@ protected override void DoTest() }); WaitForConditionUI(() => buildLibrary.Grid.ScoreTypesLoaded); OkDialog(buildLibrary, buildLibrary.OkWizardPage); + WaitForConditionUI(() => peptideSettingsUi.PickedLibraries.Contains(libraryName)); OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog); WaitForDocumentLoaded(); diff --git a/pwiz_tools/Skyline/TestFunctional/LibraryBuildTest.cs b/pwiz_tools/Skyline/TestFunctional/LibraryBuildTest.cs index 4ea520ee80..552205dc58 100644 --- a/pwiz_tools/Skyline/TestFunctional/LibraryBuildTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/LibraryBuildTest.cs @@ -424,7 +424,7 @@ private void MainTest() // no recalibrate, add iRTs, add predictor _libraryName = libraryBaseName + "_irt2"; // library_test_irt2 BuildLibraryIrt(true, false, true); - RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(_libraryName))); + RunUI(() => Assert.IsTrue(PeptideSettingsUI.SelectedRTPredictor.Equals(_libraryName))); var editIrtDlg2 = ShowDialog(PeptideSettingsUI.EditCalculator); RunUI(() => Assert.IsTrue(ReferenceEquals(editIrtDlg2.IrtStandards, IrtStandard.BIOGNOSYS_10))); OkDialog(editIrtDlg2, editIrtDlg2.CancelDialog); @@ -432,12 +432,12 @@ private void MainTest() // recalibrate, add iRTs, no add predictor _libraryName = libraryBaseName + "_irt3"; // library_test_irt3 BuildLibraryIrt(true, true, false); - RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(libraryBaseName + "_irt2"))); + RunUI(() => Assert.IsTrue(PeptideSettingsUI.SelectedRTPredictor.Equals(libraryBaseName + "_irt2"))); // recalibrate, add iRTs, add predictor _libraryName = libraryBaseName + "_irt4"; // library_test_irt4 BuildLibraryIrt(true, true, true); - RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(_libraryName))); + RunUI(() => Assert.IsTrue(PeptideSettingsUI.SelectedRTPredictor.Equals(_libraryName))); var editIrtDlg4 = ShowDialog(PeptideSettingsUI.EditCalculator); RunUI(() => Assert.IsTrue(editIrtDlg4.IrtStandards.IsEmpty)); OkDialog(editIrtDlg4, editIrtDlg4.CancelDialog); @@ -675,7 +675,7 @@ private void EnsurePeptideSettings() ShowDialog(SkylineWindow.ShowPeptideSettingsUI); // Control console output on failure for diagnosing nightly test failures - PeptideSettingsUI.ReportLibraryBuildFailure = ReportLibraryBuildFailures; + // PeptideSettingsUI.ReportLibraryBuildFailure = ReportLibraryBuildFailures; // Allow a person watching to see what is going on in the Library tab RunUI(() => diff --git a/pwiz_tools/Skyline/TestFunctional/ProxlTest.cs b/pwiz_tools/Skyline/TestFunctional/ProxlTest.cs index 692eabc95d..486286c0fa 100644 --- a/pwiz_tools/Skyline/TestFunctional/ProxlTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/ProxlTest.cs @@ -64,15 +64,17 @@ protected override void DoTest() peptideSettingsUi.SelectedTab = PeptideSettingsUI.TABS.Library; }); var buildLibraryDlg = ShowDialog(peptideSettingsUi.ShowBuildLibraryDlg); + const string libraryName = "ProxlLibrary"; RunUI(() => { - buildLibraryDlg.LibraryName = "ProxlLibrary"; + buildLibraryDlg.LibraryName = libraryName; buildLibraryDlg.LibraryPath = TestFilesDir.GetTestPath("MyProxlLibrary.blib"); buildLibraryDlg.OkWizardPage(); buildLibraryDlg.AddInputFiles(new []{TestFilesDir.GetTestPath("ProxlTest.proxl.xml") }); }); WaitForConditionUI(() => buildLibraryDlg.Grid.ScoreTypesLoaded); OkDialog(buildLibraryDlg, buildLibraryDlg.OkWizardPage); + WaitForConditionUI(() => peptideSettingsUi.PickedLibraries.Contains(libraryName)); OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog); var transitionSettingsUi = ShowDialog(SkylineWindow.ShowTransitionSettingsUI); diff --git a/pwiz_tools/Skyline/TestPerf/OrbiPrmTutorialTest.cs b/pwiz_tools/Skyline/TestPerf/OrbiPrmTutorialTest.cs index 7e99cc5068..746aaf02eb 100644 --- a/pwiz_tools/Skyline/TestPerf/OrbiPrmTutorialTest.cs +++ b/pwiz_tools/Skyline/TestPerf/OrbiPrmTutorialTest.cs @@ -266,6 +266,7 @@ private void PrepareTargets() buildLibraryDlg.Grid.SetScoreThreshold(0.1); buildLibraryDlg.OkWizardPage(); }); + WaitForConditionUI(() => peptideSettingsUI.PickedLibraries.Contains(HEAVY_LIBRARY)); var editListUI = ShowDialog, LibrarySpec>>(peptideSettingsUI.EditLibraryList); diff --git a/pwiz_tools/Skyline/TestRunnerLib/TestRunnerFormLookup.csv b/pwiz_tools/Skyline/TestRunnerLib/TestRunnerFormLookup.csv index d08d06224b..36c55e1f0a 100644 --- a/pwiz_tools/Skyline/TestRunnerLib/TestRunnerFormLookup.csv +++ b/pwiz_tools/Skyline/TestRunnerLib/TestRunnerFormLookup.csv @@ -29,7 +29,6 @@ BuildBackgroundProteomeDlg,TestBackgroundProteome BuildLibraryDlg.PropertiesPage,TestFullScanId BuildLibraryDlg.FilesPage,TestFullScanId BuildLibraryDlg.LearningPage,* -BuildLibraryNotification,* CalculateIsolationSchemeDlg,TestCalculateIsolationWindows CalibrateIrtDlg,IrtFunctionalTest CalibrationForm,TestCalibration diff --git a/pwiz_tools/Skyline/TestTutorial/MethodEditTutorialTest.cs b/pwiz_tools/Skyline/TestTutorial/MethodEditTutorialTest.cs index 160b87f173..d5b0069ca6 100644 --- a/pwiz_tools/Skyline/TestTutorial/MethodEditTutorialTest.cs +++ b/pwiz_tools/Skyline/TestTutorial/MethodEditTutorialTest.cs @@ -94,15 +94,6 @@ protected override void DoTest() peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Library; peptideSettingsUI1.PickedLibraries = new[] { YEAST_ATLAS }; }); - WaitForOpenForm(); // To show Library tab for Forms testing - // Make sure the build complete notification is removed first since it has problems when the preview form is around - if (IsPauseForScreenShots) - { - WaitForConditionUI(() => FindOpenForm() != null); - Thread.Sleep(200); // Can hang if the remove happens too quickly - RunUI(SkylineWindow.RemoveLibraryBuildNotification); - WaitForConditionUI(() => FindOpenForm() == null); - } PauseForScreenShot("Peptide Settings - Library tab"); // Not L10N RunUI(() => peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Digest); diff --git a/pwiz_tools/Skyline/TestTutorial/SRMTutorialTest.cs b/pwiz_tools/Skyline/TestTutorial/SRMTutorialTest.cs index 817433f2f9..ebed529af7 100644 --- a/pwiz_tools/Skyline/TestTutorial/SRMTutorialTest.cs +++ b/pwiz_tools/Skyline/TestTutorial/SRMTutorialTest.cs @@ -267,10 +267,11 @@ protected override void DoTest() var pepSettings2 = ShowDialog(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => pepSettings2.SelectedTab = PeptideSettingsUI.TABS.Library); var buildLibraryDlg = ShowDialog(pepSettings2.ShowBuildLibraryDlg); + const string libraryName = "Mtb_hDP_20140210"; RunUI(() => { buildLibraryDlg.LibraryPath = GetTestPath("Skyline"); - buildLibraryDlg.LibraryName = "Mtb_hDP_20140210"; + buildLibraryDlg.LibraryName = libraryName; }); PauseForScreenShot("Build Library Window"); RunUI(() => @@ -282,6 +283,7 @@ protected override void DoTest() RunUI(() => buildLibraryDlg.Grid.SetScoreThreshold(0.9)); PauseForScreenShot("Build Library Window Next"); OkDialog(buildLibraryDlg, buildLibraryDlg.OkWizardPage); + WaitForConditionUI(() => pepSettings2.PickedLibraries.Contains(libraryName)); RunUI(() => { pepSettings2.SetLibraryChecked(0, true); diff --git a/pwiz_tools/Skyline/TestUtil/TestFunctional.cs b/pwiz_tools/Skyline/TestUtil/TestFunctional.cs index 3614a4cdca..e69ebbe600 100644 --- a/pwiz_tools/Skyline/TestUtil/TestFunctional.cs +++ b/pwiz_tools/Skyline/TestUtil/TestFunctional.cs @@ -2534,9 +2534,6 @@ private void EndTest() if (Program.TestExceptions.Count == 0) { - // Long wait for library build notifications - SkylineWindow.RemoveLibraryBuildNotification(); // Remove off UI thread to avoid deadlocking - WaitForConditionUI(() => !OpenForms.Any(f => f is BuildLibraryNotification)); // Short wait for anything else WaitForConditionUI(5000, () => OpenForms.Count() == 1); }