Example #1
0
        /* This method is to extract all the precursors' mz values.
         *  [M+H]+; [M+Na]+; [M+K]+; [M+NH4]+
         * //*/
        public static void FindPrecursorMZ(List <SpectrumData> allSpectraList, string outputFilePath)
        {
            List <double> mzList = new List <double>();

            for (int i = 0; i < allSpectraList.Count; i++)
            {
                for (int j = 0; j < allSpectraList[i].peakList.Count; j++)
                {
                    string iso = allSpectraList[i].peakList[j].isotopes;
                    if (!IdMSMS_Deconvolution.IsIsotope(iso))
                    {
                        //if (true) {
                        mzList.Add(allSpectraList[i].peakList[j].mz);
                    }
                }
            }
            using (StreamWriter sw = new StreamWriter(outputFilePath)) {
                for (int i = 0; i < mzList.Count; i++)
                {
                    if (i == mzList.Count - 1)
                    {
                        sw.Write(mzList[i]);
                    }
                    else
                    {
                        sw.Write(mzList[i] + ",");
                        //if (i%300==0&&i!=0) {
                        //    sw.WriteLine();
                        //}
                    }
                }
            }
            Console.WriteLine(mzList.Count);
        }
Example #2
0
        /* This method is to calculate all the neutral loss in each spectrum.
         *  cross over all peaks!
         * //*/
        public static List <double> FindNeutralLoss(SpectrumData spectrum)
        {
            List <double>   neutralLossList = new List <double>();
            List <PeakData> sortedPeakList  = spectrum.peakList.OrderByDescending(x => x.mz).Where(x => !IdMSMS_Deconvolution.IsIsotope(x.isotopes)).ToList(); //并计算和isotope的NL
            double          mzPrecursor     = double.Parse(spectrum.group.Split('_')[0]);

            for (int i = 0; i < sortedPeakList.Count; i++)   // add precursor neutral loss
            {
                double neutralLoss = mzPrecursor - sortedPeakList[i].mz;
                if (neutralLoss > 14)
                {
                    neutralLossList.Add(neutralLoss);
                }
            }
            for (int i = 0; i < sortedPeakList.Count; i++)   // add peaks neutral loss
            {
                for (int j = i + 1; j < sortedPeakList.Count; j++)
                {
                    double neutralLoss = sortedPeakList[i].mz - sortedPeakList[j].mz;
                    if (neutralLoss > 14)
                    {
                        neutralLossList.Add(neutralLoss);
                    }
                }
            }
            neutralLossList = neutralLossList.Distinct().ToList();
            return(neutralLossList);
        }