Ejemplo n.º 1
0
        protected override void Recalc()
        {
            cbxAutoFindPeak.Checked = PeptideFileAnalysis.AutoFindPeak;
            cbxSmooth.Checked       = Smooth;
            MsGraphControl.GraphPane.GraphObjList.Clear();
            MsGraphControl.GraphPane.CurveList.Clear();
            _peakLines = null;
            if (!PeptideFileAnalysis.IsMzKeySetComplete(PeptideFileAnalysis.ChromatogramSet.Chromatograms.Keys))
            {
                return;
            }
            var overlayFileAnalysis = UpdateDataFileCombo(comboOverlay);
            var peakLines           = new Dictionary <TracerFormula, PeakDisplay>();
            var tracerChromatograms = GetPoints();
            TracerChromatograms overlayTracerChromatograms = null;

            double[] mappedTimes = null;
            if (overlayFileAnalysis != null)
            {
                overlayTracerChromatograms = overlayFileAnalysis.GetTracerChromatograms(Smooth);
                var retentionTimeAlignment =
                    overlayFileAnalysis.MsDataFile.GetRetentionTimeAlignment(PeptideFileAnalysis.MsDataFile);
                mappedTimes =
                    overlayTracerChromatograms.Times.Select(retentionTimeAlignment.GetTargetTime).ToArray();
            }
            var peaks   = PeptideFileAnalysis.CalculatedPeaks;
            var entries = tracerChromatograms.Points.ToArray();

            if (dataGridView1.Rows.Count != entries.Length)
            {
                dataGridView1.Rows.Clear();
                dataGridView1.Rows.Add(entries.Length);
            }
            if (cbxShowScore.Checked)
            {
                var scoreLine = MsGraphControl.GraphPane.AddCurve("Score", tracerChromatograms.Times.ToArray(), tracerChromatograms.Scores.ToArray(), Color.Black, SymbolType.None);
                scoreLine.IsY2Axis   = true;
                scoreLine.Line.Width = Settings.Default.ChromatogramLineWidth;
            }
            double totalAmount = peaks.Peaks.Values.Sum(p => p.Area);
            double totalSlope  = peaks.Peaks.Values.Sum(p => p.RatioToBase);

            for (int iCandidate = 0; iCandidate < entries.Count(); iCandidate++)
            {
                var entry = entries[iCandidate];
                var label = entry.Key.ToDisplayString();
                var row   = dataGridView1.Rows[iCandidate];
                row.Cells[colFormula.Index].Value = label;
                var peak = peaks.GetPeak(entry.Key);
                if (peak != null)
                {
                    row.Cells[colAreaPct.Index].Value   = peak.Value.Area / totalAmount;
                    row.Cells[colSlopePct.Index].Value  = peak.Value.RatioToBase / totalSlope;
                    row.Cells[colStartTime.Index].Value = peak.Value.StartTime;
                    row.Cells[colEndTime.Index].Value   = peak.Value.EndTime;
                    row.Cells[colArea.Index].Value      = peak.Value.Area;
                    row.Cells[colCorr.Index].Value      = peak.Value.Correlation;
                }
                else
                {
                    row.Cells[colAreaPct.Index].Value   = null;
                    row.Cells[colStartTime.Index].Value = null;
                    row.Cells[colEndTime.Index].Value   = null;
                    row.Cells[colArea.Index].Value      = null;
                    row.Cells[colCorr.Index].Value      = null;
                }
                row.Cells[colFormula.Index].Style.BackColor             = row.Cells[colAreaPct.Index].Style.BackColor
                                                                        = GetColor(iCandidate, entries.Length);
                row.Tag = entry.Key;
                if (IsDisplayed(entry.Key))
                {
                    var curve = new ChromatogramGraphItem
                    {
                        Title  = label,
                        Color  = GetColor(iCandidate, entries.Length),
                        Points = new PointPairList(tracerChromatograms.Times, entry.Value),
                    };
                    var chromCurveItem = (LineItem)MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, curve);
                    chromCurveItem.Label.IsVisible = false;
                    chromCurveItem.Line.Width      = Settings.Default.ChromatogramLineWidth;
                    if (overlayTracerChromatograms != null)
                    {
                        var overlayCurve = new ChromatogramGraphItem
                        {
                            Title  = overlayFileAnalysis.MsDataFile.Label + " " + label,
                            Color  = GetColor(iCandidate, entries.Length),
                            Points =
                                new PointPairList(mappedTimes,
                                                  overlayTracerChromatograms.Points[entry.Key])
                        };
                        var overlayCurveItem = (LineItem)MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, overlayCurve);
                        overlayCurveItem.Label.IsVisible = false;
                        overlayCurveItem.Line.Style      = DashStyle.Dash;
                        overlayCurveItem.Line.Width      = Settings.Default.ChromatogramLineWidth;
                    }
                    if (peak != null)
                    {
                        var peakDisplay = new PeakDisplay();
                        var color       = GetColor(iCandidate, entries.Length);
                        var max         = MaxInRange(entry.Value, tracerChromatograms.ChromatogramSet.IndexFromTime(peak.Value.StartTime),
                                                     tracerChromatograms.ChromatogramSet.IndexFromTime(peak.Value.EndTime));
                        peakDisplay.Start  = peak.Value.StartTime;
                        peakDisplay.End    = peak.Value.EndTime;
                        peakDisplay.Height = max;
                        if (PeaksAsHorizontalLines)
                        {
                            peakDisplay.HorizontalLine            = MsGraphControl.GraphPane.AddCurve(null, new[] { peakDisplay.Start, peakDisplay.End }, new[] { max, max }, color);
                            peakDisplay.HorizontalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                        }
                        if (PeaksAsVerticalLines)
                        {
                            peakDisplay.StartVerticalLine = MsGraphControl.GraphPane.AddCurve(
                                null,
                                new[] { peakDisplay.Start, peakDisplay.Start },
                                new[] { max, 0 }, color, SymbolType.None
                                );
                            peakDisplay.StartVerticalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                            peakDisplay.EndVerticalLine = MsGraphControl.GraphPane.AddCurve(
                                null,
                                new[] { peakDisplay.End, peakDisplay.End },
                                new[] { max, 0 }, color, SymbolType.None
                                );
                            peakDisplay.EndVerticalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                        }
                        peakLines.Add(entry.Key, peakDisplay);
                    }
                }
            }
