Ejemplo n.º 1
0
        public void TestPrefixAndSuffixMatches()
        {
            string[] peptides =
            {
                "LATQSNEITIPVTFESRAqLGGPEAAK",
                "LATqSNEITIPVTFESRAQLGGPEAAK",
                "LATQSnEITIPVTFESRAQLGGPEAAK",
                "LATQSnEITIPVTFESRAQLGGPEAAKSDETAAK",
                "LATQSNEITIPVTFESRAQLGGPEAAK",
                "LATQSNEITIPVTFESRAQLGGPEAAKSDETAAK",
                "LATQSNEITIPVTFESRAqLGGPEAAKSDETAAK",
            };
            var uniquePrefixGenerator = new UniquePrefixGenerator(peptides.Select(
                                                                      sequence => new Tuple <string, bool>(sequence, true)), 3);
            Dictionary <string, string> peptideAbbreviations = new Dictionary <string, string>();

            foreach (string peptide in peptides)
            {
                string abbreviation = uniquePrefixGenerator.GetUniquePrefix(peptide, true);
                Assert.IsTrue(abbreviation.Length <= peptide.Length);
                peptideAbbreviations.Add(peptide, abbreviation);
            }
            CollectionAssert.AllItemsAreUnique(peptideAbbreviations.Values);
        }
Ejemplo n.º 2
0
        private void UpdateGraph()
        {
            if (!IsHandleCreated)
            {
                return;
            }
            zedGraphControl.GraphPane.GraphObjList.Clear();
            zedGraphControl.GraphPane.CurveList.Clear();
            _barGraph = null;
            _rows     = null;
            var points = new PointPairList();
            var groupComparisonModel = FoldChangeBindingSource.GroupComparisonModel;
            var groupComparisonDef   = groupComparisonModel.GroupComparisonDef;
            var document             = groupComparisonModel.Document;
            var sequences            = new List <Tuple <string, bool> >();

            foreach (var nodePep in document.Molecules)
            {
                sequences.Add(new Tuple <string, bool>(nodePep.ModifiedTarget.DisplayName, nodePep.IsProteomic));
            }
            var uniquePrefixGenerator = new UniquePrefixGenerator(sequences, 3);
            var textLabels            = new List <string>();
            var rows = _bindingListSource.OfType <RowItem>()
                       .Select(rowItem => rowItem.Value)
                       .OfType <FoldChangeBindingSource.FoldChangeRow>()
                       .ToArray();
            bool showLabelType = rows.Select(row => row.IsotopeLabelType).Distinct().Count() > 1;
            bool showMsLevel   = rows.Select(row => row.MsLevel).Distinct().Count() > 1;
            bool showGroup     = rows.Select(row => row.Group).Distinct().Count() > 1;

            foreach (var row in rows)
            {
                var    foldChangeResult = row.FoldChangeResult;
                double error            = Math.Log(foldChangeResult.MaxFoldChange / foldChangeResult.FoldChange, 2.0);
                var    point            = MeanErrorBarItem.MakePointPair(points.Count, foldChangeResult.Log2FoldChange, error);
                points.Add(point);
                string label;
                if (null != row.Peptide)
                {
                    try
                    {
                        label = uniquePrefixGenerator.GetUniquePrefix(
                            row.Peptide.GetDocNode().ModifiedTarget.DisplayName, row.Peptide.GetDocNode().IsProteomic);
                    }
                    catch
                    {
                        // Peptide must have been deleted.
                        label = row.Peptide.GetDocNode().ModifiedTarget.DisplayName;
                    }
                }
                else
                {
                    label = ProteinMetadataManager.ProteinModalDisplayText(row.Protein.DocNode);
                }
                if (showMsLevel && row.MsLevel.HasValue)
                {
                    label += @" MS" + row.MsLevel; //;
                }
                if (showLabelType && row.IsotopeLabelType != null)
                {
                    label += @" (" + row.IsotopeLabelType.Title + @")";
                }
                if (showGroup && !Equals(row.Group, default(GroupIdentifier)))
                {
                    label += @" " + row.Group;
                }
                textLabels.Add(label);
                if (IsSelected(row))
                {
                    double y, height;
                    if (foldChangeResult.Log2FoldChange >= 0)
                    {
                        y      = foldChangeResult.Log2FoldChange + error;
                        height = y;
                    }
                    else
                    {
                        y      = 0;
                        height = error - foldChangeResult.Log2FoldChange;
                    }
                    zedGraphControl.GraphPane.GraphObjList.Add(new BoxObj(point.X + .5, y, .99, height)
                    {
                        ZOrder = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true
                    });
                }
            }
            zedGraphControl.GraphPane.XAxis.Title.Text = groupComparisonDef.PerProtein ? GroupComparisonStrings.FoldChangeBarGraph_UpdateGraph_Protein : GroupComparisonStrings.FoldChangeBarGraph_UpdateGraph_Peptide;
            zedGraphControl.GraphPane.YAxis.Title.Text = GroupComparisonStrings.FoldChangeBarGraph_UpdateGraph_Log_2_Fold_Change;
            var barGraph = new MeanErrorBarItem(null, points, Color.Black, Color.Blue);

            zedGraphControl.GraphPane.CurveList.Add(barGraph);
            zedGraphControl.GraphPane.XAxis.Scale.MinAuto     = zedGraphControl.GraphPane.XAxis.Scale.MaxAuto =
                zedGraphControl.GraphPane.YAxis.Scale.MinAuto = zedGraphControl.GraphPane.YAxis.Scale.MaxAuto = true;
            zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
            zedGraphControl.GraphPane.XAxis.Scale.TextLabels = textLabels.ToArray();
            _axisLabelScaler.ScaleAxisLabels();
            zedGraphControl.GraphPane.AxisChange();
            zedGraphControl.Invalidate();
            _barGraph = barGraph;
            _rows     = rows;
        }
