private void lookForMissingPeaksAndInsertZeroIntensityPeaksWhenMissing(IsotopicProfile o16o18Profile, IsotopicProfile theorFeature) { if (o16o18Profile.Peaklist.Count == 0) { return; } var mzDistanceBetweenIsotopes = 1.003 / o16o18Profile.ChargeState; var monoMZ = theorFeature.getMonoPeak().XValue; var indexOfLastPeak = o16o18Profile.Peaklist.Count - 1; var toleranceInDa = 0.1; //this will iterate over the first five expected m/z values of a theoretical profile //and loosely try to the corresponding peak within the observed profile. //If missing, will add one at the expected m/z. This ensures no missing peaks within the O16O18 profile //so that looking up the first peak will always give you the intensity of the O16 peak (even if //it never existed in the real data - in this case the intensity is 0); for (var i = 0; i < 6; i++) { var currentMZ = monoMZ + mzDistanceBetweenIsotopes * i; var peaksWithinTol = PeakUtilities.GetMSPeaksWithinTolerance(o16o18Profile.Peaklist, currentMZ, toleranceInDa); if (peaksWithinTol.Count == 0) // { o16o18Profile.Peaklist.Insert(i, new MSPeak(currentMZ, 0, 0, 0)); } } }
private bool findPeakWithinMSFeatureResults(List <IsosResult> msFeatureList, MSPeakResult peakResult, double scanTolerance) { double toleranceInPPM = 5; var toleranceInMZ = toleranceInPPM / 1e6 * peakResult.MSPeak.XValue; foreach (var msfeature in msFeatureList) { if (msfeature.IsotopicProfile == null || msfeature.IsotopicProfile.Peaklist == null || msfeature.IsotopicProfile.Peaklist.Count == 0) { continue; } //check target peak is within an allowable scan tolerance var targetPeakIsWithinScanTol = Math.Abs(msfeature.ScanSet.PrimaryScanNumber - peakResult.Scan_num) <= scanTolerance; if (!targetPeakIsWithinScanTol) { continue; } var peaksWithinTol = PeakUtilities.GetMSPeaksWithinTolerance(msfeature.IsotopicProfile.Peaklist, peakResult.MSPeak.XValue, toleranceInMZ); if (peaksWithinTol.Count == 0) { continue; } else { return(true); } } return(false); }
private void addIsotopePeaks(IsotopicProfile foundO16O18Profile, IsotopicProfile profileToAdd, int numIsotopePeaksToAdd) { if (profileToAdd?.Peaklist == null || profileToAdd.Peaklist.Count == 0) { return; } for (var i = 0; i < numIsotopePeaksToAdd; i++) { if (i < profileToAdd.Peaklist.Count) { var peakMz = profileToAdd.Peaklist[i].XValue; var toleranceInMZ = ToleranceInPPM / 1e6 * peakMz; var peaksAlreadyThere = PeakUtilities.GetMSPeaksWithinTolerance(foundO16O18Profile.Peaklist, peakMz, toleranceInMZ); if (peaksAlreadyThere == null || peaksAlreadyThere.Count == 0) { foundO16O18Profile.Peaklist.Add(profileToAdd.Peaklist[i]); } } else // if profileToAdd doesn't have enough peaks { break; } } foundO16O18Profile.Peaklist = foundO16O18Profile.Peaklist.OrderBy(p => p.XValue).ToList(); }
private IsosResult getMSFeatureForCurrentSourcePeak(MSPeakResult peakResult, Run run) { if (run.ResultCollection.IsosResultBin == null || run.ResultCollection.IsosResultBin.Count == 0) { return(null); } var isosResultPossiblyContainingSourcePeak = new Dictionary <IsosResult, double>(); //store possible isosResult, along with it's difference with the peakResult for (var i = 0; i < run.ResultCollection.IsosResultBin.Count; i++) { var msfeature = run.ResultCollection.IsosResultBin[i]; double toleranceInMZ = peakResult.MSPeak.Width / 2; var peaksWithinTolerance = PeakUtilities.GetMSPeaksWithinTolerance(msfeature.IsotopicProfile.Peaklist, peakResult.MSPeak.XValue, toleranceInMZ); if (peaksWithinTolerance == null || peaksWithinTolerance.Count == 0) { } else { var diff = Math.Abs(peaksWithinTolerance[0].XValue - peakResult.MSPeak.XValue); isosResultPossiblyContainingSourcePeak.Add(msfeature, diff); } } if (isosResultPossiblyContainingSourcePeak.Count == 0) { return(null); } else if (isosResultPossiblyContainingSourcePeak.Count == 1) { return(isosResultPossiblyContainingSourcePeak.First().Key); } else { return(isosResultPossiblyContainingSourcePeak.Keys.OrderByDescending(p => p.IntensityAggregate).First()); } }