public List <ChromPeakQualityData> GetChromPeakQualityData(Run run, IqTarget target, List <Peak> chromPeakList) { var peakQualityList = new List <ChromPeakQualityData>(); if (MSGenerator == null) { MSGenerator = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); MSGenerator.IsTICRequested = false; } //iterate over peaks within tolerance and score each peak according to MSFeature quality #if DEBUG var tempMinScanWithinTol = (int)run.NetAlignmentInfo.GetScanForNet(target.ElutionTimeTheor - Parameters.ChromNETTolerance); var tempMaxScanWithinTol = (int)run.NetAlignmentInfo.GetScanForNet(target.ElutionTimeTheor + Parameters.ChromNETTolerance); var tempCenterTol = (int)run.NetAlignmentInfo.GetScanForNet(target.ElutionTimeTheor); Console.WriteLine("SmartPeakSelector --> NETTolerance= " + Parameters.ChromNETTolerance + "; chromMinCenterMax= " + tempMinScanWithinTol + "\t" + tempCenterTol + "" + "\t" + tempMaxScanWithinTol); Console.WriteLine("MT= " + target.ID + ";z= " + target.ChargeState + "; mz= " + target.MZTheor.ToString("0.000") + "; ------------------------- PeaksWithinTol = " + chromPeakList.Count); #endif //target.NumChromPeaksWithinTolerance = peaksWithinTol.Count; foreach (ChromPeak chromPeak in chromPeakList) { // TODO: Currently hard-coded to sum only 1 scan var lcscanset = _chromPeakUtilities.GetLCScanSetForChromPeak(chromPeak, run, 1); //generate a mass spectrum var massSpectrumXYData = MSGenerator.GenerateMS(run, lcscanset); //find isotopic profile var mspeakList = new List <Peak>(); var observedIso = TargetedMSFeatureFinder.IterativelyFindMSFeature(massSpectrumXYData, target.TheorIsotopicProfile, out mspeakList); double fitScore = 1; double iscore = 1; //get fit score fitScore = FitScoreCalc.CalculateFitScore(target.TheorIsotopicProfile, observedIso, massSpectrumXYData); //get i_score iscore = InterferenceScorer.GetInterferenceScore(target.TheorIsotopicProfile, mspeakList); var leftOfMonoPeakLooker = new LeftOfMonoPeakLooker(); var peakToTheLeft = leftOfMonoPeakLooker.LookforPeakToTheLeftOfMonoPeak(target.TheorIsotopicProfile.getMonoPeak(), target.ChargeState, mspeakList); var hasPeakTotheLeft = peakToTheLeft != null; //collect the results together var pq = new ChromPeakQualityData(chromPeak); if (observedIso == null) { pq.IsotopicProfileFound = false; } else { pq.IsotopicProfileFound = true; pq.Abundance = observedIso.IntensityMostAbundant; pq.FitScore = fitScore; pq.InterferenceScore = iscore; pq.IsotopicProfile = observedIso; pq.IsIsotopicProfileFlagged = hasPeakTotheLeft; pq.ScanLc = lcscanset.PrimaryScanNumber; } peakQualityList.Add(pq); #if DEBUG pq.Display(); #endif } return(peakQualityList); }
protected virtual void ExecuteWorkflow(IqResult result) { result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState); result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor); result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram); result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram); ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList); ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList); result.IqResultDetail.ChromPeakQualityData = ChromPeakAnalyzer.GetChromPeakQualityData(Run, result.Target, result.ChromPeakList); var filterOutFlagged = result.Target.TheorIsotopicProfile.GetIndexOfMostIntensePeak() == 0; result.ChromPeakSelected = ChromPeakSelector.SelectBestPeak(result.IqResultDetail.ChromPeakQualityData, filterOutFlagged); result.LCScanSetSelected = ChromPeakUtilities.GetLCScanSetForChromPeak(result.ChromPeakSelected, Run, WorkflowParameters.NumMSScansToSum); result.LcScanObs = result.LCScanSetSelected == null ? -1 : result.LCScanSetSelected.PrimaryScanNumber; result.IqResultDetail.MassSpectrum = MSGenerator.GenerateMS(Run, result.LCScanSetSelected); TrimData(result.IqResultDetail.MassSpectrum, result.Target.MZTheor, MsLeftTrimAmount, MsRightTrimAmount); List <Peak> mspeakList; result.ObservedIsotopicProfile = MsfeatureFinder.IterativelyFindMSFeature(result.IqResultDetail.MassSpectrum, result.Target.TheorIsotopicProfile, out mspeakList); result.FitScore = FitScoreCalc.CalculateFitScore(result.Target.TheorIsotopicProfile, result.ObservedIsotopicProfile, result.IqResultDetail.MassSpectrum); result.InterferenceScore = InterferenceScorer.GetInterferenceScore(result.ObservedIsotopicProfile, mspeakList); //if (_workflowParameters.ChromatogramCorrelationIsPerformed) //{ // ExecuteTask(_chromatogramCorrelator); //} result.MonoMassObs = result.ObservedIsotopicProfile == null ? 0 : result.ObservedIsotopicProfile.MonoIsotopicMass; result.MZObs = result.ObservedIsotopicProfile == null ? 0 : result.ObservedIsotopicProfile.MonoPeakMZ; result.MZObsCalibrated = result.ObservedIsotopicProfile == null ? 0 : Run.GetAlignedMZ(result.ObservedIsotopicProfile.MonoPeakMZ, result.LcScanObs); result.MonoMassObsCalibrated = result.ObservedIsotopicProfile == null ? 0 : (result.MZObsCalibrated - DeconTools.Backend.Globals.PROTON_MASS) * result.Target.ChargeState; var elutionTime = result.ChromPeakSelected == null ? 0d : ((ChromPeak)result.ChromPeakSelected).NETValue; result.ElutionTimeObs = elutionTime; result.Abundance = GetAbundance(result); }