Exemple #1
0
        /*public void WriteOutMapToCsv(ref Classes.MapRecord _glycoMap, string filename)
        {
            CSVFileHandler outfile = new CSVFileHandler(filename, CSVFileHandler.WRITE_ONLY);
            outfile.openFile();
            int numdatasets = _glycoMap._AssociatedDatasetNames.Count;

            string[] header = { "ClusterID", "Mass", "NET" };
            for (int i = 0; i < numdatasets; i++)
            {
                string[] ar2;
                ar2 = new string[header.Length + 9];
                header.CopyTo(ar2, 0);
                ar2.SetValue("DatasetID" + "." + i.ToString(), header.Length);
                ar2.SetValue("HCDScore" + "." + i.ToString(), header.Length + 1);
                ar2.SetValue("CIDScore" + "." + i.ToString(), header.Length + 2);
                ar2.SetValue("ETDScore" + "." + i.ToString(), header.Length + 3);
                ar2.SetValue("Protein" + "." + i.ToString(), header.Length + 4);
                ar2.SetValue("Peptide" + "." + i.ToString(), header.Length + 5);
                ar2.SetValue("Site" + "." + i.ToString(), header.Length + 6);
                ar2.SetValue("Glycan" + "." + i.ToString(), header.Length + 7);
                ar2.SetValue("Abundance" + "." + i.ToString(), header.Length + 8);
                header = ar2;
            }
            outfile.writeLine(header);

            _glycoMap._AllMLNRecords.ForEach(delegate(Classes.MultiAlignRecord m)
            {
                string[] outline = { Convert.ToString(m.ID), Convert.ToString(m.Mass), Convert.ToString(m.NET) };

                m._AssociatedUMCRecords.Sort(delegate(Classes.UMCRecord u1, Classes.UMCRecord u2) { return u1.DatasetID.CompareTo(u2.DatasetID); });

                int count_index = 0;
                for (int i = 0; i < numdatasets; i++)
                {
                    string[] ar3 = new string[outline.Length + 9];
                    outline.CopyTo(ar3, 0);
                    Classes.UMCRecord u = m._AssociatedUMCRecords[count_index];
                    if (u.DatasetID == i)
                    {
                        ar3.SetValue(Convert.ToString(u.DatasetID), outline.Length);
                        ar3.SetValue(Convert.ToString(u.HCDScore), outline.Length + 1);
                        ar3.SetValue(Convert.ToString(u.CIDScore), outline.Length + 2);
                        ar3.SetValue(Convert.ToString(u.ETDScore), outline.Length + 3);
                        ar3.SetValue(u.ProteinName, outline.Length + 4);
                        ar3.SetValue(u.PeptideSeq, outline.Length + 5);
                        ar3.SetValue(u.NGlycoSite, outline.Length + 6);
                        ar3.SetValue(u.GlycanComposition, outline.Length + 7);
                        ar3.SetValue(Convert.ToString(u.Abundance), outline.Length + 8);
                        count_index++;
                        if (count_index >= m._AssociatedUMCRecords.Count)
                            count_index--; // To keep it within index.
                    }
                    else
                    {
                        ar3.SetValue(Convert.ToString(i), outline.Length);
                        ar3.SetValue(Convert.ToString(1), outline.Length + 1);
                        ar3.SetValue(Convert.ToString(0), outline.Length + 2);
                        ar3.SetValue(Convert.ToString(0), outline.Length + 3);
                        ar3.SetValue("", outline.Length + 4);
                        ar3.SetValue("", outline.Length + 5);
                        ar3.SetValue("", outline.Length + 6);
                        ar3.SetValue("", outline.Length + 7);
                        ar3.SetValue(Convert.ToString(0), outline.Length + 8);

                    }
                    outline = ar3;
                }
                outfile.writeLine(outline);

            });

            outfile.closeFile();
        }*/
        public void WriteOutMapToCSV(ref Classes.MapRecord _glycoMap, string filename)
        {
            CSVFileHandler outfile = new CSVFileHandler(filename, CSVFileHandler.WRITE_ONLY);
            outfile.openFile();
            int numdatasets = _glycoMap._AssociatedDatasetNames.Count;

            string[] header = { "ClusterID", "Mass", "NET", "Protein", "Peptide", "Site", "Glycan", "PeptideMass", "GlycanMass",
                              "TypeID", "TRUE_FALSE", "RepHCDScore", "RepCIDScore","RepETDScore", "RepCIDSeqScore" };
            for (int i = 0; i < numdatasets; i++)
            {
                string[] ar2;
                ar2 = new string[header.Length + 5];
                header.CopyTo(ar2, 0);
                ar2.SetValue("DatasetID" + "." + i.ToString(), header.Length);
                ar2.SetValue("HCDScore" + "." + i.ToString(), header.Length + 1);
                ar2.SetValue("CIDScore" + "." + i.ToString(), header.Length + 2);
                ar2.SetValue("ETDScore" + "." + i.ToString(), header.Length + 3);
                ar2.SetValue("Abundance" + "." + i.ToString(), header.Length + 4);
                header = ar2;
            }
            outfile.writeLine(header);

            _glycoMap._AllMLNRecords.ForEach(delegate(Classes.MultiAlignRecord m)
              {

              if (m.ID == 2290)
              {

                  bool test = true;
              }
              if (m.BestMatchProteinName != "")
              {
                  string true_false= "TRUE" ;
                  if(m.BestMatchFalseHit)
                      true_false = "FALSE";

                  string[] outline = { Convert.ToString(m.ID), Convert.ToString(m.Mass), Convert.ToString(m.NET), m.BestMatchProteinName,
                                       m.BestMatchPeptideSeq, m.BestMatchNGlycoSite, m.BestMatchGlycanComposition,
                                   m.BestMatchPeptideMass.ToString(), m.BestMatchGlycanMass.ToString(),
                                   m.IDLabel.ToString(), true_false ,  m.RepHCDScore.ToString(), m.RepCIDScore.ToString(), m.RepETDScore.ToString(), m.RepCIDSequencingScore.ToString()};

                  m._AssociatedUMCRecords.Sort(delegate(Classes.UMCRecord u1, Classes.UMCRecord u2) { return u1.DatasetID.CompareTo(u2.DatasetID); });

                  int count_index = 0;
                  for (int i = 0; i < numdatasets; i++)
                  {
                      string[] ar3 = new string[outline.Length + 5];
                      outline.CopyTo(ar3, 0);
                      Classes.UMCRecord u = m._AssociatedUMCRecords[count_index];
                      if (u.DatasetID == i)
                      {
                          ar3.SetValue(Convert.ToString(u.DatasetID), outline.Length);
                          ar3.SetValue(Convert.ToString(u.UMCRepHCDScore), outline.Length + 1);
                          ar3.SetValue(Convert.ToString(u.UMCRepCIDScore), outline.Length + 2);
                          ar3.SetValue(Convert.ToString(u.UMCRepETDScore), outline.Length + 3);
                          ar3.SetValue(Convert.ToString(u.Abundance), outline.Length + 4);
                          count_index++;
                          if (count_index >= m._AssociatedUMCRecords.Count)
                              count_index--; // To keep it within index.
                      }
                      else
                      {
                          ar3.SetValue(Convert.ToString(i), outline.Length);
                          ar3.SetValue(Convert.ToString(1), outline.Length + 1);
                          ar3.SetValue(Convert.ToString(0), outline.Length + 2);
                          ar3.SetValue(Convert.ToString(0), outline.Length + 3);
                          ar3.SetValue(Convert.ToString(0), outline.Length + 4);

                      }
                      outline = ar3;
                  }
                  outfile.writeLine(outline);
              }
              });

              outfile.closeFile();
        }
