private void DisplayScan() { if (this.reader == null) { return; } try { this.scan.ValidateComponent(); this.minPeakIntensity.ValidateComponent(); double rt = retentionTimes[this.scan.Value - 1]; PeakList <Peak> pkl = reader.GetPeakList(rt, this.minPeakIntensity.Value, topPeak.Value); try { ZedGraphicExtension.ClearData(this.zgcScan, false); var pplLight = new PointPairList(); pkl.ForEach(p => pplLight.Add(p.Mz, p.Intensity)); ZedGraphicExtension.AddIndividualLine(this.zgcScan, MyConvert.Format("Scan {0}", this.scan.Value), pplLight, Color.Blue, false); if (reader.GetMsLevel(rt) == 2) { this.zgcScan.GraphPane.Title.Text = MyConvert.Format("Precursor MZ = {0:0.0000}", pkl.PrecursorMZ); } else { this.zgcScan.GraphPane.Title.Text = string.Empty; } } finally { ZedGraphicExtension.UpdateGraph(this.zgcScan); } StringBuilder sb = new StringBuilder(); pkl.ForEach(m => sb.AppendLine(MyConvert.Format("{0:0.0000}\t{1:0.00}", m.Mz, m.Intensity))); txtPeaks.Text = sb.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Update(object sender, UpdateQuantificationItemEventArgs e) { var summary = e.Item as SilacQuantificationSummaryItem; if (summary == null) { throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null"); } var pplRed = new PointPairList(); var pplGreen = new PointPairList(); var enabled = summary.ObservedEnvelopes.FindAll(m => m.Enabled); enabled.ForEach(m => { PointPairList ppl = m.IsSelected ? pplGreen : pplRed; if (summary.SampleIsLight) { ppl.Add(new PointPair(m.HeavyIntensity, m.LightIntensity, 0.0, m)); } else { ppl.Add(new PointPair(m.LightIntensity, m.HeavyIntensity, 0.0, m)); } }); ZedGraphicExtension.ClearData(this.zgcGraph, false); AddCurve(pplGreen, SilacQuantificationConstants.REFERENCE_COLOR); AddCurve(pplRed, SilacQuantificationConstants.SAMPLE_COLOR); var pplTotal = new PointPairList(); pplTotal.AddRange(pplRed); pplTotal.AddRange(pplGreen); if (pplTotal.Count > 0) { PointPairList line = ZedGraphicExtension.GetRegressionLine(pplTotal, summary.Ratio); ZedGraphicExtension.AddDataToLine(this.zgcGraph, MyConvert.Format("Ratio = {0:0.0000}, Correlation = {1:0.0000}", summary.Ratio, summary.RegressionCorrelation), line, SilacQuantificationConstants.IDENTIFIED_COLOR, false); } ZedGraphicExtension.UpdateGraph(this.zgcGraph); }
private void lvDirectories_SelectedIndexChanged(object sender, EventArgs e) { if (lvFiles.SelectedItems.Count > 0) { string log = lvFiles.SelectedItems[0].Text; SequestLogFormat reader = new SequestLogFormat(); var counts = reader.ReadFromFile(log); ZedGraphicExtension.ClearData(zgc, false); GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Sequest Node Distribution"; myPane.XAxis.Title.Text = "Node"; myPane.YAxis.Title.Text = "Count"; var str = (from c in counts orderby c.Key select c.Key).ToArray(); var y = (from c in counts orderby c.Key select(double) c.Value).ToArray(); BarItem myCurve = myPane.AddBar("NodeCount", null, y, Color.Blue); // Draw the X tics between the labels instead of at the labels myPane.XAxis.MajorTic.IsBetweenLabels = true; // Set the XAxis labels myPane.XAxis.Scale.TextLabels = str; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text; myPane.Legend.IsVisible = false; ZedGraphicExtension.UpdateGraph(zgc); } }
public void Update(IIsotopicProfiles profiles) { ZedGraphicExtension.ClearData(this.zgcGraph, false); try { foreach (var profile in profiles.GetIsotopicProfiles()) { var ppl = new PointPairList(); for (int i = 0; i < profile.Profile.Count; i++) { ppl.Add((i + 1), profile.Profile[i].Intensity); } ZedGraphicExtension.AddDataToBar(this.zgcGraph, ppl, profile.DisplayName, profile.DisplayColor, true); } } finally { ZedGraphicExtension.UpdateGraph(this.zgcGraph); } }
public void Update(object sender, UpdateQuantificationItemEventArgs e) { var summary = e.Item as SilacQuantificationSummaryItem; if (summary == null) { throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null"); } ZedGraphicExtension.ClearData(zgcGraph, false); try { var envelope = summary.ObservedEnvelopes.Find(m => m.IsSelected); if (envelope == null) { return; } double minMz = envelope.Light[0].Mz - 1.0; double maxMz = envelope.Heavy[envelope.Heavy.Count - 1].Mz + 1.0; zgcGraph.GraphPane.XAxis.Scale.Min = minMz; zgcGraph.GraphPane.XAxis.Scale.Max = maxMz; var pplLight = new PointPairList(); envelope.Light.ForEach(p => pplLight.Add(p.Mz, p.Intensity)); var pplHeavy = new PointPairList(); envelope.Heavy.ForEach(p => pplHeavy.Add(p.Mz, p.Intensity)); if (summary.SampleIsLight) { ZedGraphicExtension.AddIndividualLine(zgcGraph, "Sample", pplLight, SilacQuantificationConstants.SAMPLE_COLOR, false); ZedGraphicExtension.AddIndividualLine(zgcGraph, "Reference", pplHeavy, SilacQuantificationConstants.REFERENCE_COLOR, false); } else { ZedGraphicExtension.AddIndividualLine(zgcGraph, "Sample", pplHeavy, SilacQuantificationConstants.SAMPLE_COLOR, false); ZedGraphicExtension.AddIndividualLine(zgcGraph, "Reference", pplLight, SilacQuantificationConstants.REFERENCE_COLOR, false); } // Shift the text items up by 5 user scale units above the bars const float shift = 5; var ppl = new PointPairList(); ppl.AddRange(pplLight); ppl.AddRange(pplHeavy); for (int i = 0; i < ppl.Count; i++) { // format the label string to have 1 decimal place string lab = ppl[i].X.ToString("0.00"); // create the text item (assumes the x axis is ordinal or text) // for negative bars, the label appears just above the zero value var text = new TextObj(lab, ppl[i].X, ppl[i].Y + shift); // tell Zedgraph to use user scale units for locating the TextItem text.Location.CoordinateFrame = CoordType.AxisXYScale; // AlignH the left-center of the text to the specified point text.Location.AlignH = AlignH.Left; text.Location.AlignV = AlignV.Center; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; // rotate the text 90 degrees text.FontSpec.Angle = 90; // add the TextItem to the list zgcGraph.GraphPane.GraphObjList.Add(text); } if (File.Exists(summary.RawFilename)) { if (rawFile == null) { rawFile = new RawFileImpl(summary.RawFilename); } else if (!rawFile.FileName.Equals(summary.RawFilename)) { rawFile.Open(summary.RawFilename); } PeakList <Peak> pkl = rawFile.GetPeakList(envelope.Light.ScanTimes[0].Scan); var pplRaw = new PointPairList(); pplRaw.Add(minMz, 0.0); for (int i = 0; i < pkl.Count; i++) { if (pkl[i].Mz < minMz) { continue; } else if (pkl[i].Mz > maxMz) { break; } pplRaw.Add(pkl[i].Mz, -pkl[i].Intensity); } pplRaw.Add(maxMz, 0.0); ZedGraphicExtension.AddIndividualLine(zgcGraph, "PeakList From RawFile", pplRaw, SilacQuantificationConstants.IDENTIFIED_COLOR, true); } } finally { ZedGraphicExtension.UpdateGraph(zgcGraph); } }
public override void Update(object sender, UpdateQuantificationItemEventArgs e) { var summary = e.Item as O18QuantificationSummaryItem; if (summary == null) { throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null"); } panel.InitGraphPane(this.title, "m/z", "Intensity", true, 0.0); ZedGraphicExtension.ClearData(zgcGraph, false); try { var envelope = summary.ObservedEnvelopes.Find(m => m.IsSelected); if (envelope == null) { return; } panel.InitGraphPane(this.title + ", Scan=" + envelope.Scan.ToString(), "m/z", "Intensity", true, 0.0); double minMz = envelope[0].Mz - 1.0; double maxMz = envelope[envelope.Count - 1].Mz + 1.0; zgcGraph.GraphPane.XAxis.Scale.Min = minMz; zgcGraph.GraphPane.XAxis.Scale.Max = maxMz; var ppl = new PointPairList(); envelope.ForEach(p => { if (p.Intensity > 0) { ppl.Add(p.Mz, p.Intensity); } }); panel.AddIndividualLine("Isotopic Envelope", ppl, Color.Red); panel.AddTextUp(ppl, 5, (m => m.X.ToString("0.0000"))); var halfMax = (from env in envelope select env.Intensity).Max() / 2; ppl.Clear(); envelope.ForEach(p => { if (p.Intensity == 0) { ppl.Add(p.Mz, halfMax); } }); panel.AddIndividualLine("", ppl, defaultColor: Color.Red, dStyle: DashStyle.Dash); panel.AddTextUp(ppl, 5, (m => m.X.ToString("0.0000"))); if (File.Exists(summary.RawFilename)) { if (rawFile == null) { rawFile = RawFileFactory.GetRawFileReader(summary.RawFilename); } else if (!rawFile.FileName.Equals(summary.RawFilename)) { rawFile.Close(); rawFile = RawFileFactory.GetRawFileReader(summary.RawFilename); } PeakList <Peak> pkl = rawFile.GetPeakList(envelope.ScanTimes[0].Scan); var pplRaw = new PointPairList(); for (int i = 0; i < pkl.Count; i++) { if (pkl[i].Mz < minMz) { continue; } else if (pkl[i].Mz > maxMz) { break; } pplRaw.Add(pkl[i].Mz, -pkl[i].Intensity); } panel.AddIndividualLine("PeakList From RawFile", pplRaw, Color.Blue); panel.AddTextDown(pplRaw, 5, (m => m.X.ToString("0.0000"))); /* * foreach (var p in ppl) * { * if (p.Y == 0) * { * double ppm = double.MaxValue; * double ppmAbs = Math.Abs(ppm); * foreach (var pp in pplRaw) * { * double ppmCur = PrecursorUtils.mz2ppm(pp.X, pp.X - p.X); * double ppmCurAbs = Math.Abs(ppmCur); * if (Math.Abs(ppmCur) < ppmAbs) * { * ppm = ppmCur; * ppmAbs = ppmCurAbs; * } * * if (pp.X > p.X) * { * break; * } * } * * p.Z = ppm; * } * } */ } } finally { ZedGraphicExtension.UpdateGraph(zgcGraph); } }