private static void OpenVolcanoPlotProperties(FoldChangeVolcanoPlot volcanoPlot, Action <VolcanoPlotPropertiesDlg> action)
 {
     RunDlg <VolcanoPlotPropertiesDlg>(volcanoPlot.ShowProperties, d =>
     {
         action(d);
         d.OkDialog();
     });
 }
        private static void AssertVolcanoPlotCorrect(FoldChangeVolcanoPlot plot, bool showingBounds, int selectedCount, int outCount, int inCount)
        {
            var curveCounts = plot.GetCurveCounts();

            Assert.AreEqual(showingBounds, FoldChangeVolcanoPlot.AnyCutoffSettingsValid);
            Assert.AreEqual(showingBounds ? 5 : 2, curveCounts.CurveCount);
            Assert.AreEqual(selectedCount, curveCounts.SelectedCount);
            Assert.AreEqual(outCount, curveCounts.OutCount);
            Assert.AreEqual(inCount, curveCounts.InCount);
        }
 private static void AssertSelectionCorrect(FoldChangeVolcanoPlot volcanoPlot, string selectedSequence, int totalSelected)
 {
     RunUI(() =>
     {
         var row = volcanoPlot.GetSelectedRow();
         Assert.IsNotNull(row);
         Assert.IsNotNull(row.Peptide);
         Assert.AreEqual(selectedSequence, row.Peptide.Sequence);
         Assert.AreEqual(selectedSequence, SkylineWindow.SelectedPeptideSequence);
         Assert.AreEqual(totalSelected, SkylineWindow.SequenceTree.SelectedPaths.Count);
     });
 }
 private static void MoveAndClick(FoldChangeVolcanoPlot volcanoPlot, double x, double y, bool ctrl = false)
 {
     RunUI(() =>
     {
         if (ctrl)
         {
             volcanoPlot.OverridenModifierKeys = Keys.Control;
         }
         volcanoPlot.MoveMouse(MouseButtons.Left, volcanoPlot.GraphToScreenCoordinates(x, y));
         volcanoPlot.ClickSelectedRow();
         volcanoPlot.OverridenModifierKeys = Keys.None;
     });
 }
Example #5
0
        private void AssertVolcanoPlotCorrect(FoldChangeVolcanoPlot plot, VolcanoPlotPointsInfo[] pointsInfos)
        {
            RunUI(() =>
            {
                var curveList    = plot.CurveList;
                var startIndex   = plot.MatchedPointsStartIndex;
                var matchedCount = curveList.Count - startIndex - 1; // -1 because of the "other" curve item at the end of the curvelist
                Assert.AreEqual(matchedCount, pointsInfos.Length);

                var labelIndex    = 0;
                var remainingObjs = plot.GraphObjList.Count;

                var unselectedStartIndex = plot.LabeledPoints.FindIndex(p => !p.IsSelected);

                if (unselectedStartIndex < 0)
                {
                    remainingObjs = 0;
                }
                else
                {
                    remainingObjs -= unselectedStartIndex;
                }


                for (var i = startIndex; i < curveList.Count - 1; ++i)
                {
                    var curveItem = curveList[i];
                    Assert.IsInstanceOfType(curveItem, typeof(LineItem));
                    var lineItem  = (LineItem)curveItem;
                    var pointInfo = pointsInfos[i - startIndex];

                    Assert.AreEqual(pointInfo.Color, lineItem.Symbol.Fill.Color);
                    Assert.AreEqual(pointInfo.PointCount, curveItem.Points.Count);
                    Assert.AreEqual(FoldChangeVolcanoPlot.PointSymbolToSymbolType(pointInfo.PointSymbol), lineItem.Symbol.Type);
                    Assert.AreEqual(FoldChangeVolcanoPlot.PointSizeToFloat(pointInfo.PointSize), lineItem.Symbol.Size);

                    if (pointInfo.Labeled)
                    {
                        Assert.IsTrue(remainingObjs >= curveItem.Points.Count);

                        for (var j = 0; j < curveItem.Points.Count; ++j)
                        {
                            var labeledPoint = plot.LabeledPoints[unselectedStartIndex + labelIndex + j];
                            var pointPair    = curveItem.Points[j];
                            var graphObj     = plot.GraphObjList[unselectedStartIndex + labelIndex + j];
                            Assert.IsInstanceOfType(graphObj, typeof(TextObj));
                            var label = (TextObj)graphObj;

                            Assert.AreEqual(FoldChangeVolcanoPlot.PointSizeToFloat(pointInfo.PointSize), label.FontSpec.Size);
                            Assert.AreEqual(label.Location.X, pointPair.X);
                            //Assert.AreEqual(label.Location.Y, pointPair.Y);

                            Assert.AreEqual(labeledPoint.Label, label);
                            Assert.AreEqual(labeledPoint.Point, pointPair);
                            Assert.IsFalse(labeledPoint.IsSelected);

                            --remainingObjs;
                        }

                        labelIndex += curveItem.Points.Count;
                    }
                }

                Assert.AreEqual(0, remainingObjs);
            });
        }