Exemple #2
0
        /// <summary>
        /// Function to write out glycopeptides dictionary to file so that next time
        /// </summary>
        /// <param name="outfile"></param>
        public void WriteOutGlycopeptidesToFile(string filename)
        {
            CSVFileHandler outfile = new CSVFileHandler(filename, CSVFileHandler.WRITE_ONLY);
            outfile.openFile();

            int numglycopeptides = _glycopeptides.Count;
            string[] header = { "GlycoPeptideMonoMass", "GlycoPeptideAvgMass", "Protein", "Peptide", "DECOY_Peptide",
                                  "Site", "PeptideMonoMass", "PeptideAvgMass", "Glycan", "DECOY_Glycan", "GlycanMonoMass", "GlycanAvgMass" };
            outfile.writeLine(header) ;
            for (int i = 0; i < numglycopeptides; i++)
            {
                string[] outline = {Convert.ToString(_glycopeptides[i].GP_Mono_Mass),
                                       Convert.ToString(_glycopeptides[i].GP_Average_Mass),
                                       Convert.ToString(_glycopeptides[i].Sequence.proteinName),
                                       Convert.ToString(_glycopeptides[i].Sequence.sequence),
                                       Convert.ToString(_glycopeptides[i].Sequence.is_decoy),
                                       Convert.ToString(_glycopeptides[i].Sequence.nGlycoSite),
                                       Convert.ToString(_glycopeptides[i].SequenceMonoMass) ,
                                       Convert.ToString(_glycopeptides[i].SequenceAverageMass),
                                       Convert.ToString(_glycopeptides[i].Glycan.composition) ,
                                       Convert.ToString(_glycopeptides[i].Glycan.is_decoy),
                                       Convert.ToString(_glycopeptides[i].GlycanMonoMass),
                                       Convert.ToString(_glycopeptides[i].GlycanAverageMass)};

                outfile.writeLine(outline);
            }

            outfile.closeFile();
        }
