void OnProgress(ChromCacheMinimizer.MinStatistics minStatistics) { lock (this) { CheckDisposed(); bool updateUi = _minStatistics == null || _minStatistics.PercentComplete != minStatistics.PercentComplete; _minStatistics = minStatistics; if (ReferenceEquals(_dlg.StatisticsCollector, this)) { if (updateUi && !_updatePending) { //_updatePending = true; try { _dlg.BeginInvoke(new Action(UpdateStatistics)); } catch (Exception x) { throw new ObjectDisposedException(_dlg.GetType().FullName, x); } } } } if (_longWaitBroker != null) { _longWaitBroker.ProgressValue = minStatistics.PercentComplete; if (_longWaitBroker.IsCanceled) { throw new ObjectDisposedException(GetType().FullName); } } }
public void TestCollectStatistics() { var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky"); SrmDocument doc = ResultsUtil.DeserializeDocument(docPath); var docContainer = new ResultsTestDocumentContainer(doc, docPath); // Import the first RAW file (or mzML for international) string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" + ExtensionTestContext.ExtThermoRaw); var measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Single", new[] { MsDataFileUri.Parse(rawPath) }) }); SrmDocument docResults = docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21); ChromCacheMinimizer chromCacheMinimizer = docResults.Settings.MeasuredResults.GetChromCacheMinimizer(docResults); ChromCacheMinimizer.Settings settings = new ChromCacheMinimizer.Settings().SetDiscardUnmatchedChromatograms(true); ChromCacheMinimizer.MinStatistics minStatistics = null; chromCacheMinimizer.Minimize(settings, s => minStatistics = s, null); Assert.AreEqual(100, minStatistics.PercentComplete); Assert.AreEqual(1.0, minStatistics.MinimizedRatio); var docMissingFirstPeptide = (SrmDocument) docResults.ReplaceChild( docResults.PeptideGroups.First().RemoveChild(docResults.PeptideGroups.First().Children[0])); var docWithOnlyFirstPeptide = (SrmDocument) docResults.ReplaceChild( docResults.PeptideGroups.First().ChangeChildren(new[] { docResults.PeptideGroups.First().Children[0] })); ChromCacheMinimizer.MinStatistics statsMissingFirstProtein = null; ChromCacheMinimizer.MinStatistics statsWithOnlyFirstProtein = null; settings = settings.SetDiscardUnmatchedChromatograms(true); ChromCacheMinimizer minimizerMissingFirstProtein = docMissingFirstPeptide.Settings.MeasuredResults.GetChromCacheMinimizer(docMissingFirstPeptide); ChromCacheMinimizer minimizerWithOnlyFirstProtein = docWithOnlyFirstPeptide.Settings.MeasuredResults.GetChromCacheMinimizer(docWithOnlyFirstPeptide); minimizerMissingFirstProtein.Minimize(settings, s => statsMissingFirstProtein = s, null); minimizerWithOnlyFirstProtein.Minimize(settings, s => statsWithOnlyFirstProtein = s, null); Assert.AreEqual(100, statsMissingFirstProtein.PercentComplete); Assert.AreEqual(100, statsWithOnlyFirstProtein.PercentComplete); Assert.AreEqual(1.0, statsMissingFirstProtein.MinimizedRatio + statsWithOnlyFirstProtein.MinimizedRatio, .00001); settings = settings.SetDiscardUnmatchedChromatograms(false); ChromCacheMinimizer.MinStatistics statsMissingFirstProteinKeepAll = null; ChromCacheMinimizer.MinStatistics statsWithOnlyFirstProteinKeepAll = null; minimizerMissingFirstProtein.Minimize(settings, s => statsMissingFirstProteinKeepAll = s, null); minimizerWithOnlyFirstProtein.Minimize(settings, s => statsWithOnlyFirstProteinKeepAll = s, null); Assert.AreEqual(100, statsMissingFirstProteinKeepAll.PercentComplete); Assert.AreEqual(1.0, statsMissingFirstProteinKeepAll.MinimizedRatio); Assert.AreEqual(100, statsWithOnlyFirstProteinKeepAll.PercentComplete); Assert.AreEqual(1.0, statsWithOnlyFirstProteinKeepAll.MinimizedRatio); docContainer.Release(); }