//            foreach (var peakSet in tracerChromatograms.GetNonOverlappingPeakSets())
//            {
//                double start = PeptideFileAnalysis.TimeFromScanIndex(peakSet.StartIndex);
//                double end = PeptideFileAnalysis.TimeFromScanIndex(peakSet.EndIndex);
//                double rawScore = tracerChromatograms.GetScore(peakSet.StartIndex, peakSet.EndIndex);
//                double colorScore = Math.Pow(rawScore, 4);
//                var color = Color.FromArgb((int) (255 - (255*colorScore)), (int) (255*colorScore), 0);
//                var box = new BoxObj(start, int.MaxValue, end - start, int.MaxValue, Color.Black, color)
//                              {
//                                  IsClippedToChartRect = true,
//                                  ZOrder = ZOrder.F_BehindGrid,
//                              };
//                msGraphControl.GraphPane.GraphObjList.Add(box);
//                double retentionTime = tracerChromatograms.Times[peakSet.BestRetentionTime];
//                double intensity = tracerChromatograms.GetMaxIntensity(peakSet);
//                var textObj = new TextObj(retentionTime.ToString("0.##"), retentionTime,
//                                          intensity, CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom)
//                                  {
//                                      FontSpec = {Fill = new Fill(color),},
//                                      Tag = peakSet,
//                                  };
//                msGraphControl.GraphPane.GraphObjList.Add(textObj);
//            }
            if (PeptideFileAnalysis.PsmTimes != null)
            {
                foreach (var time in PeptideFileAnalysis.PsmTimes.SelectMany(entry => entry.Value))
                {
                    MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.LightBlue, time, 0, time,
                                                                          1)
                    {
                        Line   = { Style = DashStyle.DashDot },
                        ZOrder = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true,
                        Location             = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    });
                }
            }
            else
            {
                var    otherPeaks = PeptideAnalysis.FileAnalyses.Select(f => f.CalculatedPeaks);
                double firstDetectedTime, lastDetectedTime;
                PeptideFileAnalysis.CalculatedPeaks.GetFirstLastTimes(otherPeaks, out firstDetectedTime, out lastDetectedTime);
                MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.Black, firstDetectedTime, 0,
                                                                      firstDetectedTime, 1)
                {
                    Line   = { Style = DashStyle.DashDotDot },
                    ZOrder = ZOrder.E_BehindCurves,
                    IsClippedToChartRect = true,
                    Location             = { CoordinateFrame = CoordType.XScaleYChartFraction }
                });
                MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.Black, lastDetectedTime, 0,
                                                                      lastDetectedTime, 1)
                {
                    Line   = { Style = DashStyle.DashDotDot },
                    ZOrder = ZOrder.E_BehindCurves,
                    IsClippedToChartRect = true,
                    Location             = { CoordinateFrame = CoordType.XScaleYChartFraction }
                });
            }

            MsGraphControl.AxisChange();
            MsGraphControl.Invalidate();
            _peakLines = peakLines;
            tbxTracerPercentByAreas.Text  = peaks.CalcTracerPercentByAreas().ToString();
            tbxTracerPercentBySlopes.Text = peaks.CalcTracerPercentByRatios().ToString();
            tbxScore.Text = peaks.DeconvolutionScore.ToString();
            double rtShift, rtStdDev;

            peaks.RetentionTimeShift(out rtShift, out rtStdDev);
            var retentionTimeShift = rtShift.ToString("#.00");

            if (!double.IsNaN(rtStdDev) && !double.IsInfinity(rtStdDev))
            {
                retentionTimeShift += "+/-" + rtStdDev.ToString("#.00");
            }
            tbxRetentionTimeShift.Text = retentionTimeShift;
        }
