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);
     }
 }
Exemplo n.º 2
0
 private bool GetPython()
 {
     try
     {
         using (var waitDlg = new LongWaitDlg {
             ProgressValue = 0
         })
         {
             // Short wait, because this can't possible happen fast enough to avoid
             // showing progress, except in testing
             waitDlg.PerformWork(this, 50, DownloadPython);
         }
         using (var waitDlg = new LongWaitDlg(null, false)
         {
             Message = Resources.PythonInstaller_GetPython_Installing_Python
         })
         {
             waitDlg.PerformWork(this, 50, InstallPython);
         }
         MessageDlg.Show(this, Resources.PythonInstaller_GetPython_Python_installation_completed_);
         return(true);
     }
     catch (Exception ex)
     {
         MessageDlg.ShowWithException(this, (ex.InnerException ?? ex).Message, ex);
     }
     return(false);
 }
Exemplo n.º 3
0
        protected override void DoTest()
        {
            var longWaitDlg = ShowDialog <LongWaitDlg>(() =>
            {
                using (var longWaitDlg2 = new LongWaitDlg())
                {
                    longWaitDlg2.PerformWork(SkylineWindow, 1, (ILongWaitBroker longWaitBroker) =>
                    {
                        while (!longWaitDlg2.IsCanceled)
                        {
                            longWaitDlg2.CancellationToken.WaitHandle.WaitOne();
                        }
                    });
                }
            });
            Size originalSize = default(Size);

            RunUI(() => { originalSize = longWaitDlg.Size; });
            PauseForScreenShot();
            SetMessage(longWaitDlg, "TheQuickBrownFoxJumpsOverTheFirstLazyDog"
                       + "ThenTheQuickBrownFoxJumpsOverTheSecondLazyDog"
                       + "ThenTheQuickBrownFoxJumpsOverTheThirdLazyDog");
            Size newSize = default(Size);

            RunUI(() => newSize = longWaitDlg.Size);
            PauseForScreenShot();
            Assert.AreEqual(originalSize.Width, newSize.Width);
            Assert.AreNotEqual(originalSize.Height, newSize.Height);
            Assert.IsTrue(newSize.Height > originalSize.Height);
            OkDialog(longWaitDlg, longWaitDlg.Close);
        }
Exemplo n.º 4
0
        public bool Open(string skypPath, IEnumerable <Server> servers, FormEx parentWindow = null)
        {
            try
            {
                var skyp = SkypFile.Create(skypPath, servers);

                using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.SkypSupport_Open_Downloading_Skyline_Document_Archive,
                })
                {
                    longWaitDlg.PerformWork(parentWindow ?? _skyline, 1000, progressMonitor => Download(skyp, progressMonitor, parentWindow));
                    if (longWaitDlg.IsCanceled)
                    {
                        return(false);
                    }
                }
                return(_skyline.OpenSharedFile(skyp.DownloadPath));
            }
            catch (Exception e)
            {
                var message = TextUtil.LineSeparate(Resources.SkypSupport_Open_Failure_opening_skyp_file_, e.Message);
                MessageDlg.ShowWithException(parentWindow ?? _skyline, message, e);
                return(false);
            }
        }
Exemplo n.º 5
0
 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);
     }
 }
Exemplo n.º 6
0
        protected override void DoTest()
        {
            // Test non-cancellable dialog.
            RunUI(() => // Must start from same thread as Program.MainWindow
            {
                using (var longWaitDlg = new LongWaitDlg(null, false))
                {
                    longWaitDlg.PerformWork(Program.MainWindow, 20, () =>
                    {
                        for (int i = 0; i < 100; i += 10)
                        {
                            Thread.Sleep(5);
                            longWaitDlg.ProgressValue = i;
                        }
                    });
                }
            });

            // Show cancellable dialog if we're running this Form from SkylineTester.
            if (Program.PauseForms != null && Program.PauseForms.Contains(typeof(LongWaitDlg).Name))
            {
                RunUI(() => // Must start from same thread as Program.MainWindow
                {
                    using (var longWaitDlg = new LongWaitDlg())
                    {
                        longWaitDlg.PerformWork(Program.MainWindow, 0, () =>
                        {
                            WaitForOpenForm <LongWaitDlg>();
                            longWaitDlg.CancelButton.PerformClick();
                        });
                        Assert.IsTrue(longWaitDlg.IsCanceled);
                    }
                });
            }
        }
