private double? PredictRetentionTimeUsingSpecifiedReplicates(SrmDocument document, PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, int? replicateNum, ExportSchedulingAlgorithm algorithm, bool singleWindow, Predicate<ChromatogramSet> replicateFilter, out double windowRT) { // If peptide has an explicitly set RT, use that if (nodePep.ExplicitRetentionTime != null && (MeasuredRTWindow.HasValue || nodePep.ExplicitRetentionTime.RetentionTimeWindow.HasValue)) { // If peptide has an explicitly set RT window, use that, or the global setting windowRT = nodePep.ExplicitRetentionTime.RetentionTimeWindow ?? MeasuredRTWindow.Value; return nodePep.ExplicitRetentionTime.RetentionTime; } // Safe defaults double? predictedRT = null; windowRT = 0; // Use measurements, if set and available bool useMeasured = (UseMeasuredRTs && MeasuredRTWindow.HasValue && document.Settings.HasResults); if (useMeasured) { var schedulingGroups = GetSchedulingGroups(nodePep, nodeGroup); var peakTime = TransitionGroupDocNode.GetSchedulingPeakTimes(schedulingGroups, document, algorithm, replicateNum, replicateFilter); if (peakTime != null) predictedRT = peakTime.CenterTime; if (predictedRT.HasValue) windowRT = MeasuredRTWindow.Value; else if (nodePep.Children.Count > 1) { // If their are other children of this peptide, look for one // with results that can be used to predict the retention time. foreach (TransitionGroupDocNode nodeGroupOther in nodePep.Children) { if (!ReferenceEquals(nodeGroup, nodeGroupOther)) { peakTime = nodeGroupOther.GetSchedulingPeakTimes(document, algorithm, replicateNum, replicateFilter); if (peakTime != null) predictedRT = peakTime.CenterTime; if (predictedRT.HasValue) { windowRT = MeasuredRTWindow.Value; break; } } } } } // If no retention time yet, and there is a predictor, use the predictor if (!predictedRT.HasValue && RetentionTime != null && RetentionTime.IsUsable) { // but only if not using measured results, or the instrument supports // variable scheduling windows if (!useMeasured || !singleWindow || MeasuredRTWindow == RetentionTime.TimeWindow) { string modifiedSequence = document.Settings.GetSourceTextId(nodePep); if (null != replicateFilter && document.Settings.HasResults) { var retentionTimes = new List<double>(); foreach (var chromSet in document.Settings.MeasuredResults.Chromatograms) { if (!replicateFilter(chromSet)) { continue; } foreach (ChromFileInfo chromFileInfo in chromSet.MSDataFileInfos) { var conversion = RetentionTime.GetConversion(chromFileInfo.FileId); if (null == conversion) { continue; } double? time = RetentionTime.GetRetentionTime(modifiedSequence, conversion); if (time.HasValue) { retentionTimes.Add(time.Value); } } } if (retentionTimes.Count > 0) { predictedRT = retentionTimes.Average(); } } if (!predictedRT.HasValue) { predictedRT = RetentionTime.GetRetentionTime(modifiedSequence); } windowRT = RetentionTime.TimeWindow; } } return predictedRT; }
public double? PredictRetentionTime(SrmDocument document, PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, int? replicateNum, ExportSchedulingAlgorithm algorithm, bool singleWindow, out double windowRT) { return PredictRetentionTimeUsingSpecifiedReplicates(document, nodePep, nodeGroup, replicateNum, algorithm, singleWindow, null, out windowRT); }