Ejemplo n.º 2
0
        protected override void Recalc()
        {
            cbxAutoFindPeak.Checked = PeptideFileAnalysis.AutoFindPeak;
            cbxSmooth.Checked = Smooth;
            MsGraphControl.GraphPane.GraphObjList.Clear();
            MsGraphControl.GraphPane.CurveList.Clear();
            _peakLines = null;
            if (!PeptideFileAnalysis.IsMzKeySetComplete(PeptideFileAnalysis.ChromatogramSet.Chromatograms.Keys))
            {
                return;
            }
            var overlayFileAnalysis = UpdateDataFileCombo(comboOverlay);
            var peakLines = new Dictionary<TracerFormula, PeakDisplay>();
            var tracerChromatograms = GetPoints();
            TracerChromatograms overlayTracerChromatograms = null;
            double[] mappedTimes = null;
            if (overlayFileAnalysis != null)
            {
                overlayTracerChromatograms = overlayFileAnalysis.GetTracerChromatograms(Smooth);
                var retentionTimeAlignment =
                    overlayFileAnalysis.MsDataFile.GetRetentionTimeAlignment(PeptideFileAnalysis.MsDataFile);
                mappedTimes =
                    overlayTracerChromatograms.Times.Select(retentionTimeAlignment.GetTargetTime).ToArray();
            }
            var peaks = PeptideFileAnalysis.CalculatedPeaks;
            var entries = tracerChromatograms.Points.ToArray();
            if (dataGridView1.Rows.Count != entries.Length)
            {
                dataGridView1.Rows.Clear();
                dataGridView1.Rows.Add(entries.Length);
            }
            if (cbxShowScore.Checked)
            {
                var scoreLine = MsGraphControl.GraphPane.AddCurve("Score", tracerChromatograms.Times.ToArray(), tracerChromatograms.Scores.ToArray(), Color.Black, SymbolType.None);
                scoreLine.IsY2Axis = true;
                scoreLine.Line.Width = Settings.Default.ChromatogramLineWidth;
            }
            double totalAmount = peaks.Peaks.Values.Sum(p => p.Area);
            double totalSlope = peaks.Peaks.Values.Sum(p => p.RatioToBase);
            for (int iCandidate = 0; iCandidate < entries.Count(); iCandidate++)
            {
                var entry = entries[iCandidate];
                var label = entry.Key.ToDisplayString();
                var row = dataGridView1.Rows[iCandidate];
                row.Cells[colFormula.Index].Value = label;
                var peak = peaks.GetPeak(entry.Key);
                if (peak != null)
                {
                    row.Cells[colAreaPct.Index].Value = peak.Value.Area/totalAmount;
                    row.Cells[colSlopePct.Index].Value = peak.Value.RatioToBase/totalSlope;
                    row.Cells[colStartTime.Index].Value = peak.Value.StartTime;
                    row.Cells[colEndTime.Index].Value = peak.Value.EndTime;
                    row.Cells[colArea.Index].Value = peak.Value.Area;
                    row.Cells[colCorr.Index].Value = peak.Value.Correlation;
                }
                else
                {
                    row.Cells[colAreaPct.Index].Value = null;
                    row.Cells[colStartTime.Index].Value = null;
                    row.Cells[colEndTime.Index].Value = null;
                    row.Cells[colArea.Index].Value = null;
                    row.Cells[colCorr.Index].Value = null;
                }
                row.Cells[colFormula.Index].Style.BackColor = row.Cells[colAreaPct.Index].Style.BackColor
                    = GetColor(iCandidate, entries.Length);
                row.Tag = entry.Key;
                if (IsDisplayed(entry.Key))
                {
                    var curve = new ChromatogramGraphItem
                    {
                        Title = label,
                        Color = GetColor(iCandidate, entries.Length),
                        Points = new PointPairList(tracerChromatograms.Times, entry.Value),
                    };
                    var chromCurveItem = (LineItem) MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, curve);
                    chromCurveItem.Label.IsVisible = false;
                    chromCurveItem.Line.Width = Settings.Default.ChromatogramLineWidth;
                    if (overlayTracerChromatograms != null)
                    {
                        var overlayCurve = new ChromatogramGraphItem
                                               {
                                                   Title = overlayFileAnalysis.MsDataFile.Label + " " + label,
                                                   Color = GetColor(iCandidate, entries.Length),
                                                   Points =
                                                       new PointPairList(mappedTimes,
                                                                         overlayTracerChromatograms.Points[entry.Key])
                                               };
                        var overlayCurveItem = (LineItem) MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, overlayCurve);
                        overlayCurveItem.Label.IsVisible = false;
                        overlayCurveItem.Line.Style = DashStyle.Dash;
                        overlayCurveItem.Line.Width = Settings.Default.ChromatogramLineWidth;
                    }
                    if (peak != null)
                    {
                        var peakDisplay = new PeakDisplay();
                        var color = GetColor(iCandidate, entries.Length);
                        var max = MaxInRange(entry.Value, tracerChromatograms.ChromatogramSet.IndexFromTime(peak.Value.StartTime),
                            tracerChromatograms.ChromatogramSet.IndexFromTime(peak.Value.EndTime));
                        peakDisplay.Start = peak.Value.StartTime;
                        peakDisplay.End = peak.Value.EndTime;
                        peakDisplay.Height = max;
                        if (PeaksAsHorizontalLines)
                        {
                            peakDisplay.HorizontalLine = MsGraphControl.GraphPane.AddCurve(null, new[] { peakDisplay.Start, peakDisplay.End }, new[] { max, max }, color);
                            peakDisplay.HorizontalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                        }
                        if (PeaksAsVerticalLines)
                        {
                            peakDisplay.StartVerticalLine = MsGraphControl.GraphPane.AddCurve(
                                null,
                                new[] { peakDisplay.Start, peakDisplay.Start },
                                new[] {max, 0}, color, SymbolType.None
                            );
                            peakDisplay.StartVerticalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                            peakDisplay.EndVerticalLine = MsGraphControl.GraphPane.AddCurve(
                                null,
                                new[] { peakDisplay.End, peakDisplay.End },
                                new[] { max, 0 }, color, SymbolType.None
                            );
                            peakDisplay.EndVerticalLine.Line.Width = Settings.Default.ChromatogramLineWidth;
                        }
                        peakLines.Add(entry.Key, peakDisplay);
                    }
                }
            }
            //            foreach (var peakSet in tracerChromatograms.GetNonOverlappingPeakSets())
            //            {
            //                double start = PeptideFileAnalysis.TimeFromScanIndex(peakSet.StartIndex);
            //                double end = PeptideFileAnalysis.TimeFromScanIndex(peakSet.EndIndex);
            //                double rawScore = tracerChromatograms.GetScore(peakSet.StartIndex, peakSet.EndIndex);
            //                double colorScore = Math.Pow(rawScore, 4);
            //                var color = Color.FromArgb((int) (255 - (255*colorScore)), (int) (255*colorScore), 0);
            //                var box = new BoxObj(start, int.MaxValue, end - start, int.MaxValue, Color.Black, color)
            //                              {
            //                                  IsClippedToChartRect = true,
            //                                  ZOrder = ZOrder.F_BehindGrid,
            //                              };
            //                msGraphControl.GraphPane.GraphObjList.Add(box);
            //                double retentionTime = tracerChromatograms.Times[peakSet.BestRetentionTime];
            //                double intensity = tracerChromatograms.GetMaxIntensity(peakSet);
            //                var textObj = new TextObj(retentionTime.ToString("0.##"), retentionTime,
            //                                          intensity, CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom)
            //                                  {
            //                                      FontSpec = {Fill = new Fill(color),},
            //                                      Tag = peakSet,
            //                                  };
            //                msGraphControl.GraphPane.GraphObjList.Add(textObj);
            //            }
            if (PeptideFileAnalysis.PsmTimes != null)
            {
                foreach (var time in PeptideFileAnalysis.PsmTimes.SelectMany(entry=>entry.Value))
                {
                    MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.LightBlue, time, 0, time,
                                                                          1)
                    {
                        Line = { Style = DashStyle.DashDot },
                        ZOrder = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true,
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    });

                }
            }
            else
            {
                var otherPeaks = PeptideAnalysis.FileAnalyses.Select(f => f.CalculatedPeaks);
                double firstDetectedTime, lastDetectedTime;
                PeptideFileAnalysis.CalculatedPeaks.GetFirstLastTimes(otherPeaks, out firstDetectedTime, out lastDetectedTime);
                MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.Black, firstDetectedTime, 0,
                                                                      firstDetectedTime, 1)
                                                              {
                                                                  Line = {Style = DashStyle.DashDotDot},
                                                                  ZOrder = ZOrder.E_BehindCurves,
                                                                  IsClippedToChartRect = true,
                                                                  Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                                                              });
                MsGraphControl.GraphPane.GraphObjList.Add(new LineObj(Color.Black, lastDetectedTime, 0,
                                                                      lastDetectedTime, 1)
                    {
                        Line = { Style = DashStyle.DashDotDot },
                        ZOrder = ZOrder.E_BehindCurves,
                        IsClippedToChartRect = true,
                        Location = { CoordinateFrame = CoordType.XScaleYChartFraction }
                    });
            }

            MsGraphControl.AxisChange();
            MsGraphControl.Invalidate();
            _peakLines = peakLines;
            tbxTracerPercentByAreas.Text = peaks.CalcTracerPercentByAreas().ToString();
            tbxTracerPercentBySlopes.Text = peaks.CalcTracerPercentByRatios().ToString();
            tbxScore.Text = peaks.DeconvolutionScore.ToString();
            double rtShift, rtStdDev;
            peaks.RetentionTimeShift(out rtShift, out rtStdDev);
            var retentionTimeShift = rtShift.ToString("#.00");
            if (!double.IsNaN(rtStdDev) && !double.IsInfinity(rtStdDev))
            {
                retentionTimeShift += "+/-" + rtStdDev.ToString("#.00");
            }
            tbxRetentionTimeShift.Text = retentionTimeShift;
        }
