Skip to content

Commit

Permalink
not supposed to be hard
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Oct 16, 2024
1 parent 10b2333 commit 60c2d69
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class FdrAnalysisEngine : MetaMorpheusEngine
/// </summary>
public static bool QvalueThresholdOverride // property
{
get { return qvalueThresholdOverride; } // get method
set { qvalueThresholdOverride = value; } // set method
}
public FdrAnalysisEngine(List<SpectralMatch> psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters,
Expand Down Expand Up @@ -209,6 +208,7 @@ public void CalculateQValue(List<SpectralMatch> psms, bool peptideLevelCalculati
}
else
{
//we don't want to apply the QValueThreshod
if(psms.Count < PsmCountThresholdForInvertedQvalue)
{

Expand Down
4 changes: 3 additions & 1 deletion MetaMorpheus/Test/MatchIonsOfAllCharges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Omics.Modifications;
using Omics.SpectrumMatch;
using static System.Net.WebRequestMethods;
using EngineLayer.FdrAnalysis;

namespace Test
{
Expand Down Expand Up @@ -425,7 +426,7 @@ public static void TestLibraryUpdate()

string rawCopy = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch\UpdateLibrary\rawCopy.mzML");
System.IO.File.Copy(raw1, rawCopy);

FdrAnalysisEngine.QvalueThresholdOverride = true;
EverythingRunnerEngine UpdateLibrary = new(new List<(string, MetaMorpheusTask)> { ("UpdateSpectraFileOutput", task) }, new List<string> { raw1, raw2 }, new List<DbForTask> { new DbForTask(lib, false), new DbForTask( db1,false), new DbForTask(db2, false) }, thisTaskOutputFolder);

UpdateLibrary.Run();
Expand All @@ -452,6 +453,7 @@ public static void TestLibraryUpdate()

updatedLib.CloseConnections();
Directory.Delete(thisTaskOutputFolder, true);
FdrAnalysisEngine.QvalueThresholdOverride = false;
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_QValue_BottomUp(
Assert.AreEqual("All target PSMs with q-value <= 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms, singleFileResults[5]);
Assert.AreEqual("All target peptides with q-value <= 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPeptides, singleFileResults[6]);
Assert.AreEqual("All target protein groups with q-value <= 0.01 (1% FDR): 166", singleFileResults[7]);
FdrAnalysisEngine.QvalueThresholdOverride = false;
}

[Test]
Expand Down Expand Up @@ -103,6 +104,7 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_PepQValue_Bottom
Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target PSMs with pep q-value <= 0.01: 192", results[13]);
Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target peptides with pep q-value <= 0.01: 155", results[14]);
Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 141", results[15]);
FdrAnalysisEngine.QvalueThresholdOverride = false;
}

/// <summary>
Expand All @@ -112,7 +114,6 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_PepQValue_Bottom
[TestCaseSource(nameof(GetTestCases))]
public static void AllResultTxtContainsCorrectNumberOfResultLines(EverythingRunnerEngineTestCases testCaseIdentifier)
{
FdrAnalysisEngine.QvalueThresholdOverride = true;
var testCase = EverythingRunnerEngineTestCase.GetTestCase(testCaseIdentifier);

int expectedIndividualFileLines = testCase.DataFileList.Count == 1 || !testCase.WriteIndividualResults
Expand Down Expand Up @@ -158,7 +159,6 @@ public static void AllResultTxtContainsCorrectNumberOfResultLines(EverythingRunn
[TestCaseSource(nameof(GetTestCases))]
public static void CorrectFilesAreWrittenWithCorrectName(EverythingRunnerEngineTestCases testCaseIdentifier)
{
FdrAnalysisEngine.QvalueThresholdOverride = true;
var testCase = EverythingRunnerEngineTestCase.GetTestCase(testCaseIdentifier);
var psmFiles = Directory.GetFiles(testCase.OutputDirectory, "*PSMs.psmtsv", SearchOption.AllDirectories);
var pepXmlFiles = Directory.GetFiles(testCase.OutputDirectory, "*.pep.xml", SearchOption.AllDirectories);
Expand Down
3 changes: 3 additions & 0 deletions MetaMorpheus/Test/ProteinGroupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Omics.Digestion;
using Omics.Modifications;
using UsefulProteomicsDatabases;
using EngineLayer.FdrAnalysis;

namespace Test
{
Expand Down Expand Up @@ -206,6 +207,8 @@ public static void TestModificationInfoListInProteinGroupsOutput()
string mzmlName = @"TestData\PrunedDbSpectra.mzml";
string fastaName = @"TestData\DbForPrunedDb.fasta";
string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestPrunedGeneration");

FdrAnalysisEngine.QvalueThresholdOverride = false;
var engine = new EverythingRunnerEngine(taskList, new List<string> { mzmlName }, new List<DbForTask> { new DbForTask(fastaName, false) }, outputFolder);
engine.Run();
string final = Path.Combine(MySetUpClass.outputFolder, "task2", "DbForPrunedDbGPTMDproteinPruned.xml");
Expand Down
2 changes: 2 additions & 0 deletions MetaMorpheus/Test/QuantificationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Text;
using Omics.Modifications;
using TaskLayer;
using EngineLayer.FdrAnalysis;

namespace Test
{
Expand Down Expand Up @@ -224,6 +225,7 @@ public static void TestProteinQuantFileHeaders(bool hasDefinedExperimentalDesign
}

// run the search/quantification
FdrAnalysisEngine.QvalueThresholdOverride = false;
SearchTask task = new SearchTask();
task.RunTask(unitTestFolder, new List<DbForTask> { new DbForTask(dbName, false) }, fileInfos.Select(p => p.FullFilePathWithExtension).ToList(), "");

Expand Down
4 changes: 2 additions & 2 deletions MetaMorpheus/Test/SearchEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public static void TestSearchEngineResultsPsmFromTsv()
Assert.AreEqual("K", psm.PreviousAminoAcid);
Assert.AreEqual("P46013", psm.ProteinAccession);
Assert.AreEqual("Proliferation marker protein Ki-67", psm.ProteinName);
Assert.That(0.0, Is.EqualTo(psm.QValue).Within(1E-04));
Assert.That(0.0, Is.EqualTo(psm.QValueNotch).Within(1E-04));
Assert.That(0, Is.EqualTo(psm.QValue).Within(1E-04));
Assert.That(0, Is.EqualTo(psm.QValueNotch).Within(1E-04));
Assert.AreEqual(45.59512, psm.RetentionTime);
Assert.AreEqual(662.486, psm.Score);
Assert.AreEqual("[2742 to 2761]", psm.StartAndEndResiduesInProtein);
Expand Down
6 changes: 1 addition & 5 deletions MetaMorpheus/Test/TestToml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Chemistry;
using EngineLayer;
using EngineLayer.ClassicSearch;
using EngineLayer;
using MassSpectrometry;
using MzLibUtil;
using Nett;
using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert;
using Proteomics;
using Proteomics.ProteolyticDigestion;
using System.Collections.Generic;
using System.IO;
Expand All @@ -14,7 +11,6 @@
using Omics.Fragmentation;
using SpectralAveraging;
using TaskLayer;
using UsefulProteomicsDatabases;
using EngineLayer.FdrAnalysis;

namespace Test
Expand Down

0 comments on commit 60c2d69

Please sign in to comment.