コード例 #1
0
ファイル: ExcludedMzsGrid.cs プロジェクト: zrolfs/pwiz
        public void UpdateGrid()
        {
            double monoisotopicMass =
                Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideAnalysis.Peptide.Sequence);
            var masses = PeptideAnalysis.GetTurnoverCalculator().GetMzs(0);

            if (MassColumn == null)
            {
                MassColumn = new DataGridViewTextBoxColumn
                {
                    HeaderText = "Mass",
                    Name       = "colMass",
                    Width      = 60,
                    ReadOnly   = true,
                };
                Columns.Add(MassColumn);
            }
            if (ExcludedColumn == null)
            {
                ExcludedColumn = new DataGridViewCheckBoxColumn
                {
                    HeaderText = "Excluded",
                    Name       = "colExcluded",
                    Width      = 50,
                    SortMode   = DataGridViewColumnSortMode.NotSortable,
                };
                Columns.Add(ExcludedColumn);
            }
            if (Rows.Count != PeptideAnalysis.GetMassCount())
            {
                Rows.Clear();
                Rows.Add(PeptideAnalysis.GetMassCount());
                for (int iRow = 0; iRow < Rows.Count; iRow++)
                {
                    Rows[iRow].Tag = iRow;
                }
            }
            for (int iRow = 0; iRow < Rows.Count; iRow++)
            {
                var    row            = Rows[iRow];
                var    iMass          = (int)row.Tag;
                double massDifference = masses[iMass].Center - monoisotopicMass;

                var label = massDifference.ToString("0.#");
                if (label[0] != '-')
                {
                    label = "+" + label;
                }
                label = "M" + label;
                row.Cells[MassColumn.Index].Value           = label;
                row.Cells[MassColumn.Index].ToolTipText     = "Mass:" + masses[iMass];
                row.Cells[MassColumn.Index].Style.BackColor = TracerChromatogramForm.GetColor(iRow, Rows.Count);
                row.Cells[ExcludedColumn.Index].Value       = ExcludedMasses.IsMassExcluded(iMass);
            }
        }
コード例 #2
0
ファイル: PeptideAnalysisSummary.cs プロジェクト: zrolfs/pwiz
        private void UpdateGraph()
        {
            zedGraphControl.GraphPane.CurveList.Clear();
            zedGraphControl.GraphPane.GraphObjList.Clear();
            zedGraphControl.GraphPane.Title.IsVisible = false;
            MsDataFile normalizeTo  = null;
            var        fileAnalyses = new List <PeptideFileAnalysis>();

            for (int iRow = 0; iRow < dataGridView.Rows.Count; iRow++)
            {
                fileAnalyses.Add((PeptideFileAnalysis)dataGridView.Rows[iRow].Tag);
            }
            if (fileAnalyses.Count == 0)
            {
                return;
            }
            if (_normalizeRetentionTimes)
            {
                normalizeTo = fileAnalyses[0].MsDataFile;
            }
            var tracerFormulas = PeptideAnalysis.GetTurnoverCalculator().ListTracerFormulas();
            var pointPairLists = tracerFormulas.Select(tf => new PointPairList()).ToArray();

            for (int iFileAnalysis = 0; iFileAnalysis < fileAnalyses.Count; iFileAnalysis++)
            {
                var fileAnalysis = fileAnalyses[iFileAnalysis];
                var peaks        = fileAnalysis.CalculatedPeaks;
                if (peaks == null)
                {
                    continue;
                }
                for (int iTracerFormula = 0; iTracerFormula < tracerFormulas.Count; iTracerFormula++)
                {
                    var pointPairList = pointPairLists[iTracerFormula];
                    var peak          = peaks.GetPeak(tracerFormulas[iTracerFormula]);
                    if (peak == null)
                    {
                        pointPairList.Add(new PointPair(iFileAnalysis + 1, PointPairBase.Missing, PointPairBase.Missing));
                    }
                    else
                    {
                        if (normalizeTo == null)
                        {
                            pointPairList.Add(new PointPair(iFileAnalysis + 1, peak.Value.EndTime, peak.Value.StartTime));
                        }
                        else
                        {
                            var alignment = fileAnalysis.MsDataFile.GetRetentionTimeAlignment(normalizeTo);
                            if (alignment.IsInvalid)
                            {
                                pointPairList.Add(new PointPair(iFileAnalysis + 1, PointPairBase.Missing, PointPairBase.Missing));
                            }
                            else
                            {
                                pointPairList.Add(new PointPair(iFileAnalysis + 1, alignment.GetTargetTime(peak.Value.EndTime), alignment.GetTargetTime(peak.Value.StartTime), fileAnalysis));
                            }
                        }
                    }
                }
            }
            zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
            zedGraphControl.GraphPane.XAxis.Scale.TextLabels =
                fileAnalyses.Select(fileAnalysis => fileAnalysis.MsDataFile.ToString()).ToArray();
            zedGraphControl.GraphPane.XAxis.Title.Text = "Data File";
            zedGraphControl.GraphPane.YAxis.Title.Text = normalizeTo == null ? "Retention Time" : "Normalized Retention Time";

            for (int iTracerFormula = 0; iTracerFormula < tracerFormulas.Count; iTracerFormula++)
            {
                zedGraphControl.GraphPane.AddHiLowBar(tracerFormulas[iTracerFormula].ToDisplayString(),
                                                      pointPairLists[iTracerFormula],
                                                      TracerChromatogramForm.GetColor(iTracerFormula,
                                                                                      tracerFormulas.Count));
            }
            zedGraphControl.GraphPane.AxisChange();
            zedGraphControl.Invalidate();
        }
