public void OpenDatabase(string path) { if (!File.Exists(path)) { MessageDlg.Show(this, String.Format(Resources.EditOptimizationLibraryDlg_OpenDatabase_The_file__0__does_not_exist__Click_the_Create_button_to_create_a_new_library_or_the_Open_button_to_find_the_missing_file_, path)); return; } try { OptimizationDb db = OptimizationDb.GetOptimizationDb(path, null, _document); var dbOptimizations = db.GetOptimizations().ToArray(); SetOptimizations(dbOptimizations); // Clone all of the optimizations to use for comparison in OkDialog _original = dbOptimizations.Select(p => new DbOptimization(p)).ToArray(); textDatabase.Text = path; } catch (OptimizationsOpeningException e) { MessageDlg.ShowException(this, e); } }
public void GetDriftTimesFromResults() { try { var driftTable = new MeasuredDriftTimeTable(gridMeasuredDriftTimes, MeasuredDriftTimeSequence.TargetResolver); bool useHighEnergyOffset = cbOffsetHighEnergySpectra.Checked; var tempDriftTimePredictor = new IonMobilityPredictor(@"tmp", driftTable.GetTableMeasuredIonMobility(useHighEnergyOffset, Units), null, null, IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.resolving_power, 30, 0, 0); using (var longWaitDlg = new LongWaitDlg { Text = Resources.EditDriftTimePredictorDlg_GetDriftTimesFromResults_Finding_ion_mobility_values_for_peaks, Message = string.Empty, ProgressValue = 0 }) { longWaitDlg.PerformWork(this, 100, broker => { tempDriftTimePredictor = tempDriftTimePredictor.ChangeMeasuredIonMobilityValuesFromResults(Program.MainWindow.Document, Program.MainWindow.DocumentFilePath, useHighEnergyOffset, broker); }); if (!longWaitDlg.IsCanceled && tempDriftTimePredictor != null) { // Set display units based on what we found in the data UpdateMeasuredDriftTimesControl(tempDriftTimePredictor); } } } catch (Exception ex) { MessageDlg.ShowException(this, ex); } }
public void CreateDb(string fileName) { // If the file exists, then the user chose to overwrite, // so delete the existing file. try { FileEx.SafeDelete(fileName); } catch (IOException x) { MessageDlg.ShowException(this, x); return; } Settings.Default.ProteomeDbDirectory = Path.GetDirectoryName(fileName); try { ProteomeDb.CreateProteomeDb(fileName); } catch (Exception x) { var message = TextUtil.LineSeparate(string.Format( Resources .BuildBackgroundProteomeDlg_btnCreate_Click_An_error_occurred_attempting_to_create_the_proteome_file__0__, fileName), x.Message); MessageDlg.ShowWithException(this, message, x); } if (textName.Text.Length == 0) { textName.Text = Path.GetFileNameWithoutExtension(fileName); } textPath.Text = fileName; // This will cause RefreshStatus() }
private void CalculatorChanged() { var calc = _driverCalculators.SelectedItem; btnShowGraph.Enabled = (calc != null); cbAutoCalc.Enabled = (calc is RCalcIrt); if (!cbAutoCalc.Enabled) { cbAutoCalc.Checked = false; } if (calc != null) { try { var regressionPeps = UpdateCalculator(calc); if (regressionPeps != null) { SetTablePeptides(regressionPeps); } } catch (CalculatorException e) { MessageDlg.ShowException(this, e); } } }
public void DownloadSelectedTool() { try { string identifier = _tools[listBoxTools.SelectedIndex].Identifier; using (var dlg = new LongWaitDlg { ProgressValue = 0, Message = string.Format(Resources.ToolStoreDlg_DownloadSelectedTool_Downloading__0_, _tools[listBoxTools.SelectedIndex].Name) }) { dlg.PerformWork(this, 500, progressMonitor => DownloadPath = _toolStoreClient.GetToolZipFile(progressMonitor, identifier, Path.GetTempPath())); if (!dlg.IsCanceled) { DialogResult = DialogResult.OK; } } } catch (TargetInvocationException ex) { if (ex.InnerException is ToolExecutionException || ex.InnerException is WebException) { MessageDlg.ShowException(this, ex); } else { throw; } } }
public bool TestSettings() { if (!ValidateValues()) { return(false); } ChorusAccount chorusAccount = GetChorusAccount(); ChorusSession chorusSession = new ChorusSession(); try { CookieContainer cookieContainer = new CookieContainer(); try { chorusSession.Login(chorusAccount, cookieContainer); MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct); return(true); } catch (ChorusServerException chorusException) { MessageDlg.ShowException(this, chorusException); textPassword.Focus(); return(false); } } catch (Exception x) { MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x); textServerURL.Focus(); return(false); } }
public void OpenDatabase(string path) { if (!File.Exists(path)) { MessageDlg.Show(this, String.Format(Resources.EditIonMobilityLibraryDlg_OpenDatabase_The_file__0__does_not_exist__Click_the_Create_button_to_create_a_new_ion_mobility_library_or_click_the_Open_button_to_find_the_missing_file_, path)); return; } try { IonMobilityDb db = IonMobilityDb.GetIonMobilityDb(path, null); // TODO: (copied from iRT code) LongWaitDlg var dbPeptides = db.GetPeptides().ToArray(); LoadLibrary(dbPeptides); // Clone all of the peptides to use for comparison in OkDialog _originalPeptides = dbPeptides.Select(p => new ValidatingIonMobilityPeptide(p.Sequence, p.CollisionalCrossSection, p.HighEnergyDriftTimeOffsetMsec)).ToArray(); textDatabase.Text = path; } catch (DatabaseOpeningException e) { MessageDlg.ShowException(this, e); } }
public void GetDriftTimesFromResults() { try { var driftTable = new MeasuredDriftTimeTable(gridMeasuredDriftTimes); var tempDriftTimePredictor = new DriftTimePredictor("tmp", driftTable.GetTableMeasuredDriftTimes(cbOffsetHighEnergySpectra.Checked), null, null, 30); // Not L10N using (var longWaitDlg = new LongWaitDlg { Text = Resources.EditDriftTimePredictorDlg_btnGenerateFromDocument_Click_Finding_drift_time_values_for_peaks, Message = string.Empty, ProgressValue = 0 }) { longWaitDlg.PerformWork(this, 100, broker => { tempDriftTimePredictor = tempDriftTimePredictor.ChangeMeasuredDriftTimesFromResults(Program.MainWindow.Document, Program.MainWindow.DocumentFilePath, broker); }); if (!longWaitDlg.IsCanceled && tempDriftTimePredictor != null) { UpdateMeasuredDriftTimesControl(tempDriftTimePredictor); } } } catch (Exception ex) { MessageDlg.ShowException(this, ex); } }
/// <summary> /// Execute the line of the text box. /// Run any tools who's title is on the line. /// Also attempting to run the line like a SkylineRunner input. /// </summary> /// <param name="line">number line to run. Textbox.Lines is an string[] so zero indexed.</param> public void RunLine(int line) { // Case when the textBox is completely empty, line returns 1 but Lines is an array length 0. if (line < LineCount) { string lineText = textImWindow.Lines[line]; // This is to take care of the annoying case when the user trys to add a tool with a title they already used and the tool runs.@ if (!lineText.Contains("--tool-add")) // Not L10N { //Check if there is a tool to run on the line foreach (var tool in Settings.Default.ToolList.Where(tool => lineText.Contains(tool.Title))) { //CONSIDER: multiple tools running. eg. two tools titled "Tool" and "ToolTest" if you enter ToolTest then both tools will run. try { tool.RunTool(_parent.Document, _parent, _textBoxStreamWriter.WriterHelper, _parent, _parent); } catch (WebToolException e) { WebHelpers.ShowLinkFailure(_parent, e.Link); } catch (Exception e) { MessageDlg.ShowException(_parent, e); } } } // Try to parse like SkylineRunner parameters string[] args = CommandLine.ParseArgs(lineText); CommandLine commandLine = new CommandLine(new CommandStatusWriter(_textBoxStreamWriter)); commandLine.Run(args); } }
public void CreateDatabase(string path) { //The file that was just created does not have a schema, so SQLite won't touch it. //The file must have a schema or not exist for use with SQLite, so we'll delete //it and install a schema try { FileEx.SafeDelete(path); } catch (IOException x) { MessageDlg.ShowException(this, x); return; } //Create file, initialize db try { IonMobilityDb.CreateIonMobilityDb(path); textDatabase.Text = path; } catch (DatabaseOpeningException x) { MessageDlg.ShowException(this, x); } catch (Exception x) { var message = TextUtil.LineSeparate(string.Format(Resources.EditIonMobilityLibraryDlg_CreateDatabase_The_ion_mobility_library_file__0__could_not_be_created, path), x.Message); MessageDlg.ShowWithException(this, message, x); } }
private bool GetPackages() { try { using (var dlg = new LongWaitDlg(null, false) { Message = Resources.RInstaller_GetPAckages_Installing_Packages }) { dlg.PerformWork(this, 1000, InstallPackages); } } catch (TargetInvocationException ex) { //Win32Exception is thrown when the user does not ok Administrative Privileges if (ex.InnerException is ToolExecutionException || ex.InnerException is System.ComponentModel.Win32Exception) { MessageDlg.ShowException(this, ex); return(false); } else { throw; } } return(true); }
private bool TestChorusAccount(ChorusAccount chorusAccount) { using (ChorusSession chorusSession = new ChorusSession(chorusAccount)) { try { CookieContainer cookieContainer = new CookieContainer(); try { chorusSession.Login(chorusAccount, cookieContainer); MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct); return(true); } catch (RemoteServerException chorusException) { MessageDlg.ShowException(this, chorusException); textPassword.Focus(); return(false); } } catch (Exception x) { MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x); textServerURL.Focus(); return(false); } } }
private bool GetR() { try { using (var dlg = new LongWaitDlg { Message = Resources.RInstaller_InstallR_Downloading_R, ProgressValue = 0 }) { // Short wait, because this can't possible happen fast enough to avoid // showing progress, except in testing dlg.PerformWork(this, 50, DownloadR); } using (var dlg = new LongWaitDlg(null, false) { Message = Resources.RInstaller_GetR_Installing_R }) { dlg.PerformWork(this, 50, InstallR); } MessageDlg.Show(this, Resources.RInstaller_GetR_R_installation_complete_); } catch (TargetInvocationException ex) { if (ex.InnerException is ToolExecutionException) { MessageDlg.ShowException(this, ex); return(false); } throw; } return(true); }
private bool GetPip() { try { using (var dlg = new LongWaitDlg { ProgressValue = 0 }) { // Short wait, because this can't possible happen fast enough to avoid // showing progress, except in testing dlg.PerformWork(this, 50, DownloadPip); } using (var dlg = new LongWaitDlg(null, false) { Message = Resources.PythonInstaller_GetPip_Installing_Pip }) { dlg.PerformWork(this, 50, InstallPip); } } catch (TargetInvocationException ex) { if (ex.InnerException is ToolExecutionException) { MessageDlg.ShowException(this, ex); return(false); } throw; } return(true); }
private bool LoadPeptideSearchLibrary(LibrarySpec docLibSpec) { if (docLibSpec == null) { return(false); } using (var longWait = new LongWaitDlg { Text = Resources.BuildPeptideSearchLibraryControl_LoadPeptideSearchLibrary_Loading_Library }) { try { var status = longWait.PerformWork(WizardForm, 800, monitor => ImportPeptideSearch.LoadPeptideSearchLibrary(LibraryManager, docLibSpec, monitor)); if (status.IsError) { MessageDlg.ShowException(WizardForm, status.ErrorException); } } catch (Exception x) { MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_LoadPeptideSearchLibrary_An_error_occurred_attempting_to_import_the__0__library_, docLibSpec.Name), x.Message), x); } } return(ImportPeptideSearch.HasDocLib); }
public bool ExportAnnotations(string filename) { var settings = GetExportAnnotationSettings(); bool success = false; try { var documentAnnotations = new DocumentAnnotations(Document); using (var longWaitDlg = new LongWaitDlg()) { longWaitDlg.PerformWork(this, 1000, broker => { using (var fileSaver = new FileSaver(filename)) { documentAnnotations.WriteAnnotationsToFile(broker.CancellationToken, settings, fileSaver.SafeName); fileSaver.Commit(); } success = true; }); } } catch (Exception e) { MessageDlg.ShowException(this, e); return(false); } return(success); }
private List <IsolationWindow> GetIsolationWindows() { //Overlap requires an even number of windows if (Overlap && _gridViewDriver.Items.Count % 2 == 1) { MessageDlg.Show(this, Resources.EditIsolationSchemeDlg_GetIsolationWindows_Overlap_requires_an_even_number_of_windows_); return(null); } // Validate prespecified windows. var windowList = new List <IsolationWindow>(); for (int row = 0; row < _gridViewDriver.Items.Count; row++) { var editWindow = _gridViewDriver.Items[row]; // Report any problems in this row. int errorCell = FindErrorCell(editWindow); if (errorCell >= COLUMN_START) { _gridViewDriver.SelectCell(errorCell, row); MessageDlg.Show(this, string.Format(Resources.EditIsolationSchemeDlg_OkDialog_Specify__0__for_isolation_window, _gridViewDriver.GetHeaderText(errorCell))); _gridViewDriver.EditCell(); return(null); } IsolationWindow isolationWindow; try { double startValue = editWindow.Start.Value; double endValue = editWindow.End.Value; if (Equals(comboIsolation.SelectedItem, WindowType.MEASUREMENT)) { startValue += editWindow.StartMargin ?? 0; endValue -= editWindow.StartMargin ?? 0; } isolationWindow = new IsolationWindow( // ReSharper disable PossibleInvalidOperationException startValue, endValue, // ReSharper restore PossibleInvalidOperationException null, cbSpecifyMargin.Checked ? editWindow.StartMargin : null, cbSpecifyMargin.Checked ? editWindow.StartMargin : null, cbSpecifyCERange.Checked ? editWindow.CERange : null); } catch (InvalidDataException exception) { _gridViewDriver.SelectRow(row); MessageDlg.ShowException(this, exception); return(null); } windowList.Add(isolationWindow); } return(windowList); }
private void btnCreate_Click(object sender, EventArgs e) { string filterProtDb = TextUtil.FileDialogFiltersAll(FILTER_PROTDB); string fileName; using (var saveFileDialog = new SaveFileDialog { Filter = filterProtDb, InitialDirectory = Settings.Default.ProteomeDbDirectory, Title = Resources.BuildBackgroundProteomeDlg_btnCreate_Click_Create_Background_Proteome, OverwritePrompt = true, }) { if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel) { return; } fileName = saveFileDialog.FileName; } // If the file exists, then the user chose to overwrite, // so delete the existing file. try { FileEx.SafeDelete(fileName); } catch (IOException x) { MessageDlg.ShowException(this, x); return; } Settings.Default.ProteomeDbDirectory = Path.GetDirectoryName(fileName); textPath.Text = fileName; if (textName.Text.Length == 0) { textName.Text = Path.GetFileNameWithoutExtension(fileName); } try { ProteomeDb.CreateProteomeDb(fileName); } catch (Exception x) { var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_btnCreate_Click_An_error_occurred_attempting_to_create_the_proteome_file__0__, fileName), x.Message); MessageDlg.ShowWithException(this, message, x); } RefreshStatus(); }
public bool CreateIrtDatabase(string path) { try { ImportAssayLibraryHelper.CreateIrtDatabase(path); } catch (Exception x) { MessageDlg.ShowException(this, x); return(false); } return(true); }
private void UpdateIonMobilityFilterWindowWidthControls() { if (comboBoxWindowType.SelectedIndex < 0) { // Initializing comboBoxWindowType.SelectedIndex = (int)IonMobilityWindowWidthCalculator.IonMobilityWindowWidthType.none; } // Linear peak width vs Resolving Power vs fixed width labelResolvingPower.Visible = textIonMobilityFilterResolvingPower.Visible = comboBoxWindowType.SelectedIndex == (int)IonMobilityWindowWidthCalculator.IonMobilityWindowWidthType.resolving_power; labelWidthAtMobilityZero.Visible = labelWidthAtMobilityMax.Visible = textIonMobilityFilterWidthAtMobility0.Visible = textIonMobilityFilterWidthAtMobilityMax.Visible = comboBoxWindowType.SelectedIndex == (int)IonMobilityWindowWidthCalculator.IonMobilityWindowWidthType.linear_range; labelFixedWidth.Visible = textIonMobilityFilterFixedWidth.Visible = comboBoxWindowType.SelectedIndex == (int)IonMobilityWindowWidthCalculator.IonMobilityWindowWidthType.fixed_width; // The various window width value text boxes all need to be in the same location if (labelWidthAtMobilityZero.Location.X > labelResolvingPower.Location.X) { labelWidthAtMobilityZero.Location = labelResolvingPower.Location; textIonMobilityFilterWidthAtMobility0.Location = textIonMobilityFilterResolvingPower.Location; labelWidthAtMobilityMax.Location = new Point(labelResolvingPower.Location.X, labelWidthAtMobilityMax.Location.Y); textIonMobilityFilterWidthAtMobilityMax.Location = new Point(textIonMobilityFilterResolvingPower.Location.X, textIonMobilityFilterWidthAtMobilityMax.Location.Y); labelFixedWidth.Location = labelResolvingPower.Location; textIonMobilityFilterFixedWidth.Location = textIonMobilityFilterResolvingPower.Location; } // N.B. we formerly had code here to disable the window width controls if there was no library and // "Use spectral library values" was unchecked, but this ignored the possibility of document using // explicit IM filter values as read from a transition list import. So just leave it enabled, always. try { var helper = new MessageBoxHelper(this.ParentForm, false); var result = ValidateIonMobilitySettings(helper); if (result != null) { _ionMobilityFiltering = _ionMobilityFiltering == null ? result : _ionMobilityFiltering.ChangeFilterWindowWidthCalculator(result.FilterWindowWidthCalculator); } } catch (Exception e) { MessageDlg.ShowException(this, e); } }
private void IonMobilityLibraryChanged() { var lib = _driverIonMobilityLib.SelectedItem; if (lib != null) { try { _ionMobilityFiltering = _ionMobilityFiltering.ChangeLibrary(lib); } catch (Exception e) { MessageDlg.ShowException(this, e); } } UpdateIonMobilityFilterWindowWidthControls(); }
private void CalculatorChanged() { var calc = _driverCalculators.SelectedItem; btnShowGraph.Enabled = (calc != null); cbAutoCalc.Enabled = (calc is RCalcIrt); if (!cbAutoCalc.Enabled) { cbAutoCalc.Checked = false; } if (calc != null) { // Automatically set up if all fields are empty if (calc is RCalcIrt) { if (string.IsNullOrEmpty(textName.Text)) { textName.Text = Helpers.GetUniqueName(calc.Name, name => !_existing.Contains(r => Equals(r.Name, name))); } if (string.IsNullOrEmpty(textSlope.Text) && string.IsNullOrEmpty(textIntercept.Text)) { cbAutoCalc.Checked = true; } if (string.IsNullOrEmpty(textTimeWindow.Text)) { textTimeWindow.Text = ImportPeptideSearch.DEFAULT_RT_WINDOW.ToString(LocalizationHelper.CurrentCulture); } } try { var regressionPeps = UpdateCalculator(calc); if (regressionPeps != null) { SetTablePeptides(regressionPeps); } } catch (CalculatorException e) { MessageDlg.ShowException(this, e); } } }
private void IonMobilityLibraryChanged() { var calc = _driverIonMobilityLibraryListComboDriver.SelectedItem; if (calc != null) { try { if (_predictor != null) { _predictor = _predictor.ChangeLibrary(calc); } } catch (Exception e) { MessageDlg.ShowException(this, e); } } UpdateControls(); }
private void PublishDocumentDlg_Load(object sender, EventArgs e) { var listServerFolders = new List <KeyValuePair <Server, JToken> >(); try { using (var waitDlg = new LongWaitDlg { Text = Resources.PublishDocumentDlg_PublishDocumentDlg_Load_Retrieving_information_on_servers }) { waitDlg.PerformWork(this, 800, () => PublishDocumentDlgLoad(listServerFolders)); } } catch (Exception x) { MessageDlg.ShowException(this, x); } foreach (var serverFolder in listServerFolders) { var server = serverFolder.Key; var treeNode = new TreeNode(server.URI.ToString()) { Tag = new FolderInformation(server, false) }; treeViewFolders.Nodes.Add(treeNode); if (serverFolder.Value != null) { AddSubFolders(server, treeNode, serverFolder.Value); } } ServerTreeStateRestorer.RestoreExpansionAndSelection(Settings.Default.PanoramaServerExpansion); ServerTreeStateRestorer.UpdateTopNode(); IsLoaded = true; }
private void AddOptimizationLibrary(OptimizationLibrary optLibrary, SrmDocument document) { IEnumerable <DbOptimization> optimizations = null; using (var longWait = new LongWaitDlg { Text = Resources.LibraryGridViewDriver_AddOptimizationLibrary_Adding_optimization_library, Message = string.Format(Resources.LibraryGridViewDriver_AddOptimizationLibrary_Adding_optimization_values_from__0_, optLibrary.DatabasePath), FormBorderStyle = FormBorderStyle.Sizable }) { try { var status = longWait.PerformWork(MessageParent, 800, monitor => { var optDb = OptimizationDb.GetOptimizationDb(optLibrary.DatabasePath, monitor, document); if (optDb != null) { optimizations = optDb.GetOptimizations().Where(opt => Equals(opt.Type, (int)ViewDbType)); } }); if (status.IsError) { MessageDlg.ShowException(MessageParent, status.ErrorException); } } catch (Exception x) { var message = TextUtil.LineSeparate(string.Format(Resources.LibraryGridViewDriver_AddOptimizationLibrary_An_error_occurred_attempting_to_load_the_optimization_library_file__0__, optLibrary.DatabasePath), x.Message); MessageDlg.ShowWithException(MessageParent, message, x); } } AddToLibrary(optimizations); }
/// <summary> /// Copy a zip file's contents to the tools folder and loop through its .properties /// files adding the tools to the tools menu. /// </summary> /// <param name="parent">Parent window for alerts and forms</param> /// <param name="fullpath">The full path to the zipped folder containing the tools</param> /// <param name="install">Installation function</param> public static void InstallZipTool(Control parent, string fullpath, InstallProgram install) { ToolInstaller.UnzipToolReturnAccumulator result = null; var toolListStart = ToolList.CopyTools(Settings.Default.ToolList); Exception xFailure = null; try { result = ToolInstaller.UnpackZipTool(fullpath, new InstallZipToolHelper(parent, install)); } catch (ToolExecutionException x) { MessageDlg.ShowException(parent, x); } catch (Exception x) { xFailure = x; } if (xFailure != null) { MessageDlg.ShowWithException(parent, TextUtil.LineSeparate(String.Format(Resources.ConfigureToolsDlg_UnpackZipTool_Failed_attempting_to_extract_the_tool_from__0_, Path.GetFileName(fullpath)), xFailure.Message), xFailure); } if (result != null) { foreach (var message in result.MessagesThrown) { MessageDlg.Show(parent, message); } } else { // If result is Null, then we want to discard changes made to the ToolsList Settings.Default.ToolList = toolListStart; } }
public void OkDialog() { var helper = new MessageBoxHelper(this); // Validate start and end. double start; double end; if (!helper.ValidateDecimalTextBox(textStart, TransitionFullScan.MIN_RES_MZ, TransitionFullScan.MAX_RES_MZ, out start) || !helper.ValidateDecimalTextBox(textEnd, TransitionFullScan.MIN_RES_MZ, TransitionFullScan.MAX_RES_MZ, out end)) { return; } if (start >= end) { MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Start_value_must_be_less_than_End_value); return; } // Validate window width. double windowWidth; if (!helper.ValidateDecimalTextBox(textWidth, 0.1, TransitionFullScan.MAX_RES_MZ - TransitionFullScan.MIN_RES_MZ, out windowWidth)) { return; } if (windowWidth > end - start) { MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Window_width_must_be_less_than_or_equal_to_the_isolation_range); return; } // if given windowWidth is not an integer value if (windowWidth % 1 != 0 && OptimizeWindowPlacement) { MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Window_width_must_be_an_integer); return; } // if given windowWidth is odd if (windowWidth % 2 != 0 && OptimizeWindowPlacement && (string)comboDeconv.SelectedItem != EditIsolationSchemeDlg.DeconvolutionMethod.NONE && (string)comboDeconv.SelectedItem != EditIsolationSchemeDlg.DeconvolutionMethod.MSX) { MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_Window_width_not_even); return; } // Validate margins. double?margin = null; if (!helper.IsZeroOrEmpty(textMargin)) { double marginValue; if (!helper.ValidateDecimalTextBox(textMargin, TransitionInstrument.MIN_MZ_MATCH_TOLERANCE, TransitionFullScan.MAX_RES_MZ - TransitionFullScan.MIN_RES_MZ, out marginValue)) { return; } margin = marginValue; } // Validate CE range. double?ceRange = null; if (!helper.IsZeroOrEmpty(textCERange)) { double ceRangeValue; if (!helper.ValidateDecimalTextBox(textCERange, 0.0, double.MaxValue, out ceRangeValue)) { return; } ceRange = ceRangeValue; } // Validate multiplexing. if (Multiplexed) { int windowsPerScan; if (!helper.ValidateNumberTextBox(textWindowsPerScan, 2, 20, out windowsPerScan)) { return; } // Make sure multiplexed window count is a multiple of windows per scan. if (Multiplexed && IsolationWindows.Count % windowsPerScan != 0) { MessageDlg.Show(this, Resources.CalculateIsolationSchemeDlg_OkDialog_The_number_of_generated_windows_could_not_be_adjusted_to_be_a_multiple_of_the_windows_per_scan_Try_changing_the_windows_per_scan_or_the_End_value); return; } } try { // ReSharper disable ObjectCreationAsStatement new IsolationWindow(start, end, null, margin, margin, ceRange); // ReSharper restore ObjectCreationAsStatement } catch (InvalidDataException x) { MessageDlg.ShowException(this, x); return; } DialogResult = DialogResult.OK; }
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); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) { return; } if (_existing.Contains(en => !ReferenceEquals(_isolationScheme, en) && Equals(name, en.Name))) { helper.ShowTextBoxError(textName, Resources.EditIsolationSchemeDlg_OkDialog_The_isolation_scheme_named__0__already_exists, name); return; } if (rbUseResultsData.Checked) { double?precursorFilter = null; bool filterMargin = Equals(comboIsolationWidth.SelectedItem, IsolationWidthType.RESULTS_WITH_MARGIN); if (!Equals(comboIsolationWidth.SelectedItem, IsolationWidthType.RESULTS)) { double minFilt = filterMargin ? 0 : TransitionFullScan.MIN_PRECURSOR_MULTI_FILTER; double maxFilt = filterMargin ? TransitionFullScan.MAX_PRECURSOR_MULTI_FILTER_MARGIN : TransitionFullScan.MAX_PRECURSOR_MULTI_FILTER; double precFilt; if (!helper.ValidateDecimalTextBox(textPrecursorFilterMz, minFilt, maxFilt, out precFilt)) { return; } precursorFilter = precFilt; } try { _isolationScheme = new IsolationScheme(name, SpecialHandling, precursorFilter, null, filterMargin); } catch (InvalidDataException exception) { MessageDlg.ShowException(this, exception); return; } } else { // Validate prespecified windows. List <IsolationWindow> windowList; if ((windowList = GetIsolationWindows()) == null) { return; } // Must be at least one window. if (windowList.Count == 0) { _gridViewDriver.SelectCell(COLUMN_START, 0); MessageDlg.Show(this, Resources .EditIsolationSchemeDlg_OkDialog_Specify_Start_and_End_values_for_at_least_one_isolation_window); gridIsolationWindows.Focus(); _gridViewDriver.EditCell(); return; } int?windowsPerScan = null; if (Equals(SpecialHandling, IsolationScheme.SpecialHandlingType.MULTIPLEXED)) { int x; if (!helper.ValidateNumberTextBox(textWindowsPerScan, IsolationScheme.MIN_MULTIPLEXED_ISOLATION_WINDOWS, IsolationScheme.MAX_MULTIPLEXED_ISOLATION_WINDOWS, out x)) { return; } windowsPerScan = x; } // Check for overlap and gaps var sortedWindowList = windowList.OrderBy(o => o.Start).ToList(); bool gapsOk = false; bool overlapsOk = false; bool overlap = Overlap; int increment = overlap ? 2 : 1; int subtraction = overlap ? 3 : 1; const double tolerance = 0.0001; for (int i = 0; i < sortedWindowList.Count - subtraction; i += increment) { for (int j = 0; j < increment; j++) { IsolationWindow current = sortedWindowList.ElementAt(i + j); IsolationWindow next = sortedWindowList.ElementAt(i + j + increment); if (!gapsOk && next.Start - current.End > tolerance) { if (MultiButtonMsgDlg.Show(this, Resources .EditIsolationSchemeDlg_OkDialog_There_are_gaps_in_a_single_cycle_of_your_extraction_windows__Do_you_want_to_continue_, MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes) { return; } gapsOk = true; } else if (!overlapsOk && current.End - next.Start > tolerance) { if (MultiButtonMsgDlg.Show(this, Resources.EditIsolationSchemeDlgOkDialogThereAreOverlapsContinue, MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes) { return; } overlapsOk = true; } } } try { _isolationScheme = new IsolationScheme(name, windowList, SpecialHandling, windowsPerScan); } catch (InvalidDataException exception) { MessageDlg.ShowException(this, exception); return; } } DialogResult = DialogResult.OK; }
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); }