public override PeakList <Peak> GetPeakList(int scan, double minMz, double maxMz)
        {
            PeakList <Peak> result = GetPeakList(scan);

            result.RemoveAll(m => m.Mz < minMz);
            result.RemoveAll(m => m.Mz > maxMz);

            return(result);
        }
Ejemplo n.º 2
0
        public override PeakList <Peak> GetPeakList(int scan, double minMz, double maxMz)
        {
            long position = positions[scan].Position;

            sr.SetCharpos(position);
            PeakList <Peak> result = iter.Next();

            result.RemoveAll(m => { return(m.Mz < minMz || m.Mz > maxMz); });
            return(result);
        }
Ejemplo n.º 3
0
        public PeakList <T> Process(PeakList <T> t)
        {
            if (!t.Any(m => m.Charge > 0))
            {
                return(t);
            }

            List <T> kept = (from p in t
                             where p.Charge == 0
                             select p).ToList();

            t.RemoveAll(m => m.Charge == 0);

            while (t.Count > 0)
            {
                var curPeaks = FindEnvelope(t, t[0], PrecursorUtils.ppm2mz(t[0].Mz, this.ppmTolerance));
                t.RemoveAll(m => curPeaks.Contains(m));

                if (curPeaks.Count == 1 || curPeaks[0].Intensity >= curPeaks[1].Intensity)
                {
                    kept.Add(curPeaks[0]);
                    continue;
                }

                var mass = curPeaks[0].Mz * curPeaks[0].Charge - Atom.H.MonoMass;
                if (mass > 1800)
                {
                    kept.Add(curPeaks[0]);
                    continue;
                }

                kept.Add(curPeaks[0]);
                kept.Add(curPeaks[1]);
            }

            t.AddRange(kept);
            t.Sort((m1, m2) => m1.Mz.CompareTo(m2.Mz));

            return(t);
        }
        public PeakList <T> Process(PeakList <T> t)
        {
            if (!t.Any(m => m.Charge > 0))
            {
                return(t);
            }

            Parallel.ForEach(t, m =>
            {
                if (m.Charge > 1)
                {
                    m.Mz     = m.Mz * m.Charge - Atom.H.MonoMass * (m.Charge - 1);
                    m.Charge = 1;
                }
            });

            var peaks = (from p in t
                         where p.Charge == 1
                         orderby p.Intensity
                         select p).ToList();

            var deleted = new HashSet <T>();

            while (peaks.Count > 0)
            {
                var mz          = peaks[0].Mz;
                var mzTolerance = PrecursorUtils.ppm2mz(mz, ppmTolerance);
                var minMz       = mz - mzTolerance;
                var maxMz       = mz + mzTolerance;
                var curPeaks    = (from p in peaks
                                   where p.Mz >= minMz && p.Mz <= maxMz
                                   select p).ToList();
                if (curPeaks.Count > 1)
                {
                    var nIntensity = curPeaks.Sum(m => m.Intensity);
                    var nMz        = curPeaks.Sum(m => m.Mz * m.Intensity) / nIntensity;
                    peaks[0].Mz        = nMz;
                    peaks[0].Intensity = nIntensity;
                    curPeaks.Remove(peaks[0]);
                    deleted.UnionWith(curPeaks);
                }
                peaks.RemoveAll(m => curPeaks.Contains(m));
            }

            t.RemoveAll(m => deleted.Contains(m));

            t.SortByMz();
            return(t);
        }
        public PeakList <T> Process(PeakList <T> t)
        {
            if (t.PrecursorCharge > 0)
            {
                var mzWindow = massTolerance / t.PrecursorCharge;
                foreach (var offset in offsets)
                {
                    var mz = t.PrecursorMZ + offset / t.PrecursorCharge;

                    var minMz = mz - mzWindow;
                    var maxMz = mz + mzWindow;

                    t.RemoveAll(m => m.Mz >= minMz && m.Mz <= maxMz);
                }
            }

            return(t);
        }
        public PeakList <T> Process(PeakList <T> t)
        {
            if (t.PrecursorCharge > 0)
            {
                var precursorMass = PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true);

                t.RemoveAll(m =>
                {
                    double mass;
                    if (m.Charge > 1)
                    {
                        mass = PrecursorUtils.MzToMH(m.Mz, m.Charge, true);
                    }
                    else
                    {
                        mass = m.Mz;
                    }
                    return(mass > precursorMass);
                });
            }

            return(t);
        }
        public PeakList <T> Process(PeakList <T> t)
        {
            if (t.PrecursorCharge > 0)
            {
                var isobaricList  = new List <T>();
                var mzPrecursor   = PrecursorUtils.ppm2mz(t.PrecursorMZ, options.PPMTolerance);
                var precursurIons = FindPeakConsideringCharge(t, t.PrecursorMZ, t.PrecursorCharge, mzPrecursor);

                //First of all, we need to find precursor
                if (precursurIons.Count > 0)
                {
                    precursurIons.ForEach(m => { t.Remove(m); });

                    isobaricList.Add(new T()
                    {
                        Mz        = t.PrecursorMZ,
                        Charge    = t.PrecursorCharge,
                        Intensity = mzPrecursor
                    });

                    if (options.RemoveChargeMinus1Precursor && t.PrecursorCharge > 1)
                    {
                        //Get charge-1 precursor
                        var p1mz     = PrecursorUtils.MHToMz(PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true), t.PrecursorCharge - 1, true);
                        var p1Window = PrecursorUtils.ppm2mz(p1mz, options.PPMTolerance);
                        var p1Ions   = FindPeakConsideringCharge(t, p1mz, t.PrecursorCharge - 1, p1Window);
                        if (p1Ions.Count > 0)
                        {
                            p1Ions.ForEach(m => { t.Remove(m); });

                            isobaricList.Add(new T()
                            {
                                Mz        = p1mz,
                                Charge    = t.PrecursorCharge - 1,
                                Intensity = p1Window
                            });
                        }
                    }

                    if (options.RemoveIsotopicIons)
                    {
                        foreach (var ion in isobaricList)
                        {
                            RemoveIsotopicIons(t, ion);
                        }
                    }
                }

                foreach (var offset in offsets)
                {
                    var mz       = t.PrecursorMZ + offset / t.PrecursorCharge;
                    var mzWindow = PrecursorUtils.ppm2mz(mz, options.PPMTolerance);

                    var minMz = mz - mzWindow;
                    var maxMz = mz + mzWindow;

                    t.RemoveAll(m =>
                    {
                        if (m.Charge == t.PrecursorCharge || m.Charge == 0)
                        {
                            return(m.Mz >= minMz && m.Mz <= maxMz);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                }

                if (options.RemoveIonLargerThanPrecursor)
                {
                    var pmass = PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true);
                    t.RemoveAll(m =>
                    {
                        var mass = m.Charge > 0 ? PrecursorUtils.MzToMH(m.Mz, m.Charge, true) : m.Mz;
                        return(mass >= pmass);
                    });
                }
            }

            return(t);
        }
 public PeakList <T> Process(PeakList <T> t)
 {
     t.RemoveAll(m => m.Mz >= minMass && m.Mz <= maxMass);
     return(t);
 }
        public PeakList <T> Process(PeakList <T> t)
        {
            t.SortByMz();

            //删除固定区间。
            var index = 0;

            while (index < t.Count)
            {
                var peak = t[index];

                if (peak.Mz > options.MaxFixIonMz)
                {
                    break;
                }

                double mass;
                if (peak.Charge > 1)
                {
                    mass = PrecursorUtils.MzToMH(peak.Mz, peak.Charge, true);
                    if (mass > options.MaxFixIonMz)
                    {
                        index++;
                        continue;
                    }
                }
                else
                {
                    mass = peak.Mz;
                }

                bool bRemoved = false;
                for (int i = 0; i < options.FixIonRanges.Count; i++)
                {
                    var ion = options.FixIonRanges[i];

                    if (mass < ion.First)
                    {
                        break;
                    }

                    if (mass > ion.Second)
                    {
                        continue;
                    }

                    bRemoved = true;
                    t.RemoveAt(index);
                    break;
                }

                if (!bRemoved)
                {
                    index++;
                }
            }

            var precursorMass = PrecursorUtils.MzToMH(t.PrecursorMZ, t.PrecursorCharge, true);

            if (options.RemoveHighRange)
            {
                var maxPeak = precursorMass - options.Protease.GetHighBYFreeWindow() - options.MzTolerance;
                if (options.RemovePrecusor)
                {
                    t.RemoveAll(peak =>
                    {
                        double mass = PrecursorUtils.MzToMH(peak.Mz, peak.Charge, true);
                        return(mass >= maxPeak);
                    });
                }
                else
                {
                    var precursorLess  = precursorMass - options.MzTolerance;
                    var precursorLarge = precursorMass + options.MzTolerance;
                    t.RemoveAll(peak =>
                    {
                        double mass = PrecursorUtils.MzToMH(peak.Mz, peak.Charge, true);
                        return((mass >= maxPeak && mass <= precursorLess) || mass > precursorLarge);
                    });
                }
            }

            if (options.RemovePrecursorMinusLabel)
            {
                var ionmass    = precursorMass - options.LabelMass;
                var minIonMass = ionmass - options.MzTolerance;
                var maxIonMass = ionmass + options.MzTolerance;
                t.RemoveAll(peak =>
                {
                    double mass = PrecursorUtils.MzToMH(peak.Mz, peak.Charge, true);
                    return(mass >= minIonMass && mass <= maxIonMass);
                });
            }

            return(t);
        }