コード例 #3
0
ファイル: PrecursorPoolForm.cs プロジェクト: zrolfs/pwiz
        public void Recalc()
        {
            zedGraphControl.GraphPane.CurveList.Clear();
            zedGraphControl.GraphPane.GraphObjList.Clear();
            PeptideAnalysis.EnsurePeaksCalculated();
            IDictionary <TracerFormula, double> bestMatch;
            var    peaks         = PeptideFileAnalysis.CalculatedPeaks;
            var    peaksDict     = peaks.ToDictionary();
            var    peaksDictList = peaksDict.ToList();
            double turnover;
            double turnoverScore;
            var    precursorEnrichment = PeptideAnalysis.GetTurnoverCalculator().ComputePrecursorEnrichmentAndTurnover(peaksDict, out turnover, out turnoverScore, out bestMatch);

            dataGridViewPrecursorPool.Rows.Clear();
            if (precursorEnrichment == null)
            {
                tbxTurnover.Text      = "";
                tbxTurnoverScore.Text = "";
                dataGridViewPrecursorPool.Rows.Clear();
            }
            else
            {
                tbxTurnover.Text      = turnover.ToString("0.##%");
                tbxTurnoverScore.Text = turnoverScore.ToString("0.####");
                var tracerDefs = Workspace.GetTracerDefs();
                if (dataGridViewPrecursorPool.Rows.Count != tracerDefs.Count)
                {
                    dataGridViewPrecursorPool.Rows.Clear();
                    dataGridViewPrecursorPool.Rows.Add(tracerDefs.Count);
                }
                for (int i = 0; i < tracerDefs.Count; i++)
                {
                    var tracerDef = tracerDefs[i];
                    var row       = dataGridViewPrecursorPool.Rows[i];
                    row.Cells[colTracer.Index].Value  = tracerDef.Name;
                    row.Cells[colPercent.Index].Value = precursorEnrichment.GetElementCount(tracerDef.Name);
                }
            }
            var observedDistribution = new PointPairList();
            var matchedDistribution  = new PointPairList();
            var labels = new List <string>();

            for (int i = 0; i < peaksDictList.Count(); i++)
            {
                var tracerFormula = peaksDictList[i].Key;
                labels.Add(tracerFormula.ToDisplayString());
                observedDistribution.Add(i, peaksDictList[i].Value);
                if (bestMatch == null)
                {
                    matchedDistribution.Add(i, 1.0);
                }
                else
                {
                    matchedDistribution.Add(i, bestMatch[tracerFormula]);
                }
            }
            zedGraphControl.GraphPane.AddBar("Observed", observedDistribution, Color.Black);
            zedGraphControl.GraphPane.AddBar("Predicted", matchedDistribution, Color.Blue);
            zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
            zedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels.ToArray();
            zedGraphControl.AxisChange();
        }