Exemple #1
0
        private void AddPairedPeakList(MS3XcorrItem ms3, ZedGraphControl zgc, int scan1, int scan2)
        {
            zgc.GraphPane.ClearData();

            var s1 = GetPeakList(scan1);
            var s2 = GetPeakList(scan2);

            var ppl1 = new PointPairList();

            foreach (var m in s1)
            {
                ppl1.Add(new PointPair(m.Mz, m.Intensity));
            }
            zgc.GraphPane.AddIndividualLine(ms3.Sequence1 + ":" + scan1.ToString(), ppl1, Color.Red);

            var ppl2 = new PointPairList();

            foreach (var m in s2)
            {
                ppl2.Add(new PointPair(m.Mz, -m.Intensity));
            }
            zgc.GraphPane.AddIndividualLine(ms3.Sequence2 + ":" + scan2.ToString(), ppl2, Color.Blue);

            if (ms3.MS2Scan1 == scan1)
            {
                zgc.GraphPane.Title.Text = "MS2: " + ms3.Sequence1 + " ~ " + ms3.Sequence2;
            }
            else
            {
                zgc.GraphPane.Title.Text = string.Format("MS3: m/z = {0:0.####}, Xcorr = {1:0.####} ~ {2:0.####} = {3:0.####}", ms3.MS3Precursor1, SpectrumXcorr.CalculateUnnormalized(s1, s1), SpectrumXcorr.CalculateUnnormalized(s2, s2), ms3.Xcorr);
            }

            zgc.UpdateGraph();
        }
Exemple #2
0
        private void DrawSpectrum(IIdentifiedSpectrum spectrum)
        {
            if (spectrum.Annotations.ContainsKey("PepMutation"))
            {
                zgcPeaks.MasterPane.PaneList[0].Title.Text = string.Format("MH={0:0.00000},PPM={1:0.0},SEQ={2},MUT={3},COUNT={4}",
                                                                           spectrum.TheoreticalMH,
                                                                           PrecursorUtils.mz2ppm(spectrum.TheoreticalMH, spectrum.TheoreticalMinusExperimentalMass),
                                                                           spectrum.Sequence,
                                                                           spectrum.Annotations["PepMutation"],
                                                                           (from a in spectrum.Annotations
                                                                            where a.Key.EndsWith("_PepCount")
                                                                            select Convert.ToInt32(a.Value)).Sum());
            }
            else
            {
                zgcPeaks.MasterPane.PaneList[0].Title.Text = string.Format("MH={0:0.00000},PPM={1:0.0},SEQ={2}",
                                                                           spectrum.TheoreticalMH,
                                                                           PrecursorUtils.mz2ppm(spectrum.TheoreticalMH, spectrum.TheoreticalMinusExperimentalMass),
                                                                           spectrum.Sequence);
            }

            var mass = aas.MonoPeptideMass(PeptideUtils.GetMatchedSequence(spectrum.Sequence));

            if (Math.Abs(mass - spectrum.TheoreticalMass) > 0.1)
            {
                MessageBox.Show(string.Format("Error : {0} - {1}", mass, spectrum.TheoreticalMass));
                return;
            }

            var name = string.Format("{0}_{1}", spectrum.Query.FileScan.Experimental, spectrum.Query.FileScan.FirstScan);

            var peakPane = zgcPeaks.MasterPane.PaneList[0];

            peakPane.ClearData();

            var ppmPane = zgcPeaks.MasterPane.PaneList[1];

            ppmPane.ClearData();

            if (!mgfMap.ContainsKey(name))
            {
                MessageBox.Show("Cannot find peak list {0}", name);
                return;
            }

            var mgf = mgfMap[name];

            var maxIntensity = mgf.Max(m => m.Intensity);
            var maxMz        = Math.Min(2000, mgf.Max(m => m.Mz));

            var productTolerance = productIonPPM;
            var minIntensity     = maxIntensity * 0.05;

            AddIonSeries(peakPane, ppmPane, mgf, productTolerance, minIntensity, yBuilder, spectrum.Sequence, Color.Red);
            AddIonSeries(peakPane, ppmPane, mgf, productTolerance, minIntensity, bBuilder, spectrum.Sequence, Color.Blue);

            if (spectrum.Charge > 2)
            {
                AddIonSeries(peakPane, ppmPane, mgf, productTolerance, minIntensity, y2Builder, spectrum.Sequence, Color.Brown);
                AddIonSeries(peakPane, ppmPane, mgf, productTolerance, minIntensity, b2Builder, spectrum.Sequence, Color.GreenYellow);
            }

            AddUnmatchedIons(peakPane, mgf);

            foreach (var pane in zgcPeaks.MasterPane.PaneList)
            {
                pane.XAxis.Scale.Min = 0;
                pane.XAxis.Scale.Max = maxMz;
            }
            zgcPeaks.UpdateGraph();

            var targetpngfile = GetTargetFile(targetDir, spectrum);

            zgcPeaks.GetImage().Save(targetpngfile, ImageFormat.Png);
        }