Exemplo n.º 7
0
        public void CommitBatchModifyDocument(string description)
        {
            if (null == _batchChangesOriginalDocument)
            {
                throw new InvalidOperationException();
            }
            string message = Resources.DataGridViewPasteHandler_EndDeferSettingsChangesOnDocument_Updating_settings;

            SkylineWindow.ModifyDocument(description, document =>
            {
                VerifyDocumentCurrent(_batchChangesOriginalDocument, document);
                using (var longWaitDlg = new LongWaitDlg
                {
                    Message = message
                })
                {
                    SrmDocument newDocument = null;
                    longWaitDlg.PerformWork(SkylineWindow, 1000, progressMonitor =>
                    {
                        var srmSettingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor,
                                                                                    message);
                        newDocument = _document.EndDeferSettingsChanges(_batchChangesOriginalDocument.Settings, srmSettingsChangeMonitor);
                    });
                    return(newDocument);
                }
            });
            _batchChangesOriginalDocument = null;
            DocumentChangedEventHandler(_documentContainer, new DocumentChangedEventArgs(_document));
        }
Exemplo n.º 8
0
        public void ShowRefineDlg()
        {
            using (var refineDlg = new RefineDlg(SkylineWindow))
            {
                if (refineDlg.ShowDialog(SkylineWindow) == DialogResult.OK)
                {
                    ModifyDocument(Resources.SkylineWindow_ShowRefineDlg_Refine,
                                   doc =>
                    {
                        using (var longWaitDlg = new LongWaitDlg(SkylineWindow))
                        {
                            longWaitDlg.Message = Resources.SkylineWindow_ShowRefineDlg_Refining_document;
                            longWaitDlg.PerformWork(refineDlg, 1000, progressMonitor =>
                            {
                                var srmSettingsChangeMonitor =
                                    new SrmSettingsChangeMonitor(progressMonitor, Resources.SkylineWindow_ShowRefineDlg_Refining_document, SkylineWindow, doc);

                                doc = refineDlg.RefinementSettings.Refine(doc, srmSettingsChangeMonitor);
                            });
                        }

                        return(doc);
                    }, refineDlg.FormSettings.EntryCreator.Create);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Uses an <see cref="IToolStoreClient"/> to download (zip files) for each of the tools selected in the form's checklistbox.
        /// Returns a collection of tools to be updated.
        /// </summary>
        private ICollection <ToolUpdateInfo> GetToolsToUpdate()
        {
            labelOperation.Text = Resources.ToolUpdatesDlg_GetTools_Downloading_Updates;
            var toolsToDownload = new Collection <ToolUpdateInfo>();
            var toolList        = _tools.Keys.ToList();

            // get tools to update based on which ones are checked
            foreach (int index in checkedListBoxTools.CheckedIndices)
            {
                toolsToDownload.Add(toolList[index]);
            }

            ICollection <ToolUpdateInfo> successfulDownloads = null;
            ICollection <string>         failedDownloads     = null;

            using (var dlg = new LongWaitDlg {
                Message = Resources.ToolUpdatesDlg_GetToolsToUpdate_Downloading_Updates
            })
            {
                dlg.PerformWork(this, 1000,
                                longWaitBroker =>
                                DownloadTools(longWaitBroker, toolsToDownload, out successfulDownloads,
                                              out failedDownloads));
            }

            DisplayDownloadSummary(failedDownloads);
            return(successfulDownloads);
        }
Exemplo n.º 10
0
        private void RefreshDocument()
        {
            Document = Program.MainWindow.Document;
            using (var longWaitDlg = new LongWaitDlg())
            {
                longWaitDlg.PerformWork(this, 200, pm =>
                {
                    foreach (var peakBoundaries in _peakBoundaryList)
                    {
                        string comparisonName = peakBoundaries.Name;
                        BeginInvoke((Action)(() =>
                        {
                            longWaitDlg.Text = string.Format(Resources.ComparePeakPickingDlg_RefreshDocument_Refresh__0_, comparisonName);
                            longWaitDlg.ProgressValue = 0;
                        }));

                        if (pm.IsCanceled)
                        {
                            break;
                        }

                        peakBoundaries.GenerateComparison(Document, pm);
                    }
                });
            }
            UpdateAll();
            btnRefresh.Enabled = false;
        }
Exemplo n.º 11
0
        private MsDataFilePath[] GetWiffSubPaths(string filePath)
        {
            using (var longWaitDlg = new LongWaitDlg
            {
                Text = Resources.ImportResultsDlg_GetWiffSubPaths_Sample_Names,
                Message = string.Format(Resources.ImportResultsDlg_GetWiffSubPaths_Reading_sample_names_from__0__,
                                        Path.GetFileName(filePath))
            })
            {
                string[] dataIds = null;
                try
                {
                    longWaitDlg.PerformWork(this, 800, () => dataIds = MsDataFileImpl.ReadIds(filePath));
                }
                catch (Exception x)
                {
                    string message = TextUtil.LineSeparate(
                        string.Format(Resources.ImportResultsDlg_GetWiffSubPaths_An_error_occurred_attempting_to_read_sample_information_from_the_file__0__, filePath),
                        Resources.ImportResultsDlg_GetWiffSubPaths_The_file_may_be_corrupted_missing_or_the_correct_libraries_may_not_be_installed,
                        x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                }

                return(DataSourceUtil.GetWiffSubPaths(filePath, dataIds, ChooseSamples));
            }
        }
Exemplo n.º 12
0
 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;
         }
     }
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 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);
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 private void ModifyDocument(string message, Action <SrmSettingsChangeMonitor> modifyAction)
 {
     using (var longWaitDlg = new LongWaitDlg(Program.MainWindow)
     {
         Text = Text, // Same as dialog box
         Message = message,
         ProgressValue = 0
     })
     {
         try
         {
             longWaitDlg.PerformWork(this, 800, progressMonitor =>
             {
                 using (var settingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor, message, Program.MainWindow))
                 {
                     modifyAction(settingsChangeMonitor);
                 }
             });
         }
         catch (OperationCanceledException)
         {
             // SrmSettingsChangeMonitor can throw OperationCancelledException without LongWaitDlg knowing about it.
         }
     }
 }
