public void PickChromatogramPeaks() { // Make sure times are evenly spaced before doing any peak detection. EvenlySpaceTimes(); // Pick peak groups at the precursor level foreach (var chromDataSet in _dataSets) { chromDataSet.PickChromatogramPeaks(_retentionTimes, _isAlignedTimes); } // Merge where possible and pick peak groups at the peptide level _listListPeakSets.Clear(); foreach (var dataSets in ComparableDataSets) { _listListPeakSets.Add(PickPeptidePeaks(dataSets.ToArray())); } // Adjust peak dimensions based on peak picking foreach (var chromDataSet in _dataSets) { chromDataSet.GeneratePeakData(); } var detailedCalcs = DetailedPeakFeatureCalculators.Select(calc => (IPeakFeatureCalculator)calc).ToList(); foreach (var listPeakSets in _listListPeakSets) { var maxPossibleShift = GetMaxPossibleShift(listPeakSets); // Score the peaks under the legacy model score foreach (var peakSet in listPeakSets.Where(peakSet => peakSet != null)) { var context = new PeakScoringContext(_document); context.AddInfo(_predictedRetentionTime); context.AddInfo(maxPossibleShift); peakSet.ScorePeptideSets(context, detailedCalcs); } SortAndLimitPeaks(listPeakSets); } // Propagate sorting down to precursor level UpdatePrecursorsFromPeptidePeaks(); // Sort transition group level peaks by retention time and record the best peak foreach (var chromDataSet in _dataSets) { chromDataSet.StorePeaks(); } }
public void ScorePeptideSets(PeakScoringContext context, IList <IPeakFeatureCalculator> detailFeatureCalculators) { var modelCalcs = ScoringModel.PeakFeatureCalculators; var detailFeatures = new float [detailFeatureCalculators.Count]; var modelFeatures = new float [modelCalcs.Count]; // Here we score both the detailFeatureCalculators (for storage) // and the peak calculators of the legacy model (for import-stage peak scoring) // This will cause some scores to be calculated multiple times, but score // caching should make this fast. var allFeatureCalculators = detailFeatureCalculators.Union(modelCalcs); // Calculate summary data once for all scores var summaryData = new PeptidePeakDataConverter <IDetailedPeakData>(this); foreach (var calc in allFeatureCalculators) { float feature; var summaryCalc = calc as SummaryPeakFeatureCalculator; if (summaryCalc != null) { feature = summaryCalc.Calculate(context, summaryData); } else { feature = calc.Calculate(context, this); } int detailIndex = detailFeatureCalculators.IndexOf(calc); if (detailIndex != -1) { detailFeatures[detailIndex] = feature; } int modelIndex = modelCalcs.IndexOf(calc); if (modelIndex != -1) { modelFeatures[modelIndex] = double.IsNaN(feature) ? 0 : feature; } } CombinedScore = ScoringModel.Score(modelFeatures); foreach (var peak in this.Where(peak => peak.PeakGroup != null)) { peak.PeakGroup.DetailScores = detailFeatures; } }