private MSPeak GetPeakToTheLeftIfExists(IsotopicProfile isotopicProfile, IEnumerable <Peak> peakList) { if (isotopicProfile == null) { return(null); } var monoPeak = isotopicProfile.getMonoPeak(); const double maxPossiblePeakWidth = 0.1; var mzTol = Math.Min(maxPossiblePeakWidth, monoPeak.Width); var targetMZ = monoPeak.XValue - (1.003 / isotopicProfile.ChargeState); MSPeak peakToTheLeft = null; foreach (var peak in peakList) { var msPeak = (MSPeak)peak; if (Math.Abs(msPeak.XValue - targetMZ) < mzTol) { peakToTheLeft = msPeak; break; } } //peak to the left height must be greater than half the mono peak if (peakToTheLeft?.Height > monoPeak.Height * 0.5) //if peak-to-the-left exceeds min Ratio, then consider it { return(peakToTheLeft); } return(null); }
/// <summary> /// Use binary search to find all Isotopic Peaks we want to consider when looking for the cross-links shifts. /// </summary> /// <param name="completePeakList">The complete list of Isotopic Peaks that we will use for searching.</param> /// <param name="minimumMz">The minimum m/z value to consider.</param> /// <param name="scanLc">The LC Scan to consider.</param> /// <param name="scanIms">The IMS Scan to consider.</param> /// <returns>All peaks that are in the given LC Scan and IMS Scan and m/z >= thegiven m/z of the Feature.</returns> public static List<IPeak> FindCandidatePeaks(List<IsotopicPeak> completePeakList, double minimumMz, int scanLc, int scanIms) { // Set up Peak Comparer to use for binary search later on AnonymousComparer<IsotopicPeak> peakComparer = new AnonymousComparer<IsotopicPeak>((x, y) => x.ScanLc != y.ScanLc ? x.ScanLc.CompareTo(y.ScanLc) : x.ScanIms != y.ScanIms ? x.ScanIms.CompareTo(y.ScanIms) : x.Mz.CompareTo(y.Mz)); IsotopicPeak lowPeak = new IsotopicPeak {ScanLc = scanLc, ScanIms = scanIms, Mz = minimumMz, Intensity = 1}; IsotopicPeak highPeak = new IsotopicPeak { ScanLc = scanLc, ScanIms = scanIms + 1, Mz = 0, Intensity = 1 }; int lowPeakPosition = completePeakList.BinarySearch(lowPeak, peakComparer); int highPeakPosition = completePeakList.BinarySearch(highPeak, peakComparer); lowPeakPosition = lowPeakPosition < 0 ? ~lowPeakPosition : lowPeakPosition; highPeakPosition = highPeakPosition < 0 ? ~highPeakPosition : highPeakPosition; List<IPeak> candidatePeaks = new List<IPeak>(); for (int j = lowPeakPosition; j < highPeakPosition; j++) { IsotopicPeak peak = completePeakList[j]; MSPeak msPeak = new MSPeak(peak.Mz, peak.Intensity, 0.05f, 1); candidatePeaks.Add(msPeak); } return candidatePeaks; }
/// <summary> /// Returns a 'peak-to-the-left' of the monoisotopic peak if: 1) it exists and 2) it is above the user provided relative intensity /// </summary> /// <param name="monoPeak"></param> /// <param name="chargeState"></param> /// <param name="peakList"></param> /// <param name="minRelIntensityForFlag"></param> /// <returns></returns> public MSPeak LookforPeakToTheLeftOfMonoPeak(MSPeak monoPeak, int chargeState, List <Peak> peakList, double minRelIntensityForFlag) { double mzTol = monoPeak.Width; var targetMZ = monoPeak.XValue - (1.003 / (double)chargeState); var foundLeftOfMonoPeaks = PeakUtilities.GetPeaksWithinTolerance(peakList, targetMZ, mzTol); //if found a peak to the left, will return that peak. If if (foundLeftOfMonoPeaks.Count == 0) { return(null); } var peakToTheLeft = foundLeftOfMonoPeaks.OrderByDescending(p => p.Height).First() as MSPeak; if (peakToTheLeft == null) { return(null); } if (peakToTheLeft.Height > monoPeak.Height * MinRatioToGiveFlag) { return(peakToTheLeft); } return(null); }
/* * public MSResultPeakWithLocation(MSPeakResult peak, int numFrames, int numScans) * { * this.XValue = peak.MSPeak.XValue; * this.frameNumber = peak.Frame_num; * this.scanNumber = peak.Scan_num; * * frameScansRange = new BitArray2D(numScans, numFrames); * }*/ /** * constructor * Creates a peak result with a sorted list of framenumbers and scannumbers within those frame numbers * * To improve efficiency these arrays should be passed in sorted order. We might be able to do that by * using insertion sort during the creation of these arrays. * * An nlogn sort here might be an overkill. * * */ public MSResultPeakWithLocation(MSPeak peak, Dictionary <ushort, List <ushort> > frameAndScansRange, int frameNum, int scanNum) { this.XValue = peak.XValue; this.frameAndScansRange = frameAndScansRange; this.frameNumber = (ushort)frameNum; this.scanNumber = (ushort)scanNum; }
private MSPeak findClosestPeak(List <MSPeak> list, double targetMZ) { if (list == null) { return(null); } if (list.Count == 0) { return(null); } double diff = double.MaxValue; MSPeak closestPeak = new MSPeak(); foreach (MSPeak peak in list) { double currentDiff = Math.Abs(peak.MZ - targetMZ); if (currentDiff < diff) { closestPeak = peak; diff = currentDiff; } } return(closestPeak); }
/// <summary> /// Use binary search to find all Isotopic Peaks we want to consider when looking for the cross-links shifts. /// </summary> /// <param name="completePeakList">The complete list of Isotopic Peaks that we will use for searching.</param> /// <param name="minimumMz">The minimum m/z value to consider.</param> /// <param name="scanLc">The LC Scan to consider.</param> /// <param name="scanIms">The IMS Scan to consider.</param> /// <returns>All peaks that are in the given LC Scan and IMS Scan and m/z >= thegiven m/z of the Feature.</returns> public static List <IPeak> FindCandidatePeaks(List <IsotopicPeak> completePeakList, double minimumMz, int scanLc, int scanIms) { // Set up Peak Comparer to use for binary search later on AnonymousComparer <IsotopicPeak> peakComparer = new AnonymousComparer <IsotopicPeak>((x, y) => x.ScanLc != y.ScanLc ? x.ScanLc.CompareTo(y.ScanLc) : x.ScanIms != y.ScanIms ? x.ScanIms.CompareTo(y.ScanIms) : x.Mz.CompareTo(y.Mz)); IsotopicPeak lowPeak = new IsotopicPeak { ScanLc = scanLc, ScanIms = scanIms, Mz = minimumMz, Intensity = 1 }; IsotopicPeak highPeak = new IsotopicPeak { ScanLc = scanLc, ScanIms = scanIms + 1, Mz = 0, Intensity = 1 }; int lowPeakPosition = completePeakList.BinarySearch(lowPeak, peakComparer); int highPeakPosition = completePeakList.BinarySearch(highPeak, peakComparer); lowPeakPosition = lowPeakPosition < 0 ? ~lowPeakPosition : lowPeakPosition; highPeakPosition = highPeakPosition < 0 ? ~highPeakPosition : highPeakPosition; List <IPeak> candidatePeaks = new List <IPeak>(); for (int j = lowPeakPosition; j < highPeakPosition; j++) { IsotopicPeak peak = completePeakList[j]; MSPeak msPeak = new MSPeak(peak.Mz, peak.Intensity, 0.05f, 1); candidatePeaks.Add(msPeak); } return(candidatePeaks); }
public MatchedGlycanPeak(int argScanNum, double argTime, MSPeak argPeak, GlycanCompound argGlycanComp) { _ScanNum = argScanNum; _Time = argTime; _MSPeak = argPeak; _glycanComposition = argGlycanComp; }
private MSPeak findClosestPeak(IReadOnlyCollection <MSPeak> list, double targetMZ) { if (list == null) { return(null); } if (list.Count == 0) { return(null); } var diff = double.MaxValue; var closestPeak = new MSPeak(0); foreach (var peak in list) { var currentDiff = Math.Abs(peak.XValue - targetMZ); if (currentDiff < diff) { closestPeak = peak; diff = currentDiff; } } return(closestPeak); }
private MSPeak MakeMSPeak(double width, double xValue) { var mspeak = new MSPeak(); mspeak.Width = (float)width; mspeak.XValue = xValue; return(mspeak); }
protected override IsotopicProfile CreateTargetIso(Run run) { IsotopicProfile iso; Check.Require(run.CurrentMassTag != null, "Run's 'CurrentMassTag' has not been declared"); switch (this.IsotopicProfileType) { case Globals.IsotopicProfileType.UNLABELLED: Check.Require(run.CurrentMassTag.IsotopicProfile != null, "Target's theoretical isotopic profile has not been established"); iso = run.CurrentMassTag.IsotopicProfile.CloneIsotopicProfile(); break; case Globals.IsotopicProfileType.LABELLED: Check.Require(run.CurrentMassTag.IsotopicProfileLabelled != null, "Target's labelled theoretical isotopic profile has not been established"); iso = run.CurrentMassTag.IsotopicProfileLabelled.CloneIsotopicProfile(); break; default: iso = run.CurrentMassTag.IsotopicProfile.CloneIsotopicProfile(); break; } for (var i = 0; i < MaxPeaksToInclude; i++) { if (i >= iso.Peaklist.Count) { var lastPeak = iso.Peaklist[iso.Peaklist.Count - 1]; var newPeak = new MSPeak(); newPeak.XValue = lastPeak.XValue + Globals.MASS_DIFF_BETWEEN_ISOTOPICPEAKS / iso.ChargeState; newPeak.Height = _valueForAppendedTheorPeaks; newPeak.Width = lastPeak.Width; newPeak.MSFeatureID = lastPeak.MSFeatureID; iso.Peaklist.Add(newPeak); } } //adjust the target m/z based on the alignment information if (run.MassIsAligned) { for (var i = 0; i < iso.Peaklist.Count; i++) { iso.Peaklist[i].XValue = run.GetTargetMZAligned(iso.Peaklist[i].XValue); } } return(iso); }
/// <summary> /// Copy constructor /// </summary> /// <param name="pk"></param> public ThrashV1Peak(MSPeak pk) { Mz = pk.XValue; FWHM = pk.Width; Intensity = pk.Height; SignalToNoiseDbl = pk.SignalToNoise; DataIndex = pk.DataIndex; PeakIndex = -1; }
public IsotopicProfile GetMixedIsotopicProfile() { IsotopicProfile mixedIso = null; foreach (var isotopicProfileComponent in IsotopicProfiles) { if (mixedIso == null) { mixedIso = isotopicProfileComponent.IsotopicProfile.CloneIsotopicProfile(); mixedIso.Peaklist.Clear(); } //we need to first make sure all the intensities of the peaks add up to 1 for each isotopic profile //then we need to adjust the ratios of each peak according to the fractional amount the isotopic profile contributes to the mixture var iso = isotopicProfileComponent.IsotopicProfile.CloneIsotopicProfile(); var sumIntensities = iso.Peaklist.Sum(p => p.Height); foreach (var msPeak in iso.Peaklist) { msPeak.Height = (float)(msPeak.Height / sumIntensities * isotopicProfileComponent.Fraction); } for (var i = 0; i < iso.Peaklist.Count; i++) { var currentPeak = iso.Peaklist[i]; var indexOfPeak = GetIndexOfTargetPeak(mixedIso, currentPeak.XValue, out var mixedIsoContainsMZ); if (mixedIsoContainsMZ) { mixedIso.Peaklist[indexOfPeak].Height += currentPeak.Height; } else { var addedPeak = new MSPeak(currentPeak.XValue, currentPeak.Height, currentPeak.Width, currentPeak.SignalToNoise) { MSFeatureID = currentPeak.MSFeatureID, DataIndex = currentPeak.DataIndex }; var insertionIndex = indexOfPeak - 1; //the above method returns the m/z of the next highest peak if (insertionIndex >= 0) { mixedIso.Peaklist.Insert(insertionIndex, addedPeak); } else { mixedIso.Peaklist.Add(addedPeak); } } } } return(mixedIso); }
private MSPeak convertDeconPeakToMSPeak(DeconToolsV2.Peaks.clsPeak monoPeak) { MSPeak peak = new MSPeak(); peak.XValue = monoPeak.mdbl_mz; peak.Width = (float)monoPeak.mdbl_FWHM; peak.SignalToNoise = (float)monoPeak.mdbl_SN; peak.Height = (int)monoPeak.mdbl_intensity; return(peak); }
private List <DeconTools.Backend.Core.IsotopicProfile> ConvertRapidResultsToProfileList(DeconToolsV2.Peaks.clsPeak[] peaklist, ref int[] chargeResults, ref double[] intensityResults, ref double[] mzResults, ref double[] scoreResults, ref double[] avgmassResults, ref double[] massResults, ref double[] mostAbundantMassResults) { List <IsotopicProfile> isotopicProfileList = new List <IsotopicProfile>(); for (int i = 0; i < chargeResults.Length; i++) { if (chargeResults[i] == 0) { continue; } IsotopicProfile profile = new IsotopicProfile(); profile.ChargeState = chargeResults[i]; profile.IntensityMostAbundant = (float)intensityResults[i]; profile.IntensityMostAbundantTheor = profile.IntensityMostAbundant; profile.Score = scoreResults[i]; MSPeak monoPeak = new MSPeak(); monoPeak.XValue = ConvertMassToMZ(massResults[i], profile.ChargeState); GetIsotopicProfilePeaks(peaklist, profile.ChargeState, monoPeak.XValue, ref profile); if (profile.Peaklist.Count == 0) // couldn't find original monoIsotopicPeak in the peaklist { //So first check and see if it is the most abundant peak (mzResults returns the mz for the most abundant peak); get the m/z from there (This m/z matches with DeconTools peaklist m/z values) if (Math.Abs(monoPeak.XValue - mzResults[i]) < (1 / profile.ChargeState - 1 / profile.ChargeState * 0.2)) { monoPeak.XValue = mzResults[i]; profile.Peaklist = new List <MSPeak>(); profile.Peaklist.Add(monoPeak); } else // happens if the mono peak is not the most abundant peak. Will have to use Rapid's calculated value for the mono peak { profile.Peaklist = new List <MSPeak>(); profile.Peaklist.Add(monoPeak); } } double mostabundantPeakMZ = mzResults[i]; Console.WriteLine("mostAbundantPeakMZ = " + mostabundantPeakMZ); Console.WriteLine("calculated mostAbundantMZ = " + ConvertMassToMZ(mostAbundantMassResults[i], profile.ChargeState)); profile.MonoIsotopicMass = massResults[i]; profile.MostAbundantIsotopeMass = mostAbundantMassResults[i]; profile.AverageMass = avgmassResults[i]; profile.MonoPeakMZ = profile.GetMZ(); isotopicProfileList.Add(profile); } return(isotopicProfileList); }
public static List <Peak> CreatePeakDataFromXYData(XYData xyData, double peakWidth) { var msPeakList = new List <Peak>(); for (var i = 0; i < xyData.Xvalues.Length; i++) { var peak = new MSPeak(xyData.Xvalues[i], (float)xyData.Yvalues[i], (float)peakWidth, 0); msPeakList.Add(peak); } return(msPeakList); }
private void GetIsotopicProfilePeaks(List <Peak> peakList, int chargeState, double monoMass, ref IsotopicProfile inputProfile) { double toleranceInPPM = 20; var tff = new BasicTFF(toleranceInPPM); var theorProfile = new IsotopicProfile(); theorProfile.MonoIsotopicMass = monoMass; theorProfile.ChargeState = chargeState; theorProfile.MonoPeakMZ = monoMass / chargeState + Globals.PROTON_MASS; //a hack to guess how many peaks to include in the theor isotopic profile int numPeaksToIncludeInProfile = (int)Math.Round(Math.Max(3, 3 + (monoMass - 1000) / 1000)); double monoPeakMZ = monoMass / chargeState + Globals.PROTON_MASS; for (int i = 0; i < numPeaksToIncludeInProfile; i++) { var peak = new MSPeak(); peak.XValue = monoPeakMZ + i * Globals.MASS_DIFF_BETWEEN_ISOTOPICPEAKS / chargeState; if (i == 0) { peak.Height = 1; } else { peak.Height = 0; } theorProfile.Peaklist.Add(peak); } var foundIso = tff.FindMSFeature(peakList, theorProfile); if (foundIso == null) { var monoPeak = PeakUtilities.GetPeaksWithinTolerance(peakList, monoPeakMZ, toleranceInPPM).OrderByDescending(p => p.Height).FirstOrDefault(); if (monoPeak != null) { inputProfile.Peaklist.Add((MSPeak)monoPeak); } } else { inputProfile.Peaklist = new List <MSPeak>(foundIso.Peaklist); } }
private void GetIsotopicProfilePeaks(DeconToolsV2.Peaks.clsPeak[] peaklist, int chargeState, double monoMZ, ref IsotopicProfile profile) { profile.Peaklist = new List <MSPeak>(); double mzVar = 0.01; // TODO: find a more accurate way of defining the mz variability DeconToolsV2.Peaks.clsPeak monoPeak = lookupPeak(monoMZ, peaklist, mzVar); if (monoPeak != null) { MSPeak mspeak = convertDeconPeakToMSPeak(monoPeak); profile.Peaklist.Add(mspeak); return; } }
private XYData GetTheoreticalIsotopicProfileXYData(IsotopicProfile iso, double fwhm, double minRelIntensity) { var xydata = new XYData(); var xvals = new List <double>(); var yvals = new List <double>(); var mspeaks = new List <MSPeak>(iso.Peaklist); var zeroIntensityPeakToTheLeft = new MSPeak(); zeroIntensityPeakToTheLeft.XValue = iso.Peaklist[0].XValue - 1 * 1.00235 / iso.ChargeState; zeroIntensityPeakToTheLeft.Height = 0; mspeaks.Insert(0, zeroIntensityPeakToTheLeft); //TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData() for (var peakIndex = 0; peakIndex < mspeaks.Count; peakIndex++) { var msPeak = mspeaks[peakIndex]; var tempXYData = TheorXYDataCalculationUtilities.GetTheorPeakData(msPeak, fwhm, NumPointsPerTheorPeak); for (var j = 0; j < tempXYData.Xvalues.Length; j++) { //First peak is a zero-intensity peak. We always want to add that one. For the others, //add intensity points that are above a certain intensity if (peakIndex > 0) { if (tempXYData.Yvalues[j] >= minRelIntensity) { xvals.Add(tempXYData.Xvalues[j]); yvals.Add(tempXYData.Yvalues[j]); } } else { xvals.Add(tempXYData.Xvalues[j]); yvals.Add(tempXYData.Yvalues[j]); } } } xydata.Xvalues = xvals.ToArray(); xydata.Yvalues = yvals.ToArray(); return(xydata); }
private List <Peak> ConvertDeconEnginePeakList(List <ThrashV1Peak> peakList) { var returnedList = new List <Peak>(); foreach (var p in peakList) { var peak = new MSPeak(p.Mz, (int)p.Intensity, (float)p.FWHM, p.SignalToNoise) { DataIndex = p.DataIndex // this points to the index value of the raw xy values - I think }; returnedList.Add(peak); } return(returnedList); }
public int containsPeak(MSPeak peak, int frameNum, int scanNum, int toleranceInPPM, int netRange, int driftRange) { if (peak == null) { return(-1); } else { //TODO:: two peaks are the same if they are within a tolerance of each other in //terms of mz, scan and lc frame. in this case we're only implementing mz values // double differenceInPPM = Math.Abs(1000000 * (peak.XValue - this.XValue) / this.XValue); if (differenceInPPM <= toleranceInPPM) { //it's within the mass tolerance of our peak //now check for net tolerance //check if the frameScansRange bit is set for the frame number and a few other scans within tolerance for (int i = frameNum - netRange; i < frameNum + netRange; i++) { for (int j = scanNum - driftRange; j < scanNum + driftRange; j++) { if (frameScansRange[j, i] == true) { //that means it's within the net and drift time tolerances of the current peak return(0); } } } int netDiff = this.Frame_num.CompareTo(frameNum); if (netDiff == 0) { //now compare on scan range return(this.Scan_num.CompareTo(frameNum)); } else { return(netDiff); } } else { return(this.XValue.CompareTo(peak.XValue)); } } }
private List <DeconTools.Backend.Core.Peak> ConvertDeconEnginePeakList(List <ThrashV1Peak> peakList) { var returnedList = new List <Peak>(); foreach (var p in peakList) { var peak = new MSPeak(); peak.XValue = p.Mz; peak.Height = (int)p.Intensity; peak.SignalToNoise = (float)p.SignalToNoise; peak.Width = (float)p.FWHM; peak.DataIndex = p.DataIndex; // this points to the index value of the raw xy values - I think returnedList.Add(peak); } return(returnedList); }
//NOTE: this is duplicated code from the O16O18IterativeTff public IsotopicProfile ConvertO16ProfileToO18(IsotopicProfile theorFeature, int numPeaksToShift) { var o18Iso = new IsotopicProfile { ChargeState = theorFeature.ChargeState, Peaklist = new List <MSPeak>() }; var mzBetweenIsotopes = 1.003 / theorFeature.ChargeState; foreach (var theorpeak in theorFeature.Peaklist) { var peak = new MSPeak(theorpeak.XValue, theorpeak.Height, theorpeak.Width, theorpeak.SignalToNoise); peak.XValue += numPeaksToShift * mzBetweenIsotopes; o18Iso.Peaklist.Add(peak); } return(o18Iso); }
public void FindMSPeaksTest1() { ParameterLoader loader = new ParameterLoader(); loader.LoadParametersFromFile(parameterFilename); Run run = new IMFRun(imfFilepath); run.CurrentScanSet = new ScanSet(1, 1, 100000); ResultCollection resultcollection = new ResultCollection(run); Task msgen = new GenericMSGenerator(); msgen.Execute(resultcollection); DeconToolsPeakDetector peakfinder = new DeconToolsPeakDetector(loader.PeakParameters); peakfinder.Execute(resultcollection); StringBuilder sb = new StringBuilder(); for (int i = 0; i < resultcollection.Run.PeakList.Count; i++) { MSPeak mspeak = (MSPeak)resultcollection.Run.PeakList[i]; sb.Append(resultcollection.Run.PeakList[i].XValue); sb.Append("\t"); sb.Append(resultcollection.Run.PeakList[i].Height); sb.Append("\t"); sb.Append(mspeak.SN); sb.Append("\t"); sb.Append(resultcollection.Run.PeakList[i].Width); sb.Append("\t"); sb.Append(Environment.NewLine); } Console.Write(sb.ToString()); Assert.AreEqual(2438, resultcollection.Run.PeakList.Count); Assert.AreEqual(547.316411323136, Convert.ToDecimal(resultcollection.Run.PeakList[982].XValue)); Assert.AreEqual(100385, resultcollection.Run.PeakList[982].Height); }
private MSPeak GetMaxPeak(IEnumerable <MSPeak> mspeakList) { MSPeak maxMsPeak = null; foreach (var msPeak in mspeakList) { if (maxMsPeak == null) { maxMsPeak = msPeak; continue; } if (msPeak.Height > maxMsPeak.Height) { maxMsPeak = msPeak; } } return(maxMsPeak); }
public void test1() { Run run = new XCaliburRun(xcaliburTestfile); Task msgen = new GenericMSGenerator(); Task peakDetector = new DeconToolsPeakDetector(); run.CurrentScanSet = new ScanSet(6005); msgen.Execute(run.ResultCollection); peakDetector.Execute(run.ResultCollection); MSPeak testPeak = (MSPeak)run.PeakList[500]; PattersonChargeStateCalculator chargeCalc = new PattersonChargeStateCalculator(); short chargeState = chargeCalc.GetChargeState(run.XYData, run.PeakList, testPeak); Console.WriteLine(testPeak.XValue + "; Charge = " + chargeState); }
private void offsetDistribution(XYData theorXYData, IsotopicProfile theorIsotopicProfile, IsotopicProfile obsIsotopicProfile) { double offset = 0; if (theorIsotopicProfile == null || theorIsotopicProfile.Peaklist == null || theorIsotopicProfile.Peaklist.Count == 0) { return; } MSPeak mostIntensePeak = theorIsotopicProfile.getMostIntensePeak(); int indexOfMostIntensePeak = theorIsotopicProfile.Peaklist.IndexOf(mostIntensePeak); if (obsIsotopicProfile.Peaklist == null || obsIsotopicProfile.Peaklist.Count == 0) { return; } bool enoughPeaksInTarget = (indexOfMostIntensePeak <= obsIsotopicProfile.Peaklist.Count - 1); if (enoughPeaksInTarget) { MSPeak targetPeak = obsIsotopicProfile.Peaklist[indexOfMostIntensePeak]; offset = targetPeak.XValue - mostIntensePeak.XValue; //offset = observedIsotopicProfile.Peaklist[0].XValue - theorIsotopicProfile.Peaklist[0].XValue; //want to test to see if Thrash is same as rapid } else { offset = obsIsotopicProfile.Peaklist[0].XValue - theorIsotopicProfile.Peaklist[0].XValue; } for (int i = 0; i < theorXYData.Xvalues.Length; i++) { theorXYData.Xvalues[i] = theorXYData.Xvalues[i] + offset; } foreach (var peak in theorIsotopicProfile.Peaklist) { peak.XValue = peak.XValue + offset; } }
public bool FindPeakWithinFeatures(IPeak value, int frameNum, int scanNum, int toleranceInPPM, int netTolRange, int driftTolRange) { BinaryTreeNode <T> node = this.head; while (node != null) { try { MSResultPeakWithLocation thisFeature = node.Value as MSResultPeakWithLocation; MSPeak msPeak = value as MSPeak; //now check if the peak value is within the mass tolerance of this UMC int number = thisFeature.containsPeak(msPeak, frameNum, scanNum, toleranceInPPM, netTolRange, driftTolRange); if (number == 0) { //we've found a node that contains that feature value return(true); } else if (number < 0) { //search in the left tree node = node.LeftChild; } else { //search in the right tree node = node.RightChild; } } catch (InvalidCastException invalidCast) { Console.WriteLine("The node is not of type UMC"); Console.WriteLine(invalidCast.Message); } } return(false); }
/// <summary> /// This applies an offset to the XY data of the theoretical distribution. This is typically done /// to align the theoretical distribution to the observed dist. The algorithm finds the most /// intense peak of the theor dist, and then checks to see if the same relative peak is available in /// the observed dist. The offset is calculated from the difference in the mz of these two peaks. /// If the relative peak can't be found in the observed dist, then the theor dist is offset based on /// the first peak of each dist. /// </summary> /// <param name="targetIsotopicProfile"></param> public void OffsetDistribution(IsotopicProfile targetIsotopicProfile) { double offset = 0; getIsotopicProfile(); //this generates the peakList from the theor dist if (this.isotopicProfile == null || this.isotopicProfile.Peaklist == null || this.isotopicProfile.Peaklist.Count == 0) { return; } MSPeak mostIntensePeak = this.isotopicProfile.getMostIntensePeak(); int indexOfMostIntensePeak = this.isotopicProfile.Peaklist.IndexOf(mostIntensePeak); if (targetIsotopicProfile.Peaklist == null || targetIsotopicProfile.Peaklist.Count == 0) { return; } bool enoughPeaksInTarget = (indexOfMostIntensePeak <= targetIsotopicProfile.Peaklist.Count - 1); if (enoughPeaksInTarget) { MSPeak targetPeak = targetIsotopicProfile.Peaklist[indexOfMostIntensePeak]; //offset = targetPeak.MZ - mostIntensePeak.MZ; offset = targetIsotopicProfile.Peaklist[0].MZ - this.isotopicProfile.Peaklist[0].MZ; //want to test to see if Thrash is same as rapid } else { offset = targetIsotopicProfile.Peaklist[0].MZ - this.isotopicProfile.Peaklist[0].MZ; } for (int i = 0; i < this.data.Xvalues.Length; i++) { this.data.Xvalues[i] = this.data.Xvalues[i] + offset; } }
public MSPeakResult(int peakID, int frameNum, int scanNum, MSPeak peak) : this(peakID, scanNum, peak) { this.FrameNum = frameNum; }
public MSPeakResult(int peakID, int scanNum, MSPeak peak) : this() { this.PeakID = peakID; this.Scan_num = scanNum; this.MSPeak = peak; }
public void AddPeak(MSPeak argPeak) { if (argPeak.MonoisotopicMZ > _maxMZ) { _maxMZ = argPeak.MonoisotopicMZ; } if (argPeak.MonoisotopicMZ <= _minMZ) { _minMZ = argPeak.MonoisotopicMZ; } if (argPeak.MonoIntensity > _maxIntensity) { _maxIntensity = argPeak.MonoIntensity; } if (argPeak.MonoIntensity <= _minIntensity) { _minIntensity = argPeak.MonoIntensity; } _lstMsPeak.Add(argPeak); _lstMsPeak.Sort(); }
/// <summary> /// TODO: add info here /// </summary> /// <param name="intensityMap"></param> /// <param name="maxIntensity"></param> /// <param name="threshold"></param> /// <param name="startFrameInMap"></param> /// <param name="startScanInMap"></param> /// <param name="startFrame"></param> /// <param name="startScan"></param> /// <param name="frameAndScanNumbers"></param> /// <param name="minimumScanNumber"></param> /// <param name="maximumScanNumber"></param> /// <param name="totalSummed"></param> /// <returns></returns> public List <MSPeakResult> getFrameAndScanNumberListFromIntensityMap(int[][] intensityMap, int maxIntensity, float threshold, ushort startFrameInMap, ushort startScanInMap, ushort startFrame, ushort startScan, Dictionary <ushort, List <ushort> > frameAndScanNumbers, out ushort minimumScanNumber, out ushort maximumScanNumber, out ushort totalSummed) { var peaksForCurveFitting = new List <MSPeakResult>(3000); var peakId = 0; var frameIndex = startFrameInMap; var scanIndex = startScanInMap; var scanNumber = startScan; var frameNumber = startFrame; totalSummed = 0; //multiply the threshold by max intensity for now threshold *= maxIntensity; //start at the center of the map minimumScanNumber = ushort.MaxValue; maximumScanNumber = ushort.MinValue; //go up from the start frame value while (frameIndex > 0 && intensityMap[frameIndex][startScanInMap] >= threshold) { var scanNumberList = new List <ushort>(200); var end = intensityMap[frameIndex].Length; scanIndex = startScanInMap; scanNumber = startScan; //go left to determine the first value taht's below the threshold while (scanIndex > 0 && intensityMap[frameIndex][scanIndex] > threshold) { var peak = new MSPeak(); peak.Height = intensityMap[frameIndex][scanIndex]; var msPeak = new MSPeakResult(peakId++, frameNumber, scanNumber, peak); peaksForCurveFitting.Add(msPeak); if (scanNumber < minimumScanNumber) { minimumScanNumber = scanNumber; } else if (scanNumber > maximumScanNumber) { maximumScanNumber = scanNumber; } scanNumberList.Add(scanNumber--); scanIndex--; } //start the search for the right value from the next scan scanIndex = (ushort)(startScanInMap + 1); scanNumber = (ushort)(startScan + 1); //go right to determine the next value that's below the threshold while (scanIndex < end && intensityMap[frameIndex][scanIndex] > threshold) { var peak = new MSPeak(); peak.Height = intensityMap[frameIndex][scanIndex]; var msPeak = new MSPeakResult(peakId++, frameNumber, scanNumber, peak); peaksForCurveFitting.Add(msPeak); if (scanNumber < minimumScanNumber) { minimumScanNumber = scanNumber; } else if (scanNumber > maximumScanNumber) { maximumScanNumber = scanNumber; } scanNumberList.Add(scanNumber++); scanIndex++; } frameIndex--; //this means we've finished adding scan numbers to the list for current frame //now check if that is more than 3 if (scanNumberList.Count < 3) { break; } else { scanNumberList.Sort(); frameAndScanNumbers.Add(frameNumber, scanNumberList); totalSummed += (ushort)scanNumberList.Count; } frameNumber--; } //go down frameIndex = (ushort)(startFrameInMap + 1); scanIndex = startScanInMap; scanNumber = startScan; frameNumber = (ushort)(startFrame + 1); while (frameIndex < intensityMap.Length - 1 && intensityMap[frameIndex][startScanInMap] >= threshold) { //processing frame // Console.WriteLine("processing frame " + frameIndex); var scanNumberList = new List <ushort>(200); var end = intensityMap[frameIndex].Length; scanIndex = startScanInMap; scanNumber = startScan; //go left to determine the first value taht's below the threshold while (scanIndex > 0 && intensityMap[frameIndex][scanIndex] > threshold) { var peak = new MSPeak(); peak.Height = intensityMap[frameIndex][scanIndex]; var msPeak = new MSPeakResult(peakId++, frameNumber, scanNumber, peak); peaksForCurveFitting.Add(msPeak); if (scanNumber < minimumScanNumber) { minimumScanNumber = scanNumber; } else if (scanNumber > maximumScanNumber) { maximumScanNumber = scanNumber; } scanNumberList.Add(scanNumber--); scanIndex--; } //start the search for the right value from the next scan scanIndex = (ushort)(startScanInMap + 1); scanNumber = (ushort)(startScan + 1); //go right to determine the next value that's below the threshold while (scanIndex < end && intensityMap[frameIndex][scanIndex] > threshold) { var peak = new MSPeak(); peak.Height = intensityMap[frameIndex][scanIndex]; var msPeak = new MSPeakResult(peakId++, frameNumber, scanNumber, peak); peaksForCurveFitting.Add(msPeak); if (scanNumber < minimumScanNumber) { minimumScanNumber = scanNumber; } else if (scanNumber > maximumScanNumber) { maximumScanNumber = scanNumber; } scanNumberList.Add(scanNumber++); scanIndex++; } frameIndex++; //this means we've finished adding scan numbers to the list for current frame //now check if that is more than 3 if (scanNumberList.Count < 3) { break; } else { scanNumberList.Sort(); frameAndScanNumbers.Add(frameNumber, scanNumberList); totalSummed += (ushort)scanNumberList.Count; } frameNumber++; } return(peaksForCurveFitting); }
public static int DescendingIntensityComparison(MSPeak left, MSPeak right) { return -(left.Intensity.CompareTo(right.Intensity)); }
public static int AscendingMassComparison(MSPeak left, MSPeak right) { return left.Mass.CompareTo(right.Mass); }