Exemplo n.º 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;
        }
    public void TestBuild()
    {
      var aas = new Aminoacids();
      aas['*'].ResetMass(79.9799, 79.9799);
      aas['C'].ResetMass(160.1652, 160.1652);

      var builder = new CIDPeptideB2SeriesBuilder<IonTypePeak>()
      {
        CurAminoacids = aas
      };

      List<IonTypePeak> pkl = builder.Build("APYMEEQLQLLMCKYPEMT*LEDK");

      //Output(pkl, IonType.B2);

      Assert.IsTrue(pkl.All(m => m.Charge == 2));

      Assert.AreEqual(22, pkl.Count);

      AssertPeak(pkl[0], IonType.B2, 1, 36.5264);
      AssertPeak(pkl[1], IonType.B2, 2, 85.0528);
      AssertPeak(pkl[2], IonType.B2, 3, 166.5844);
      AssertPeak(pkl[3], IonType.B2, 4, 232.1047);
      AssertPeak(pkl[4], IonType.B2, 5, 296.6260);
      AssertPeak(pkl[5], IonType.B2, 6, 361.1473);
      AssertPeak(pkl[6], IonType.B2, 7, 425.1765);
      AssertPeak(pkl[7], IonType.B2, 8, 481.7186);
      AssertPeak(pkl[8], IonType.B2, 9, 545.7479);
      AssertPeak(pkl[9], IonType.B2, 10, 602.2899);
      AssertPeak(pkl[10], IonType.B2, 11, 658.8319);
      AssertPeak(pkl[11], IonType.B2, 12, 724.3522);
      AssertPeak(pkl[12], IonType.B2, 13, 804.4348);
      AssertPeak(pkl[13], IonType.B2, 14, 868.4823);
      AssertPeak(pkl[14], IonType.B2, 15, 950.0139);
      AssertPeak(pkl[15], IonType.B2, 16, 998.5403);
      AssertPeak(pkl[16], IonType.B2, 17, 1063.0616);
      AssertPeak(pkl[17], IonType.B2, 18, 1128.5818);
      AssertPeak(pkl[18], IonType.B2, 19, 1219.0956);
      AssertPeak(pkl[19], IonType.B2, 20, 1275.6377);
      AssertPeak(pkl[20], IonType.B2, 21, 1340.1590);
      AssertPeak(pkl[21], IonType.B2, 22, 1397.6724);
    }
        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;
        }