Exemplo n.º 17
0
        public bool WriteChromatograms(string filePath)
        {
            var fileNames = (from object fileName in checkedListVars.CheckedItems select fileName.ToString()).ToList();

            using (var longWaitDlg = new LongWaitDlg
            {
                Text = Resources.ExportChromatogramDlg_OkDialog_Exporting_Chromatograms,
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 1000,
                                            broker => WriteChromatograms(filePath,
                                                                         broker,
                                                                         fileNames,
                                                                         LocalizationHelper.CurrentCulture,
                                                                         _chromExtractors,
                                                                         _chromSources));
                    if (longWaitDlg.IsCanceled)
                    {
                        return(false);
                    }
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.ExportChromatogramDlg_OkDialog_Failed_attempting_to_save_chromatograms_to__0__, filePath),
                                                        x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                }
            }
            return(true);
        }
Exemplo n.º 18
0
 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);
 }
Exemplo n.º 19
0
        public Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> GetClusteredResults()
        {
            Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> resultsTuple = null;

            try
            {
                using (var longWaitDlg = new LongWaitDlg())
                {
                    longWaitDlg.PerformWork(FormUtil.FindTopLevelOwner(this), 1000,
                                            broker => { resultsTuple = GetClusteredResultsBackground(broker); });
                    if (longWaitDlg.IsCanceled)
                    {
                        return(null);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageDlg.ShowWithException(FormUtil.FindTopLevelOwner(this), Resources.DataboundGridControl_GetClusteredResults_An_error_occured_while_performing_clustering_, exception);
                return(null);
            }

            if (resultsTuple == null)
            {
                MessageDlg.Show(FormUtil.FindTopLevelOwner(this),
                                Resources.DataboundGridControl_GetClusteredResults_Unable_to_choose_a_set_of_columns_to_use_for_hierarchical_clustering_);
                return(null);
            }

            return(resultsTuple);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
 public override bool RunLongJob(Control owner, Action <IProgressMonitor> job)
 {
     using (var longWaitDlg = new LongWaitDlg())
     {
         var status = longWaitDlg.PerformWork(FormUtil.FindTopLevelOwner(owner), 1000, job);
         return(status.IsComplete);
     }
 }
Exemplo n.º 22
0
 private void RunOnBackgroundThread(Action <ILongWaitBroker> action)
 {
     using (var longWaitDlg = new LongWaitDlg())
     {
         InitLongWaitDlg(longWaitDlg);
         longWaitDlg.PerformWork(ParentControl, DelayMillis, action);
     }
 }
Exemplo n.º 23
0
        private void RefreshStatus()
        {
            if (File.Exists(textPath.Text))
            {
                btnAddFastaFile.Enabled = true;
                ProteomeDb proteomeDb   = null;
                int        proteinCount = 0;
                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_Proteome_File,
                        Message =
                            string.Format(
                                Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_protein_information_from__0__,
                                textPath.Text)
                    })
                    {
                        longWaitDlg.PerformWork(this, 1000, () =>
                        {
                            proteomeDb = ProteomeDb.OpenProteomeDb(textPath.Text);
                            if (proteomeDb != null)
                            {
                                proteinCount = proteomeDb.GetProteinCount(); // This can be a lengthy operation on a large protdb, do it within the longwait
                            }
                        });
                    }
                    if (proteomeDb == null)
                    {
                        throw new Exception();
                    }

                    tbxStatus.Text =
                        string.Format(
                            Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_file_contains__0__proteins,
                            proteinCount);
                }
                catch (Exception)
                {
                    tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid;
                    btnAddFastaFile.Enabled = false;
                }
                finally
                {
                    if (null != proteomeDb)
                    {
                        proteomeDb.Dispose();
                    }
                }
                textPath.ForeColor = Color.Black;
            }
            else
            {
                btnAddFastaFile.Enabled = false;
                tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Click_the_Open_button_to_choose_an_existing_proteome_file_or_click_the_Create_button_to_create_a_new_proteome_file;
                textPath.ForeColor      = string.IsNullOrEmpty(textPath.Text) ? Color.Black : Color.Red;
            }
        }
