コード例 #1
0
ファイル: DetectionsPlotTest.cs プロジェクト: laeubisoft/pwiz
        private void AssertDataCorrect(DetectionsPlotPane pane, int refIndex, float qValue, bool record = false)
        {
            WaitForConditionUI(() => pane.CurrentData != null &&
                               pane.CurrentData.QValueCutoff == qValue &&
                               DetectionPlotData.GetDataCache().Status == DetectionPlotData.DetectionDataCache.CacheStatus.idle,
                               () => $"Retrieving data for qValue {qValue}, refIndex {refIndex} took too long.");
            WaitForGraphs();
            WaitForCondition(() => pane.CurrentData.IsValid);

            if (record)
            {
                Console.WriteLine(@"Peptides");
                pane.CurrentData.GetTargetData(DetectionsGraphController.TargetType.PEPTIDE).TargetsCount
                .ForEach((cnt) => { Console.Write($@"{cnt}, "); });
                Console.WriteLine(@"\nPrecursors");
                pane.CurrentData.GetTargetData(DetectionsGraphController.TargetType.PRECURSOR).TargetsCount
                .ForEach((cnt) => { Console.Write($@"{cnt}, "); });
            }

            Assert.IsTrue(
                REF_DATA[refIndex].SequenceEqual(
                    pane.CurrentData.GetTargetData(DetectionsGraphController.TargetType.PEPTIDE).TargetsCount));
            Assert.IsTrue(
                REF_DATA[refIndex + 1].SequenceEqual(
                    pane.CurrentData.GetTargetData(DetectionsGraphController.TargetType.PRECURSOR).TargetsCount));
        }
コード例 #2
0
ファイル: DetectionsPlotTest.cs プロジェクト: laeubisoft/pwiz
        protected override void DoTest()
        {
            OpenDocument(TestFilesDir.GetTestPath(@"DIA-TTOF-tutorial.sky"));
            WaitForDocumentLoaded();

            RunUI(() => { SkylineWindow.ShowDetectionsReplicateComparisonGraph(); });
            WaitForGraphs();

            GraphSummary graph   = SkylineWindow.DetectionsPlot;
            var          toolbar = graph.Toolbar as DetectionsToolbar;

            Assert.IsNotNull(toolbar);
            RunUI(() => { toolbar.CbLevel.SelectedItem = DetectionsGraphController.TargetType.PRECURSOR; });
            WaitForGraphs();

            DetectionsPlotPane pane;

            Assert.IsTrue(graph.TryGetGraphPane(out pane));
            Assert.IsTrue(pane.HasToolbar);

            //use properties dialog to update the q-value
            var propDialog = ShowDialog <DetectionToolbarProperties>(() =>
            {
                toolbar.pbProperties_Click(graph.GraphControl, new EventArgs());
            });

            //verify data correct for 2 q-values
            RunUI(() =>
            {
                propDialog.SetQValueTo(0.003f);
                propDialog.OkDialog();
            });
            WaitForClosedForm(propDialog);
            WaitForCondition(() => (DetectionsGraphController.Settings.QValueCutoff == 0.003f));
            AssertDataCorrect(pane, 0, 0.003f);

            //use properties dialog to update the q-value
            propDialog = ShowDialog <DetectionToolbarProperties>(() =>
            {
                toolbar.pbProperties_Click(graph.GraphControl, new EventArgs());
            });
            RunUI(() =>
            {
                propDialog.SetQValueTo(0.001f);
                propDialog.OkDialog();
            });
            WaitForClosedForm(propDialog);
            WaitForCondition(() => (DetectionsGraphController.Settings.QValueCutoff == 0.001f));
            AssertDataCorrect(pane, 2, 0.001f);

            //verify the number of the bars on the plot
            RunUI(() =>
            {
                Assert.IsTrue(
                    pane.CurveList[0].IsBar && pane.CurveList[0].Points.Count == REF_DATA[0].Length);
            });

            string[] tipText =
            {
                Resources.DetectionPlotPane_Tooltip_Replicate + TextUtil.SEPARATOR_TSV_STR + @"2_SW-B",
                string.Format(Resources.DetectionPlotPane_Tooltip_Count, DetectionsGraphController.TargetType.PRECURSOR) +
                TextUtil.SEPARATOR_TSV_STR + 118.ToString(CultureInfo.CurrentCulture),
                Resources.DetectionPlotPane_Tooltip_CumulativeCount + TextUtil.SEPARATOR_TSV_STR +
                123.ToString(CultureInfo.CurrentCulture),
                Resources.DetectionPlotPane_Tooltip_AllCount + TextUtil.SEPARATOR_TSV_STR +
                115.ToString(CultureInfo.CurrentCulture),
                Resources.DetectionPlotPane_Tooltip_QMedian + TextUtil.SEPARATOR_TSV_STR +
                (6.0d).ToString(@"F1", CultureInfo.CurrentCulture)
            };
            RunUI(() =>
            {
                Assert.IsNotNull(pane.ToolTip);
                pane.PopulateTooltip(1);
                //verify the tooltip text
                CollectionAssert.AreEqual(tipText, pane.ToolTip.TipLines);
            });

            //test the data correct after a doc change (delete peptide)
            RunUI(() =>
            {
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 12);
                SkylineWindow.EditDelete();
            });
            WaitForGraphs();
            WaitForConditionUI(() => DetectionPlotData.GetDataCache().Datas.Any((dat) =>
                                                                                ReferenceEquals(SkylineWindow.DocumentUI, dat.Document) &&
                                                                                DetectionsGraphController.Settings.QValueCutoff == dat.QValueCutoff),
                               "Cache is not updated on document change.");

            //verify that the cache is purged after the document update
            RunUI(() =>
            {
                Assert.IsTrue(DetectionPlotData.GetDataCache().Datas.All((dat) =>
                                                                         ReferenceEquals(SkylineWindow.DocumentUI, dat.Document)));
            });
            AssertDataCorrect(pane, 4, 0.001f);

            RunUI(() => { SkylineWindow.ShowDetectionsHistogramGraph(); });
            WaitForGraphs();
            DetectionsHistogramPane paneHistogram;
            var graphHistogram = SkylineWindow.DetectionsPlot;

            Assert.IsTrue(graphHistogram.TryGetGraphPane(out paneHistogram), "Cannot get histogram pane.");
            //display and hide tooltip
            string[] histogramTipText =
            {
                Resources.DetectionHistogramPane_Tooltip_ReplicateCount + TextUtil.SEPARATOR_TSV_STR +
                5.ToString(CultureInfo.CurrentCulture),
                String.Format(Resources.DetectionHistogramPane_Tooltip_Count, DetectionsGraphController.TargetType.PRECURSOR) +
                TextUtil.SEPARATOR_TSV_STR + 102.ToString(CultureInfo.CurrentCulture),
            };
            RunUI(() =>
            {
                Assert.IsNotNull(paneHistogram.ToolTip, "No tooltip found.");
                paneHistogram.PopulateTooltip(5);
                //verify the tooltip text
                CollectionAssert.AreEqual(histogramTipText, paneHistogram.ToolTip.TipLines);
            });
            RunUI(() =>
            {
                graph.Close();
                graphHistogram.Close();
            });
            WaitForGraphs();
        }