public PeakList <T> Process(PeakList <T> t) { List <PeakList <T> > envelopes = t.GetEnvelopes(this.ppmTolerance); ((List <T>)t).Clear(); foreach (var envelope in envelopes) { t.Add(envelope[0]); } 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); } 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 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); } }