Exemplo n.º 24
0
        // find matches using the background proteome
        public void UseBackgroundProteome()
        {
            if (_parent.Document.Settings.PeptideSettings.BackgroundProteome.Equals(BackgroundProteome.NONE))
            {
                MessageDlg.Show(this, Resources.AssociateProteinsDlg_UseBackgroundProteome_No_background_proteome_defined);
                return;
            }
            _isFasta  = false;
            _fileName = _parent.Document.Settings.PeptideSettings.BackgroundProteome.DatabasePath;
            checkBoxListMatches.Items.Clear();
            BackgroundProteome proteome = _parent.Document.Settings.PeptideSettings.BackgroundProteome;
            var proteinAssociations     = new List <KeyValuePair <FastaSequence, List <PeptideDocNode> > >();
            var peptidesForMatching     = ListPeptidesForMatching();

            IDictionary <String, List <Protein> > proteinsWithSequences = null;

            using (var longWaitDlg = new LongWaitDlg())
            {
                longWaitDlg.PerformWork(this, 1000, longWaitBroker =>
                {
                    using (var proteomeDb = proteome.OpenProteomeDb(longWaitBroker.CancellationToken))
                    {
                        proteinsWithSequences = proteomeDb.GetDigestion()
                                                .GetProteinsWithSequences(peptidesForMatching.Select(pep => pep.Peptide.Target.Sequence));
                    }
                });
            }
            if (proteinsWithSequences == null)
            {
                return;
            }
            HashSet <String> processedProteinSequence = new HashSet <string>();

            foreach (var entry in proteinsWithSequences)
            {
                foreach (var protein in entry.Value)
                {
                    if (!processedProteinSequence.Add(protein.Sequence))
                    {
                        continue;
                    }
                    var matches = peptidesForMatching.Where(pep => protein.Sequence.Contains(pep.Peptide.Target.Sequence)).ToList();
                    if (matches.Count == 0)
                    {
                        continue;
                    }
                    FastaSequence fastaSequence = proteome.MakeFastaSequence(protein);
                    if (fastaSequence != null)
                    {
                        proteinAssociations.Add(new KeyValuePair <FastaSequence, List <PeptideDocNode> >(fastaSequence, matches));
                    }
                }
            }
            SetCheckBoxListItems(proteinAssociations,
                                 Resources.AssociateProteinsDlg_UseBackgroundProteome_No_matches_were_found_using_the_background_proteome_);
        }
