// assume the spectrum read sequentially
        public double GetMonoMass(ISpectrum spectrum)
        {
            if (spectrum.GetMSnOrder() == 1)
            {
                List <IPoint> points = new List <IPoint>();
                foreach (IPeak pk in spectrum.GetPeaks())
                {
                    points.Add(new PeakPoint(pk));
                }
                matcher.setData(points);

                return(0);
            }

            ISpectrumMSn spectrumMSn = spectrum as ISpectrumMSn;

            double mz       = spectrumMSn.GetParentMZ();
            double monoMass = mz;


            // search isotopic point on full MS spectrum
            int charge   = spectrumMSn.GetParentCharge();
            int isotopic = 0;

            while (isotopic < maxIsotopic)
            {
                double target = mz - Proton / charge * (isotopic + 1);
                if (!matcher.Found(new GeneralPoint(target)))
                {
                    break;
                }
                isotopic++;
            }

            // get max intensity peak
            if (isotopic == 0)
            {
                return(monoMass);
            }
            double        isoMZ   = mz - Proton / charge * isotopic;
            List <IPoint> matched = matcher.Search(new GeneralPoint(isoMZ));

            return(matched.OrderBy(x => Math.Abs((x as PeakPoint).MZ - isoMZ)).First().GetValue());
        }
Exemple #2
0
        public override void Run(ISpectrumMSn spectrum)
        {
            if (msSpectrum == null)
            {
                monoPeak = null;
                monoMass = spectrum.GetParentMZ();
                return;
            }
            List <IPeak> peaks  = msSpectrum.GetPeaks();
            double       mz     = spectrum.GetParentMZ();
            int          charge = spectrum.GetParentCharge();
            double       Proton = UtilMass.Hydrogen;

            isotopics = 0;
            int index = FindMassPeak(mz, peaks, tol);

            while (isotopics < 10)
            {
                int matchIndex = FindMassPeak(mz - Proton / charge * (isotopics + 1), peaks, tol);
                if (matchIndex > 0)
                {
                    isotopics++;
                    index = matchIndex;
                }
                else
                {
                    break;
                }
            }
            if (index > 0)
            {
                monoPeak = peaks[index];
                monoMass = monoPeak.GetMZ();
            }
            else
            {
                monoPeak = null;
                monoMass = mz;
            }
        }