Skip to content

Commit a4f89be

Browse files
committed
Use single cast PSM list for protein best-peptide metrics
1 parent 8c3d448 commit a4f89be

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ private List<ProteinGroup> DoProteinFdr(List<ProteinGroup> proteinGroups)
164164
}
165165
}
166166

167-
pg.BestPeptideScore = pg.AllPsmsBelowOnePercentFDR.Max(psm => psm.Score);
168-
pg.BestPeptideQValue = pg.AllPsmsBelowOnePercentFDR.OfType<SpectralMatch>().Min(psm => psm.FdrInfo.QValueNotch);
169-
pg.BestPeptidePEP = pg.AllPsmsBelowOnePercentFDR.OfType<SpectralMatch>().Min(psm => psm.FdrInfo.PEP);
167+
// Downcast once and reuse so Score, QValueNotch, and PEP are all computed over the
168+
// identical PSM population. Cast (not OfType) so an unexpected ISpectralMatch impl
169+
// throws loudly instead of being silently dropped from the QValue/PEP minimums.
170+
var bestPeptidePsms = pg.AllPsmsBelowOnePercentFDR.Cast<SpectralMatch>().ToList();
171+
pg.BestPeptideScore = bestPeptidePsms.Max(psm => psm.Score);
172+
pg.BestPeptideQValue = bestPeptidePsms.Min(psm => psm.FdrInfo.QValueNotch);
173+
pg.BestPeptidePEP = bestPeptidePsms.Min(psm => psm.FdrInfo.PEP);
170174
}
171175

172176
// pick the best for each paired accession based on filter type

0 commit comments

Comments
 (0)