Example #6
0
        private void VerifyMatchExpressions(FoldChangeVolcanoPlot volcanoPlot, MatchExprInfo[] matchExprInfos, int initialRowCount = 0, RemoveMode removeMode = RemoveMode.Cancel)
        {
            int count = matchExprInfos.Length;

            var formattingDlg = ShowDialog <VolcanoPlotFormattingDlg>(volcanoPlot.ShowFormattingDialog);

            for (var i = 0; i < count; ++i)
            {
                var index    = i;
                var exprInfo = matchExprInfos[i];

                var createExprDlg = ShowDialog <CreateMatchExpressionDlg>(() =>
                {
                    var bindingList = formattingDlg.GetCurrentBindingList();
                    Assert.AreEqual(initialRowCount + index, bindingList.Count);

                    bindingList.Add(new MatchRgbHexColor(string.Empty, exprInfo.ExpectedPointsInfo.Labeled,
                                                         exprInfo.ExpectedPointsInfo.Color, exprInfo.ExpectedPointsInfo.PointSymbol,
                                                         exprInfo.ExpectedPointsInfo.PointSize));
                    formattingDlg.ClickCreateExpression(bindingList.Count - 1);
                });

                RunUI(() =>
                {
                    createExprDlg.MatchSelectedItem =
                        CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.MatchItems.ToArray(),
                                                                          exprInfo.MatchExpression.matchOptions);

                    createExprDlg.FoldChangeSelectedItem =
                        CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.FoldChangeItems.ToArray(),
                                                                          exprInfo.MatchExpression.matchOptions);

                    createExprDlg.PValueSelectedItem =
                        CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.PValueItems.ToArray(),
                                                                          exprInfo.MatchExpression.matchOptions);

                    createExprDlg.Expression = exprInfo.MatchExpression.RegExpr;
                });

                WaitForConditionUI(() => exprInfo.ExpectedMatches.Count == createExprDlg.MatchingRows.Count(), () =>
                                   string.Format("Expected: {0}\nActual: {1}", string.Join(", ", exprInfo.ExpectedMatches),
                                                 string.Join(", ", createExprDlg.MatchingRows)));

                RunUI(() => CollectionAssert.AreEqual(exprInfo.ExpectedMatches, createExprDlg.MatchingRows.ToArray()));

                OkDialog(createExprDlg, createExprDlg.OkDialog);
            }

            AssertVolcanoPlotCorrect(volcanoPlot, matchExprInfos.Select(info => info.ExpectedPointsInfo).ToArray());

            switch (removeMode)
            {
            case RemoveMode.Cancel:
                OkDialog(formattingDlg, formattingDlg.CancelDialog);
                break;

            case RemoveMode.Undo:
                OkDialog(formattingDlg, formattingDlg.OkDialog);
                RunUI(SkylineWindow.Undo);
                break;

            default:
                Assert.Fail();
                break;
            }

            var groupDef = FindGroupComparison(GROUP_COMPARISON_NAME);

            Assert.AreEqual(initialRowCount, groupDef.ColorRows.Count);
        }