private static Tuple <Peak, int>[] GetAllIsotopePeaks( Spectrum spec, double monoisotopicMass, int charge, IsotopomerEnvelope envelope, Tolerance tolerance, double relativeIntensityThreshold) { var mostAbundantIsotopeIndex = envelope.MostAbundantIsotopeIndex; var isotopomerEnvelope = envelope.Envelope; var mostAbundantIsotopeMz = Ion.GetIsotopeMz(monoisotopicMass, charge, mostAbundantIsotopeIndex); var mostAbundantIsotopePeakIndex = spec.FindPeakIndex(mostAbundantIsotopeMz, tolerance); if (mostAbundantIsotopePeakIndex < 0) { return(null); } var observedPeaks = new Tuple <Peak, int> [isotopomerEnvelope.Length]; observedPeaks[mostAbundantIsotopeIndex] = new Tuple <Peak, int>(spec.Peaks[mostAbundantIsotopePeakIndex], mostAbundantIsotopePeakIndex); // go down var peakIndex = mostAbundantIsotopePeakIndex - 1; for (var isotopeIndex = mostAbundantIsotopeIndex - 1; isotopeIndex >= 0; isotopeIndex--) { if (isotopomerEnvelope[isotopeIndex] < relativeIntensityThreshold) { break; } var isotopeMz = Ion.GetIsotopeMz(monoisotopicMass, charge, isotopeIndex); var tolTh = tolerance.GetToleranceAsMz(isotopeMz); var minMz = isotopeMz - tolTh; var maxMz = isotopeMz + tolTh; for (var i = peakIndex; i >= 0; i--) { var peakMz = spec.Peaks[i].Mz; if (peakMz < minMz) { peakIndex = i; break; } if (peakMz <= maxMz) // find match, move to prev isotope { var peak = spec.Peaks[i]; if (observedPeaks[isotopeIndex] == null || peak.Intensity > observedPeaks[isotopeIndex].Item1.Intensity) { observedPeaks[isotopeIndex] = new Tuple <Peak, int>(peak, peakIndex); } } } } // go up peakIndex = mostAbundantIsotopePeakIndex + 1; for (var isotopeIndex = mostAbundantIsotopeIndex + 1; isotopeIndex < isotopomerEnvelope.Length; isotopeIndex++) { if (isotopomerEnvelope[isotopeIndex] < relativeIntensityThreshold) { break; } var isotopeMz = Ion.GetIsotopeMz(monoisotopicMass, charge, isotopeIndex); var tolTh = tolerance.GetToleranceAsMz(isotopeMz); var minMz = isotopeMz - tolTh; var maxMz = isotopeMz + tolTh; for (var i = peakIndex; i < spec.Peaks.Length; i++) { var peakMz = spec.Peaks[i].Mz; if (peakMz > maxMz) { peakIndex = i; break; } if (peakMz >= minMz) // find match, move to prev isotope { var peak = spec.Peaks[i]; if (observedPeaks[isotopeIndex] == null || peak.Intensity > observedPeaks[isotopeIndex].Item1.Intensity) { observedPeaks[isotopeIndex] = new Tuple <Peak, int>(peak, peakIndex); } } } } return(observedPeaks); }
public Peak[] GetAllIsotopePeaks(double monoIsotopeMass, int charge, IsotopomerEnvelope envelope, Tolerance tolerance, double relativeIntensityThreshold) { var mostAbundantIsotopeIndex = envelope.MostAbundantIsotopeIndex; var isotopomerEnvelope = envelope.Envolope; var mostAbundantIsotopeMz = Ion.GetIsotopeMz(monoIsotopeMass, charge, mostAbundantIsotopeIndex); var mostAbundantIsotopePeakIndex = FindPeakIndex(mostAbundantIsotopeMz, tolerance); if (mostAbundantIsotopePeakIndex < 0) { return(null); } var observedPeaks = new Peak[isotopomerEnvelope.Length]; observedPeaks[mostAbundantIsotopeIndex] = Peaks[mostAbundantIsotopePeakIndex]; // go down var peakIndex = mostAbundantIsotopePeakIndex - 1; for (var isotopeIndex = mostAbundantIsotopeIndex - 1; isotopeIndex >= 0; isotopeIndex--) { if (isotopomerEnvelope[isotopeIndex] < relativeIntensityThreshold) { break; } var isotopeMz = Ion.GetIsotopeMz(monoIsotopeMass, charge, isotopeIndex); var tolTh = tolerance.GetToleranceAsTh(isotopeMz); var minMz = isotopeMz - tolTh; var maxMz = isotopeMz + tolTh; for (var i = peakIndex; i >= 0; i--) { var peakMz = Peaks[i].Mz; if (peakMz < minMz) { peakIndex = i; break; } if (peakMz <= maxMz) // find match, move to prev isotope { var peak = Peaks[i]; if (observedPeaks[isotopeIndex] == null || peak.Intensity > observedPeaks[isotopeIndex].Intensity) { observedPeaks[isotopeIndex] = peak; } } } } // go up peakIndex = mostAbundantIsotopePeakIndex + 1; for (var isotopeIndex = mostAbundantIsotopeIndex + 1; isotopeIndex < isotopomerEnvelope.Length; isotopeIndex++) { if (isotopomerEnvelope[isotopeIndex] < relativeIntensityThreshold) { break; } var isotopeMz = Ion.GetIsotopeMz(monoIsotopeMass, charge, isotopeIndex); var tolTh = tolerance.GetToleranceAsTh(isotopeMz); var minMz = isotopeMz - tolTh; var maxMz = isotopeMz + tolTh; for (var i = peakIndex; i < Peaks.Length; i++) { var peakMz = Peaks[i].Mz; if (peakMz > maxMz) { peakIndex = i; break; } if (peakMz >= minMz) // find match, move to prev isotope { var peak = Peaks[i]; if (observedPeaks[isotopeIndex] == null || peak.Intensity > observedPeaks[isotopeIndex].Intensity) { observedPeaks[isotopeIndex] = peak; } } } } return(observedPeaks); }