示例#1
0
        public MatchImageBuilder(string mgfFile, string targetDir)
        {
            var mgfReader = new Mascot.MascotGenericFormatReader <MatchedPeak>();
            var spectra   = mgfReader.ReadFromFile(mgfFile);

            spectra.ForEach(m => m.Experimental = m.Experimental.Substring(0, m.Experimental.Length - 4));
            mgfMap = spectra.ToDictionary(m => string.Format("{0}_{1}", m.Experimental, m.ScanTimes[0].Scan));

            var mods = new Dictionary <char, double>();

            mods['&'] = 7.017166;
            mods['#'] = 3.010071;
            mods['@'] = 6.013809;
            mods['*'] = 15.994919;
            mods['C'] = 57.021464 + aas['C'].MonoMass; // 160.16523;
            mods['K'] = 8.014206 + aas['K'].MonoMass;
            mods['R'] = 10.008270 + aas['R'].MonoMass;

            aas.SetModification(mods);

            yBuilder = new CIDPeptideYSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            bBuilder = new CIDPeptideBSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            y2Builder = new CIDPeptideY2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            b2Builder = new CIDPeptideB2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };

            zgcPeaks        = new ZedGraphControl();
            zgcPeaks.Width  = 1600;
            zgcPeaks.Height = 1200;
            zgcPeaks.MasterPane.Border.IsVisible = false;

            zgcPeaks.InitMasterPanel(Graphics.FromImage(zgcPeaks.GetImage()), 2, "");
            zgcPeaks.IsSynchronizeXAxes = true;

            if (!Directory.Exists(targetDir))
            {
                Directory.CreateDirectory(targetDir);
            }
            this.targetDir = targetDir;
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            //var mgf = @"E:\backup\data\SAP\20111116_ZDSu_v_SAP_26_JPT_HCD.raw.mgf";
            if (mgfFile.GetFileDialog().ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                var mgf       = mgfFile.GetFileDialog().FileName;
                var mgfReader = new Mascot.MascotGenericFormatReader <MatchedPeak>();
                var spectra   = mgfReader.ReadFromFile(mgf);
                spectra.ForEach(m => m.Experimental = m.Experimental.Substring(0, m.Experimental.Length - 4));
                mgfMap = spectra.ToDictionary(m => string.Format("{0}_{1}", m.Experimental, m.ScanTimes[0].Scan));
            }
            else
            {
                return;
            }

            //var peptideFile = @"E:\backup\data\SAP\final.peptides.type1.paired.one2one.mut";
            if (pepFile.GetFileDialog().ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                var peptideFile = pepFile.GetFileDialog().FileName;
                peptides = new MascotPeptideTextFormat().ReadFromFile(peptideFile);
            }
            else
            {
                return;
            }

            var annKeys = new string[] { "OriginalSequence", "PepMutation", "_PepCount", "_OriginalCount" };

            foreach (var key in peptides[0].Annotations.Keys)
            {
                if (annKeys.Any(m => key.Contains(m)))
                {
                    gvPeptides.Columns.Add(new DataGridViewTextBoxColumn()
                    {
                        HeaderText = key,
                        Tag        = 1
                    });
                }
            }

            var mods = new Dictionary <char, double>();

            mods['&'] = 7.017166;
            mods['#'] = 3.010071;
            mods['@'] = 6.013809;
            mods['*'] = 15.994919;
            mods['C'] = 57.021464 + aas['C'].MonoMass; // 160.16523;
            mods['K'] = 8.01 + aas['K'].MonoMass;
            mods['R'] = 10.01 + aas['R'].MonoMass;

            aas.SetModification(mods);

            yBuilder = new CIDPeptideYSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            bBuilder = new CIDPeptideBSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            y2Builder = new CIDPeptideY2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            b2Builder = new CIDPeptideB2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };

            zgcPeaks.InitMasterPanel(this.CreateGraphics(), 2, "");
            zgcPeaks.IsSynchronizeXAxes = true;

            gvPeptides.DataSource = peptides;
        }
        private void AddIonSeries(GraphPane peakPane, GraphPane ppmPane, PeakList <MatchedPeak> mgf, double mzTolerance, double minIntensity, IPeptideFragmentationBuilder <MatchedPeak> builder, string sequence, Color tagColor)
        {
            MatchedPeakUtils.Match(mgf, builder.Build(sequence), mzTolerance, minIntensity);

            var ionType     = builder.SeriesType.ToString();
            var matchedIons = (from m in mgf
                               where m.Matched && m.PeakType == builder.SeriesType
                               select m).ToList();

            var ppl = new PointPairList();

            foreach (var m in matchedIons)
            {
                ppl.Add(new PointPair(m.Mz, m.Intensity, m.Information));
            }

            peakPane.AddIndividualLine("", ppl, Color.Black, tagColor);

            if (ppmPane != null)
            {
                var diff = new PointPairList();
                foreach (var m in matchedIons)
                {
                    if (isPPM)
                    {
                        diff.Add(new PointPair(m.Mz, PrecursorUtils.mz2ppm(m.Mz, m.Mz - m.MatchedMZ)));
                    }
                    else
                    {
                        diff.Add(new PointPair(m.Mz, m.Mz - m.MatchedMZ));
                    }
                }
                ppmPane.AddPoints(diff, tagColor);
            }
        }