Exemple #3
0
        public void WriteOutPrecursorInfoToFileV2(ref Classes.MapRecord _glycoMap, string filename)
        {
            CSVFileHandler outfile = new CSVFileHandler(filename, CSVFileHandler.WRITE_ONLY);
            outfile.openFile();
            int numdatasets = _glycoMap._AssociatedDatasetNames.Count;

            string[] header = { "ClusterID", "Mass", "NET", "Protein", "Peptide", "Site", "Glycan", "PeptideMass", "GlycanMass",
                              "TypeID", "TRUE_FALSE", "RepHCDScore", "RepCIDScore","RepETDScore", "RepCIDSeqScore","ParentMZ", "ParentScanTime"};
            for (int i = 0; i < numdatasets; i++)
            {
            }
            outfile.writeLine(header);

            _glycoMap._AllMLNRecords.ForEach(delegate(Classes.MultiAlignRecord m)
               {
               if (m.BestMatchProteinName != "")
               {
                   string true_false = "TRUE";
                   if (m.BestMatchFalseHit)
                       true_false = "FALSE";

                   string[] outline = { Convert.ToString(m.ID), Convert.ToString(m.Mass), Convert.ToString(m.NET), m.BestMatchProteinName,
                                       m.BestMatchPeptideSeq, m.BestMatchNGlycoSite, m.BestMatchGlycanComposition,
                                   m.BestMatchPeptideMass.ToString(), m.BestMatchGlycanMass.ToString(),
                                   m.IDLabel.ToString(), true_false ,  m.RepHCDScore.ToString(), m.RepCIDScore.ToString(), m.RepETDScore.ToString(), m.RepCIDSequencingScore.ToString(),
                                  m.BestMatchParentMz.ToString(), m.BestMatchParentScanTime.ToString()};
                   outfile.writeLine(outline);
               }

               });

               outfile.closeFile();
        }
