Ejemplo n.º 1
0
        public PeakList <T> Process(PeakList <T> t)
        {
            for (int i = t.Count - 1; i >= 0; i--)
            {
                if (t[i].Intensity < this.minIonIntensity)
                {
                    t.RemoveAt(i);
                }
            }

            if (0 == t.Count)
            {
                return(null);
            }
            else
            {
                return(t);
            }
        }
        public void TestFindEnvelope()
        {
            var peaks = new PeakList <Peak>();

            peaks.Add(new Peak(301, 1, 1));
            peaks.Add(new Peak(302, 2, 1));
            peaks.Add(new Peak(303, 1, 1));
            peaks.Add(new Peak(304, 2, 1));

            var env = this.FindEnvelope(peaks, peaks[0], 0.1);

            Assert.AreEqual(3, env.Count);
            Assert.IsTrue(!env.Contains(peaks[3]));

            peaks.RemoveAt(0);
            env = this.FindEnvelope(peaks, peaks[0], 0.1);
            Assert.AreEqual(2, env.Count);
            Assert.IsTrue(!env.Contains(peaks[2]));
        }
        public XCorrelationSpectrumScore(PeakList <U> experimentalPkl)
        {
            var tmp = new PeakList <U>(experimentalPkl);

            tmp.Sort((m1, m2) => m1.Mz.CompareTo(m2.Mz));

            //A 10-u window around the precursor ion is removed
            double minPrecursor = tmp.PrecursorMZ - 10.0;
            double maxPrecursor = tmp.PrecursorMZ + 10.0;

            for (int i = tmp.Count - 1; i >= 0; i--)
            {
                if (tmp[i].Mz > maxPrecursor)
                {
                    continue;
                }

                if (tmp[i].Mz < minPrecursor)
                {
                    break;
                }

                tmp.RemoveAt(i);
            }

            //The spectrum is then divided into 10 equal sections and the ion abundances in each section are normalized to 50.0;
            double maxMz = (int)Math.Round(tmp[tmp.Count - 1].Mz + 2.0);

            double stepMz = (maxMz) / 10.0;

            var peakBin = new List <PeakList <U> >();

            for (int i = 0; i < 10; i++)
            {
                peakBin.Add(new PeakList <U>());
            }

            foreach (U p in tmp)
            {
                var index = (int)(p.Mz / stepMz);
                peakBin[index].Add(p);
            }

            foreach (var peaks in peakBin)
            {
                if (peaks.Count > 0)
                {
                    double maxIntensity = peaks.FindMaxIntensityPeak().Intensity;
                    foreach (U p in peaks)
                    {
                        p.Intensity = p.Intensity * 50 / maxIntensity;
                    }
                }
            }

            //convert to discrte signals
            this._maxIndex = GetMinPowerOfTwo(maxMz);

            this._experimentalIntensities = new double[this._maxIndex];
            for (int i = 0; i < this._maxIndex; i++)
            {
                this._experimentalIntensities[i] = 0.0;
            }

            foreach (U p in tmp)
            {
                var index = (int)Math.Round(p.Mz);

                AssignIntensity(this._experimentalIntensities, index, (int)p.Intensity);
            }
        }
        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);
        }