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.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 bool IsBy2Matched() { return(ExperimentalPeakList.Any(m => m.Matched && (m.PeakType == IonType.B2 || m.PeakType == IonType.Y2))); }