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); }
private void GenerateResults( IEnumerable <HornTransformResults> transformResults, ThrashV1Peak[] mspeakList, ResultCollection resultList, bool processingWasAborted, int maxProcessingTimeMinutes) { ScanSet currentScanset; var currentRun = resultList.Run as UIMFRun; bool processingUIMF; if (currentRun != null) { currentScanset = currentRun.CurrentIMSScanSet; processingUIMF = true; } else { currentScanset = resultList.Run.CurrentScanSet; processingUIMF = false; } currentScanset.NumIsotopicProfiles = 0; //reset to 0; foreach (var hornResult in transformResults) { var result = resultList.CreateIsosResult(); var profile = new IsotopicProfile { AverageMass = hornResult.AverageMw, ChargeState = hornResult.ChargeState, MonoIsotopicMass = hornResult.MonoMw, Score = hornResult.Fit, ScoreCountBasis = hornResult.FitCountBasis, MostAbundantIsotopeMass = hornResult.MostIntenseMw }; GetIsotopicProfile(hornResult.IsotopePeakIndices, mspeakList, ref profile); profile.IntensityMostAbundant = (float)hornResult.Abundance; profile.IntensityMostAbundantTheor = (float)hornResult.Abundance; if (NumPeaksUsedInAbundance == 1) // fyi... this is typical { result.IntensityAggregate = profile.IntensityMostAbundant; } else { result.IntensityAggregate = SumPeaks(profile, hornResult.Abundance); } profile.MonoPlusTwoAbundance = profile.GetMonoPlusTwoAbundance(); profile.MonoPeakMZ = profile.GetMZ(); result.IsotopicProfile = profile; AddDeconResult(resultList, result, DeconResultComboMode.simplyAddIt); //resultList.ResultList.Add(result); currentScanset.NumIsotopicProfiles++; } if (!processingWasAborted) { return; } string messageBase; if (processingUIMF) { // LC-IMS-MS dataset if (currentScanset.GetScanCount() <= 1) { messageBase = string.Format("Aborted processing of frame {0}, IMS scan {1}", currentScanset.PrimaryScanNumber, currentScanset.getLowestScanNumber()); } else { messageBase = string.Format("Aborted processing of frame {0}, IMS scans {1}-{2}", currentScanset.PrimaryScanNumber, currentScanset.getLowestScanNumber(), currentScanset.getHighestScanNumber()); } } else { // LC-MS dataset if (currentScanset.GetScanCount() <= 1) { messageBase = string.Format("Aborted processing of scan {0}", currentScanset.getLowestScanNumber()); } else { messageBase = string.Format("Aborted processing of summed scans {0}-{1}", currentScanset.getLowestScanNumber(), currentScanset.getHighestScanNumber()); } } Console.WriteLine("{0}; runtime exceeded {1} minutes. IsotopicProfileCount={2}", messageBase, maxProcessingTimeMinutes, currentScanset.NumIsotopicProfiles); }
private void GenerateResults(ResultCollection resultList, ref int[] chargeResults, ref double[] intensityResults, ref double[] mzResults, ref double[] scoreResults, ref double[] avgmassResults, ref double[] massResults, ref double[] mostAbundantMassResults, DeconResultComboMode comboMode) { ScanSet currentScanset; if (resultList.Run is UIMFRun) { currentScanset = ((UIMFRun)resultList.Run).CurrentIMSScanSet; } else { currentScanset = resultList.Run.CurrentScanSet; } currentScanset.NumIsotopicProfiles = 0; //reset to 0; for (int i = 0; i < chargeResults.Length; i++) { if (chargeResults[i] == 0) { continue; } double rapidScore = scoreResults[i]; if ((float)rapidScore == 0.9999999999999f) { continue; // this is an oddity about the Rapid results. For very poor or immeasurable scores, it will give a score of 1.000000000; } IsosResult result = resultList.CreateIsosResult(); result.IntensityAggregate = intensityResults[i]; IsotopicProfile profile = new IsotopicProfile(); profile.ChargeState = chargeResults[i]; profile.Score = scoreResults[i]; MSPeak monoPeak = new MSPeak(); monoPeak.XValue = ConvertMassToMZ(massResults[i], profile.ChargeState); //TODO: make it so that the entire isotopic profile peak list is populated. Right now, just the monoisotopic peak is found. GetIsotopicProfilePeaks(resultList.Run.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(); result.IsotopicProfile = profile; //resultList.ResultList.Add(result); this.AddDeconResult(resultList, result, comboMode); currentScanset.NumIsotopicProfiles++; } }