Exemple #4
0
        public void SequenceCIDPeaks(ref Classes.MapRecord _glycoMap, ref Classes.Params _params, string sequencingFolder)
        {
            Classes.MapRecord _tempMap = new MapRecord();
            _tempMap._AssociatedDatasetNames = _glycoMap._AssociatedDatasetNames;
            _tempMap._IsCID = _glycoMap._IsCID;
            _tempMap._IsETD = _glycoMap._IsETD;
            _tempMap._IsHCD = _glycoMap._IsHCD;

            Classes.FragEvents e = new FragEvents();
            if (sequencingFolder == "")
             sequencingFolder = @"c:\sequencing\";

            for (int i = 0; i < _glycoMap._AllMLNRecords.Count; i++)
            {
                MultiAlignRecord m = new MultiAlignRecord();
                m = _glycoMap._AllMLNRecords[i];
                int num_records = m._AssociatedUMCRecords.Count;

                 if (m.ID == 2290)
                {

                    bool test = true;
                }

                //for (int j = 0; j < num_records; j++)
                //{
                   // for (int k = 0; k < m._AssociatedUMCRecords[j]._AssociatedFragEvents.Count; k++)
                for (int k = 0; k < m._ClusterRepFragEvents.Count; k++)
                {
                    e = new FragEvents();
                    e = m._ClusterRepFragEvents[k]; // m._AssociatedUMCRecords[j]._AssociatedFragEvents[k];

                    if (e.ETDScore > 0)
                    {
                        float PeptideMass = 0;
                        float GlcNAcMass = 0;
                        COL.MassLib.MSScan _msScan = new COL.MassLib.MSScan(e.CIDMzs, e.CIDIntensities, Convert.ToSingle(e.TransformResult.mdbl_mz),
                            Convert.ToSingle(e.TransformResult.mdbl_mono_mw), Convert.ToSingle(e.TransformResult.mdbl_average_mw), Convert.ToInt32(e.TransformResult.mshort_cs));
                        if (e.TransformResult.mdbl_average_mw > 0)
                        {
                            PeptideMass = Convert.ToSingle(e.GP_Record.SequenceAverageMass); // this means proper deisotoping has occured so use average compostion
                            GlcNAcMass = COL.GlycoLib.GlycanMass.GetGlycanAVGMass(COL.GlycoLib.Glycan.Type.HexNAc);
                        }
                        else
                        {
                            PeptideMass = Convert.ToSingle(e.GP_Record.SequenceMonoMass); // CS has been assigned, in which case both y1 and precursor should be just mono
                            GlcNAcMass = COL.GlycoLib.GlycanMass.GetGlycanMass(COL.GlycoLib.Glycan.Type.HexNAc);
                        }

                        short y1cs = e.TransformResult.mshort_cs;
                        y1cs--;
                        while (y1cs > 0)
                        {
                            float y1Mz = ((PeptideMass + GlcNAcMass) + (float)_utils._CC_MASS * y1cs) / y1cs;
                            COL.GlycoSequence.GlycanSequencing _Gs = new COL.GlycoSequence.GlycanSequencing(_msScan, y1Mz, y1cs, e.GP_Record.Glycan.numHex,
                                e.GP_Record.Glycan.numHexNAc, e.GP_Record.Glycan.numDeHex, e.GP_Record.Glycan.numNeuAc, 0, sequencingFolder, true, 0.8f, 60);

                            _Gs.NumbersOfPeaksForSequencing = 140;
                            _Gs.CreatePrecursotMZ = true;
                            _Gs.RewardForCompleteStructure = 3;

                            if (e.TransformResult.mdbl_average_mw > 0)
                                _Gs.UseAVGMass = true;
                            else
                                _Gs.UseAVGMass = false;
                            int structure_count = _Gs.StartSequencing();
                            if (structure_count > 0)
                            {
                                List<COL.GlycoLib.GlycanStructure> topstructures = _Gs.GetTopRankScoreStructre(1);
                                e.CIDSequencingScore = topstructures[0].Score;
                                e.GP_Record.GlycanSequence = topstructures[0].IUPACString;

                                // Printing out the sequences
                                string opfile = sequencingFolder + m.ID.ToString() + "_" + e.CIDScan.ToString() + ".txt";
                                Utils.CSVFileHandler cidString = new CSVFileHandler(opfile, CSVFileHandler.WRITE_ONLY);
                                cidString.openFile();
                                for (int zz = 0; zz < topstructures.Count; zz++)
                                {
                                    cidString.writeLine(topstructures[zz].IUPACString);
                                    /*COL.GlycoLib.GlycansDrawer _gdraw = new COL.GlycoLib.GlycansDrawer(topstructures[zz].IUPACString, false);
                                    System.Drawing.Image img1 = _gdraw.GetImage();*/
                                }
                                cidString.closeFile();
                                break;
                            }
                            y1cs--;
                        }
                    }

                }

            }
        }