Ejemplo n.º 3
0
        protected void ShowChromatograms()
        {
            if (MsGraphControl.GraphPane == null)
            {
                // TODO: How can this happen?
                return;
            }
            MsGraphControl.GraphPane.GraphObjList.Clear();
            MsGraphControl.GraphPane.CurveList.Clear();
            var selectedCharges  = gridIntensities.GetSelectedCharges();
            var selectedMasses   = gridIntensities.GetSelectedMasses();
            var chromatograms    = PeptideFileAnalysis.ChromatogramSet;
            var mzRanges         = PeptideFileAnalysis.TurnoverCalculator.GetMzs(0);
            var monoisotopicMass = Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideAnalysis.Peptide.Sequence);

            for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++)
            {
                if (selectedCharges.Count > 0 && !selectedCharges.Contains(charge))
                {
                    continue;
                }
                for (int iMass = 0; iMass < PeptideAnalysis.GetMassCount(); iMass++)
                {
                    var    mzKey          = new MzKey(charge, iMass);
                    double massDifference = mzRanges[iMass].Center - monoisotopicMass;

                    var label = massDifference.ToString("0.#");
                    if (label[0] != '-')
                    {
                        label = "+" + label;
                    }
                    label  = "M" + label;
                    label += new string('+', charge);

                    if (selectedMasses.Count > 0)
                    {
                        if (!selectedMasses.Contains(iMass))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (ExcludedMasses.IsExcluded(mzKey.MassIndex))
                        {
                            continue;
                        }
                    }
                    ChromatogramSetData.Chromatogram chromatogram;
                    if (!chromatograms.Chromatograms.TryGetValue(mzKey, out chromatogram))
                    {
                        continue;
                    }
                    var graphItem = new ChromatogramGraphItem
                    {
                        Title = label,
                    };
                    graphItem.Color = TracerChromatogramForm.GetColor(iMass, PeptideAnalysis.GetMassCount());
                    var mzRange      = PeptideFileAnalysis.TurnoverCalculator.GetMzs(mzKey.Charge)[mzKey.MassIndex];
                    var massAccuracy = PeptideAnalysis.GetMassAccuracy();
                    var intensities  = chromatogram.ChromatogramPoints.Select(point => point.GetIntensity(mzRange, massAccuracy)).ToArray();
                    if (Smooth)
                    {
                        intensities = TracerChromatograms.SavitzkyGolaySmooth(intensities);
                    }
                    PointPairList points = new PointPairList(chromatograms.Times, intensities);
                    graphItem.Points = points;
                    var lineItem = (LineItem)MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, graphItem);
                    lineItem.Line.Style      = TracerChromatogramForm.GetDashStyle(charge - PeptideAnalysis.MinCharge);
                    lineItem.Line.Width      = Settings.Default.ChromatogramLineWidth;
                    lineItem.Label.IsVisible = false;
                }
            }
        }
