Пример #1
0
        private List <Tuple <string, string, string> > GetPossibleRatios()
        {
            IReport reportPeptideRatios = _toolClient.GetReport("BLR Peptide Ratios");
            var     PeptideList         = reportPeptideRatios.Cells.Where(p => p[3] != null).Select(p => p[3]).Distinct();
            var     PossibleRatios      = from peptideN in PeptideList
                                          from peptideD in PeptideList
                                          where peptideN != peptideD
                                          select Tuple.Create(Peptide.GetPeptideShortName(peptideN),
                                                              Peptide.GetPeptideShortName(peptideD),
                                                              String.Format("{0}/{1}", Peptide.GetPeptideShortName(peptideN), Peptide.GetPeptideShortName(peptideD)));

            return(PossibleRatios.ToList());
        }
Пример #2
0
        private void BuildPeptideRatiosGraph()
        {
            IReport reportPeptideRatios = _toolClient.GetReport("BLR Peptide Ratios");
            var     graph     = this.graphPeptideRatios;
            var     graphPane = this.graphPeptideRatios.GraphPane;

            graphPane.CurveList.Clear();
            Color[]       graphColors    = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Gray };
            Queue <Color> queColors      = new Queue <Color>(graphColors);
            var           PeptideList    = reportPeptideRatios.Cells.Where(p => p[3] != null).Select(p => p[3]).Distinct();
            var           PossibleRatios = from peptideN in PeptideList.Select(p => Peptide.GetPeptideShortName(p))
                                           from peptideD in PeptideList.Select(p => Peptide.GetPeptideShortName(p))
                                           where peptideN != peptideD &&
                                           _peptideIntStdConcentrations.ContainsKey(peptideN) &&
                                           _peptideIntStdConcentrations.ContainsKey(peptideD)
                                           select new
            {
                Nominator   = peptideN,
                Denominator = peptideD,
                RatioName   = String.Format("{0}/{1}", peptideN, peptideD),
                CorCoef     = _peptideIntStdConcentrations[peptideN] / _peptideIntStdConcentrations[peptideD]
            };
            var SelectedRatios = from mnuItem in mnuRatioSelection.DropDownItems.Cast <ToolStripMenuItem>()
                                 where mnuItem.Checked
                                 select mnuItem.Text;
            var GrouppedByPeptide = from reportRow in reportPeptideRatios.Cells
                                    group reportRow by Peptide.GetPeptideShortName(reportRow[3]) into GrouppedRows
                                    select new { Peptide = GrouppedRows.Key, Rows = GrouppedRows };

            foreach (var ratioVariant in PossibleRatios)
            {
                var Nominators   = GrouppedByPeptide.Where(p => p.Peptide == ratioVariant.Nominator).Single().Rows.Where(r => r[4] != null).Select(r => r);
                var Denominators = GrouppedByPeptide.Where(p => p.Peptide == ratioVariant.Denominator).Single().Rows.Where(r => r[4] != null).Select(r => r);
                var Ratios       = Nominators.Join(Denominators,
                                                   n => n[0], d => d[0],
                                                   (n, d) => new
                {
                    FileName     = n[0],
                    PeptideRatio = ConvertUtil.doubleTryParse(n[4]) / ConvertUtil.doubleTryParse(d[4]) * ratioVariant.CorCoef
                });
                if (SelectedRatios.Contains(ratioVariant.RatioName))
                {
                    graphPane.AddBar(ratioVariant.RatioName, null, Ratios.Select(r => r.PeptideRatio).ToArray(), queColors.Dequeue());
                    graphPane.XAxis.Scale.TextLabels = Ratios.Select(f => AnalysisResults.GetMSRunShorten(f.FileName, "0, 5")).ToArray();
                }
            }
            graphPane.XAxis.MajorTic.IsBetweenLabels = true;
            graphPane.XAxis.Type = ZedGraph.AxisType.Text;
            graph.AxisChange();
            graph.Refresh();
        }