Exemplo n.º 25
0
        private void RefreshStatus()
        {
            if (File.Exists(textPath.Text))
            {
                btnAddFastaFile.Enabled = true;
                ProteomeDb proteomeDb = null;
                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_Proteome_File,
                        Message =
                            string.Format(
                                Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_protein_information_from__0__,
                                textPath.Text)
                    })
                    {
                        longWaitDlg.PerformWork(this, 1000, () => proteomeDb = ProteomeDb.OpenProteomeDb(textPath.Text));
                    }
                    if (proteomeDb == null)
                    {
                        throw new Exception();
                    }

                    int proteinCount = proteomeDb.GetProteinCount();
                    var digestions   = proteomeDb.ListDigestions();
                    tbxStatus.Text =
                        string.Format(
                            Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_file_contains__0__proteins,
                            proteinCount);
                    if (proteinCount != 0 && digestions.Count > 0)
                    {
                        tbxStatus.Text = TextUtil.LineSeparate(tbxStatus.Text,
                                                               Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_has_already_been_digested);
                    }
                }
                catch (Exception)
                {
                    tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid;
                    btnAddFastaFile.Enabled = false;
                }
                finally
                {
                    if (null != proteomeDb)
                    {
                        proteomeDb.Dispose();
                    }
                }
            }
            else
            {
                btnAddFastaFile.Enabled = false;
                tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Click_the_Open_button_to_choose_an_existing_proteome_file_or_click_the_Create_button_to_create_a_new_proteome_file;
            }
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);
            var isotopeModification = _driverIsotopeModification.SelectedItem;

            if (isotopeModification == null)
            {
                helper.ShowTextBoxError(comboIsotopeModification, Resources.MessageBoxHelper_ValidateNameTextBox__0__cannot_be_empty);
                return;
            }
            lock (SkylineWindow.GetDocumentChangeLock())
            {
                var originalDocument       = SkylineWindow.Document;
                var deferSettingsChangeDoc = originalDocument.BeginDeferSettingsChanges();
                var globalStaticMods       = Settings.Default.StaticModList.ToList();
                var globalIsotopeMods      = Settings.Default.HeavyModList.ToList();
                var newDocument            = deferSettingsChangeDoc;
                var simplePermutation      = SimplePermutation;
                using (var longWaitDlg = new LongWaitDlg()
                {
                    Text = Resources.PermuteIsotopeModificationsDlg_OkDialog_Permuting_Isotope_Modifications
                })
                {
                    longWaitDlg.PerformWork(this, 1000, progressMonitor =>
                    {
                        var isotopePermuter = new IsotopeModificationPermuter(isotopeModification,
                                                                              simplePermutation, IsotopeLabelType.heavy, globalStaticMods, globalIsotopeMods);
                        newDocument = isotopePermuter.PermuteIsotopeModifications(progressMonitor, newDocument);
                        if (!ReferenceEquals(newDocument, deferSettingsChangeDoc))
                        {
                            var settingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor, Resources.PermuteIsotopeModificationsDlg_OkDialog_Updating_settings);
                            newDocument = newDocument.EndDeferSettingsChanges(originalDocument, settingsChangeMonitor);
                        }
                    });
                    if (longWaitDlg.IsCanceled)
                    {
                        return;
                    }
                }
                if (!ReferenceEquals(newDocument, deferSettingsChangeDoc))
                {
                    SkylineWindow.ModifyDocument(Resources.PermuteIsotopeModificationsDlg_OkDialog_Permute_isotope_modifications, doc =>
                    {
                        // This will be true because we have acquired the lock on SkylineWindow.DocumentChangeLock()
                        Assume.IsTrue(ReferenceEquals(doc, originalDocument));
                        return(newDocument);
                    }, docPair => GetAuditLogEntry(docPair, isotopeModification, simplePermutation));
                }
                DialogResult = DialogResult.OK;
            }
        }