Ejemplo n.º 3
0
        public void TestUniquePrefix()
        {
            var testSequences = new[, ]
            {
                // Original name on left, expected result on right.
                { null, null },
                { "", "" },
                { "A", "A" },
                { "A", "A" }, // duplicate name (on purpose)
                { "AB", "AB" },
                { "ABC", "ABC" },
                { "ABCD", "ABCD" },
                { "ABCDE", "ABCDE" },
                { "ABCDEF", "ABCDEF" },
                { "ABCDEFG", "ABCDEFG" },
                { "ABCDEFG", "ABCDEFG" }, // duplicate name (on purpose)
                { "ABCDEFGH", "ABC…FGH" },
                { "ABCDEFGHI", "ABC…GHI" },

                { "ABCE", "ABCE" },

                { "ABDEFGHI", "ABD…" },

                { "ABEFGHI", "ABEFGHI" },
                { "ABEFGHIJ", "ABE…HIJ" },
                { "ABEFHI", "ABEFHI" },

                { "ABFFFGHI", "ABF(5)" },
                { "ABFFFFGHI", "ABF(6)" },
                { "ABFFFFAFGHI", "ABF…FA…" },
                { "ABFFFAFFGHI", "ABF…A…" },

                { "ABGAABAABAGHI", "ABG…B…B…" },
                { "ABGAAbAABAGHI", "ABG…b…B…" },
                { "ABGAABAAbAGHI", "ABG…B…b…" },
                { "ABGAAB[80]AAB[99]AGHI", "ABG…b…b…" }
            };
            var testCustomIons = new[, ]
            {
                // Original name on left, expected result on right.
                { "C32:0", "C32:0" },
                { "C32:1", "C32:1" },
                { "C32:2", "C32:2" },
                { "C32:2", "C32:2" }, // Duplicated on purpose
                { "C30:0", "C30:0" },
                { "C[30]:0", "C[30]:0" },
                { "C[400]:0", "C[4…" },
                { "C12:0 fish breath", "C12…" },
                { "C15:0 fish breath", "C15(14)" },
                { "C15:0 doggy breath", "C15(15)" },
                { "C16:0 fishy breath", "C16…f…" },
                { "C16:0 doggy breath", "C16…d…" },
                { "C14", "C14" },
                { "C14:1", "C14:1" },
                { "C14:1-OH", "C14:1…" },
                { "C14:2", "C14:2" },
                { "C14:2-OH", "C14:2…" }
            };

            for (var loop = 2; loop > 0; loop--)
            {
                var strings    = new List <Tuple <string, bool> >();
                var commontext = (loop == 1) ? String.Empty : "Delta Niner Foxtrot "; // non-peptides should strip leading common text

                for (int i = 0; i < testSequences.GetLength(0); i++)
                {
                    strings.Add(new Tuple <string, bool>(testSequences[i, 0], true));
                }
                for (int i = 0; i < testCustomIons.GetLength(0); i++)
                {
                    strings.Add(new Tuple <string, bool>(commontext + testCustomIons[i, 0], false));
                }
                var prefixGenerator = new UniquePrefixGenerator(strings, 3);
                for (int i = 0; i < testSequences.GetLength(0); i++)
                {
                    var expected     = testSequences[i, 1];
                    var uniquePrefix = prefixGenerator.GetUniquePrefix(testSequences[i, 0], true);
                    Assert.AreEqual(expected, uniquePrefix);
                }
                for (int i = 0; i < testCustomIons.GetLength(0); i++)
                {
                    var expected     = testCustomIons[i, 1];
                    var uniquePrefix = prefixGenerator.GetUniquePrefix(commontext + testCustomIons[i, 0], false);
                    Assert.AreEqual(expected, uniquePrefix);
                }
            }
        }