Skip to content

Commit

Permalink
add override qValue threshold for unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Oct 15, 2024
1 parent 5231c70 commit 5186b82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ public class FdrAnalysisEngine : MetaMorpheusEngine
private readonly string AnalysisType;
private readonly string OutputFolder; // used for storing PEP training models
private readonly bool DoPEP;
private readonly bool QvalueThresholdOverride;
private readonly int PsmCountThresholdForInvertedQvalue = 1000;

public FdrAnalysisEngine(List<SpectralMatch> psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters,
List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List<string> nestedIds, string analysisType = "PSM",
bool doPEP = true, string outputFolder = null) : base(commonParameters, fileSpecificParameters, nestedIds)
bool doPEP = true, string outputFolder = null, bool qvalueThresholdOverride = false) : base(commonParameters, fileSpecificParameters, nestedIds)
{
AllPsms = psms.OrderByDescending(p => p).ToList();
MassDiffAcceptorNumNotches = massDiffAcceptorNumNotches;
Expand All @@ -28,6 +29,7 @@ public FdrAnalysisEngine(List<SpectralMatch> psms, int massDiffAcceptorNumNotche
if (AllPsms.Any())
AddPsmAndPeptideFdrInfoIfNotPresent();
if (fileSpecificParameters == null) throw new ArgumentNullException("file specific parameters cannot be null");
QvalueThresholdOverride = qvalueThresholdOverride;
}

private void AddPsmAndPeptideFdrInfoIfNotPresent()
Expand Down Expand Up @@ -72,10 +74,10 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults)
.Select(b => b.FirstOrDefault())
.ToList();

if (psms.Count > PsmCountThresholdForInvertedQvalue & DoPEP)
if ((psms.Count > PsmCountThresholdForInvertedQvalue || QvalueThresholdOverride) & DoPEP)
{
CalculateQValue(psms, peptideLevelCalculation: false, pepCalculation: false);
if (peptides.Count > PsmCountThresholdForInvertedQvalue)
if (peptides.Count > PsmCountThresholdForInvertedQvalue || QvalueThresholdOverride)
{
CalculateQValue(peptides, peptideLevelCalculation: true, pepCalculation: false);

Expand Down Expand Up @@ -200,7 +202,7 @@ public void CalculateQValue(List<SpectralMatch> psms, bool peptideLevelCalculati
}
else
{
if(psms.Count < PsmCountThresholdForInvertedQvalue)
if(psms.Count < PsmCountThresholdForInvertedQvalue || QvalueThresholdOverride)
{

QValueTraditional(psms, peptideLevelAnalysis: peptideLevelCalculation);
Expand Down

0 comments on commit 5186b82

Please sign in to comment.