Exemplo n.º 27
0
        public void AddFastaFile(string fastaFilePath)
        {
            String databasePath = textPath.Text;

            Settings.Default.FastaDirectory = Path.GetDirectoryName(fastaFilePath);
            int duplicateSequenceCount = 0;

            using (var longWaitDlg = new LongWaitDlg {
                ProgressValue = 0
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 0, progressMonitor =>
                    {
                        ProteomeDb proteomeDb = File.Exists(databasePath)
                            ? ProteomeDb.OpenProteomeDb(databasePath)
                            : ProteomeDb.CreateProteomeDb(databasePath);
                        using (proteomeDb)
                        {
                            using (var reader = File.OpenText(fastaFilePath))
                            {
                                IProgressStatus status = new ProgressStatus(longWaitDlg.Message);
                                proteomeDb.AddFastaFile(reader, progressMonitor, ref status, false, out duplicateSequenceCount);
                            }
                        }
                    });
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_An_error_occurred_attempting_to_add_the_FASTA_file__0__,
                                                                      fastaFilePath), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            string path = Path.GetFileName(fastaFilePath);

            if (path != null)
            {
                listboxFasta.Items.Add(path);
            }
            RefreshStatus();

            if (duplicateSequenceCount > 0)
            {
                MessageDlg.Show(this, string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_The_added_file_included__0__repeated_protein_sequences__Their_names_were_added_as_aliases_to_ensure_the_protein_list_contains_only_one_copy_of_each_sequence_, duplicateSequenceCount));
            }
        }
