Exemplo n.º 1
0
        protected override bool MsGraphControlOnMouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            if (_peakResize != null)
            {
                var    point = new PointF(e.X - _peakResize.MousePt.X + _peakResize.CoordPt.X, e.Y);
                double x, y;
                MsGraphControl.GraphPane.ReverseTransform(point, out x, out y);
                var    peaks = PeptideFileAnalysis.CalculatedPeaks;
                double newStart, newEnd;
                switch (_peakResize.LineSegment)
                {
                case LineSegment.Start:
                    newStart = x;
                    newEnd   = _peakResize.Peak.EndTime;
                    break;

                case LineSegment.End:
                    newStart = _peakResize.Peak.StartTime;
                    newEnd   = x;
                    break;

                default:
                    newStart = x;
                    newEnd   = x - _peakResize.Peak.StartTime + _peakResize.Peak.EndTime;
                    break;
                }
                var newPeaks = peaks.ChangeTime(_peakResize.TracerFormula, Math.Min(newStart, newEnd), Math.Max(newStart, newEnd));
                _peakResize = null;
                PeptideFileAnalysis.SetCalculatedPeaks(newPeaks);
                PeptideAnalysis.EnsurePeaksCalculated();
            }
            return(base.MsGraphControlOnMouseUpEvent(sender, e));
        }
Exemplo n.º 2
0
 protected void SetAutoFindPeak(bool autoFindPeak)
 {
     if (autoFindPeak == PeptideFileAnalysis.AutoFindPeak)
     {
         return;
     }
     if (autoFindPeak)
     {
         PeptideFileAnalysis.SetAutoFindPeak();
     }
     else
     {
         PeptideAnalysis.EnsurePeaksCalculated();
         var newPeaks = PeptideFileAnalysis.CalculatedPeaks.ChangeBasePeak(PeptideFileAnalysis.CalculatedPeaks.BasePeakKey);
         Debug.Assert(!newPeaks.AutoFindPeak);
         PeptideFileAnalysis.SetCalculatedPeaks(newPeaks);
     }
 }
Exemplo n.º 3
0
        protected void OnPeptideAnalysisChanged()
        {
            PeptideAnalysis.EnsurePeaksCalculated();
            var res = Workspace.GetAminoAcidFormulas();

            tbxFormula.Text      = res.GetFormula(Peptide.Sequence).ToString();
            tbxMonoMass.Text     = Peptide.GetChargedPeptide(1).GetMonoisotopicMass(res).ToString("0.####");
            tbxAvgMass.Text      = Peptide.GetChargedPeptide(1).GetMassDistribution(res).AverageMass.ToString("0.####");
            tbxMinCharge.Text    = PeptideAnalysis.MinCharge.ToString(CultureInfo.CurrentCulture);
            tbxMaxCharge.Text    = PeptideAnalysis.MaxCharge.ToString(CultureInfo.CurrentCulture);
            tbxProtein.Text      = Peptide.ProteinName + " " + Peptide.ProteinDescription;
            tbxMassAccuracy.Text = PeptideAnalysis.GetMassAccuracy().ToString(CultureInfo.CurrentCulture);
            if (PeptideAnalysis.MassAccuracy == null)
            {
                tbxMassAccuracy.Font = Font;
            }
            else
            {
                tbxMassAccuracy.Font = new Font(Font, FontStyle.Bold);
            }
            if (_originalMinCharge.HasValue && _originalMinCharge != PeptideAnalysis.MinCharge)
            {
                tbxMinCharge.Font = new Font(Font, FontStyle.Bold);
            }
            else
            {
                tbxMinCharge.Font = Font;
            }
            if (_originalMaxCharge.HasValue && _originalMaxCharge != PeptideAnalysis.MaxCharge)
            {
                tbxMaxCharge.Font = new Font(Font, FontStyle.Bold);
            }
            else
            {
                tbxMaxCharge.Font = Font;
            }

            UpdateMassGrid();
            UpdateRows(PeptideAnalysis.FileAnalyses);
        }
Exemplo n.º 4
0
        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();
        }