Ejemplo n.º 4
0
        protected void ShowChromatograms()
        {
            if (MsGraphControl.GraphPane == null)
            {
                // TODO: How can this happen?
                return;
            }
            MsGraphControl.GraphPane.GraphObjList.Clear();
            MsGraphControl.GraphPane.CurveList.Clear();
            var selectedCharges = gridIntensities.GetSelectedCharges();
            var selectedMasses = gridIntensities.GetSelectedMasses();
            var chromatograms = PeptideFileAnalysis.ChromatogramSet;
            var mzRanges = PeptideFileAnalysis.TurnoverCalculator.GetMzs(0);
            var monoisotopicMass = Workspace.GetAminoAcidFormulas().GetMonoisotopicMass(PeptideAnalysis.Peptide.Sequence);
            for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge++)
            {
                if (selectedCharges.Count > 0 && !selectedCharges.Contains(charge))
                {
                    continue;
                }
                for (int iMass = 0; iMass < PeptideAnalysis.GetMassCount(); iMass++)
                {
                    var mzKey = new MzKey(charge, iMass);
                    double massDifference = mzRanges[iMass].Center - monoisotopicMass;

                    var label = massDifference.ToString("0.#");
                    if (label[0] != '-')
                    {
                        label = "+" + label;
                    }
                    label = "M" + label;
                    label += new string('+', charge);

                    if (selectedMasses.Count > 0)
                    {
                        if (!selectedMasses.Contains(iMass))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (ExcludedMasses.IsExcluded(mzKey.MassIndex))
                        {
                            continue;
                        }
                    }
                    ChromatogramSetData.Chromatogram chromatogram;
                    if (!chromatograms.Chromatograms.TryGetValue(mzKey, out chromatogram))
                    {
                        continue;
                    }
                    var graphItem = new ChromatogramGraphItem
                                        {
                                            Title = label,
                                        };
                    graphItem.Color = TracerChromatogramForm.GetColor(iMass, PeptideAnalysis.GetMassCount());
                    var mzRange = PeptideFileAnalysis.TurnoverCalculator.GetMzs(mzKey.Charge)[mzKey.MassIndex];
                    var massAccuracy = PeptideAnalysis.GetMassAccuracy();
                    var intensities = chromatogram.ChromatogramPoints.Select(point => point.GetIntensity(mzRange, massAccuracy)).ToArray();
                    if (Smooth)
                    {
                        intensities = TracerChromatograms.SavitzkyGolaySmooth(intensities);
                    }
                    PointPairList points = new PointPairList(chromatograms.Times, intensities);
                    graphItem.Points = points;
                    var lineItem = (LineItem)MsGraphControl.AddGraphItem(MsGraphControl.GraphPane, graphItem);
                    lineItem.Line.Style = TracerChromatogramForm.GetDashStyle(charge - PeptideAnalysis.MinCharge);
                    lineItem.Line.Width = Settings.Default.ChromatogramLineWidth;
                    lineItem.Label.IsVisible = false;
                }
            }
        }