Exemplo n.º 28
0
        public void ShowExportSpectralLibraryDialog(Control owner)
        {
            if (Document.MoleculeTransitionGroupCount == 0)
            {
                MessageDlg.Show(owner, Resources.SkylineWindow_ShowExportSpectralLibraryDialog_The_document_must_contain_at_least_one_peptide_precursor_to_export_a_spectral_library_);
                return;
            }
            else if (!Document.Settings.HasResults)
            {
                MessageDlg.Show(owner, Resources.SkylineWindow_ShowExportSpectralLibraryDialog_The_document_must_contain_results_to_export_a_spectral_library_);
                return;
            }

            using (var dlg = new SaveFileDialog
            {
                Title = Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Export_Spectral_Library,
                OverwritePrompt = true,
                DefaultExt = BiblioSpecLiteSpec.EXT,
                Filter = TextUtil.FileDialogFiltersAll(BiblioSpecLiteSpec.FILTER_BLIB)
            })
            {
                if (!string.IsNullOrEmpty(DocumentFilePath))
                {
                    dlg.InitialDirectory = Path.GetDirectoryName(DocumentFilePath);
                }

                if (dlg.ShowDialog(owner) == DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Export_Spectral_Library,
                        Message = string.Format(Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Exporting_spectral_library__0____, Path.GetFileName(dlg.FileName))
                    })
                    {
                        longWaitDlg.PerformWork(owner, 800, monitor => ExportSpectralLibrary(dlg.FileName, monitor));
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(owner, TextUtil.LineSeparate(string.Format(Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Failed_exporting_spectral_library_to__0__, dlg.FileName), x.Message), x);
                }
            }
        }
Exemplo n.º 29
0
        public void OkDialog()
        {
            MessageBoxHelper helper = new MessageBoxHelper(this);
            string           serverName;

            if (!helper.ValidateNameTextBox(textServerURL, out serverName))
            {
                return;
            }

            Uri uriServer = PanoramaUtil.ServerNameToUri(serverName);

            if (uriServer == null)
            {
                helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_text__0__is_not_a_valid_server_name_, serverName);
                return;
            }

            var panoramaClient = PanoramaClient ?? new WebPanoramaClient(uriServer);

            using (var waitDlg = new LongWaitDlg {
                Text = Resources.EditServerDlg_OkDialog_Verifying_server_information
            })
            {
                try
                {
                    waitDlg.PerformWork(this, 1000, () => PanoramaUtil.VerifyServerInformation(panoramaClient, Username, Password));
                }
                catch (Exception x)
                {
                    helper.ShowTextBoxError(textServerURL, x.Message);
                    return;
                }
            }

            Uri updatedUri = panoramaClient.ServerUri ?? uriServer;

            if (_existing.Contains(server => !ReferenceEquals(_server, server) && Equals(updatedUri, server.URI)))
            {
                helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_server__0__already_exists_, uriServer.Host);
                return;
            }

            _server      = new Server(updatedUri, Username, Password);
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 30
0
        public Database GetDatabase(Control owner)
        {
            if (_database == null)
            {
                var status = new ProgressStatus(Resources.ExportReportDlg_GetDatabase_Generating_Report_Data);
                using (var longWait = new LongWaitDlg
                {
                    Text = status.Message,
                    Message = Resources.ExportReportDlg_GetDatabase_Analyzing_document
                })
                {
                    longWait.PerformWork(owner, 1500, broker => EnsureDatabase(broker, 100, ref status));
                }
            }

            return(_database);
        }
Exemplo n.º 31
0
 public void LongWaitDlgAction(SkylineWindow skylineWindow)
 {
     skylineWindow.ResetDefaultSettings();
     try
     {
         using (var longWaitDlg = new LongWaitDlg
         {
             Text = Resources.ActionTutorial_LongWaitDlgAction_Downloading_Tutorial_Zip_File,
             Message =
                 String.Format(
                     Resources
                         .ActionTutorial_LongWaitDlgAction_Downloading_to___0__1_Tutorial_will_open_in_browser_when_download_is_complete_,
                     getTempPath(), Environment.NewLine),
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, DownloadTutorials);
             if (longWaitDlg.IsCanceled)
             {
                 return;
             }
         }
         using (var longWaitDlg = new LongWaitDlg
         {
             Text =
                 Resources.ActionTutorial_LongWaitDlgAction_Extracting_Tutorial_Zip_File_in_the_same_directory_,
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, ExtractTutorial);
         }
     }
     catch (Exception exception)
     {
         MessageDlg.ShowWithException(Program.MainWindow, string.Format(Resources.ActionTutorial_DownloadTutorials_Error__0_, exception.Message), exception);
     }
 }