示例#1
0
        public static Spectra Import(string filenameMSMS, string filenameTracks, DBOptions dbOptions)
        {
            Spectra spectra = new Spectra();
            vsCSV   csv     = new vsCSV(filenameMSMS);

            if (csv.LINES_LIST.Count == 0 || csv.LINES_LIST[0].CompareTo(ProductSpectrum.TITLE) != 0)
            {
                return(null);
            }
            for (int i = 1; i < csv.LINES_LIST.Count; i++)
            {
                string[] splits  = csv.LINES_LIST[i].Split(vsCSV._Generic_Separator);
                double   mz      = double.Parse(splits[3]);
                int      charge  = int.Parse(splits[5]);
                int      nbPeaks = int.Parse(splits[9]);
                GraphML_List <MsMsPeak> peaks = new GraphML_List <MsMsPeak>(nbPeaks);
                i++;
                for (int j = 0; j < nbPeaks; i++, j++)
                {
                    try
                    {
                        string[] splitPeaks = csv.LINES_LIST[i].Split('\t');
                        if (splitPeaks.Length > 2)
                        {
                            peaks.Add(new MsMsPeak(double.Parse(splitPeaks[0]), double.Parse(splitPeaks[1]), int.Parse(splitPeaks[2])));
                        }
                        else
                        {
                            peaks.Add(new MsMsPeak(double.Parse(splitPeaks[0]), double.Parse(splitPeaks[1]), 0));
                        }
                    }
                    catch (Exception)
                    {
                        dbOptions.ConSole.WriteLine("Error parsing line : " + csv.LINES_LIST[i]);
                    }
                }
                spectra.AddMSMS(new ProductSpectrum(int.Parse(splits[0]), double.Parse(splits[1]), splits[2], mz, double.Parse(splits[4]), charge, Proteomics.Utilities.Numerics.MassFromMZ(mz, charge), peaks, double.Parse(splits[8]), double.Parse(splits[10]), double.Parse(splits[11])));
            }
            if (!string.IsNullOrEmpty(filenameTracks))
            {
                spectra.tracks = Tracks.Import(filenameTracks, dbOptions);
            }
            return(spectra);
        }