public TargetDecoyGenerator(SrmDocument document, IPeakScoringModel scoringModel, IFeatureScoreProvider scoreProvider, IProgressMonitor progressMonitor) : this(scoringModel, scoreProvider != null ? scoreProvider.GetFeatureScores(document, scoringModel, progressMonitor) : document.GetPeakFeatures(scoringModel.PeakFeatureCalculators, progressMonitor)) { }
public PeakTransitionGroupFeatureSet GetFeatureScores(SrmDocument document, IPeakScoringModel scoringModel, IProgressMonitor progressMonitor) { if (!ReferenceEquals(document, _document) || !ArrayUtil.EqualsDeep(_cacheCalculators, scoringModel.PeakFeatureCalculators)) { _document = document; _cacheCalculators = scoringModel.PeakFeatureCalculators; _cachedFeatureScores = document.GetPeakFeatures(_cacheCalculators, progressMonitor); } return(_cachedFeatureScores); }
public TargetDecoyGenerator(SrmDocument document, IPeakScoringModel scoringModel, IProgressMonitor progressMonitor = null) { // Determine which calculators will be used to score peaks in this document. FeatureCalculators = scoringModel.PeakFeatureCalculators.ToArray(); _peakTransitionGroupFeaturesList = document.GetPeakFeatures(FeatureCalculators, progressMonitor); PopulateDictionary(); EligibleScores = new bool[FeatureCalculators.Count]; // Disable calculators that have only a single score value or any unknown scores. for (int i = 0; i < FeatureCalculators.Count; i++) EligibleScores[i] = IsValidCalculator(i); }
public TargetDecoyGenerator(SrmDocument document, IPeakScoringModel scoringModel, IProgressMonitor progressMonitor = null) { // Determine which calculators will be used to score peaks in this document. FeatureCalculators = scoringModel.PeakFeatureCalculators.ToArray(); _peakTransitionGroupFeaturesList = document.GetPeakFeatures(FeatureCalculators, progressMonitor); PopulateDictionary(); EligibleScores = new bool[FeatureCalculators.Count]; // Disable calculators that have only a single score value or any unknown scores. for (int i = 0; i < FeatureCalculators.Count; i++) { EligibleScores[i] = IsValidCalculator(i); } }
private static IEnumerable <PeakTransitionGroupFeatures> GetPeakFeatures(this SrmDocument document, PeptideGroupDocNode nodePepGroup, PeptideDocNode nodePep, IList <IPeakFeatureCalculator> calcs, IDictionary <int, int> runEnumDict, bool verbose) { // Get peptide features for each set of comparable groups foreach (var nodeGroups in ComparableGroups(nodePep)) { var arrayGroups = nodeGroups.ToArray(); var labelType = arrayGroups[0].TransitionGroup.LabelType; foreach (var peakFeature in document.GetPeakFeatures(nodePepGroup, nodePep, labelType, arrayGroups, calcs, runEnumDict, verbose)) { yield return(peakFeature); } } }
public static PeakTransitionGroupFeatureSet GetPeakFeatures(this SrmDocument document, IList <IPeakFeatureCalculator> calcs, IProgressMonitor progressMonitor = null, bool verbose = false) { // Get features for each peptide int totalPeptides = document.MoleculeCount; int currentPeptide = 0; IProgressStatus status = new ProgressStatus(Resources.PeakFeatureEnumerator_GetPeakFeatures_Calculating_peak_group_scores); // Set up run ID dictionary var runEnumDict = new Dictionary <int, int>(); var chromatograms = document.Settings.MeasuredResults.Chromatograms; foreach (var fileInfo in chromatograms.SelectMany(c => c.MSDataFileInfos)) { runEnumDict.Add(fileInfo.FileIndex, runEnumDict.Count + 1); } // Using Parallel.For is quicker, but order needs to be maintained var moleculeGroupPairs = document.GetMoleculeGroupPairs(); var peakFeatureLists = new PeakTransitionGroupFeatures[moleculeGroupPairs.Length][]; int peakFeatureCount = 0; ParallelEx.For(0, moleculeGroupPairs.Length, i => { var pair = moleculeGroupPairs[i]; var nodePepGroup = pair.NodeMoleculeGroup; var nodePep = pair.NodeMolecule; if (nodePep.TransitionGroupCount == 0) { return; } // Exclude standard peptides if (nodePep.GlobalStandardType != null) { return; } if (progressMonitor != null) { if (progressMonitor.IsCanceled) { throw new OperationCanceledException(); } int?percentComplete = ProgressStatus.ThreadsafeIncementPercent(ref currentPeptide, totalPeptides); if (percentComplete.HasValue && percentComplete.Value < 100) { progressMonitor.UpdateProgress(status = status.ChangePercentComplete(percentComplete.Value)); } } var peakFeatureList = new List <PeakTransitionGroupFeatures>(); foreach (var peakFeature in document.GetPeakFeatures(nodePepGroup, nodePep, calcs, runEnumDict, verbose)) { if (peakFeature.PeakGroupFeatures.Any()) { peakFeatureList.Add(peakFeature); Interlocked.Increment(ref peakFeatureCount); } } peakFeatureLists[i] = peakFeatureList.ToArray(); }); var result = new PeakTransitionGroupFeatures[peakFeatureCount]; int peakFeatureCurrent = 0; int decoyCount = 0; foreach (var peakFeatureList in peakFeatureLists) { if (peakFeatureList == null) { continue; } foreach (var peakFeature in peakFeatureList) { result[peakFeatureCurrent++] = peakFeature; if (peakFeature.IsDecoy) { decoyCount++; } } } if (progressMonitor != null) { progressMonitor.UpdateProgress(status.ChangePercentComplete(100)); } return(new PeakTransitionGroupFeatureSet(decoyCount, result)); }