From 14ef43dca2a723a6e6fccc39f293275f74e13939 Mon Sep 17 00:00:00 2001 From: trishorts Date: Wed, 13 Nov 2024 11:19:15 -0600 Subject: [PATCH] eliminate nunit legacy code (#2438) * lets try a little change * k * f * tmt * h * thru parameter * thru search engine tests * thru stefan * done cross your fingers --- MetaMorpheus/Test/AddCompIonsTest.cs | 68 ++- MetaMorpheus/Test/AmbiguityTest.cs | 55 ++- MetaMorpheus/Test/AnalysisEngineTest.cs | 10 +- .../Test/AveragingGuiComponentsTest.cs | 6 +- MetaMorpheus/Test/AveragingTests.cs | 4 +- MetaMorpheus/Test/BinGenerationTest.cs | 18 +- MetaMorpheus/Test/CalibrationTests.cs | 7 +- MetaMorpheus/Test/CoIsolationTests.cs | 12 +- MetaMorpheus/Test/CustomAminoAcidsTest.cs | 10 +- MetaMorpheus/Test/CustomFragmentationTest.cs | 2 +- .../Test/DigestionModificationTests.cs | 14 +- MetaMorpheus/Test/EventArgsTest.cs | 5 +- MetaMorpheus/Test/FdrTest.cs | 97 ++--- MetaMorpheus/Test/GPTMDengineTest.cs | 41 +- MetaMorpheus/Test/GlobalVariablesTest.cs | 5 +- MetaMorpheus/Test/GuiFunctionsTest.cs | 4 +- MetaMorpheus/Test/IndexEngineTest.cs | 26 +- MetaMorpheus/Test/LocalizationTest.cs | 42 +- MetaMorpheus/Test/MatchIonsOfAllCharges.cs | 29 +- .../Test/MetaDraw/FragmentReanalysis.cs | 21 +- .../MetaDraw/MetaDrawSettingsAndViewsTest.cs | 53 ++- MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs | 140 ++++--- .../Test/MetaDraw/SpectrumMatchPlotTests.cs | 2 +- MetaMorpheus/Test/ModificationAnalysisTest.cs | 30 +- MetaMorpheus/Test/MsDataFileTest.cs | 8 +- .../Test/MultiProteaseParsimonyTest.cs | 128 +++--- .../Test/Multiplex_Labeling_TMT_iTRAQ.cs | 82 ++-- MetaMorpheus/Test/MyEngineTest.cs | 2 +- MetaMorpheus/Test/MyPeptideTest.cs | 24 +- MetaMorpheus/Test/MyTaskTest.cs | 20 +- MetaMorpheus/Test/OutputTest.cs | 24 +- MetaMorpheus/Test/ParameterTest.cs | 157 ++++--- MetaMorpheus/Test/PeptideSpectralMatchTest.cs | 18 +- .../Test/PostSearchAnalysisTaskTests.cs | 117 +++--- MetaMorpheus/Test/ProteaseTests.cs | 6 +- MetaMorpheus/Test/ProteinGroupTest.cs | 36 +- MetaMorpheus/Test/ProteinLoaderTest.cs | 2 +- MetaMorpheus/Test/PsmTsvWriterTests.cs | 13 +- MetaMorpheus/Test/PsvTsvTest.cs | 53 ++- MetaMorpheus/Test/RetentionTimeTest.cs | 3 +- MetaMorpheus/Test/RobTest.cs | 42 +- MetaMorpheus/Test/SearchEngineTests.cs | 282 ++++++------- MetaMorpheus/Test/SearchModesTest.cs | 66 +-- MetaMorpheus/Test/SearchTaskTest.cs | 32 +- .../SearchWithPeptidesAddedInParsimony.cs | 2 +- MetaMorpheus/Test/SeqCoverageTest.cs | 20 +- MetaMorpheus/Test/SilacTest.cs | 197 ++++----- MetaMorpheus/Test/SlicedTest.cs | 14 +- .../Test/SpectralLibraryReaderTest.cs | 58 +-- MetaMorpheus/Test/SpectralRecoveryTest.cs | 18 +- MetaMorpheus/Test/StefanParsimonyTest.cs | 14 +- MetaMorpheus/Test/TestNGlyco.cs | 34 +- MetaMorpheus/Test/TestOGlyco.cs | 39 +- MetaMorpheus/Test/TestPsm.cs | 68 +-- MetaMorpheus/Test/TestToml.cs | 64 +-- MetaMorpheus/Test/TestTopDown.cs | 2 +- .../TestNegativeModeDeconvolution.cs | 5 +- MetaMorpheus/Test/VariantSearchTests.cs | 387 +++++++++--------- MetaMorpheus/Test/XLSearchOutputTest.cs | 12 +- MetaMorpheus/Test/XLTest.cs | 241 ++++++----- MetaMorpheus/Test/gptmdPrunedBdTests.cs | 54 +-- 61 files changed, 1480 insertions(+), 1565 deletions(-) diff --git a/MetaMorpheus/Test/AddCompIonsTest.cs b/MetaMorpheus/Test/AddCompIonsTest.cs index 8b75190bb..802dd1849 100644 --- a/MetaMorpheus/Test/AddCompIonsTest.cs +++ b/MetaMorpheus/Test/AddCompIonsTest.cs @@ -5,12 +5,10 @@ using EngineLayer.ModernSearch; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; -using Proteomics.RetentionTimePrediction; -using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -70,16 +68,13 @@ public static void TestAddCompIonsClassic() double scoreF = allPsmsArray[0].Score; // Single search mode - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); // Single ms2 scan - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); - - Assert.IsTrue(scoreT > 1); - - Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); - - Assert.IsTrue(scoreT == scoreF * 3 && scoreT > scoreF + 2); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); + Assert.That(scoreT > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(allPsmsArray2[0].ScanNumber)); + Assert.That(scoreT == scoreF * 3 && scoreT > scoreF + 2); } [Test] @@ -145,18 +140,15 @@ public static void TestCompIons_ModernSearch() new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); // Single ms2 scan - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); - - Assert.IsTrue(allPsmsArray2[0].Score > 1); - - Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); - - Assert.IsTrue(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 3); + Assert.That(allPsmsArray2[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(allPsmsArray2[0].ScanNumber)); + Assert.That(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 3); ProteaseDictionary.Dictionary.Remove(protease.Name); } @@ -223,16 +215,16 @@ public static void TestCompIons_ETHCD_ModernSearch() new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); // Single ms2 scan - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); - Assert.IsTrue(allPsmsArray2[0].Score > 1); + Assert.That(allPsmsArray2[0].Score > 1); - Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(allPsmsArray2[0].ScanNumber)); Assert.That(allPsmsArray2[0].Score, Is.EqualTo(7.007).Within(0.001)); ProteaseDictionary.Dictionary.Remove(protease.Name); } @@ -300,17 +292,17 @@ public static void TestCompIons_LowCID_ModernSearch() new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); // Single ms2 scan - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); - Assert.IsTrue(allPsmsArray2[0].Score > 1); + Assert.That(allPsmsArray2[0].Score > 1); - Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); - Assert.IsTrue(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 2); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(allPsmsArray2[0].ScanNumber)); + Assert.That(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 2); ProteaseDictionary.Dictionary.Remove(protease.Name); } @@ -340,7 +332,7 @@ public static void TestCompIons_MatchIonsScore() double localizedScore = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedIons); double scoreNormal = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedIons); double scoreComp = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedCompIons); - Assert.IsTrue(scoreNormal * 2 == scoreComp && scoreComp > scoreNormal + 1); + Assert.That(scoreNormal * 2 == scoreComp && scoreComp > scoreNormal + 1); } [Test] @@ -367,23 +359,23 @@ public static void TestCompIons_MatchIons() //MetaMorpheusEngine.MatchIons(t.GetOneBasedScan(2), productMassTolerance, sorted_theoretical_product_masses_for_this_peptide, matchedIonSeriesF, matchedIonMassesF, matchedDaErrorF, matchedPpmErrorF, matchedIonIntensityF, precursorMass, ProductType.B, false); //Test the number of series is doubled - Assert.IsTrue(matchedIonSeriesT.Count == matchedIonSeriesF.Count * 2); + Assert.That(matchedIonSeriesT.Count == matchedIonSeriesF.Count * 2); //Test the number of ions is doubled - Assert.IsTrue(matchedIonMassesT.Count == matchedIonMassesF.Count * 2); + Assert.That(matchedIonMassesT.Count == matchedIonMassesF.Count * 2); //Test the number of da errors is doubled - Assert.IsTrue(matchedDaErrorT.Count == matchedDaErrorF.Count * 2); + Assert.That(matchedDaErrorT.Count == matchedDaErrorF.Count * 2); //test the number of ppm errors is doubled - Assert.IsTrue(matchedPpmErrorT.Count == matchedPpmErrorF.Count * 2); + Assert.That(matchedPpmErrorT.Count == matchedPpmErrorF.Count * 2); //test the number of the intensity values is doubled - Assert.IsTrue(matchedIonIntensityT.Count == matchedIonIntensityF.Count * 2); + Assert.That(matchedIonIntensityT.Count == matchedIonIntensityF.Count * 2); foreach (double d in matchedDaErrorF) { - Assert.IsTrue(d <= 0.01); + Assert.That(d <= 0.01); } foreach (double d in matchedDaErrorT) { - Assert.IsTrue(d <= 0.01); + Assert.That(d <= 0.01); } } @@ -460,8 +452,8 @@ public static void AddCompIonsMzOutput() //A fix was introduced to save a "fake" m/z for the added ion foreach(MatchedFragmentIon ion in matchedIons) { - Assert.IsTrue(ion.NeutralTheoreticalProduct.NeutralMass < ion.Mz); - Assert.IsTrue(ion.NeutralTheoreticalProduct.NeutralMass + 2 > ion.Mz); + Assert.That(ion.NeutralTheoreticalProduct.NeutralMass < ion.Mz); + Assert.That(ion.NeutralTheoreticalProduct.NeutralMass + 2 > ion.Mz); } } diff --git a/MetaMorpheus/Test/AmbiguityTest.cs b/MetaMorpheus/Test/AmbiguityTest.cs index f483560ef..e910866ed 100644 --- a/MetaMorpheus/Test/AmbiguityTest.cs +++ b/MetaMorpheus/Test/AmbiguityTest.cs @@ -2,9 +2,8 @@ using EngineLayer; using EngineLayer.ClassicSearch; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; -using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -65,12 +64,12 @@ public static void TestResolveAmbiguities() new ClassicSearchEngine(allPsmsArray_withOutAmbiguity, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters_f, fsp_f, null, new List(), writeSpectralLibrary).Run(); //report all ambiguity FALSE - Assert.AreEqual("QQQ", allPsmsArray_withAmbiguity[0].BaseSequence); - Assert.AreEqual("QQQ", allPsmsArray_withOutAmbiguity[0].BaseSequence); - Assert.IsTrue(allPsmsArray_withAmbiguity[0].ParentLength == null); - Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].ParentLength != null); - Assert.IsTrue(allPsmsArray_withAmbiguity[0].OneBasedStartResidue == null); - Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].OneBasedStartResidue != null); + Assert.That(allPsmsArray_withAmbiguity[0].BaseSequence, Is.EqualTo("QQQ")); + Assert.That(allPsmsArray_withOutAmbiguity[0].BaseSequence, Is.EqualTo("QQQ")); + Assert.That(allPsmsArray_withAmbiguity[0].ParentLength == null); + Assert.That(allPsmsArray_withOutAmbiguity[0].ParentLength != null); + Assert.That(allPsmsArray_withAmbiguity[0].OneBasedStartResidue == null); + Assert.That(allPsmsArray_withOutAmbiguity[0].OneBasedStartResidue != null); } [Test] @@ -104,8 +103,8 @@ public static void TestContaminantAmbiguity() var headerSplits = SpectralMatch.GetTabSeparatedHeader().Split('\t'); string[] splitLine = psmLine.Split('\t'); - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("N|Y")); //column "Contaminant" - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("T|C")); //column "Decoy/Contaminant/Target" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("N|Y")); //column "Contaminant" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("T|C")); //column "Decoy/Contaminant/Target" //KEEP ONLY TARGET @@ -123,8 +122,8 @@ public static void TestContaminantAmbiguity() //check that the psm file shows it's both a target and a contaminant psmLine = File.ReadAllLines(Path.Combine(outputFolder, "task1", "AllPSMs.psmtsv"))[1]; splitLine = psmLine.Split('\t'); - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("N")); //column "Contaminant" - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("T")); //column "Decoy/Contaminant/Target" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("N")); //column "Contaminant" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("T")); //column "Decoy/Contaminant/Target" //KEEP ONLY CONTAMINANT @@ -142,8 +141,8 @@ public static void TestContaminantAmbiguity() //check that the psm file shows it's both a target and a contaminant psmLine = File.ReadAllLines(Path.Combine(outputFolder, "task1", "AllPSMs.psmtsv"))[1]; splitLine = psmLine.Split('\t'); - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("Y")); //column "Contaminant" - Assert.IsTrue(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("C")); //column "Decoy/Contaminant/Target" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.Contaminant)].Equals("Y")); //column "Contaminant" + Assert.That(splitLine[Array.IndexOf(headerSplits, PsmTsvHeader.DecoyContaminantTarget)].Equals("C")); //column "Decoy/Contaminant/Target" Directory.Delete(outputFolder, true); @@ -161,21 +160,21 @@ public static void TestDatabaseSanitizationPrioritizesXml() Protein xmlProtein = new Protein("APEPTIDE", "Test", oneBasedModifications: new Dictionary> { { 1, new List { mod } } }); List proteins = new List { fastaProtein, xmlProtein }; SanitizeProteinDatabase(proteins, TargetContaminantAmbiguity.RemoveTarget); - Assert.IsTrue(proteins.Count == 1); - Assert.IsTrue(proteins.First().OneBasedPossibleLocalizedModifications.Count != 0); + Assert.That(proteins.Count == 1); + Assert.That(proteins.First().OneBasedPossibleLocalizedModifications.Count != 0); //reverse order and try again proteins = new List { xmlProtein, fastaProtein }; SanitizeProteinDatabase(proteins, TargetContaminantAmbiguity.RemoveTarget); - Assert.IsTrue(proteins.Count == 1); - Assert.IsTrue(proteins.First().OneBasedPossibleLocalizedModifications.Count != 0); + Assert.That(proteins.Count == 1); + Assert.That(proteins.First().OneBasedPossibleLocalizedModifications.Count != 0); //same with no mods xmlProtein = new Protein("APEPTIDE", "Test", proteolysisProducts: new List { new ProteolysisProduct(1, 3, "zrWuzHere") }); proteins = new List { xmlProtein, fastaProtein }; SanitizeProteinDatabase(proteins, TargetContaminantAmbiguity.RemoveTarget); - Assert.IsTrue(proteins.Count == 1); - Assert.IsTrue(proteins.First().ProteolysisProducts.Count() != 0); + Assert.That(proteins.Count == 1); + Assert.That(proteins.First().ProteolysisProducts.Count() != 0); } [Test] @@ -189,17 +188,17 @@ public static void TestDatabaseSanitizationRemovesDecoys() Protein cDecoyProtein = new Protein("AEDITPEP", "DECOY_Test"); List proteins = new List { targetProtein, contaminantProtein, tDecoyProtein, cDecoyProtein }; //two decoys, one for target, one for contaminant SanitizeProteinDatabase(proteins, TargetContaminantAmbiguity.RemoveContaminant); - Assert.IsTrue(proteins.Count == 2); - Assert.IsTrue(!proteins[0].IsContaminant); //forward is target - Assert.IsTrue(proteins[0].OneBasedPossibleLocalizedModifications.Count == 1); - Assert.IsTrue(proteins[1].OneBasedPossibleLocalizedModifications.Count == 1); + Assert.That(proteins.Count == 2); + Assert.That(!proteins[0].IsContaminant); //forward is target + Assert.That(proteins[0].OneBasedPossibleLocalizedModifications.Count == 1); + Assert.That(proteins[1].OneBasedPossibleLocalizedModifications.Count == 1); proteins = new List { targetProtein, contaminantProtein, tDecoyProtein, cDecoyProtein }; //two decoys, one for target, one for contaminant SanitizeProteinDatabase(proteins, TargetContaminantAmbiguity.RemoveTarget); - Assert.IsTrue(proteins.Count == 2); - Assert.IsTrue(proteins[0].IsContaminant); //forward is contaminant - Assert.IsTrue(proteins[0].OneBasedPossibleLocalizedModifications.Count == 0); //contaminant doesn't have mods - Assert.IsTrue(proteins[1].OneBasedPossibleLocalizedModifications.Count == 1); //would be cool if this was 0 and we could keep the correct decoy, but kind of an edge case + Assert.That(proteins.Count == 2); + Assert.That(proteins[0].IsContaminant); //forward is contaminant + Assert.That(proteins[0].OneBasedPossibleLocalizedModifications.Count == 0); //contaminant doesn't have mods + Assert.That(proteins[1].OneBasedPossibleLocalizedModifications.Count == 1); //would be cool if this was 0 and we could keep the correct decoy, but kind of an edge case } } } diff --git a/MetaMorpheus/Test/AnalysisEngineTest.cs b/MetaMorpheus/Test/AnalysisEngineTest.cs index 29ee6db0a..0acde4696 100644 --- a/MetaMorpheus/Test/AnalysisEngineTest.cs +++ b/MetaMorpheus/Test/AnalysisEngineTest.cs @@ -3,7 +3,7 @@ using EngineLayer.HistogramAnalysis; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -60,17 +60,17 @@ public static void TestAnalysisEngineTests() HashSet value1 = new HashSet { modPep }; PeptideWithSetModifications compactPeptide1 = value1.First(); - Assert.AreEqual("QQQ", value1.First().BaseSequence); + Assert.That(value1.First().BaseSequence, Is.EqualTo("QQQ")); var modPep2 = proteinList.First().Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).First(); HashSet value2 = new HashSet { modPep2 }; PeptideWithSetModifications compactPeptide2 = value2.First(); - Assert.AreEqual("MNNNK", value2.First().BaseSequence); + Assert.That(value2.First().BaseSequence, Is.EqualTo("MNNNK")); var modPep3 = proteinList.First().Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[1]; HashSet value3 = new HashSet { modPep3 }; PeptideWithSetModifications compactPeptide3 = value3.First(); - Assert.AreEqual("NNNK", value3.First().BaseSequence); + Assert.That(value3.First().BaseSequence, Is.EqualTo("NNNK")); Ms2ScanWithSpecificMass scanA = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 2, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 1, 1, null, new CommonParameters()); @@ -94,7 +94,7 @@ public static void TestAnalysisEngineTests() Action action1 = (BinTreeStructure l, string s) => { - Assert.AreEqual(1, l.FinalBins.Count); + Assert.That(l.FinalBins.Count, Is.EqualTo(1)); }; FdrAnalysisEngine engine = new FdrAnalysisEngine(newPsms, searchMode.NumNotches, CommonParameters, fsp, new List { "ff" }); diff --git a/MetaMorpheus/Test/AveragingGuiComponentsTest.cs b/MetaMorpheus/Test/AveragingGuiComponentsTest.cs index 09e07e48d..86520d8cf 100644 --- a/MetaMorpheus/Test/AveragingGuiComponentsTest.cs +++ b/MetaMorpheus/Test/AveragingGuiComponentsTest.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; using GuiFunctions; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using SpectralAveraging; namespace Test diff --git a/MetaMorpheus/Test/AveragingTests.cs b/MetaMorpheus/Test/AveragingTests.cs index 8c416abde..64a567b98 100644 --- a/MetaMorpheus/Test/AveragingTests.cs +++ b/MetaMorpheus/Test/AveragingTests.cs @@ -5,10 +5,8 @@ using System.Linq; using EngineLayer; using FlashLFQ; -using GuiFunctions; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; -using Readers; +using NUnit.Framework; using SpectralAveraging; using TaskLayer; using Mzml = IO.MzML.Mzml; diff --git a/MetaMorpheus/Test/BinGenerationTest.cs b/MetaMorpheus/Test/BinGenerationTest.cs index 36cc3a0f8..2a321d099 100644 --- a/MetaMorpheus/Test/BinGenerationTest.cs +++ b/MetaMorpheus/Test/BinGenerationTest.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.ProteolyticDigestion; using System; @@ -70,7 +70,8 @@ public static void TestBinGeneration() new List { mzmlFilePath }, null); - Assert.AreEqual(3, File.ReadLines(Path.Combine(output_folder, @"MassDifferenceHistogram.tsv")).Count()); + + Assert.That(File.ReadLines(Path.Combine(output_folder, @"MassDifferenceHistogram.tsv")).Count(), Is.EqualTo(3)); Directory.Delete(output_folder, true); File.Delete(proteinDbFilePath); File.Delete(mzmlFilePath); @@ -147,20 +148,19 @@ public static void TestBin_IdentifyAA() { var bin = new Bin(71); bin.IdentifyAA(1); - Assert.AreEqual("Add Alanine", bin.AA); + Assert.That(bin.AA, Is.EqualTo("Add Alanine")); bin = new Bin(-56.1); bin.IdentifyAA(1); - Assert.AreEqual("Remove Glycine", bin.AA); - + Assert.That(bin.AA, Is.EqualTo("Remove Glycine")); bin = new Bin(114.102); bin.IdentifyAA(1); - Assert.AreEqual("Add Aspartic Acid|Add (Glycine+Glycine)|Add Asparagine", bin.AA); + Assert.That(bin.AA, Is.EqualTo("Add Aspartic Acid|Add (Glycine+Glycine)|Add Asparagine")); bin = new Bin(-142.156); bin.IdentifyAA(1); - Assert.AreEqual("Remove (Alanine+Alanine)", bin.AA); + Assert.That(bin.AA, Is.EqualTo("Remove (Alanine+Alanine)")); } [Test] @@ -168,8 +168,8 @@ public static void TestBin_IdentifyUnimodBins() { var bin = new Bin(77.987066); bin.IdentifyUnimodBins(0.001); - Assert.AreEqual("Methylphosphonate on Y|Methylphosphonate on T|Methylphosphonate on S", bin.UnimodId); - Assert.AreEqual("CH3O2P", bin.UnimodFormulas); + Assert.That(bin.UnimodId, Is.EqualTo("Methylphosphonate on Y|Methylphosphonate on T|Methylphosphonate on S")); + Assert.That(bin.UnimodFormulas, Is.EqualTo("CH3O2P")); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/CalibrationTests.cs b/MetaMorpheus/Test/CalibrationTests.cs index 276ba2332..a32305f30 100644 --- a/MetaMorpheus/Test/CalibrationTests.cs +++ b/MetaMorpheus/Test/CalibrationTests.cs @@ -1,8 +1,7 @@ using EngineLayer; using FlashLFQ; using MassSpectrometry; -using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System.Collections.Generic; using System.IO; using System.Linq; @@ -277,7 +276,7 @@ public static void TestExperimentalDesignErrors(string experimentalFolder, strin string experimentalDesignPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData", @"TestExperimentalDesign", experimentalFolder, "ExperimentalDesign.tsv"); List rawFilePaths = new() { Path.Combine(experimentalDesignPath, rawFile) }; _ = ExperimentalDesign.ReadExperimentalDesign(experimentalDesignPath, rawFilePaths, out var errors); - Assert.IsTrue(errors[0].ToString().Contains(expectedError)); + Assert.That(errors[0].ToString().Contains(expectedError)); } [Test] @@ -312,7 +311,7 @@ public static void TestWriteNewExperimentalDesignFileDuringCalibration() calibrationTask.RunTask(outputFolder, new List { new DbForTask(myDatabase, false) }, new List { nonCalibratedFilePath }, "test"); //The original experimental design file is bad so we expect Warn event in "WriteNewExperimentalDesignFile" - Assert.IsTrue(wasCalled); + Assert.That(wasCalled); // clean up diff --git a/MetaMorpheus/Test/CoIsolationTests.cs b/MetaMorpheus/Test/CoIsolationTests.cs index 972bbbf7d..c61499c91 100644 --- a/MetaMorpheus/Test/CoIsolationTests.cs +++ b/MetaMorpheus/Test/CoIsolationTests.cs @@ -3,7 +3,7 @@ using EngineLayer.ClassicSearch; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -70,13 +70,13 @@ public static void TestCoIsolation() proteinList, searchModes, CommonParameters, fsp, null, new List(), writeSpectralLibrary).Run(); // Two matches for this single scan! Corresponding to two co-isolated masses - Assert.AreEqual(2, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(2)); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual("NNNK", allPsmsArray[0].BaseSequence); - Assert.AreEqual("NDNK", allPsmsArray[1].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("NNNK")); + Assert.That(allPsmsArray[1].BaseSequence, Is.EqualTo("NDNK")); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/CustomAminoAcidsTest.cs b/MetaMorpheus/Test/CustomAminoAcidsTest.cs index 66b4d0add..719570bfc 100644 --- a/MetaMorpheus/Test/CustomAminoAcidsTest.cs +++ b/MetaMorpheus/Test/CustomAminoAcidsTest.cs @@ -1,7 +1,7 @@ using Chemistry; using Proteomics.AminoAcidPolymer; using System.IO; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using EngineLayer; using System.Collections.Generic; @@ -23,8 +23,8 @@ public static void TestCustomAminoAcidReading() GlobalVariables.LoadCustomAminoAcids(); //read the file //test that we read the new amino acid - Assert.IsTrue(Residue.TryGetResidue('f', out Residue r)); - Assert.IsTrue(r.MonoisotopicMass.Equals(60)); + Assert.That(Residue.TryGetResidue('f', out Residue r)); + Assert.That(r.MonoisotopicMass.Equals(60)); //now crash it intentionally with an invalid character lines.Add("evenFaker\tX\t72\tC6"); @@ -33,7 +33,7 @@ public static void TestCustomAminoAcidReading() { GlobalVariables.LoadCustomAminoAcids(); //read the file //we're trying to crash it, so if we didn't, we failed :/ - Assert.IsTrue(false); + Assert.That(false); } catch(MetaMorpheusException) { @@ -48,7 +48,7 @@ public static void TestCustomAminoAcidReading() { GlobalVariables.LoadCustomAminoAcids(); //read the file //we're trying to crash it, so if we didn't, we failed :/ - Assert.IsTrue(false); + Assert.That(false); } catch (MetaMorpheusException) { diff --git a/MetaMorpheus/Test/CustomFragmentationTest.cs b/MetaMorpheus/Test/CustomFragmentationTest.cs index 4d4e60cf4..e051ca2bb 100644 --- a/MetaMorpheus/Test/CustomFragmentationTest.cs +++ b/MetaMorpheus/Test/CustomFragmentationTest.cs @@ -1,7 +1,7 @@ using EngineLayer; using MzLibUtil; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Omics.Fragmentation; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; diff --git a/MetaMorpheus/Test/DigestionModificationTests.cs b/MetaMorpheus/Test/DigestionModificationTests.cs index 001d05d78..b268440f8 100644 --- a/MetaMorpheus/Test/DigestionModificationTests.cs +++ b/MetaMorpheus/Test/DigestionModificationTests.cs @@ -1,12 +1,10 @@ using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; -using Proteomics; +using NUnit.Framework; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using Omics.Modifications; using UsefulProteomicsDatabases; @@ -29,11 +27,11 @@ public static void ProteaseModTest() var proteinList = ProteinDbLoader.LoadProteinFasta(databasePath1, true, DecoyType.None, false, out List errors); var protein = proteinList[0]; var peptides = protein.Digest(param, new List(), new List()).ToList(); - Assert.AreEqual(2, peptides.Count()); - Assert.AreNotEqual(peptides[0].FullSequence, peptides[1].FullSequence); - Assert.AreEqual(882.39707781799996, peptides[0].MonoisotopicMass); - Assert.AreEqual(930.400449121, peptides[1].MonoisotopicMass); - + Assert.That(peptides.Count(), Is.EqualTo(2)); + Assert.That(peptides[0].FullSequence, !Is.EqualTo(peptides[1].FullSequence)); + Assert.That(peptides[0].MonoisotopicMass, Is.EqualTo(882.39707781799996)); + Assert.That(peptides[1].MonoisotopicMass, Is.EqualTo(930.400449121)); + } diff --git a/MetaMorpheus/Test/EventArgsTest.cs b/MetaMorpheus/Test/EventArgsTest.cs index bd028252e..b69531444 100644 --- a/MetaMorpheus/Test/EventArgsTest.cs +++ b/MetaMorpheus/Test/EventArgsTest.cs @@ -3,14 +3,13 @@ using EngineLayer.Localization; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Omics.Modifications; namespace Test @@ -31,7 +30,7 @@ public static void SingleEventArgsTest() List variableModifications = new List { new Modification(_originalId: "21", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; List allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); + Assert.That(allPeptidesWithSetModifications.Count(), Is.EqualTo(4)); PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; diff --git a/MetaMorpheus/Test/FdrTest.cs b/MetaMorpheus/Test/FdrTest.cs index 73bb1af82..fabe958eb 100644 --- a/MetaMorpheus/Test/FdrTest.cs +++ b/MetaMorpheus/Test/FdrTest.cs @@ -2,11 +2,9 @@ using EngineLayer; using EngineLayer.ClassicSearch; using EngineLayer.FdrAnalysis; -using EngineLayer.Indexing; -using EngineLayer.ModernSearch; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -19,11 +17,6 @@ using TaskLayer; using UsefulProteomicsDatabases; using Omics; -using Org.BouncyCastle.Utilities.Collections; -using OxyPlot; -using static iText.Svg.SvgConstants; -using System.Reflection; -using UsefulProteomicsDatabases.Generated; namespace Test { @@ -37,18 +30,18 @@ public static void TestSeeModsThatShiftMobility() Modification am = new Modification(_originalId: "Ammonia loss"); List real = new List { ac, am }; - Assert.IsTrue(PepAnalysisEngine.ContainsModificationsThatShiftMobility(real)); - Assert.AreEqual(2, PepAnalysisEngine.CountModificationsThatShiftMobility(real)); + Assert.That(PepAnalysisEngine.ContainsModificationsThatShiftMobility(real)); + Assert.That(PepAnalysisEngine.CountModificationsThatShiftMobility(real), Is.EqualTo(2)); Modification fac = new Modification(_originalId: "fake Acetylation"); Modification fam = new Modification(_originalId: "fake Ammonia loss"); List fake = new List { fac, fam }; - Assert.IsFalse(PepAnalysisEngine.ContainsModificationsThatShiftMobility(fake)); - Assert.AreEqual(0, PepAnalysisEngine.CountModificationsThatShiftMobility(fake)); + Assert.That(!PepAnalysisEngine.ContainsModificationsThatShiftMobility(fake)); + Assert.That(PepAnalysisEngine.CountModificationsThatShiftMobility(fake), Is.EqualTo(0)); - Assert.IsTrue(PepAnalysisEngine.ContainsModificationsThatShiftMobility(real.Concat(fake))); - Assert.AreEqual(2, PepAnalysisEngine.CountModificationsThatShiftMobility(real.Concat(fake))); + Assert.That(PepAnalysisEngine.ContainsModificationsThatShiftMobility(real.Concat(fake))); + Assert.That(PepAnalysisEngine.CountModificationsThatShiftMobility(real.Concat(fake)), Is.EqualTo(2)); } [Test] @@ -95,20 +88,20 @@ public static void FdrTestMethod() fdr.Run(); - Assert.AreEqual(2, searchModes.NumNotches); - Assert.AreEqual(0, newPsms[0].FdrInfo.CumulativeDecoyNotch); - Assert.AreEqual(1, newPsms[0].FdrInfo.CumulativeTargetNotch); - Assert.AreEqual(0, newPsms[1].FdrInfo.CumulativeDecoyNotch); - Assert.AreEqual(1, newPsms[1].FdrInfo.CumulativeTargetNotch); - Assert.AreEqual(0, newPsms[2].FdrInfo.CumulativeDecoyNotch); - Assert.AreEqual(1, newPsms[2].FdrInfo.CumulativeTargetNotch); - - Assert.AreEqual(0, newPsms[0].FdrInfo.CumulativeDecoy); - Assert.AreEqual(1, newPsms[0].FdrInfo.CumulativeTarget); - Assert.AreEqual(0, newPsms[1].FdrInfo.CumulativeDecoy); - Assert.AreEqual(2, newPsms[1].FdrInfo.CumulativeTarget); - Assert.AreEqual(0, newPsms[2].FdrInfo.CumulativeDecoy); - Assert.AreEqual(3, newPsms[2].FdrInfo.CumulativeTarget); + Assert.That(searchModes.NumNotches, Is.EqualTo(2)); + Assert.That(newPsms[0].FdrInfo.CumulativeDecoyNotch, Is.EqualTo(0)); + Assert.That(newPsms[0].FdrInfo.CumulativeTargetNotch, Is.EqualTo(1)); + Assert.That(newPsms[1].FdrInfo.CumulativeDecoyNotch, Is.EqualTo(0)); + Assert.That(newPsms[1].FdrInfo.CumulativeTargetNotch, Is.EqualTo(1)); + Assert.That(newPsms[2].FdrInfo.CumulativeDecoyNotch, Is.EqualTo(0)); + Assert.That(newPsms[2].FdrInfo.CumulativeTargetNotch, Is.EqualTo(1)); + + Assert.That(newPsms[0].FdrInfo.CumulativeDecoy, Is.EqualTo(0)); + Assert.That(newPsms[0].FdrInfo.CumulativeTarget, Is.EqualTo(1)); + Assert.That(newPsms[1].FdrInfo.CumulativeDecoy, Is.EqualTo(0)); + Assert.That(newPsms[1].FdrInfo.CumulativeTarget, Is.EqualTo(2)); + Assert.That(newPsms[2].FdrInfo.CumulativeDecoy, Is.EqualTo(0)); + Assert.That(newPsms[2].FdrInfo.CumulativeTarget, Is.EqualTo(3)); } [Test] @@ -254,7 +247,7 @@ public static void TestComputePEPValue() Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch)); Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode)); - Assert.AreEqual((float)0, maxPsmData.IsVariantPeptide); + Assert.That((float)0, Is.EqualTo(maxPsmData.IsVariantPeptide)); List psmCopyForCZETest = nonNullPsms.ToList(); List psmCopyForPEPFailure = nonNullPsms.ToList(); @@ -286,7 +279,7 @@ public static void TestComputePEPValue() pepEngine = new PepAnalysisEngine(moreNonNullPSMs, "standard", fsp, Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\")); string metrics = pepEngine.ComputePEPValuesForAllPSMs(); - Assert.GreaterOrEqual(32, trueCount); + Assert.That(32 >= trueCount); //Test Variant Peptide as Input is identified as such as part of PEP calculation input much of the next several lines simply necessry to create a psm. @@ -336,7 +329,7 @@ public static void TestComputePEPValue() PsmData variantPsmData = pepEngine.CreateOnePsmDataEntry("standard", variantPSM, vpwsm, vnotch, !maxScorePsm.IsDecoy); - Assert.AreEqual((float)1, variantPsmData.IsVariantPeptide); + Assert.That(variantPsmData.IsVariantPeptide, Is.EqualTo((float)1)); //TEST CZE fsp = new List<(string fileName, CommonParameters fileSpecificParameters)>(); @@ -368,13 +361,13 @@ public static void TestComputePEPValue() pepEngine = new PepAnalysisEngine(moreNonNullPSMsCZE, "standard", fsp, Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\")); metrics = pepEngine.ComputePEPValuesForAllPSMs(); - Assert.GreaterOrEqual(32, trueCount); + Assert.That(32 >= trueCount); //TEST PEP calculation failure psmCopyForPEPFailure.RemoveAll(x => x.IsDecoy); pepEngine = new PepAnalysisEngine(psmCopyForPEPFailure, "standard", fsp, Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\")); string result = pepEngine.ComputePEPValuesForAllPSMs(); - Assert.AreEqual("Posterior error probability analysis failed. This can occur for small data sets when some sample groups are missing positive or negative training examples.", result); + Assert.That(result, Is.EqualTo("Posterior error probability analysis failed. This can occur for small data sets when some sample groups are missing positive or negative training examples.")); //Run PEP with no output folder; //There is no assertion here. We simply want to show that PEP calculation does not fail with null folder. @@ -481,12 +474,12 @@ public static void TestComputePEPValueTopDown() Assert.That(maxPsmDeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05)); float maxPsmIntensity = (float)Math.Min(50, Math.Round((maxScorePsm.Score - (int)maxScorePsm.Score) / normalizationFactor * 100.0, 0)); Assert.That(maxPsmIntensity, Is.EqualTo(maxPsmData.Intensity).Within(0.05)); - Assert.AreEqual(maxPsmData.HydrophobicityZScore, float.NaN); + Assert.That(maxPsmData.HydrophobicityZScore, Is.EqualTo(float.NaN)); Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount)); Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch)); Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode)); - Assert.AreEqual((float)0, maxPsmData.IsVariantPeptide); + Assert.That((float)0, Is.EqualTo(maxPsmData.IsVariantPeptide)); } [Test] @@ -513,9 +506,9 @@ public static void TestPEP_peptideRemoval() List pepValuePredictions = new List { 1.0d, 0.99d, 0.9d }; PepAnalysisEngine.GetIndiciesOfPeptidesToRemove(indiciesOfPeptidesToRemove, pepValuePredictions); - Assert.AreEqual(1, indiciesOfPeptidesToRemove.Count); - Assert.AreEqual(2, indiciesOfPeptidesToRemove.FirstOrDefault()); - Assert.AreEqual(2, pepValuePredictions.Count); + Assert.That(indiciesOfPeptidesToRemove.Count, Is.EqualTo(1)); + Assert.That(indiciesOfPeptidesToRemove.FirstOrDefault(), Is.EqualTo(2)); + Assert.That(pepValuePredictions.Count, Is.EqualTo(2)); List notches = new List(); List peptides = new List(); @@ -526,8 +519,8 @@ public static void TestPEP_peptideRemoval() } PepAnalysisEngine.RemoveBestMatchingPeptidesWithLowPEP(psm, indiciesOfPeptidesToRemove, notches, peptides, pepValuePredictions, ref ambiguousPeptidesRemovedCount); - Assert.AreEqual(1, ambiguousPeptidesRemovedCount); - Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Notch).ToList().Count); + Assert.That(ambiguousPeptidesRemovedCount, Is.EqualTo(1)); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Notch).ToList().Count, Is.EqualTo(2)); } [Test] @@ -546,14 +539,14 @@ public static void TestPEP_standardDeviationsToChange() Assert.That(stDevsToChange.ContainsKey(0)); Assert.That(stDevsToChange.ContainsKey(1)); Assert.That(stDevsToChange.ContainsKey(3)); - Assert.AreEqual(3, stDevsToChange.Keys.Count); + Assert.That(stDevsToChange.Keys.Count, Is.EqualTo(3)); PepAnalysisEngine.UpdateOutOfRangeStDevsWithGlobalAverage(stDevsToChange, averagesCommaStandardDeviations); - Assert.AreEqual(1.0d, averagesCommaStandardDeviations[0].Item2); - Assert.AreEqual(1.0d, averagesCommaStandardDeviations[1].Item2); + Assert.That(averagesCommaStandardDeviations[0].Item2, Is.EqualTo(1.0d)); + Assert.That(averagesCommaStandardDeviations[1].Item2, Is.EqualTo(1.0d)); Assert.That(1.1d, Is.EqualTo(averagesCommaStandardDeviations[2].Item2).Within(0.01)); - Assert.AreEqual(1.0d, averagesCommaStandardDeviations[3].Item2); + Assert.That(averagesCommaStandardDeviations[3].Item2, Is.EqualTo(1.0d)); } [Test] @@ -684,11 +677,11 @@ public static void TestRemoveThisAmbiguousePeptide() psm1.AddOrReplace(pwsm, 10, 1, true, new List(), 0); - Assert.AreEqual(2, psm1.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm1.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(2)); psm1.RemoveThisAmbiguousPeptide(1, pwsm); - Assert.AreEqual(1, psm1.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm1.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(1)); } [Test] @@ -717,7 +710,7 @@ public static void TestPsmData() "LongestFragmentIonSeries", "ComplementaryIonCount", "HydrophobicityZScore", "IsVariantPeptide", "IsDeadEnd", "IsLoop", "SpectralAngle", "HasSpectralAngle" }; - Assert.AreEqual(expectedTrainingInfoStandard, trainingInfoStandard); + Assert.That(trainingInfoStandard, Is.EqualTo(expectedTrainingInfoStandard)); searchType = "top-down"; string[] trainingInfoTopDown = PsmData.trainingInfos[searchType]; @@ -728,7 +721,7 @@ public static void TestPsmData() "ComplementaryIonCount", "SpectralAngle", "HasSpectralAngle", "PeaksInPrecursorEnvelope", "ChimeraCount", "MostAbundantPrecursorPeakIntensity", "PrecursorFractionalIntensity", "InternalIonCount" }; - Assert.AreEqual(expectedTrainingInfoTopDown, trainingInfoTopDown); + Assert.That(trainingInfoTopDown, Is.EqualTo(expectedTrainingInfoTopDown)); List positiveAttributes = new List { @@ -745,11 +738,11 @@ public static void TestPsmData() foreach (string attribute in positiveAttributes) { - Assert.AreEqual(1, PsmData.assumedAttributeDirection[attribute]); + Assert.That(PsmData.assumedAttributeDirection[attribute], Is.EqualTo(1)); } foreach (string attribute in negativeAttributes) { - Assert.AreEqual(-1, PsmData.assumedAttributeDirection[attribute]); + Assert.That(PsmData.assumedAttributeDirection[attribute], Is.EqualTo(-1)); } PsmData pd = new PsmData @@ -786,10 +779,10 @@ public static void TestPsmData() }; string standardToString = "\t0\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t17\t18\t21\t22"; - Assert.AreEqual(standardToString, pd.ToString("standard")); + Assert.That(pd.ToString("standard"), Is.EqualTo(standardToString)); string topDownToString = "\t0\t1\t2\t3\t4\t5\t6\t8\t9\t10\t21\t22\t23\t24\t25\t26\t27"; - Assert.AreEqual(topDownToString, pd.ToString("top-down")); + Assert.That(pd.ToString("top-down"), Is.EqualTo(topDownToString)); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/GPTMDengineTest.cs b/MetaMorpheus/Test/GPTMDengineTest.cs index a06db8496..4f08da0e7 100644 --- a/MetaMorpheus/Test/GPTMDengineTest.cs +++ b/MetaMorpheus/Test/GPTMDengineTest.cs @@ -3,7 +3,7 @@ using EngineLayer.Gptmd; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -37,7 +37,7 @@ public static void TestGptmdEngine(string proteinSequence, string accession, str var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary { { "filepath", precursorMassTolerance } }, new CommonParameters(), fsp, new List()); var res = (GptmdResults)engine.Run(); - Assert.AreEqual(0, res.Mods.Count); + Assert.That(res.Mods.Count, Is.EqualTo(0)); var parentProtein = new Protein(proteinSequence, accession, sequenceVariations: new List { new SequenceVariation(1, "N", "A", sequenceVariantDescription) }); var variantProteins = parentProtein.GetVariantProteins(); @@ -59,8 +59,8 @@ public static void TestGptmdEngine(string proteinSequence, string accession, str engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary { { "filepath", precursorMassTolerance } }, new CommonParameters(), null, new List()); res = (GptmdResults)engine.Run(); - Assert.AreEqual(1, res.Mods.Count); - Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count); + Assert.That(res.Mods.Count, Is.EqualTo(1)); + Assert.That(res.Mods["accession"].Count, Is.EqualTo(numModifiedResidues)); } [Test] @@ -97,23 +97,14 @@ public static void TestCombos(string proteinSequence, string accession, string v var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary { { "filepath", precursorMassTolerance } }, new CommonParameters(), null, new List()); var res = (GptmdResults)engine.Run(); - Assert.AreEqual(numModHashes, res.Mods.Count); - Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count); - Assert.AreEqual(numModifiedResiduesN, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("21")).Count()); - Assert.AreEqual(numModifiedResiduesP, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("16")).Count()); + Assert.That(res.Mods.Count, Is.EqualTo(numModHashes)); + Assert.That(res.Mods["accession"].Count, Is.EqualTo(numModifiedResidues)); + Assert.That(res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("21")).Count(), Is.EqualTo(numModifiedResiduesN)); + Assert.That(res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("16")).Count(), Is.EqualTo(numModifiedResiduesP)); res.Mods.TryGetValue("accession_N1P", out var hash); - Assert.AreEqual(numModifiedResiduesNP, (hash ?? new HashSet>()).Count); + Assert.That((hash ?? new HashSet>()).Count, Is.EqualTo(numModifiedResiduesNP)); } - //[Test] - //public static void LoadOriginalMismatchedModifications() - //{ - // var protein = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "oblm.xml"), true, DecoyType.Reverse, null, false, null, out var unknownModifications); - // Assert.AreEqual(0, protein[0].OneBasedPossibleLocalizedModifications.Count); - // protein[0].RestoreUnfilteredModifications(); - // Assert.AreEqual(1, protein[0].OneBasedPossibleLocalizedModifications.Count); - //} - [Test] public static void TestSearchPtmVariantDatabase() { @@ -162,14 +153,14 @@ public static void TestSearchPtmVariantDatabase() var variantProteins = ProteinDbLoader.LoadProteinXML(xmlName, true, DecoyType.Reverse, null, false, null, out var unknownModifications); var variantProtein = variantProteins[0]; var variantDecoy = variantProteins[1]; - Assert.AreEqual(0, unknownModifications.Count); + Assert.That(unknownModifications.Count, Is.EqualTo(0)); - Assert.AreEqual(2, variantProteins.Count); // target & decoy - Assert.AreEqual(2, variantProteins[0].OneBasedPossibleLocalizedModifications.Count); + Assert.That(variantProteins.Count, Is.EqualTo(2)); // target & decoy + Assert.That(variantProteins[0].OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(2)); List foundResidueIndicies = variantProtein.OneBasedPossibleLocalizedModifications.Select(k => k.Key).ToList(); List expectedResidueIndices = new List() { 1, 3 }; Assert.That(foundResidueIndicies, Is.EquivalentTo(expectedResidueIndices)); - Assert.AreEqual(2, variantDecoy.OneBasedPossibleLocalizedModifications.Count); + Assert.That(variantDecoy.OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(2)); foundResidueIndicies = variantDecoy.OneBasedPossibleLocalizedModifications.Select(k => k.Key).ToList(); expectedResidueIndices = new List() { 4, 6 }; //originally modified residues are now at the end in the decoy Assert.That(foundResidueIndicies, Is.EquivalentTo(expectedResidueIndices)); @@ -178,13 +169,13 @@ public static void TestSearchPtmVariantDatabase() var commonParamsAtThisPoint = task1.CommonParameters.DigestionParams; //for debugging var digestedList = variantProteins[0].GetVariantProteins()[0].Digest(task1.CommonParameters.DigestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(4, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(4)); //Set Peptide with 1 mod at position 3 PeptideWithSetModifications pepWithSetMods1 = digestedList[1]; //Finally Write MZML file - Assert.AreEqual("PEK[type:acetyl on K]TID", pepWithSetMods1.FullSequence);//this might be base sequence + Assert.That(pepWithSetMods1.FullSequence, Is.EqualTo("PEK[type:acetyl on K]TID"));//this might be base sequence MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); string mzmlName = @"hello.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); @@ -221,7 +212,7 @@ public static void Test_GptmdEngineModFits(string targetAminoAcid, string protei oneBasedModifications.Add(proteinOneBasedIndex, new List() { attemptToLocalize }); Protein protein = new Protein(proteinSequence, null, null, null, oneBasedModifications, null, null, null, false, false, null, null, null, null, null, null, ""); - Assert.AreEqual(result, GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); + Assert.That(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex), Is.EqualTo(result)); } [Test] diff --git a/MetaMorpheus/Test/GlobalVariablesTest.cs b/MetaMorpheus/Test/GlobalVariablesTest.cs index eb9482da4..88bf0f1fb 100644 --- a/MetaMorpheus/Test/GlobalVariablesTest.cs +++ b/MetaMorpheus/Test/GlobalVariablesTest.cs @@ -1,10 +1,7 @@ using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System; -using System.Collections.Generic; using System.IO; -using System.Text; -using System.Threading; namespace Test { diff --git a/MetaMorpheus/Test/GuiFunctionsTest.cs b/MetaMorpheus/Test/GuiFunctionsTest.cs index 139bd705a..5bc8f7687 100644 --- a/MetaMorpheus/Test/GuiFunctionsTest.cs +++ b/MetaMorpheus/Test/GuiFunctionsTest.cs @@ -1,5 +1,5 @@ using GuiFunctions.Databases; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using System; using System.Collections.Generic; @@ -39,7 +39,7 @@ public static void TestGetUniprotFilename(string proteomeID, bool reviewed, bool Console.WriteLine("Finished with Uniprot database test."); } - Assert.AreEqual(expectedResult, filename); + Assert.That(expectedResult, Is.EqualTo(filename)); } // Occasionally the downloaded files will change, and thus the expected result will need to be updated. diff --git a/MetaMorpheus/Test/IndexEngineTest.cs b/MetaMorpheus/Test/IndexEngineTest.cs index c60fd14ba..4d2814279 100644 --- a/MetaMorpheus/Test/IndexEngineTest.cs +++ b/MetaMorpheus/Test/IndexEngineTest.cs @@ -1,7 +1,7 @@ using EngineLayer; using EngineLayer.Indexing; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -53,14 +53,14 @@ public static void TestIndexEngine() var results = (IndexingResults)engine.Run(); - Assert.AreEqual(5, results.PeptideIndex.Count); + Assert.That(results.PeptideIndex.Count, Is.EqualTo(5)); var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(5, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(5)); foreach (PeptideWithSetModifications peptide in digestedList) { - Assert.Contains(peptide, results.PeptideIndex); + Assert.That(results.PeptideIndex.Contains(peptide)); var fragments = new List(); peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both, fragments); @@ -78,7 +78,7 @@ public static void TestIndexEngine() List fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! - Assert.Contains(positionInPeptideIndex, fragmentBin); + Assert.That(fragmentBin.Contains(positionInPeptideIndex)); } } } @@ -124,10 +124,10 @@ public static void TestIndexEngineWithWeirdSeq() var results = (IndexingResults)engine.Run(); - Assert.AreEqual(1, results.PeptideIndex.Count); + Assert.That(results.PeptideIndex.Count, Is.EqualTo(1)); - Assert.IsNaN(results.PeptideIndex[0].MonoisotopicMass); - Assert.AreEqual(30000000 + 1, results.FragmentIndex.Length); + Assert.That(results.PeptideIndex[0].MonoisotopicMass, Is.NaN); + Assert.That(results.FragmentIndex.Length, Is.EqualTo(30000000 + 1)); } [Test] @@ -164,7 +164,7 @@ public static void TestIndexEngineLowRes() var results = (IndexingResults)engine.Run(); - Assert.AreEqual(10, results.PeptideIndex.Count); + Assert.That(results.PeptideIndex.Count, Is.EqualTo(10)); var bubba = results.FragmentIndex; var tooBubba = results.PrecursorIndex; @@ -173,10 +173,10 @@ public static void TestIndexEngineLowRes() var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List(), variableModifications).ToList(); digestedList.AddRange(proteinList[1].Digest(CommonParameters.DigestionParams, new List(), variableModifications)); - Assert.AreEqual(10, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(10)); foreach (PeptideWithSetModifications peptide in digestedList) { - Assert.Contains(peptide, results.PeptideIndex); + Assert.That(results.PeptideIndex.Contains(peptide)); var fragments = new List(); peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both, fragments); @@ -194,12 +194,12 @@ public static void TestIndexEngineLowRes() List fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! - Assert.Contains(positionInPeptideIndex, fragmentBin); + Assert.That(fragmentBin.Contains(positionInPeptideIndex)); } } foreach (var fdfd in digestedList) { - Assert.Contains(fdfd, results.PeptideIndex); + Assert.That(results.PeptideIndex.Contains(fdfd)); } } } diff --git a/MetaMorpheus/Test/LocalizationTest.cs b/MetaMorpheus/Test/LocalizationTest.cs index f2fb765ee..fe08b6506 100644 --- a/MetaMorpheus/Test/LocalizationTest.cs +++ b/MetaMorpheus/Test/LocalizationTest.cs @@ -3,7 +3,7 @@ using EngineLayer.Localization; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -25,7 +25,7 @@ public static void TestNonSpecific() DigestionParams digestionParams = new DigestionParams(protease: p.Name, maxMissedCleavages: 8, minPeptideLength: 1, maxPeptideLength: 9, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); var peps = prot.Digest(digestionParams, new List(), new List()).ToList(); - Assert.AreEqual(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, peps.Count); + Assert.That(peps.Count, Is.EqualTo(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)); } [Test] @@ -39,7 +39,7 @@ public static void TestLocalization() List variableModifications = new List { new Modification(_originalId: "21", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; List allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); + Assert.That(allPeptidesWithSetModifications.Count(), Is.EqualTo(4)); PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; @@ -58,11 +58,11 @@ public static void TestLocalization() f.Run(); // single peak matches - Assert.AreEqual(1, newPsm.MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.b).Count());//including b1 now - Assert.AreEqual(1, newPsm.MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.y).Count()); + Assert.That(newPsm.MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.b).Count(), Is.EqualTo(1));//including b1 now + Assert.That(newPsm.MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.y).Count(), Is.EqualTo(1)); // when localizing, three peaks match - Assert.IsTrue(newPsm.LocalizedScores[1] > 4 && newPsm.LocalizedScores[1] < 5);//we have another matched ion + Assert.That(newPsm.LocalizedScores[1] > 4 && newPsm.LocalizedScores[1] < 5);//we have another matched ion } [Test] @@ -70,23 +70,23 @@ public static void TestSeparateIonsByTerminus() { List allIonTypes = new List { ProductType.b, ProductType.c, ProductType.zPlusOne, ProductType.y }; List> separated = ProductTypeMethods.SeparateIonsByTerminus(allIonTypes); - Assert.IsTrue(separated.Count == 2); - Assert.IsTrue(separated[0].Count == 2); - Assert.IsTrue(separated[1].Count == 2); - Assert.IsTrue(separated[0].Contains(ProductType.b)); - Assert.IsTrue(separated[0].Contains(ProductType.c)); - Assert.IsTrue(separated[1].Contains(ProductType.y)); - Assert.IsTrue(separated[1].Contains(ProductType.zPlusOne)); + Assert.That(separated.Count == 2); + Assert.That(separated[0].Count == 2); + Assert.That(separated[1].Count == 2); + Assert.That(separated[0].Contains(ProductType.b)); + Assert.That(separated[0].Contains(ProductType.c)); + Assert.That(separated[1].Contains(ProductType.y)); + Assert.That(separated[1].Contains(ProductType.zPlusOne)); List> nOnly = ProductTypeMethods.SeparateIonsByTerminus(separated[0]); - Assert.IsTrue(nOnly.Count == 1); - Assert.IsTrue(nOnly[0].Count == 2); - Assert.IsTrue(nOnly[0].Contains(ProductType.b)); - Assert.IsTrue(nOnly[0].Contains(ProductType.c)); + Assert.That(nOnly.Count == 1); + Assert.That(nOnly[0].Count == 2); + Assert.That(nOnly[0].Contains(ProductType.b)); + Assert.That(nOnly[0].Contains(ProductType.c)); List> cOnly = ProductTypeMethods.SeparateIonsByTerminus(separated[1]); - Assert.IsTrue(cOnly.Count == 1); - Assert.IsTrue(cOnly[0].Count == 2); - Assert.IsTrue(cOnly[0].Contains(ProductType.y)); - Assert.IsTrue(cOnly[0].Contains(ProductType.zPlusOne)); + Assert.That(cOnly.Count == 1); + Assert.That(cOnly[0].Count == 2); + Assert.That(cOnly[0].Contains(ProductType.y)); + Assert.That(cOnly[0].Contains(ProductType.zPlusOne)); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs index 970500680..49de53381 100644 --- a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs +++ b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs @@ -5,7 +5,7 @@ using EngineLayer.ClassicSearch; using IO.MzML; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -69,8 +69,8 @@ public static void TestMatchIonsOfAllChargesBottomUp() //compare 2 scores , they should have same integer part but new search has a little higher score than old search Assert.That(psm[1].Score > psm_oneCharge[1].Score); - Assert.AreEqual(Math.Truncate(psm[1].Score), 12); - Assert.AreEqual(Math.Truncate(psm_oneCharge[1].Score), 12); + Assert.That(Math.Truncate(psm[1].Score), Is.EqualTo(12)); + Assert.That(Math.Truncate(psm_oneCharge[1].Score), Is.EqualTo(12)); //compare 2 results and evaluate the different matched ions var peptideTheorProducts = new List(); @@ -118,7 +118,7 @@ public static void TestMatchIonsOfAllChargesBottomUp() proteinList1, searchModes, CommonParameters1, fsp, null, new List(), writeSpectralLibrary).Run(); var psm1 = allPsmsArray1.Where(p => p != null).ToList(); - Assert.AreEqual(psm1.Count, 222); + Assert.That(psm1.Count, Is.EqualTo(222)); } [Test] @@ -168,8 +168,8 @@ public static void TestMatchIonsOfAllChargesTopDown() //compare 2 scores , they should have same integer but new search has a little higher score than old search Assert.That(psm.Score > psm_oneCharge.Score); - Assert.AreEqual(Math.Truncate(psm.Score), 47); - Assert.AreEqual(Math.Truncate(psm_oneCharge.Score), 47); + Assert.That(Math.Truncate(psm.Score), Is.EqualTo(47)); + Assert.That(Math.Truncate(psm_oneCharge.Score), Is.EqualTo(47)); //compare 2 results and evaluate the different matched ions var peptideTheorProducts = new List(); @@ -217,28 +217,27 @@ public static void TestLookingForAcceptableIsotopicEnvelopes() //test1 when all the masses are too small var test1 = ms2ScanTest.GetClosestExperimentalIsotopicEnvelopeList(50, 95); - Assert.AreEqual(test1, null); + Assert.That(test1, Is.EqualTo(null)); //test2 when all the masses are too big var test2 = ms2ScanTest.GetClosestExperimentalIsotopicEnvelopeList(582, 682); - Assert.AreEqual(test2, null); + Assert.That(test2, Is.EqualTo(null)); //test3 when the mass which is bigger than given min mass is bigger than the mass which is smaller than the given max mass //for example: the mass array is [1,2,3,4,5], the given min mass is 2.2, the given max mass is 2.8 var test3 = ms2ScanTest.GetClosestExperimentalIsotopicEnvelopeList(110, 111); - Assert.AreEqual(test3, null); - + Assert.That(test3, Is.EqualTo(null)); //test normal conditions:look for IsotopicEnvelopes which are in the range of acceptable mass var test4 = ms2ScanTest.GetClosestExperimentalIsotopicEnvelopeList(120, 130); IsotopicEnvelope[] expected4 = ms2ScanTest.ExperimentalFragments.Skip(15).Take(9).ToArray(); Assert.That(ms2ScanTest.ExperimentalFragments[15].MonoisotopicMass > 120 && ms2ScanTest.ExperimentalFragments[14].MonoisotopicMass < 120); Assert.That(ms2ScanTest.ExperimentalFragments[23].MonoisotopicMass < 130 && ms2ScanTest.ExperimentalFragments[24].MonoisotopicMass > 130); - Assert.AreEqual(test4, expected4); + Assert.That(test4, Is.EqualTo(expected4)); var test5 = ms2ScanTest.GetClosestExperimentalIsotopicEnvelopeList(400, 500); IsotopicEnvelope[] expected5 = ms2ScanTest.ExperimentalFragments.Skip(150).Take(7).ToArray(); Assert.That(ms2ScanTest.ExperimentalFragments[150].MonoisotopicMass > 400 && ms2ScanTest.ExperimentalFragments[149].MonoisotopicMass < 400); Assert.That(ms2ScanTest.ExperimentalFragments[156].MonoisotopicMass < 500 && ms2ScanTest.ExperimentalFragments[157].MonoisotopicMass > 500); - Assert.AreEqual(test5, expected5); + Assert.That(test5, Is.EqualTo(expected5)); } [Test] @@ -509,10 +508,8 @@ public static void TestLibrarySpectrumCalculateSpectralAngleOnTheFly() var computedSpectralSimilarity = spectrum.CalculateSpectralAngleOnTheFly(psms[0].MatchedIons); - Assert.AreEqual(1,Convert.ToDouble(computedSpectralSimilarity),0.01); - - - Assert.AreEqual("N/A", spectrum.CalculateSpectralAngleOnTheFly(new List())); + Assert.That(Convert.ToDouble(computedSpectralSimilarity), Is.EqualTo(1).Within(0.01)); + Assert.That(spectrum.CalculateSpectralAngleOnTheFly(new List()), Is.EqualTo("N/A")); } diff --git a/MetaMorpheus/Test/MetaDraw/FragmentReanalysis.cs b/MetaMorpheus/Test/MetaDraw/FragmentReanalysis.cs index 4f508f134..3ccee2319 100644 --- a/MetaMorpheus/Test/MetaDraw/FragmentReanalysis.cs +++ b/MetaMorpheus/Test/MetaDraw/FragmentReanalysis.cs @@ -3,8 +3,6 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Easy.Common.Extensions; using EngineLayer; using GuiFunctions; @@ -12,9 +10,6 @@ using Nett; using NUnit.Framework; using NUnit.Framework.Legacy; -using Assert = NUnit.Framework.Legacy.ClassicAssert; -using Omics.Fragmentation; -using pepXML.Generated; using Readers; using TaskLayer; @@ -29,12 +24,12 @@ public static void TestFragmentationReanalysisViewModel_DefaultProperties() var viewModel = new FragmentationReanalysisViewModel(); // check default parameters on loading - Assert.AreEqual(DissociationType.HCD, viewModel.SelectedDissociationType); - Assert.False(viewModel.Persist); - Assert.False(viewModel.UseInternalIons); - Assert.AreEqual(10, viewModel.MinInternalIonLength); - Assert.AreEqual(7, viewModel.DissociationTypes.Count()); - Assert.AreEqual(20, viewModel.ProductIonMassTolerance); + Assert.That(viewModel.SelectedDissociationType, Is.EqualTo(DissociationType.HCD)); + Assert.That(!viewModel.Persist); + Assert.That(!viewModel.UseInternalIons); + Assert.That(viewModel.MinInternalIonLength, Is.EqualTo(10)); + Assert.That(viewModel.DissociationTypes.Count(), Is.EqualTo(7)); + Assert.That(viewModel.ProductIonMassTolerance, Is.EqualTo(20)); var productsToUse = viewModel.PossibleProducts.Where(p => p.Use).Select(p => p.ProductType).ToList(); var hcdProducts = Omics.Fragmentation.Peptide.DissociationTypeCollection.ProductsFromDissociationType[DissociationType.HCD]; @@ -101,12 +96,12 @@ public static void TestFragmentationReanalysisViewModel_RematchIons() // increase product ion tolerance and ensure more ions are found viewModel.ProductIonMassTolerance = 200; var newMatchedIons = viewModel.MatchIonsWithNewTypes(scan, psmToResearch); - Assert.Less(psmToResearch.MatchedIons.Count, newMatchedIons.Count); + Assert.That(psmToResearch.MatchedIons.Count < newMatchedIons.Count); // decrease product ion tolerance and ensure fewer ions are found viewModel.ProductIonMassTolerance = 2; newMatchedIons = viewModel.MatchIonsWithNewTypes(scan, psmToResearch); - Assert.Less(newMatchedIons.Count, psmToResearch.MatchedIons.Count); + Assert.That(newMatchedIons.Count < psmToResearch.MatchedIons.Count); viewModel.ProductIonMassTolerance = 20; // ensure ambiguous psms get kicked out before reanalysis diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs index c94868f6b..9e9bfbf6c 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs @@ -3,13 +3,11 @@ using System.IO; using System.Linq; using System.Windows.Media; -using Easy.Common.Extensions; using EngineLayer; using GuiFunctions; using GuiFunctions.ViewModels.Legends; using NUnit.Framework; using NUnit.Framework.Legacy; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using OxyPlot; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -213,14 +211,14 @@ public static void TestLoadMetaDrawSettings() // Desired outcome: All default values are used MetaDrawSettingsViewModel viewModel = new MetaDrawSettingsViewModel(false); var modelSettingsPath = MetaDrawSettingsViewModel.SettingsPath; - Assert.False(File.Exists(modelSettingsPath)); - NUnit.Framework.Assert.That(!viewModel.HasDefaultSaved); + Assert.That(!File.Exists(modelSettingsPath)); + Assert.That(!viewModel.HasDefaultSaved); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), defaultCoverageColors[0]); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(1), defaultCoverageColors[1]); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(2), defaultCoverageColors[2]); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), Is.EqualTo(defaultCoverageColors[0])); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(1), Is.EqualTo(defaultCoverageColors[1])); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(2), Is.EqualTo(defaultCoverageColors[2])); - // Make one change and save this viewModel as a modern settings config for next test case + // Make one change and save this viewModel as a modern settings config for next test case viewModel.CoverageColors.First().SelectionChanged("Yellow"); string modernSettingsPath = Path.Combine(testingDir, "temporaryCurrentSettingsConfig.xml"); MetaDrawSettingsViewModel.SettingsPath = modernSettingsPath; @@ -229,17 +227,18 @@ public static void TestLoadMetaDrawSettings() // CASE: user has modern settings config file stored // Desired outcome: Read in correctly modelSettingsPath = MetaDrawSettingsViewModel.SettingsPath; - Assert.True(File.Exists(modelSettingsPath)); + Assert.That(File.Exists(modelSettingsPath)); var creationTime = File.GetLastWriteTime(modernSettingsPath); viewModel = new MetaDrawSettingsViewModel(false); - // check that no new file was generated + // check that no new file was generated var creationTimeAfterLoad = File.GetLastWriteTime(modernSettingsPath); - Assert.AreEqual(creationTimeAfterLoad, creationTime); - - Assert.AreNotEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), defaultCoverageColors[0]); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), OxyColors.Yellow); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(1), defaultCoverageColors[1]); - Assert.AreEqual(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(2), defaultCoverageColors[2]); + Assert.That(creationTimeAfterLoad, Is.EqualTo(creationTime)); + + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), !Is.EqualTo(defaultCoverageColors[0])); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(0), Is.EqualTo(OxyColors.Yellow)); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(1), Is.EqualTo(defaultCoverageColors[1])); + Assert.That(MetaDrawSettings.CoverageTypeToColor.Values.ElementAt(2), Is.EqualTo(defaultCoverageColors[2])); + // CASE: user has old settings config file stored @@ -248,16 +247,16 @@ public static void TestLoadMetaDrawSettings() // Ensure settings are in outdated format int commaCount = File.ReadLines(outdatedSettingsPath).Sum(p => p.Count(m => m.Equals(','))); - Assert.AreEqual(0, commaCount); + Assert.That(commaCount, Is.EqualTo(0)); creationTime = File.GetLastWriteTime(outdatedSettingsPath); viewModel = new MetaDrawSettingsViewModel(false); creationTimeAfterLoad = File.GetLastWriteTime(outdatedSettingsPath); - Assert.AreNotEqual(creationTimeAfterLoad, creationTime); + Assert.That(creationTimeAfterLoad, !Is.EqualTo(creationTime)); - Assert.AreEqual(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(0), defaultColorValues[0]); - Assert.AreEqual(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(1), defaultColorValues[1]); - Assert.AreEqual(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(2), defaultColorValues[2]); + Assert.That(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(0), Is.EqualTo(defaultColorValues[0])); + Assert.That(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(1), Is.EqualTo(defaultColorValues[1])); + Assert.That(MetaDrawSettings.ProductTypeToColor.Values.ElementAt(2), Is.EqualTo(defaultColorValues[2])); Directory.Delete(testingDir, true); } @@ -547,8 +546,8 @@ public static void TestChimeraLegendViewModels() List overflowInducingProteins = psms.DistinctBy(p => p.BaseSeq) .Take(ChimeraSpectrumMatchPlot.ColorByProteinDictionary.Keys.Count + 1).ToList(); chimeraLegend = new(overflowInducingProteins); - Assert.AreEqual(chimeraLegend.ChimeraLegendItems.Values.DistinctBy(p => - p.Select(m => m.ColorBrush.Color)).Count(), overflowInducingProteins.Count()); + Assert.That(chimeraLegend.ChimeraLegendItems.Values.DistinctBy(p => + p.Select(m => m.ColorBrush.Color)).Count(), Is.EqualTo(overflowInducingProteins.Count())); Assert.That(chimeraLegend.ChimeraLegendItems.First().Value.First().ColorBrush.Color != chimeraLegend.ChimeraLegendItems[overflowInducingProteins[1].BaseSeq].First().ColorBrush.Color); Assert.That(chimeraLegend.ChimeraLegendItems.First().Value.First().ColorBrush.Color == @@ -563,11 +562,11 @@ public static void TestChimeraLegendViewModels() Assert.That(overflowInducingProteins.All(p => p.FullSequence == overflowInducingProteins.First().FullSequence)); chimeraLegend = new(overflowInducingProteins); - Assert.AreEqual(overflowInducingProteins.Count() + 1, - chimeraLegend.ChimeraLegendItems.First().Value.DistinctBy(p => p.ColorBrush.Color).Count()); + Assert.That(chimeraLegend.ChimeraLegendItems.First().Value.DistinctBy(p => p.ColorBrush.Color).Count(), + Is.EqualTo(overflowInducingProteins.Count() + 1)); Assert.That(chimeraLegend.ChimeraLegendItems.First().Value.Count() == overflowInducingProteins.Count + 1); - Assert.AreEqual(chimeraLegend.ChimeraLegendItems.First().Value.Last().ColorBrush.Color, DrawnSequence - .ParseColorBrushFromOxyColor(ChimeraSpectrumMatchPlot.OverflowColors.Dequeue()).Color); + Assert.That(chimeraLegend.ChimeraLegendItems.First().Value.Last().ColorBrush.Color, Is.EqualTo(DrawnSequence + .ParseColorBrushFromOxyColor(ChimeraSpectrumMatchPlot.OverflowColors.Dequeue()).Color)); // test chimera legend item ChimeraLegendItemViewModel chimeraLegendItem = new("tacos", OxyColors.Chocolate); diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs index 427d62bf9..c9248b028 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs @@ -14,7 +14,7 @@ using EngineLayer; using GuiFunctions; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using OxyPlot.Series; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -50,8 +50,8 @@ public static void TestMetaDrawReadPsmFile() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(10, parsedPsms.Count); - Assert.AreEqual(0, warnings.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(10)); + Assert.That(warnings.Count, Is.EqualTo(0)); Directory.Delete(folderPath, true); } @@ -65,8 +65,8 @@ public static void TestMetaDrawReadPsmFileWithoutSpectralAngle() List parsedPsms = PsmTsvReader.ReadTsv(noSA, out var warnings); - Assert.AreEqual(15, parsedPsms.Count); - Assert.AreEqual(0, warnings.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(15)); + Assert.That(warnings.Count, Is.EqualTo(0)); } [Test] @@ -86,9 +86,9 @@ public static void TestMetaDrawReadSAwhenReadingPsmFile() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(-1, parsedPsms.First().SpectralAngle); - Assert.AreEqual(10, parsedPsms.Count); - Assert.AreEqual(0, warnings.Count); + Assert.That(parsedPsms.First().SpectralAngle, Is.EqualTo(-1)); + Assert.That(parsedPsms.Count, Is.EqualTo(10)); + Assert.That(warnings.Count, Is.EqualTo(0)); Directory.Delete(folderPath, true); } @@ -99,7 +99,7 @@ public static void TestParenthesesRemovalForSilac() { string baseSequence = "ASDF(+8.01)ASDF"; string cleanedSequence = PsmFromTsv.RemoveParentheses(baseSequence); - Assert.IsTrue(cleanedSequence.Equals("ASDFASDF")); + Assert.That(cleanedSequence.Equals("ASDFASDF")); } [Test] @@ -134,11 +134,11 @@ public static void TestFindVariantCrossingIons() psms = PsmTsvReader.ReadTsv(myFile, out warnings); // test will fail if the order of psms is changed to something other than top to bottom row // check that variant psm properties are being parsed correctly - Assert.AreEqual("", psms[0].IdentifiedSequenceVariations); - Assert.AreEqual("A147T", psms[1].IdentifiedSequenceVariations); + Assert.That(psms[0].IdentifiedSequenceVariations, Is.EqualTo("")); + Assert.That(psms[1].IdentifiedSequenceVariations, Is.EqualTo("A147T")); - Assert.AreEqual("541-541", psms[0].SpliceSites); - Assert.AreEqual("", psms[1].SpliceSites); + Assert.That(psms[0].SpliceSites, Is.EqualTo("541-541")); + Assert.That(psms[1].SpliceSites, Is.EqualTo("")); // check that the correct ions are being added to VariantCrossingIons List> expected = new List>(); @@ -162,10 +162,10 @@ public static void TestFindVariantCrossingIons() { IEnumerable actualIons = psms[i].VariantCrossingIons.Select(p => p.NeutralTheoreticalProduct.Annotation); foreach (string expectedIon in expected[i]) - Assert.IsTrue(actualIons.Contains(expectedIon), + Assert.That(actualIons.Contains(expectedIon), "VariantCrossingIons should contain ion " + expectedIon + " in file " + psms[i].FileNameWithoutExtension + "."); foreach (string actualIon in actualIons) - Assert.IsTrue(expected[i].Contains(actualIon), + Assert.That(expected[i].Contains(actualIon), "VariantCrossingIons should not contain ion " + actualIon + " in file " + psms[i].FileNameWithoutExtension + "."); } } @@ -222,7 +222,7 @@ public static void MetaDraw_TestStationarySequencePositioning() var expected = modifiedBaseSeq.Length + matchedIons.Count + fullSequence.Count(p => p == '[') + startAA.Length + endAA.Length + 2; - Assert.AreEqual(metadrawLogic.StationarySequence.SequenceDrawingCanvas.Children.Count, expected); + Assert.That(metadrawLogic.StationarySequence.SequenceDrawingCanvas.Children.Count, Is.EqualTo(expected)); } } @@ -656,7 +656,7 @@ public static void TestMetaDrawXlSpectralLibrary() // test that library peaks were drawn in the mirror plot (these peaks have negative intensities) var mirrorPlotPeaks = plotSeries.Where(p => ((LineSeries)p).Points[1].Y < 0).ToList(); - Assert.AreEqual(mirrorPlotPeaks.Count, 59); + Assert.That(mirrorPlotPeaks.Count, Is.EqualTo(59)); var plotAxes = plotView.Model.Axes; Assert.That(plotAxes.Count == 2); @@ -734,7 +734,7 @@ public static void MetaDraw_GlycoSearchTaskWithChildScansTest() Assert.That(psmObj.FullSequence.Contains(filterString)); c++; } - Assert.Greater(c, 0); + Assert.That(c > 0); // test text search filter (filter by MS2 scan number) filterString = @"2"; @@ -747,7 +747,7 @@ public static void MetaDraw_GlycoSearchTaskWithChildScansTest() Assert.That(psmObj.Ms2ScanNumber.ToString().Contains(filterString)); c++; } - Assert.Greater(c, 0); + Assert.That(c > 0); // draw PSM var plotView = new OxyPlot.Wpf.PlotView(){Name = "plotView"}; @@ -771,48 +771,47 @@ public static void MetaDraw_GlycoSearchTaskWithChildScansTest() Assert.That((int)peakPoints[1].Y == 3847); var plotAxes = plotView.Model.Axes; - Assert.AreEqual(2, plotAxes.Count); + Assert.That(plotAxes.Count, Is.EqualTo(2)); // test that base sequence annotation was drawn - Assert.Greater(metadrawLogic.StationarySequence.SequenceDrawingCanvas.Children.Count, 0); + Assert.That(metadrawLogic.StationarySequence.SequenceDrawingCanvas.Children.Count > 0); // test that the plots were drawn in the parent/child view - Assert.AreEqual(2, parentChildView.Plots.Count); + Assert.That(parentChildView.Plots.Count, Is.EqualTo(2)); // test parent scan var parentPlot = parentChildView.Plots[0]; - Assert.AreEqual("Scan: 27 Dissociation Type: HCD MsOrder: 2 Selected Mz: 924.12 Retention Time: 32.65", parentPlot.SpectrumLabel); + Assert.That(parentPlot.SpectrumLabel, Is.EqualTo("Scan: 27 Dissociation Type: HCD MsOrder: 2 Selected Mz: 924.12 Retention Time: 32.65")); int numAnnotatedResidues = psm.BaseSeq.Length; int numAnnotatedIons = psm.MatchedIons.Count(p => p.NeutralTheoreticalProduct.ProductType != ProductType.M && p.NeutralTheoreticalProduct.ProductType != ProductType.D); int numAnnotatedMods = psm.FullSequence.Count(p => p == '['); - Assert.AreEqual(numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods, parentPlot.TheCanvas.Children.Count); + Assert.That(parentPlot.TheCanvas.Children.Count, Is.EqualTo(numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods)); peak = (LineSeries)parentPlot.Plot.Model.Series[0]; // the first m/z peak peakPoints = peak.Points; - Assert.AreEqual(101.07, Math.Round(peakPoints[0].X, 2)); // m/z - Assert.AreEqual(101.07, (Math.Round(peakPoints[1].X, 2))); - Assert.AreEqual(0, (int)peakPoints[0].Y); // intensity - Assert.AreEqual(3847, (int)peakPoints[1].Y); + Assert.That(Math.Round(peakPoints[0].X, 2), Is.EqualTo(101.07)); // m/z + Assert.That(Math.Round(peakPoints[1].X, 2), Is.EqualTo(101.07)); + Assert.That((int)peakPoints[0].Y, Is.EqualTo(0)); // intensity + Assert.That((int)peakPoints[1].Y, Is.EqualTo(3847)); // test child scan var childPlot = parentChildView.Plots[1]; - Assert.AreEqual("Scan: 30 Dissociation Type: EThcD MsOrder: 2 Selected Mz: 924.12 RetentionTime: 32.66", - childPlot.SpectrumLabel); - Assert.Greater(childPlot.TheCanvas.Children.Count, 0); + Assert.That(childPlot.SpectrumLabel, Is.EqualTo("Scan: 30 Dissociation Type: EThcD MsOrder: 2 Selected Mz: 924.12 RetentionTime: 32.66")); + Assert.That(childPlot.TheCanvas.Children.Count > 0); numAnnotatedResidues = psm.BaseSeq.Length; numAnnotatedIons = psm.ChildScanMatchedIons[30] .Count(p => p.NeutralTheoreticalProduct.ProductType != ProductType.M && p.NeutralTheoreticalProduct.ProductType != ProductType.D); numAnnotatedMods = psm.FullSequence.Count(p => p == '['); - Assert.AreEqual(numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods, childPlot.TheCanvas.Children.Count); + Assert.That(childPlot.TheCanvas.Children.Count, Is.EqualTo(numAnnotatedResidues + numAnnotatedIons + numAnnotatedMods)); peak = (LineSeries)childPlot.Plot.Model.Series[0]; // the first m/z peak peakPoints = peak.Points; - Assert.AreEqual(126.06, Math.Round(peakPoints[0].X, 2)); // m/z - Assert.AreEqual(126.06, Math.Round(peakPoints[1].X, 2)); - Assert.AreEqual(0, (int)peakPoints[0].Y); // intensity - Assert.AreEqual(8496, (int)peakPoints[1].Y); + Assert.That(Math.Round(peakPoints[0].X, 2), Is.EqualTo(126.06)); // m/z + Assert.That(Math.Round(peakPoints[1].X, 2), Is.EqualTo(126.06)); + Assert.That((int)peakPoints[0].Y, Is.EqualTo(0)); // intensity + Assert.That((int)peakPoints[1].Y, Is.EqualTo(8496)); // write pdf var psmsToExport = metadrawLogic.FilteredListOfPsms.Where(p => p.FullSequence == "STTAVQTPTSGEPLVST[O-Glycosylation:H1N1 on X]SEPLSSK").ToList(); @@ -1258,7 +1257,7 @@ public static void TestPsmFromTsvIonParsing() } //check that the proteoform classification was correct - Assert.IsTrue(metadrawLogic.FilteredListOfPsms[0].AmbiguityLevel.Equals("1")); + Assert.That(metadrawLogic.FilteredListOfPsms[0].AmbiguityLevel.Equals("1")); // delete output Directory.Delete(outputFolder, true); @@ -1628,87 +1627,87 @@ public static void TestMetaDrawHistogramPlots() .ToDictionary(p => p.Key, p => new ObservableCollection(p)); // check that fragment mass error was read in correctly - Assert.AreEqual(Math.Round(-0.27631606125063707, 5), Math.Round(psms[1].MatchedIons[1].MassErrorPpm, 5)); - + Assert.That(Math.Round(-0.27631606125063707, 5), Is.EqualTo(Math.Round(psms[1].MatchedIons[1].MassErrorPpm, 5))); + // check aspects of each histogram type: var plot = new PlotModelStat("Histogram of Precursor Masses", psms, psmDict); // Ensure axes are labeled correctly, and intervals are correct - Assert.AreEqual(2, plot.Model.Axes.Count); - Assert.AreEqual("Count", plot.Model.Axes[1].Title); - Assert.AreEqual(0, plot.Model.Axes[1].AbsoluteMinimum); - Assert.AreEqual(60, plot.Model.Axes[0].IntervalLength); + Assert.That(plot.Model.Axes.Count, Is.EqualTo(2)); + Assert.That(plot.Model.Axes[1].Title, Is.EqualTo("Count")); + Assert.That(plot.Model.Axes[1].AbsoluteMinimum, Is.EqualTo(0)); + Assert.That(plot.Model.Axes[0].IntervalLength, Is.EqualTo(60)); var plot2 = new PlotModelStat("Histogram of Precursor Charges", psms, psmDict); var series2 = plot2.Model.Series.ToList()[0]; var items2 = (List)series2.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series2); - Assert.AreEqual(items2[0].Value, 9); - Assert.AreEqual(items2[1].Value, 1); + Assert.That(items2[0].Value, Is.EqualTo(9)); + Assert.That(items2[1].Value, Is.EqualTo(1)); var plot3 = new PlotModelStat("Histogram of Precursor PPM Errors (around 0 Da mass-difference notch only)", psms, psmDict); var series3 = plot3.Model.Series.ToList()[0]; var items3 = (List)series3.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series3); - Assert.AreEqual(items3[7].Value, 2); + Assert.That(items3[7].Value, Is.EqualTo(2)); var plot4 = new PlotModelStat("Histogram of Fragment Charges", psms, psmDict); var series4 = plot4.Model.Series.ToList()[0]; var items4 = (List)series4.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series4); - Assert.AreEqual(items4[0].Value, 101); + Assert.That(items4[0].Value, Is.EqualTo(101)); var plot5 = new PlotModelStat("Histogram of Precursor m/z", psms, psmDict); var series5 = plot5.Model.Series.ToList()[0]; var items5 = (List)series5.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series5); - Assert.AreEqual(items5.Count, 5); - Assert.AreEqual(items5[0].Value, 5); + Assert.That(items5.Count, Is.EqualTo(5)); + Assert.That(items5[0].Value, Is.EqualTo(5)); var plot6 = new PlotModelStat("Histogram of PTM Spectral Counts", psms, psmDict); var series6 = plot6.Model.Series.ToList()[0]; var items6 = (List)series6.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series6); - Assert.AreEqual(items6.Count, 1); - Assert.AreEqual(items6[0].Value, 2); + Assert.That(items6.Count, Is.EqualTo(1)); + Assert.That(items6[0].Value, Is.EqualTo(2)); var plot7 = new PlotModelStat("Precursor PPM Error vs. RT", psms, psmDict); var series7 = plot7.Model.Series.ToList()[0]; var points7 = (List)series7.GetType() .GetProperty("Points", BindingFlags.Public | BindingFlags.Instance).GetValue(series7); - Assert.AreEqual(points7.Count, 9); - Assert.AreEqual(points7[1].X, 42.07841); - Assert.AreEqual(points7[1].Y, -1.48); - Assert.AreEqual(points7[1].Tag, "LSRIDTPK"); + Assert.That(points7.Count, Is.EqualTo(9)); + Assert.That(points7[1].X, Is.EqualTo(42.07841)); + Assert.That(points7[1].Y, Is.EqualTo(-1.48)); + Assert.That(points7[1].Tag, Is.EqualTo("LSRIDTPK")); var plot8 = new PlotModelStat("Predicted RT vs. Observed RT", psms, psmDict); var series8 = plot8.Model.Series.ToList()[0]; var points8 = (List)series8.GetType() .GetProperty("Points", BindingFlags.Public | BindingFlags.Instance).GetValue(series8); - Assert.AreEqual(points8.Count, 10); - Assert.AreEqual(points8[7].X, 42.06171); - Assert.AreEqual(points8[7].Y, 19.00616880619646); - Assert.AreEqual(points8[7].Tag, "AFISYHDEAQK"); + Assert.That(points8.Count, Is.EqualTo(10)); + Assert.That(points8[7].X, Is.EqualTo(42.06171)); + Assert.That(points8[7].Y, Is.EqualTo(19.00616880619646)); + Assert.That(points8[7].Tag, Is.EqualTo("AFISYHDEAQK")); var plot9 = new PlotModelStat("Histogram of Fragment PPM Errors", psms, psmDict); var series9 = plot9.Model.Series.ToList()[0]; var items9 = (List)series9.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series9); - Assert.AreEqual(items9[11].Value, 18); + Assert.That(items9[11].Value, Is.EqualTo(18)); var plot10 = new PlotModelStat("Histogram of Hydrophobicity scores", psms, psmDict); var series10 = plot10.Model.Series.ToList()[0]; var items10 = (List)series10.GetType() .GetProperty("Items", BindingFlags.Public | BindingFlags.Instance).GetValue(series10); - Assert.AreEqual(items10.Count, 5); - Assert.AreEqual(items10[1].Value, 3); + Assert.That(items10.Count, Is.EqualTo(5)); + Assert.That(items10[1].Value, Is.EqualTo(3)); //test variant plotting string variantFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\VariantCrossTest.psmtsv"); @@ -1724,20 +1723,19 @@ public static void TestMetaDrawHistogramPlots() var variantSeries1 = variantPlot1.Model.Series.ToList()[0]; var variantPoints1 = (List)variantSeries1.GetType() .GetProperty("Points", BindingFlags.Public | BindingFlags.Instance).GetValue(variantSeries1); - Assert.AreEqual(variantPoints1.Count, 1); - Assert.AreEqual(variantPoints1[0].X, 97.8357); - Assert.AreEqual(variantPoints1[0].Y, 0.35); - Assert.AreEqual(variantPoints1[0].Tag, "MQVDQEEPHVEEQQQQTPAENKAESEEMETSQAGSK"); + Assert.That(variantPoints1.Count, Is.EqualTo(1)); + Assert.That(variantPoints1[0].X, Is.EqualTo(97.8357)); + Assert.That(variantPoints1[0].Y, Is.EqualTo(0.35)); + Assert.That(variantPoints1[0].Tag, Is.EqualTo("MQVDQEEPHVEEQQQQTPAENKAESEEMETSQAGSK")); var variantPlot2 = new PlotModelStat("Predicted RT vs. Observed RT", psmsWithVariants, psmVariantDict); var variantSeries2 = variantPlot2.Model.Series.ToList()[0]; var variantPoints2 = (List)variantSeries2.GetType() .GetProperty("Points", BindingFlags.Public | BindingFlags.Instance).GetValue(variantSeries2); - Assert.AreEqual(variantPoints2.Count, 1); - Assert.AreEqual(variantPoints2[0].X, 97.8357); - Assert.AreEqual(variantPoints2[0].Y, 16.363848874371111); - Assert.AreEqual(variantPoints2[0].Tag, "MQVDQEEPHVEEQQQQTPAENKAESEEMETSQAGSK"); - + Assert.That(variantPoints2.Count, Is.EqualTo(1)); + Assert.That(variantPoints2[0].X, Is.EqualTo(97.8357)); + Assert.That(variantPoints2[0].Y, Is.EqualTo(16.363848874371111)); + Assert.That(variantPoints2[0].Tag, Is.EqualTo("MQVDQEEPHVEEQQQQTPAENKAESEEMETSQAGSK")); Directory.Delete(folderPath, true); } diff --git a/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs b/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs index b2741ab39..3e959e34d 100644 --- a/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs +++ b/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs @@ -6,7 +6,7 @@ using System.Windows.Controls; using EngineLayer; using GuiFunctions; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using OxyPlot; using OxyPlot.Annotations; using Omics.Fragmentation; diff --git a/MetaMorpheus/Test/ModificationAnalysisTest.cs b/MetaMorpheus/Test/ModificationAnalysisTest.cs index a3d3d590c..407a0f90d 100644 --- a/MetaMorpheus/Test/ModificationAnalysisTest.cs +++ b/MetaMorpheus/Test/ModificationAnalysisTest.cs @@ -2,7 +2,7 @@ using EngineLayer.FdrAnalysis; using EngineLayer.ModificationAnalysis; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -93,18 +93,18 @@ public static void TestModificationAnalysis() ModificationAnalysisEngine modificationAnalysisEngine = new ModificationAnalysisEngine(newPsms, new CommonParameters(), fsp, new List()); var res = (ModificationAnalysisResults)modificationAnalysisEngine.Run(); - Assert.AreEqual(2, res.CountOfEachModSeenOnProteins.Count()); - Assert.AreEqual(2, res.CountOfEachModSeenOnProteins[mod1.IdWithMotif]); - Assert.AreEqual(1, res.CountOfEachModSeenOnProteins[mod2.IdWithMotif]); + Assert.That(res.CountOfEachModSeenOnProteins.Count(), Is.EqualTo(2)); + Assert.That(res.CountOfEachModSeenOnProteins[mod1.IdWithMotif], Is.EqualTo(2)); + Assert.That(res.CountOfEachModSeenOnProteins[mod2.IdWithMotif], Is.EqualTo(1)); - Assert.AreEqual(1, res.CountOfModsSeenAndLocalized.Count()); - Assert.AreEqual(2, res.CountOfModsSeenAndLocalized[mod1.IdWithMotif]); + Assert.That(res.CountOfModsSeenAndLocalized.Count(), Is.EqualTo(1)); + Assert.That(res.CountOfModsSeenAndLocalized[mod1.IdWithMotif], Is.EqualTo(2)); - Assert.AreEqual(0, res.CountOfAmbiguousButLocalizedModsSeen.Count()); + Assert.That(res.CountOfAmbiguousButLocalizedModsSeen.Count(), Is.EqualTo(0)); - Assert.AreEqual(0, res.CountOfUnlocalizedMods.Count()); + Assert.That(res.CountOfUnlocalizedMods.Count(), Is.EqualTo(0)); - Assert.AreEqual(0, res.CountOfUnlocalizedFormulas.Count()); + Assert.That(res.CountOfUnlocalizedFormulas.Count(), Is.EqualTo(0)); } [Test] @@ -152,12 +152,12 @@ public static void TestModificationAnalysisWithNonLocalizedPtms() ModificationAnalysisEngine modificationAnalysisEngine = new ModificationAnalysisEngine(new List { myPsm }, new CommonParameters(), fsp, new List()); var res = (ModificationAnalysisResults)modificationAnalysisEngine.Run(); - Assert.AreEqual(1, res.CountOfEachModSeenOnProteins.Count()); - Assert.AreEqual(2, res.CountOfEachModSeenOnProteins[mod1.IdWithMotif]); - Assert.AreEqual(0, res.CountOfModsSeenAndLocalized.Count()); - Assert.AreEqual(0, res.CountOfAmbiguousButLocalizedModsSeen.Count); - Assert.AreEqual(1, res.CountOfUnlocalizedMods[mod1.IdWithMotif]); // Saw it, but not sure where! - Assert.AreEqual(0, res.CountOfUnlocalizedFormulas.Count()); + Assert.That(res.CountOfEachModSeenOnProteins.Count(), Is.EqualTo(1)); + Assert.That(res.CountOfEachModSeenOnProteins[mod1.IdWithMotif], Is.EqualTo(2)); + Assert.That(res.CountOfModsSeenAndLocalized.Count(), Is.EqualTo(0)); + Assert.That(res.CountOfAmbiguousButLocalizedModsSeen.Count, Is.EqualTo(0)); + Assert.That(res.CountOfUnlocalizedMods[mod1.IdWithMotif], Is.EqualTo(1)); // Saw it, but not sure where! + Assert.That(res.CountOfUnlocalizedFormulas.Count(), Is.EqualTo(0)); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/MsDataFileTest.cs b/MetaMorpheus/Test/MsDataFileTest.cs index 48c72fb04..54c1dbde2 100644 --- a/MetaMorpheus/Test/MsDataFileTest.cs +++ b/MetaMorpheus/Test/MsDataFileTest.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; @@ -56,14 +56,14 @@ public static void TestCompressionDecompression() foreach (FileInfo file in testDirectory.GetFiles()) { - Assert.AreEqual(".gz", file.Extension); + Assert.That(file.Extension, Is.EqualTo(".gz")); } MyFileManager.DecompressDirectory(testDirectory); foreach (FileInfo file in testDirectory.GetFiles()) { - Assert.AreNotEqual(".gz", file.Extension); + Assert.That(file.Extension, Is.Not.EqualTo(".gz")); } } @@ -78,7 +78,7 @@ public static void TestMs2ScanWithSpecificMass() var closestExperimentalMassB = scanB.GetClosestExperimentalIsotopicEnvelope(10); - Assert.IsNull(closestExperimentalMassB); + Assert.That(closestExperimentalMassB, Is.Null); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs index d44d3226c..b9220d789 100644 --- a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs +++ b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs @@ -1,7 +1,7 @@ using EngineLayer; using EngineLayer.FdrAnalysis; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -82,13 +82,13 @@ public static void MultiProteaseTest() var results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(2, proteinGroups.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(2)); var proteinGroup1 = proteinGroups.Where(h => h.ProteinGroupName == "1").First(); - Assert.AreEqual(1, proteinGroup1.UniquePeptides.Count); - Assert.AreEqual(2, proteinGroup1.AllPeptides.Count); + Assert.That(proteinGroup1.UniquePeptides.Count, Is.EqualTo(1)); + Assert.That(proteinGroup1.AllPeptides.Count, Is.EqualTo(2)); var proteinGroup2 = proteinGroups.Where(h => h.ProteinGroupName == "2|3").First(); - Assert.AreEqual(0, proteinGroup2.UniquePeptides.Count); - Assert.AreEqual(4, proteinGroup2.AllPeptides.Count); + Assert.That(proteinGroup2.UniquePeptides.Count, Is.EqualTo(0)); + Assert.That(proteinGroup2.AllPeptides.Count, Is.EqualTo(4)); } /// @@ -171,8 +171,8 @@ public static void MultiProteaseSamePeptideSameProteinsDifferentProteases() List proteinGroups = results.SortedAndScoredProteinGroups; // should result in 1 protein group (protein2) - Assert.AreEqual(1, proteinGroups.Count); - Assert.AreEqual("2", proteinGroups.ElementAt(0).ProteinGroupName); + Assert.That(proteinGroups.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("2")); } /// @@ -248,11 +248,11 @@ public static void MultiProteaseParsimony_SharedSequenceCanBeUniquePeptide() var results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(2, proteinGroups.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(2)); var proteinGroup1 = proteinGroups.Where(p => p.ProteinGroupName == "1").First(); - Assert.AreEqual(2, proteinGroup1.AllPeptides.Count); - Assert.AreEqual(1, proteinGroup1.UniquePeptides.Count); + Assert.That(proteinGroup1.AllPeptides.Count, Is.EqualTo(2)); + Assert.That(proteinGroup1.UniquePeptides.Count, Is.EqualTo(1)); var pg1pep1 = proteinGroup1.AllPeptides.Where(p => p.BaseSequence == "XYZ").First(); Assert.That(pg1pep1.DigestionParams.DigestionAgent.Name == "proteaseA"); var pg1pep2 = proteinGroup1.AllPeptides.Where(p => p.BaseSequence == "ABC").First(); @@ -260,8 +260,8 @@ public static void MultiProteaseParsimony_SharedSequenceCanBeUniquePeptide() Assert.That(proteinGroup1.UniquePeptides.First().BaseSequence.Equals("ABC")); var proteinGroup2 = proteinGroups.Where(p => p.ProteinGroupName == "2").First(); - Assert.AreEqual(3, proteinGroup2.AllPeptides.Count); - Assert.AreEqual(2, proteinGroup2.UniquePeptides.Count); + Assert.That(proteinGroup2.AllPeptides.Count, Is.EqualTo(3)); + Assert.That(proteinGroup2.UniquePeptides.Count, Is.EqualTo(2)); var pg2pep1 = proteinGroup2.AllPeptides.Where(p => p.BaseSequence == "XYZ").First(); Assert.That(pg2pep1.DigestionParams.DigestionAgent.Name == "proteaseA"); var pg2pep2 = proteinGroup2.AllPeptides.Where(p => p.BaseSequence == "ABC").First(); @@ -340,7 +340,7 @@ public static void MultiProteaseParsimony_IndistringuishableProteinsNowDistingui List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(2, proteinGroups.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(2)); // check first protein group ProteinGroup pg1 = proteinGroups.Where(v => v.ProteinGroupName == "1").First(); @@ -432,9 +432,9 @@ public static void MultiProteaseParsimony_SameAminoAcidsResultInTwoUniquePeptide List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(1, proteinGroups.Count); - Assert.AreEqual("1", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(2, proteinGroups.ElementAt(0).UniquePeptides.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("1")); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.Count, Is.EqualTo(2)); } /// @@ -496,24 +496,24 @@ public static void MultiProteaseParsimony_TestingPeptideBaseSequenceCanBeBothSha List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(2, proteinGroups.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(2)); if (proteinGroups.ElementAt(0).ProteinGroupName == "1") { - Assert.AreEqual("1", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(1, proteinGroups.ElementAt(0).UniquePeptides.Count); - Assert.AreEqual("ABC", proteinGroups.ElementAt(0).UniquePeptides.ElementAt(0).FullSequence); - Assert.AreEqual("2|3", proteinGroups.ElementAt(1).ProteinGroupName); - Assert.AreEqual(0, proteinGroups.ElementAt(1).UniquePeptides.Count); - Assert.AreEqual(2, proteinGroups.ElementAt(1).AllPeptides.Count); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("1")); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.ElementAt(0).FullSequence, Is.EqualTo("ABC")); + Assert.That(proteinGroups.ElementAt(1).ProteinGroupName, Is.EqualTo("2|3")); + Assert.That(proteinGroups.ElementAt(1).UniquePeptides.Count, Is.EqualTo(0)); + Assert.That(proteinGroups.ElementAt(1).AllPeptides.Count, Is.EqualTo(2)); } else { - Assert.AreEqual("1", proteinGroups.ElementAt(1).ProteinGroupName); - Assert.AreEqual(1, proteinGroups.ElementAt(1).UniquePeptides.Count); - Assert.AreEqual("ABC", proteinGroups.ElementAt(1).UniquePeptides.ElementAt(0).FullSequence); - Assert.AreEqual("2|3", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(0, proteinGroups.ElementAt(0).UniquePeptides.Count); - Assert.AreEqual(2, proteinGroups.ElementAt(0).AllPeptides.Count); + Assert.That(proteinGroups.ElementAt(1).ProteinGroupName, Is.EqualTo("1")); + Assert.That(proteinGroups.ElementAt(1).UniquePeptides.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(1).UniquePeptides.ElementAt(0).FullSequence, Is.EqualTo("ABC")); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("2|3")); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.Count, Is.EqualTo(0)); + Assert.That(proteinGroups.ElementAt(0).AllPeptides.Count, Is.EqualTo(2)); } } @@ -588,10 +588,10 @@ public static void MultiProteaseParsimony_BaseSequenceCanBeSharedOrUniqueButOnly List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(1, proteinGroups.Count); - Assert.AreEqual("1", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(1, proteinGroups.ElementAt(0).UniquePeptides.Count); - Assert.AreEqual("ABC", proteinGroups.ElementAt(0).UniquePeptides.ElementAt(0).FullSequence); + Assert.That(proteinGroups.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("1")); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).UniquePeptides.ElementAt(0).FullSequence, Is.EqualTo("ABC")); } /// @@ -716,7 +716,7 @@ public static void TestPSMFdrFiltering_Simulated() } } - Assert.AreEqual(3, fdrFilteredPsms.Count); + Assert.That(fdrFilteredPsms.Count, Is.EqualTo(3)); var test1 = fdrFilteredPsms.Contains(psms.ElementAt(2)); var test2 = fdrFilteredPsms.Contains(psms.ElementAt(4)); @@ -724,12 +724,12 @@ public static void TestPSMFdrFiltering_Simulated() var test4 = fdrFilteredPsms.Contains(psms.ElementAt(0)); var test5 = fdrFilteredPsms.Contains(psms.ElementAt(1)); var test6 = fdrFilteredPsms.Contains(psms.ElementAt(3)); - Assert.AreEqual(true, test1); - Assert.AreEqual(true, test2); - Assert.AreEqual(true, test3); - Assert.AreEqual(false, test4); - Assert.AreEqual(false, test5); - Assert.AreEqual(false, test6); + Assert.That(test1, Is.EqualTo(true)); + Assert.That(test2, Is.EqualTo(true)); + Assert.That(test3, Is.EqualTo(true)); + Assert.That(test4, Is.EqualTo(false)); + Assert.That(test5, Is.EqualTo(false)); + Assert.That(test6, Is.EqualTo(false)); } /// @@ -762,10 +762,10 @@ public static void TestPSMFdrFiltering_RealFile() var psms = Path.Combine(thisTaskOutputFolder, "AllPSMs.psmtsv"); - Assert.AreEqual(11, File.ReadLines(psms).Count()); + Assert.That(File.ReadLines(psms).Count(), Is.EqualTo(11)); var protGroups = Path.Combine(thisTaskOutputFolder, "AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(7, File.ReadLines(protGroups).Count()); + Assert.That(File.ReadLines(protGroups).Count(), Is.EqualTo(7)); Directory.Delete(outputFolder, true); } @@ -841,13 +841,13 @@ public static void MultiProteaseParsimony_TestingSameBaseSequenceSharedandUnique var results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(2, proteinGroups.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(2)); var proteinGroup1 = proteinGroups.Where(h => h.ProteinGroupName == "1").First(); - Assert.AreEqual(1, proteinGroup1.UniquePeptides.Count); - Assert.AreEqual(1, proteinGroup1.AllPeptides.Count); + Assert.That(proteinGroup1.UniquePeptides.Count, Is.EqualTo(1)); + Assert.That(proteinGroup1.AllPeptides.Count, Is.EqualTo(1)); var proteinGroup2 = proteinGroups.Where(h => h.ProteinGroupName == "4").First(); - Assert.AreEqual(0, proteinGroup2.UniquePeptides.Count); - Assert.AreEqual(2, proteinGroup2.AllPeptides.Count); + Assert.That(proteinGroup2.UniquePeptides.Count, Is.EqualTo(0)); + Assert.That(proteinGroup2.AllPeptides.Count, Is.EqualTo(2)); } /// @@ -914,9 +914,9 @@ public static void MultiProteaseParsimony_TestingActuallyIndistinguisableProtein var results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(1, proteinGroups.Count); - Assert.AreEqual("1|2", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(8, proteinGroups.ElementAt(0).AllPeptides.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("1|2")); + Assert.That(proteinGroups.ElementAt(0).AllPeptides.Count, Is.EqualTo(8)); } /// @@ -984,9 +984,9 @@ public static void MultiProteaseParsimony_TestingGreedyAlgorithm() var results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); List proteinGroups = results.SortedAndScoredProteinGroups; - Assert.AreEqual(1, proteinGroups.Count); - Assert.AreEqual("2", proteinGroups.ElementAt(0).ProteinGroupName); - Assert.AreEqual(2, proteinGroups.ElementAt(0).AllPeptides.Count); + Assert.That(proteinGroups.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.ElementAt(0).ProteinGroupName, Is.EqualTo("2")); + Assert.That(proteinGroups.ElementAt(0).AllPeptides.Count, Is.EqualTo(2)); } /// @@ -1047,16 +1047,16 @@ public static void MultiProteaseParsimony_TestingProteaseSpecificFDRCalculations // 8 d 12 tryp 3 2 0.666666667 // 9 t 11 tryp 4 2 0.666666667 - Assert.AreEqual(0.00, Math.Round(psms[0].FdrInfo.QValue, 2)); - Assert.AreEqual(0.00, Math.Round(psms[1].FdrInfo.QValue, 2)); - Assert.AreEqual(0.00, Math.Round(psms[2].FdrInfo.QValue, 2)); - Assert.AreEqual(0.00, Math.Round(psms[3].FdrInfo.QValue, 2)); - Assert.AreEqual(0.50, Math.Round(psms[4].FdrInfo.QValue, 2)); - Assert.AreEqual(0.50, Math.Round(psms[5].FdrInfo.QValue, 2)); - Assert.AreEqual(0.00, Math.Round(psms[6].FdrInfo.QValue, 2)); - Assert.AreEqual(0.33, Math.Round(psms[7].FdrInfo.QValue, 2)); - Assert.AreEqual(0.67, Math.Round(psms[8].FdrInfo.QValue, 2)); - Assert.AreEqual(0.67, Math.Round(psms[9].FdrInfo.QValue, 2)); + Assert.That(Math.Round(psms[0].FdrInfo.QValue, 2), Is.EqualTo(0.00)); + Assert.That(Math.Round(psms[1].FdrInfo.QValue, 2), Is.EqualTo(0.00)); + Assert.That(Math.Round(psms[2].FdrInfo.QValue, 2), Is.EqualTo(0.00)); + Assert.That(Math.Round(psms[3].FdrInfo.QValue, 2), Is.EqualTo(0.00)); + Assert.That(Math.Round(psms[4].FdrInfo.QValue, 2), Is.EqualTo(0.50)); + Assert.That(Math.Round(psms[5].FdrInfo.QValue, 2), Is.EqualTo(0.50)); + Assert.That(Math.Round(psms[6].FdrInfo.QValue, 2), Is.EqualTo(0.00)); + Assert.That(Math.Round(psms[7].FdrInfo.QValue, 2), Is.EqualTo(0.33)); + Assert.That(Math.Round(psms[8].FdrInfo.QValue, 2), Is.EqualTo(0.67)); + Assert.That(Math.Round(psms[9].FdrInfo.QValue, 2), Is.EqualTo(0.67)); } } diff --git a/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs b/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs index 338c6b34e..1139515a7 100644 --- a/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs +++ b/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs @@ -2,21 +2,18 @@ using EngineLayer; using IO.MzML; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using MzLibUtil; using ClassExtensions = Chemistry.ClassExtensions; using Nett; using TaskLayer; -using UsefulProteomicsDatabases; -using System.Threading.Tasks; using Omics.Modifications; namespace Test @@ -46,7 +43,7 @@ internal static class Multiplex_Labeling_TMT_iTRAQ public static void TestChemicalFormulaWithIsotopesTMT(string formula, double mass) { ChemicalFormula cf = ChemicalFormula.ParseFormula(formula); - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass)); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass), Is.EqualTo(mass)); } [Test] @@ -67,8 +64,8 @@ public static void TestPeptideLabelledWithTMT18(string peptide, double totalMass List productMasses = f.Select(m => m.NeutralMass.ToMz(1)).ToList(); productMasses.Distinct(); productMasses.Sort(); - - Assert.AreEqual(totalMass, ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4)); + + Assert.That(ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4), Is.EqualTo(totalMass)); } [Test] @@ -92,7 +89,7 @@ public static void TestPeptideLabelledWithTMT(string peptide, double totalMass) productMasses.Distinct(); productMasses.Sort(); - Assert.AreEqual(totalMass, ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4)); + Assert.That(ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4), Is.EqualTo(totalMass)); } [Test] @@ -106,27 +103,21 @@ public static void TestMultiplexIonIntensityDetection() mz: new double[] { 1, 2, 3, 4, 5 }, intensities: new double[] { 2, 4, 6, 8, 10 }, shouldCopy: false); - Assert.AreEqual( - PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), - fakeSpectrum.YArray); + Assert.That(PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), Is.EqualTo(fakeSpectrum.YArray)); // Every other diagnostic ion is present in spectrum fakeSpectrum = new MzSpectrum( mz: new double[] { 1, 2.5, 3, 4.5, 5 }, intensities: new double[] { 2, 4, 6, 8, 10 }, shouldCopy: false); - Assert.AreEqual( - PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), - new double[] { 2, 0, 6, 0, 10 }); + Assert.That(PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), Is.EqualTo(new double[] { 2, 0, 6, 0, 10 })); // Last two diagnostic ions (highest m/z) are not observed fakeSpectrum = new MzSpectrum( mz: new double[] { 1, 2, 3 }, intensities: new double[] { 2, 4, 6 }, shouldCopy: false); - Assert.AreEqual( - PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), - new double[] { 2, 4, 6, 0, 0 }); + Assert.That(PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), Is.EqualTo(new double[] { 2, 4, 6, 0, 0 })); // This test uses values from a 12-plex DiLeu experiment ionMzs = new double[] { 117.13147, 117.13731, 117.14363, 118.14067, 118.14699, 118.15283 }; @@ -159,9 +150,7 @@ public static void TestMultiplexIonIntensityDetection() 0 }, shouldCopy: false); - Assert.AreEqual( - PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), - new double[] { 1, 2, 3, 4, 5, 6 }); + Assert.That(PostSearchAnalysisTask.GetMultiplexIonIntensities(fakeSpectrum, ionMzs, tol), Is.EqualTo(new double[] { 1, 2, 3, 4, 5, 6 })); } [Test] @@ -197,7 +186,7 @@ public static void TestAbilityToIDTMTDiagnosticIons() } } // will pass if all diagnostic ions are found in scans - Assert.AreEqual(0, diagnosticIons.Count()); + Assert.That(diagnosticIons.Count(), Is.EqualTo(0)); } [Test] @@ -310,7 +299,7 @@ public static void TestPeptideLabelledWith_iTRAQ_4plex(string peptide, double to productMasses.Distinct(); productMasses.Sort(); - Assert.AreEqual(totalMass, ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4)); + Assert.That(ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4), Is.EqualTo(totalMass)); } [Test] @@ -332,7 +321,7 @@ public static void TestPeptideLabelledWith_DiLeu_4plex(string peptide, double to productMasses.Distinct(); productMasses.Sort(); - Assert.AreEqual(totalMass, ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4)); + Assert.That(ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4), Is.EqualTo(totalMass)); } [Test] @@ -354,7 +343,7 @@ public static void TestPeptideLabelledWith_iTRAQ_8plex(string peptide, double to productMasses.Distinct(); productMasses.Sort(); - Assert.AreEqual(totalMass, ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4)); + Assert.That(ClassExtensions.RoundedDouble(p.MonoisotopicMass.ToMz(1), 4), Is.EqualTo(totalMass)); } [Test] @@ -372,11 +361,11 @@ public static void TestChemicalFormulaWithIsotopes_iTRAQ(string formula, double ChemicalFormula cf = ChemicalFormula.ParseFormula(formula); if (mz) { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1))); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1)), Is.EqualTo(mass)); } else { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass)); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass), Is.EqualTo(mass)); } } @@ -394,11 +383,11 @@ public static void TestChemicalFormulaWithIsotopes_DiLeu4plex(string formula, do ChemicalFormula cf = ChemicalFormula.ParseFormula(formula); if (mz) { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1))); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1)), Is.EqualTo(mass)); } else { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass)); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass), Is.EqualTo(mass)); } } [Test] @@ -433,11 +422,11 @@ public static void TestChemicalFormulaWithIsotopes_DiLeu12plex(string formula, d ChemicalFormula cf = ChemicalFormula.ParseFormula(formula); if (mz) { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1), 5)); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass.ToMz(1), 5), Is.EqualTo(mass)); } else { - Assert.AreEqual(mass, ClassExtensions.RoundedDouble(cf.MonoisotopicMass)); + Assert.That(ClassExtensions.RoundedDouble(cf.MonoisotopicMass), Is.EqualTo(mass)); } } /// @@ -463,20 +452,19 @@ public static void TestDoNotCountDiagnosticIonsInScore_HCD() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); PsmFromTsv psm = parsedPsms.First(); - - Assert.AreEqual(38, psm.MatchedIons.Count); //matched ions include b, y and D (diagnostic ions in TMT search) - Assert.AreEqual(8,psm.MatchedIons.Where(i=>i.NeutralTheoreticalProduct.ProductType == ProductType.D).Count()); //There are 8 discovered diagnostic ions - Assert.AreEqual(30, psm.MatchedIons.Where(i => i.NeutralTheoreticalProduct.ProductType != ProductType.D).Count()); //There are 30 b and y ions (excluding diagnostic ions) - Assert.AreEqual(30.273, psm.Score); //score should only use non-diagnostic ions (start with 30 in this case). - Assert.AreEqual((int)psm.Score, psm.MatchedIons.Where(i => i.NeutralTheoreticalProduct.ProductType != ProductType.D).Count()); //integer part of the MM score should match the count of non-diagnostic ions + Assert.That(psm.MatchedIons.Count, Is.EqualTo(38)); //matched ions include b, y and D (diagnostic ions in TMT search) + Assert.That(psm.MatchedIons.Where(i => i.NeutralTheoreticalProduct.ProductType == ProductType.D).Count(), Is.EqualTo(8)); //There are 8 discovered diagnostic ions + Assert.That(psm.MatchedIons.Where(i => i.NeutralTheoreticalProduct.ProductType != ProductType.D).Count(), Is.EqualTo(30)); //There are 30 b and y ions (excluding diagnostic ions) + Assert.That(psm.Score, Is.EqualTo(30.273)); //score should only use non-diagnostic ions (start with 30 in this case). + Assert.That((int)psm.Score, Is.EqualTo(psm.MatchedIons.Where(i => i.NeutralTheoreticalProduct.ProductType != ProductType.D).Count())); //integer part of the MM score should match the count of non-diagnostic ions - Assert.AreEqual("VFNTTPDDLDLHVIYDVSHNIAK", psm.BaseSeq); - Assert.AreEqual("T", psm.DecoyContamTarget); - Assert.AreEqual("[Multiplex Label:TMT11 on X]VFNTTPDDLDLHVIYDVSHNIAK[Multiplex Label:TMT11 on K]", psm.FullSequence); - Assert.AreEqual("Mus musculus", psm.OrganismName); - Assert.AreEqual("full", psm.PeptideDescription); - Assert.AreEqual("Q99LF4", psm.ProteinAccession); + Assert.That(psm.BaseSeq, Is.EqualTo("VFNTTPDDLDLHVIYDVSHNIAK")); + Assert.That(psm.DecoyContamTarget, Is.EqualTo("T")); + Assert.That(psm.FullSequence, Is.EqualTo("[Multiplex Label:TMT11 on X]VFNTTPDDLDLHVIYDVSHNIAK[Multiplex Label:TMT11 on K]")); + Assert.That(psm.OrganismName, Is.EqualTo("Mus musculus")); + Assert.That(psm.PeptideDescription, Is.EqualTo("full")); + Assert.That(psm.ProteinAccession, Is.EqualTo("Q99LF4")); Directory.Delete(outputFolder,true); } @@ -502,16 +490,16 @@ public static void TestDoNotCountDiagnosticIonsInScore_LowCID() } //ensure there is only one diagnostic ion - Assert.AreEqual(1, productsWithLocalizedMassDiff.Where(p => p.ProductType == ProductType.D).Count()); + Assert.That(productsWithLocalizedMassDiff.Where(p => p.ProductType == ProductType.D).Count(), Is.EqualTo(1)); //Check total ion count - Assert.AreEqual(14, productsWithLocalizedMassDiff.Count); + Assert.That(productsWithLocalizedMassDiff.Count, Is.EqualTo(14)); MsDataScan scan = testDataFile.GetOneBasedScan(2); - scan.MassSpectrum.XCorrPrePreprocessing(1.0,500.0,300.0); + scan.MassSpectrum.XCorrPrePreprocessing(1.0, 500.0, 300.0); //check that the scan is noted as xcorr processed - Assert.IsTrue(scan.MassSpectrum.XcorrProcessed); + Assert.That(scan.MassSpectrum.XcorrProcessed); Tolerance tolerance = new AbsoluteTolerance(1.0); CommonParameters commonParams = new(productMassTolerance: tolerance); @@ -521,7 +509,7 @@ public static void TestDoNotCountDiagnosticIonsInScore_LowCID() // score when the mass-diff is on this residue double score = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedIons); - Assert.AreEqual(0, (int)score); + Assert.That((int)score, Is.EqualTo(0)); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/MyEngineTest.cs b/MetaMorpheus/Test/MyEngineTest.cs index b8c31d273..3c2030942 100644 --- a/MetaMorpheus/Test/MyEngineTest.cs +++ b/MetaMorpheus/Test/MyEngineTest.cs @@ -1,5 +1,5 @@ using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System.Collections.Generic; using System.Text; diff --git a/MetaMorpheus/Test/MyPeptideTest.cs b/MetaMorpheus/Test/MyPeptideTest.cs index 73250b0e3..d1db8d674 100644 --- a/MetaMorpheus/Test/MyPeptideTest.cs +++ b/MetaMorpheus/Test/MyPeptideTest.cs @@ -1,11 +1,11 @@ - using Chemistry; +using Chemistry; using EngineLayer; using EngineLayer.ClassicSearch; using EngineLayer.Indexing; using EngineLayer.ModernSearch; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -13,8 +13,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; - using Omics.Modifications; - using UsefulProteomicsDatabases; +using Omics.Modifications; +using UsefulProteomicsDatabases; namespace Test { @@ -54,7 +54,7 @@ public static void TestIdenticalPeaks() new List { prot }, new OpenSearchMode(), CommonParameters, null, null, new List(), writeSpectralLibrary); cse.Run(); - Assert.AreEqual(3, globalPsms[0].MatchedFragmentIons.Count); + Assert.That(globalPsms[0].MatchedFragmentIons.Count, Is.EqualTo(3)); } [Test] @@ -90,8 +90,8 @@ public static void TestLastPeaks() new List { prot }, new OpenSearchMode(), CommonParameters, null, null, new List(), writeSpectralLibrary); cse.Run(); - Assert.Less(globalPsms[0].Score, 2); - Assert.Greater(globalPsms[0].Score, 1); + Assert.That(globalPsms[0].Score < 2); + Assert.That(globalPsms[0].Score > 1); } [Test] @@ -127,8 +127,8 @@ public static void TestVeryCloseExperimentalsClassic() new List { prot }, new OpenSearchMode(), CommonParameters, null, null, new List(), writeSpetralLibrary); cse.Run(); - Assert.Less(globalPsms[0].Score, 2); - Assert.Greater(globalPsms[0].Score, 1); + Assert.That(globalPsms[0].Score < 2); + Assert.That(globalPsms[0].Score > 1); } [Test] @@ -159,8 +159,8 @@ public static void TestVeryCloseExperimentalsModern() var cse = new ModernSearchEngine(globalPsms, arrayOfSortedMS2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, new OpenSearchMode(), 0, new List()); cse.Run(); - Assert.Less(globalPsms[0].Score, 2); - Assert.Greater(globalPsms[0].Score, 1); + Assert.That(globalPsms[0].Score < 2); + Assert.That(globalPsms[0].Score > 1); } [Test] @@ -188,7 +188,7 @@ public static void TestAllNaN() new List { prot }, new OpenSearchMode(), CommonParameters, null, null, new List(), writeSpetralLibrary); cse.Run(); - Assert.IsNull(globalPsms[0]); + Assert.That(globalPsms[0], Is.Null); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/MyTaskTest.cs b/MetaMorpheus/Test/MyTaskTest.cs index 109af1c4e..61ef75101 100644 --- a/MetaMorpheus/Test/MyTaskTest.cs +++ b/MetaMorpheus/Test/MyTaskTest.cs @@ -3,7 +3,6 @@ using MzLibUtil; using Nett; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using Proteomics; using Proteomics.ProteolyticDigestion; using System; @@ -78,7 +77,7 @@ public static void TestEverythingRunner() var digestedList = ParentProtein.Digest(task1.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); - Assert.AreEqual(3, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(3)); PeptideWithSetModifications pepWithSetMods1 = digestedList[0]; @@ -171,7 +170,7 @@ public static void TestMultipleFilesRunner() var digestedList = ParentProtein.Digest(task1.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); - Assert.AreEqual(3, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(3)); PeptideWithSetModifications pepWithSetMods1 = digestedList[0]; @@ -182,7 +181,7 @@ public static void TestMultipleFilesRunner() dictHere.Add(3, new List { new Modification(_originalId: "21", _modificationType: "myModType", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }); Protein ParentProteinToNotInclude = new("MPEPTIDEK", "accession2", "organism", new List>(), dictHere); digestedList = ParentProteinToNotInclude.Digest(task1.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); - Assert.AreEqual(4, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(4)); MsDataFile myMsDataFile1 = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); @@ -258,7 +257,7 @@ public static void MakeSureFdrDoesntSkip() var newIntensityArray = ms1IntensityList.ToArray(); var ms1MzList = myMsDataFile.GetOneBasedScan(1).MassSpectrum.XArray.ToList(); - Assert.AreEqual(6,ms1MzList.Count); + Assert.That(ms1MzList.Count, Is.EqualTo(6)); List expectedMzList = new List() { 69.70, 70.03, 70.37, 104.04, 104.55, 105.05 }; CollectionAssert.AreEquivalent(expectedMzList, ms1MzList.Select(m=>Math.Round(m,2)).ToList()); @@ -285,7 +284,7 @@ public static void MakeSureFdrDoesntSkip() //There is one PSM with close peptide mass (0 ppm difference) and one PSM with large mass difference (>1000 ppm difference) //Since this is an open search, both PSMs should be reported because they share the exact same MS2 scan - Assert.IsTrue(theStringResult.Contains("All target PSMs with q-value <= 0.01: 1")); + Assert.That(theStringResult.Contains("All target PSMs with q-value <= 0.01: 1")); Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); @@ -348,7 +347,7 @@ public static void MakeSureGptmdTaskMatchesExactMatches() // RUN! var theStringResult = task1.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); - Assert.IsTrue(theStringResult.Contains("Modifications added: 1")); + Assert.That(theStringResult.Contains("Modifications added: 1")); Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); @@ -416,7 +415,7 @@ public static void TestPeptideCount() //now write MZML file var protein = ProteinDbLoader.LoadProteinXML(xmlName, true, DecoyType.Reverse, new List(), false, new List(), out Dictionary ok); var setList1 = protein[0].Digest(testPeptides.CommonParameters.DigestionParams, new List { }, variableModifications).ToList(); - Assert.AreEqual(4, setList1.Count); + Assert.That(setList1.Count, Is.EqualTo(4)); //Finally Write MZML file MsDataFile myMsDataFile = new TestDataFile(new List { setList1[0], setList1[1], setList1[2], setList1[3], setList1[0], setList1[1] }); @@ -440,7 +439,7 @@ public static void TestPeptideCount() } } } - Assert.IsTrue(foundD); + Assert.That(foundD); Directory.Delete(outputFolder, true); File.Delete(mzmlName); File.Delete(xmlName); @@ -622,8 +621,7 @@ public static void MissingDbInSpectralLibrarySearch() List warnings = engine.Warnings; - - Assert.AreEqual("Cannot proceed. No protein database files selected.", warnings[0]); + Assert.That(warnings[0], Is.EqualTo("Cannot proceed. No protein database files selected.")); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/OutputTest.cs b/MetaMorpheus/Test/OutputTest.cs index 73981bdd3..7f48464ea 100644 --- a/MetaMorpheus/Test/OutputTest.cs +++ b/MetaMorpheus/Test/OutputTest.cs @@ -1,10 +1,5 @@ -using EngineLayer; -using IO.MzML; -using MassSpectrometry; -using MzLibUtil; -using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; -using Proteomics; +using Nett; +using NUnit.Framework; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -14,7 +9,6 @@ using NUnit.Framework.Legacy; using Readers; using TaskLayer; -using UsefulProteomicsDatabases; namespace Test { @@ -65,25 +59,25 @@ public static void TestIndividualFileOutput() }; HashSet writtenFiles = new HashSet(Directory.GetFiles(Path.Combine(outputFolder, "allowFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7))); //check they're the same - Assert.IsTrue(expectedFiles.Except(writtenFiles).Count() == 0); + Assert.That(expectedFiles.Except(writtenFiles).Count() == 0); //check the second one is compressed and contains all the information writtenFiles = new HashSet(Directory.GetFiles(Path.Combine(outputFolder, "compressFiles")).Select(v => Path.GetFileName(v))); //check the zip exists - Assert.IsTrue(writtenFiles.Contains("Individual File Results.zip")); + Assert.That(writtenFiles.Contains("Individual File Results.zip")); //check the original folder does not exist string[] subfolders = Directory.GetDirectories(Path.Combine(outputFolder, "compressFiles")); - Assert.IsTrue(subfolders.Length == 0); + Assert.That(subfolders.Length == 0); ZipFile.ExtractToDirectory(Path.Combine(outputFolder, "compressFiles", "Individual File Results.zip"), Path.Combine(outputFolder, "compressFiles", "Individual File Results")); //read the extracted files writtenFiles = new HashSet(Directory.GetFiles(Path.Combine(outputFolder, "compressFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7))); //check they're the same - Assert.IsTrue(expectedFiles.Except(writtenFiles).Count() == 0); + Assert.That(expectedFiles.Except(writtenFiles).Count() == 0); //check the last one to make sure nothing was written except for the mzID files writtenFiles = new HashSet(Directory.GetFiles(Path.Combine(outputFolder, "noFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7))); - Assert.IsTrue(writtenFiles.Count == 1); - Assert.IsTrue(writtenFiles.Contains(".mzID")); + Assert.That(writtenFiles.Count == 1); + Assert.That(writtenFiles.Contains(".mzID")); Directory.Delete(outputFolder, true); @@ -94,7 +88,7 @@ public static void TestIndividualFileOutput() new EverythingRunnerEngine(new List<(string, MetaMorpheusTask)> { ("weird", weirdTask) }, new List { pathOne }, new List { db }, outputFolder).Run(); //check that a zip was not created writtenFiles = new HashSet(Directory.GetFiles(Path.Combine(outputFolder, "weird"))); - Assert.IsFalse(writtenFiles.Contains("Individual File Results.zip")); + Assert.That(!writtenFiles.Contains("Individual File Results.zip")); Directory.Delete(subFolder, true); } diff --git a/MetaMorpheus/Test/ParameterTest.cs b/MetaMorpheus/Test/ParameterTest.cs index 20d477a94..11c4fb810 100644 --- a/MetaMorpheus/Test/ParameterTest.cs +++ b/MetaMorpheus/Test/ParameterTest.cs @@ -2,10 +2,9 @@ using MassSpectrometry; using MzLibUtil; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; -using System; using System.Collections.Generic; using System.IO; using NUnit.Framework.Legacy; @@ -24,15 +23,15 @@ public static void TestFileSpecificParametersClone() var fileSpecificToml = Toml.ReadFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "testFileSpecfic.toml"), MetaMorpheusTask.tomlConfig); FileSpecificParameters fsp = new FileSpecificParameters(fileSpecificToml); FileSpecificParameters fspClone = fsp.Clone(); - Assert.AreEqual(fsp.DissociationType, fspClone.DissociationType); - Assert.AreEqual(fsp.MaxMissedCleavages, fspClone.MaxMissedCleavages); - Assert.AreEqual(fsp.MaxModsForPeptide, fspClone.MaxModsForPeptide); - Assert.AreEqual(fsp.MaxPeptideLength, fspClone.MaxPeptideLength); - Assert.AreEqual(fsp.MinPeptideLength, fspClone.MinPeptideLength); - Assert.AreEqual(fsp.PrecursorMassTolerance, fspClone.PrecursorMassTolerance); - Assert.AreEqual(fsp.ProductMassTolerance, fspClone.ProductMassTolerance); - Assert.AreEqual(fsp.Protease, fspClone.Protease); - Assert.AreEqual(fsp.SeparationType, fspClone.SeparationType); + Assert.That(fsp.DissociationType, Is.EqualTo(fspClone.DissociationType)); + Assert.That(fsp.MaxMissedCleavages, Is.EqualTo(fspClone.MaxMissedCleavages)); + Assert.That(fsp.MaxModsForPeptide, Is.EqualTo(fspClone.MaxModsForPeptide)); + Assert.That(fsp.MaxPeptideLength, Is.EqualTo(fspClone.MaxPeptideLength)); + Assert.That(fsp.MinPeptideLength, Is.EqualTo(fspClone.MinPeptideLength)); + Assert.That(fsp.PrecursorMassTolerance, Is.EqualTo(fspClone.PrecursorMassTolerance)); + Assert.That(fsp.ProductMassTolerance, Is.EqualTo(fspClone.ProductMassTolerance)); + Assert.That(fsp.Protease, Is.EqualTo(fspClone.Protease)); + Assert.That(fsp.SeparationType, Is.EqualTo(fspClone.SeparationType)); CollectionAssert.AreEqual(fsp.CustomIons, fspClone.CustomIons); } @@ -79,53 +78,53 @@ public static void TestFileSpecifcParameterOverwrite() //check that the defaults are not the same as the not defaults. //IF ONE OF THESE FAILS, PLEASE UPDATE THE "notDefaultParameters" - Assert.AreNotEqual(defaultParameters.DissociationType, notDefaultParameters.DissociationType); - Assert.AreNotEqual(defaultParameters.DoPrecursorDeconvolution, notDefaultParameters.DoPrecursorDeconvolution); - Assert.AreNotEqual(defaultParameters.UseProvidedPrecursorInfo, notDefaultParameters.UseProvidedPrecursorInfo); - Assert.AreNotEqual(defaultParameters.DeconvolutionIntensityRatio, notDefaultParameters.DeconvolutionIntensityRatio); - Assert.AreNotEqual(defaultParameters.DeconvolutionMaxAssumedChargeState, notDefaultParameters.DeconvolutionMaxAssumedChargeState); - Assert.AreNotEqual(defaultParameters.ReportAllAmbiguity, notDefaultParameters.ReportAllAmbiguity); - Assert.AreNotEqual(defaultParameters.AddCompIons, notDefaultParameters.AddCompIons); - Assert.AreNotEqual(defaultParameters.TotalPartitions, notDefaultParameters.TotalPartitions); - Assert.AreNotEqual(defaultParameters.ScoreCutoff, notDefaultParameters.ScoreCutoff); - Assert.AreNotEqual(defaultParameters.NumberOfPeaksToKeepPerWindow, notDefaultParameters.NumberOfPeaksToKeepPerWindow); - Assert.AreNotEqual(defaultParameters.MinimumAllowedIntensityRatioToBasePeak, notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak); - Assert.AreNotEqual(defaultParameters.TrimMs1Peaks, notDefaultParameters.TrimMs1Peaks); - Assert.AreNotEqual(defaultParameters.TrimMsMsPeaks, notDefaultParameters.TrimMsMsPeaks); - Assert.AreNotEqual(defaultParameters.ProductMassTolerance, notDefaultParameters.ProductMassTolerance); - Assert.AreNotEqual(defaultParameters.PrecursorMassTolerance, notDefaultParameters.PrecursorMassTolerance); - Assert.AreNotEqual(defaultParameters.DeconvolutionMassTolerance, notDefaultParameters.DeconvolutionMassTolerance); - Assert.AreNotEqual(defaultParameters.MaxThreadsToUsePerFile, notDefaultParameters.MaxThreadsToUsePerFile); - Assert.AreNotEqual(defaultParameters.DigestionParams, notDefaultParameters.DigestionParams); - Assert.AreNotEqual(defaultParameters.ListOfModsVariable, notDefaultParameters.ListOfModsVariable); - Assert.AreNotEqual(defaultParameters.ListOfModsFixed, notDefaultParameters.ListOfModsFixed); - Assert.AreNotEqual(defaultParameters.CustomIons, notDefaultParameters.CustomIons); + Assert.That(defaultParameters.DissociationType, Is.Not.EqualTo(notDefaultParameters.DissociationType)); + Assert.That(defaultParameters.DoPrecursorDeconvolution, Is.Not.EqualTo(notDefaultParameters.DoPrecursorDeconvolution)); + Assert.That(defaultParameters.UseProvidedPrecursorInfo, Is.Not.EqualTo(notDefaultParameters.UseProvidedPrecursorInfo)); + Assert.That(defaultParameters.DeconvolutionIntensityRatio, Is.Not.EqualTo(notDefaultParameters.DeconvolutionIntensityRatio)); + Assert.That(defaultParameters.DeconvolutionMaxAssumedChargeState, Is.Not.EqualTo(notDefaultParameters.DeconvolutionMaxAssumedChargeState)); + Assert.That(defaultParameters.ReportAllAmbiguity, Is.Not.EqualTo(notDefaultParameters.ReportAllAmbiguity)); + Assert.That(defaultParameters.AddCompIons, Is.Not.EqualTo(notDefaultParameters.AddCompIons)); + Assert.That(defaultParameters.TotalPartitions, Is.Not.EqualTo(notDefaultParameters.TotalPartitions)); + Assert.That(defaultParameters.ScoreCutoff, Is.Not.EqualTo(notDefaultParameters.ScoreCutoff)); + Assert.That(defaultParameters.NumberOfPeaksToKeepPerWindow, Is.Not.EqualTo(notDefaultParameters.NumberOfPeaksToKeepPerWindow)); + Assert.That(defaultParameters.MinimumAllowedIntensityRatioToBasePeak, Is.Not.EqualTo(notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak)); + Assert.That(defaultParameters.TrimMs1Peaks, Is.Not.EqualTo(notDefaultParameters.TrimMs1Peaks)); + Assert.That(defaultParameters.TrimMsMsPeaks, Is.Not.EqualTo(notDefaultParameters.TrimMsMsPeaks)); + Assert.That(defaultParameters.ProductMassTolerance, Is.Not.EqualTo(notDefaultParameters.ProductMassTolerance)); + Assert.That(defaultParameters.PrecursorMassTolerance, Is.Not.EqualTo(notDefaultParameters.PrecursorMassTolerance)); + Assert.That(defaultParameters.DeconvolutionMassTolerance, Is.Not.EqualTo(notDefaultParameters.DeconvolutionMassTolerance)); + Assert.That(defaultParameters.MaxThreadsToUsePerFile, Is.Not.EqualTo(notDefaultParameters.MaxThreadsToUsePerFile)); + Assert.That(defaultParameters.DigestionParams, Is.Not.EqualTo(notDefaultParameters.DigestionParams)); + Assert.That(defaultParameters.ListOfModsVariable, Is.Not.EqualTo(notDefaultParameters.ListOfModsVariable)); + Assert.That(defaultParameters.ListOfModsFixed, Is.Not.EqualTo(notDefaultParameters.ListOfModsFixed)); + Assert.That(defaultParameters.CustomIons, Is.Not.EqualTo(notDefaultParameters.CustomIons)); FileSpecificParameters emptyFileSpecificParameters = new FileSpecificParameters(); CommonParameters updatedParameters = MetaMorpheusTask.SetAllFileSpecificCommonParams(notDefaultParameters, emptyFileSpecificParameters); //CHECK THAT NOTHING CHANGED - Assert.AreEqual(updatedParameters.DissociationType, notDefaultParameters.DissociationType); - Assert.AreEqual(updatedParameters.DoPrecursorDeconvolution, notDefaultParameters.DoPrecursorDeconvolution); - Assert.AreEqual(updatedParameters.UseProvidedPrecursorInfo, notDefaultParameters.UseProvidedPrecursorInfo); - Assert.AreEqual(updatedParameters.DeconvolutionIntensityRatio, notDefaultParameters.DeconvolutionIntensityRatio); - Assert.AreEqual(updatedParameters.DeconvolutionMaxAssumedChargeState, notDefaultParameters.DeconvolutionMaxAssumedChargeState); - Assert.AreEqual(updatedParameters.ReportAllAmbiguity, notDefaultParameters.ReportAllAmbiguity); - Assert.AreEqual(updatedParameters.AddCompIons, notDefaultParameters.AddCompIons); - Assert.AreEqual(updatedParameters.TotalPartitions, notDefaultParameters.TotalPartitions); - Assert.AreEqual(updatedParameters.ScoreCutoff, notDefaultParameters.ScoreCutoff); - Assert.AreEqual(updatedParameters.NumberOfPeaksToKeepPerWindow, notDefaultParameters.NumberOfPeaksToKeepPerWindow); - Assert.AreEqual(updatedParameters.MinimumAllowedIntensityRatioToBasePeak, notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak); - Assert.AreEqual(updatedParameters.TrimMs1Peaks, notDefaultParameters.TrimMs1Peaks); - Assert.AreEqual(updatedParameters.TrimMsMsPeaks, notDefaultParameters.TrimMsMsPeaks); - Assert.AreEqual(updatedParameters.ProductMassTolerance, notDefaultParameters.ProductMassTolerance); - Assert.AreEqual(updatedParameters.PrecursorMassTolerance, notDefaultParameters.PrecursorMassTolerance); - Assert.AreEqual(updatedParameters.DeconvolutionMassTolerance, notDefaultParameters.DeconvolutionMassTolerance); - Assert.AreEqual(updatedParameters.MaxThreadsToUsePerFile, notDefaultParameters.MaxThreadsToUsePerFile); - Assert.AreEqual(updatedParameters.DigestionParams, notDefaultParameters.DigestionParams); - Assert.AreEqual(updatedParameters.ListOfModsVariable, notDefaultParameters.ListOfModsVariable); - Assert.AreEqual(updatedParameters.ListOfModsFixed, notDefaultParameters.ListOfModsFixed); - Assert.AreEqual(updatedParameters.CustomIons, notDefaultParameters.CustomIons); + Assert.That(updatedParameters.DissociationType, Is.EqualTo(notDefaultParameters.DissociationType)); + Assert.That(updatedParameters.DoPrecursorDeconvolution, Is.EqualTo(notDefaultParameters.DoPrecursorDeconvolution)); + Assert.That(updatedParameters.UseProvidedPrecursorInfo, Is.EqualTo(notDefaultParameters.UseProvidedPrecursorInfo)); + Assert.That(updatedParameters.DeconvolutionIntensityRatio, Is.EqualTo(notDefaultParameters.DeconvolutionIntensityRatio)); + Assert.That(updatedParameters.DeconvolutionMaxAssumedChargeState, Is.EqualTo(notDefaultParameters.DeconvolutionMaxAssumedChargeState)); + Assert.That(updatedParameters.ReportAllAmbiguity, Is.EqualTo(notDefaultParameters.ReportAllAmbiguity)); + Assert.That(updatedParameters.AddCompIons, Is.EqualTo(notDefaultParameters.AddCompIons)); + Assert.That(updatedParameters.TotalPartitions, Is.EqualTo(notDefaultParameters.TotalPartitions)); + Assert.That(updatedParameters.ScoreCutoff, Is.EqualTo(notDefaultParameters.ScoreCutoff)); + Assert.That(updatedParameters.NumberOfPeaksToKeepPerWindow, Is.EqualTo(notDefaultParameters.NumberOfPeaksToKeepPerWindow)); + Assert.That(updatedParameters.MinimumAllowedIntensityRatioToBasePeak, Is.EqualTo(notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak)); + Assert.That(updatedParameters.TrimMs1Peaks, Is.EqualTo(notDefaultParameters.TrimMs1Peaks)); + Assert.That(updatedParameters.TrimMsMsPeaks, Is.EqualTo(notDefaultParameters.TrimMsMsPeaks)); + Assert.That(updatedParameters.ProductMassTolerance, Is.EqualTo(notDefaultParameters.ProductMassTolerance)); + Assert.That(updatedParameters.PrecursorMassTolerance, Is.EqualTo(notDefaultParameters.PrecursorMassTolerance)); + Assert.That(updatedParameters.DeconvolutionMassTolerance, Is.EqualTo(notDefaultParameters.DeconvolutionMassTolerance)); + Assert.That(updatedParameters.MaxThreadsToUsePerFile, Is.EqualTo(notDefaultParameters.MaxThreadsToUsePerFile)); + Assert.That(updatedParameters.DigestionParams, Is.EqualTo(notDefaultParameters.DigestionParams)); + Assert.That(updatedParameters.ListOfModsVariable, Is.EqualTo(notDefaultParameters.ListOfModsVariable)); + Assert.That(updatedParameters.ListOfModsFixed, Is.EqualTo(notDefaultParameters.ListOfModsFixed)); + Assert.That(updatedParameters.CustomIons, Is.EqualTo(notDefaultParameters.CustomIons)); FileSpecificParameters basicFileSpecificParameters = new FileSpecificParameters { @@ -141,33 +140,33 @@ public static void TestFileSpecifcParameterOverwrite() }; updatedParameters = MetaMorpheusTask.SetAllFileSpecificCommonParams(notDefaultParameters, basicFileSpecificParameters); //CHECK THAT SOMETHINGS CHANGED AND OTHERS DIDN'T - Assert.AreEqual(updatedParameters.DissociationType, basicFileSpecificParameters.DissociationType); - Assert.AreEqual(updatedParameters.ProductMassTolerance, basicFileSpecificParameters.ProductMassTolerance); - Assert.AreEqual(updatedParameters.PrecursorMassTolerance, basicFileSpecificParameters.PrecursorMassTolerance); - Assert.AreEqual(updatedParameters.DigestionParams.MaxModsForPeptide, basicFileSpecificParameters.MaxModsForPeptide); - Assert.AreEqual(updatedParameters.DigestionParams.MaxMissedCleavages, basicFileSpecificParameters.MaxMissedCleavages); - Assert.AreEqual(updatedParameters.DigestionParams.MinPeptideLength, basicFileSpecificParameters.MinPeptideLength); - Assert.AreEqual(updatedParameters.DigestionParams.MaxPeptideLength, basicFileSpecificParameters.MaxPeptideLength); - Assert.AreEqual(updatedParameters.DigestionParams.Protease, basicFileSpecificParameters.Protease); - Assert.AreEqual(updatedParameters.CustomIons, basicFileSpecificParameters.CustomIons); + Assert.That(updatedParameters.DissociationType, Is.EqualTo(basicFileSpecificParameters.DissociationType)); + Assert.That(updatedParameters.ProductMassTolerance, Is.EqualTo(basicFileSpecificParameters.ProductMassTolerance)); + Assert.That(updatedParameters.PrecursorMassTolerance, Is.EqualTo(basicFileSpecificParameters.PrecursorMassTolerance)); + Assert.That(updatedParameters.DigestionParams.MaxModsForPeptide, Is.EqualTo(basicFileSpecificParameters.MaxModsForPeptide)); + Assert.That(updatedParameters.DigestionParams.MaxMissedCleavages, Is.EqualTo(basicFileSpecificParameters.MaxMissedCleavages)); + Assert.That(updatedParameters.DigestionParams.MinPeptideLength, Is.EqualTo(basicFileSpecificParameters.MinPeptideLength)); + Assert.That(updatedParameters.DigestionParams.MaxPeptideLength, Is.EqualTo(basicFileSpecificParameters.MaxPeptideLength)); + Assert.That(updatedParameters.DigestionParams.Protease, Is.EqualTo(basicFileSpecificParameters.Protease)); + Assert.That(updatedParameters.CustomIons, Is.EqualTo(basicFileSpecificParameters.CustomIons)); - Assert.AreEqual(updatedParameters.DoPrecursorDeconvolution, notDefaultParameters.DoPrecursorDeconvolution); - Assert.AreEqual(updatedParameters.UseProvidedPrecursorInfo, notDefaultParameters.UseProvidedPrecursorInfo); - Assert.AreEqual(updatedParameters.DeconvolutionIntensityRatio, notDefaultParameters.DeconvolutionIntensityRatio); - Assert.AreEqual(updatedParameters.DeconvolutionMaxAssumedChargeState, notDefaultParameters.DeconvolutionMaxAssumedChargeState); - Assert.AreEqual(updatedParameters.ReportAllAmbiguity, notDefaultParameters.ReportAllAmbiguity); - Assert.AreEqual(updatedParameters.AddCompIons, notDefaultParameters.AddCompIons); - Assert.AreEqual(updatedParameters.TotalPartitions, notDefaultParameters.TotalPartitions); - Assert.AreEqual(updatedParameters.ScoreCutoff, notDefaultParameters.ScoreCutoff); - Assert.AreEqual(updatedParameters.NumberOfPeaksToKeepPerWindow, notDefaultParameters.NumberOfPeaksToKeepPerWindow); - Assert.AreEqual(updatedParameters.MinimumAllowedIntensityRatioToBasePeak, notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak); - Assert.AreEqual(updatedParameters.TrimMs1Peaks, notDefaultParameters.TrimMs1Peaks); - Assert.AreEqual(updatedParameters.TrimMsMsPeaks, notDefaultParameters.TrimMsMsPeaks); - Assert.AreEqual(updatedParameters.DeconvolutionMassTolerance, notDefaultParameters.DeconvolutionMassTolerance); - Assert.AreEqual(updatedParameters.MaxThreadsToUsePerFile, notDefaultParameters.MaxThreadsToUsePerFile); - Assert.AreEqual(updatedParameters.DigestionParams.InitiatorMethionineBehavior, notDefaultParameters.DigestionParams.InitiatorMethionineBehavior); - Assert.AreEqual(updatedParameters.ListOfModsVariable, notDefaultParameters.ListOfModsVariable); - Assert.AreEqual(updatedParameters.ListOfModsFixed, notDefaultParameters.ListOfModsFixed); + Assert.That(updatedParameters.DoPrecursorDeconvolution, Is.EqualTo(notDefaultParameters.DoPrecursorDeconvolution)); + Assert.That(updatedParameters.UseProvidedPrecursorInfo, Is.EqualTo(notDefaultParameters.UseProvidedPrecursorInfo)); + Assert.That(updatedParameters.DeconvolutionIntensityRatio, Is.EqualTo(notDefaultParameters.DeconvolutionIntensityRatio)); + Assert.That(updatedParameters.DeconvolutionMaxAssumedChargeState, Is.EqualTo(notDefaultParameters.DeconvolutionMaxAssumedChargeState)); + Assert.That(updatedParameters.ReportAllAmbiguity, Is.EqualTo(notDefaultParameters.ReportAllAmbiguity)); + Assert.That(updatedParameters.AddCompIons, Is.EqualTo(notDefaultParameters.AddCompIons)); + Assert.That(updatedParameters.TotalPartitions, Is.EqualTo(notDefaultParameters.TotalPartitions)); + Assert.That(updatedParameters.ScoreCutoff, Is.EqualTo(notDefaultParameters.ScoreCutoff)); + Assert.That(updatedParameters.NumberOfPeaksToKeepPerWindow, Is.EqualTo(notDefaultParameters.NumberOfPeaksToKeepPerWindow)); + Assert.That(updatedParameters.MinimumAllowedIntensityRatioToBasePeak, Is.EqualTo(notDefaultParameters.MinimumAllowedIntensityRatioToBasePeak)); + Assert.That(updatedParameters.TrimMs1Peaks, Is.EqualTo(notDefaultParameters.TrimMs1Peaks)); + Assert.That(updatedParameters.TrimMsMsPeaks, Is.EqualTo(notDefaultParameters.TrimMsMsPeaks)); + Assert.That(updatedParameters.DeconvolutionMassTolerance, Is.EqualTo(notDefaultParameters.DeconvolutionMassTolerance)); + Assert.That(updatedParameters.MaxThreadsToUsePerFile, Is.EqualTo(notDefaultParameters.MaxThreadsToUsePerFile)); + Assert.That(updatedParameters.DigestionParams.InitiatorMethionineBehavior, Is.EqualTo(notDefaultParameters.DigestionParams.InitiatorMethionineBehavior)); + Assert.That(updatedParameters.ListOfModsVariable, Is.EqualTo(notDefaultParameters.ListOfModsVariable)); + Assert.That(updatedParameters.ListOfModsFixed, Is.EqualTo(notDefaultParameters.ListOfModsFixed)); } } diff --git a/MetaMorpheus/Test/PeptideSpectralMatchTest.cs b/MetaMorpheus/Test/PeptideSpectralMatchTest.cs index a5f097ed5..7f776bbcf 100644 --- a/MetaMorpheus/Test/PeptideSpectralMatchTest.cs +++ b/MetaMorpheus/Test/PeptideSpectralMatchTest.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics.ProteolyticDigestion; using Proteomics; using System; @@ -44,9 +44,9 @@ public static void GetAminoAcidCoverageTest() //PSM has neither sequence nor matched fragment ions var b = psmNoBaseSequenceNoMFI.BaseSequence; - Assert.AreEqual("", b); + Assert.That(b, Is.EqualTo("")); var m = psmNoBaseSequenceNoMFI.MatchedFragmentIons; - Assert.AreEqual(0, m.Count); + Assert.That(m.Count, Is.EqualTo(0)); psmNoBaseSequenceNoMFI.GetAminoAcidCoverage(); sequence = "PEPTIDE"; @@ -62,9 +62,9 @@ public static void GetAminoAcidCoverageTest() //PSM has sequence but does not have matched fragment ions psmBaseSequenceNoMFI.ResolveAllAmbiguities(); b = psmBaseSequenceNoMFI.BaseSequence; - Assert.AreEqual(sequence, b); + Assert.That(b, Is.EqualTo(sequence)); m = psmBaseSequenceNoMFI.MatchedFragmentIons; - Assert.AreEqual(0, m.Count); + Assert.That(m.Count, Is.EqualTo(0)); psmBaseSequenceNoMFI.GetAminoAcidCoverage(); //PSM has no sequence but does have matched fragment ions @@ -76,9 +76,9 @@ public static void GetAminoAcidCoverageTest() psmNoBaseSequenceMFI.ResolveAllAmbiguities(); b = psmNoBaseSequenceMFI.BaseSequence; - Assert.AreEqual("", b); + Assert.That(b, Is.EqualTo("")); m = psmNoBaseSequenceMFI.MatchedFragmentIons; - Assert.AreEqual(1, m.Count); + Assert.That(m.Count, Is.EqualTo(1)); psmNoBaseSequenceMFI.GetAminoAcidCoverage(); //PSM has sequence and matched fragment ions @@ -87,9 +87,9 @@ public static void GetAminoAcidCoverageTest() psmBaseSequenceMFI.ResolveAllAmbiguities(); b = psmBaseSequenceMFI.BaseSequence; - Assert.AreEqual("PEPTIDE", b); + Assert.That(b, Is.EqualTo("PEPTIDE")); m = psmBaseSequenceMFI.MatchedFragmentIons; - Assert.AreEqual(1, m.Count); + Assert.That(m.Count, Is.EqualTo(1)); psmBaseSequenceMFI.GetAminoAcidCoverage(); List psms = new List() { psmNoBaseSequenceNoMFI, psmBaseSequenceNoMFI, psmNoBaseSequenceMFI, psmBaseSequenceMFI }; diff --git a/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs b/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs index f6b68a08a..2ec5e8c0f 100644 --- a/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs +++ b/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; namespace Test { @@ -28,28 +27,28 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_QValue_BottomUp( // The new PEP calculation method improves things, so all these numbers are increasing as of (7/17/24) // There is a discrepancy between the number of All target peptides and individual file target peptides, // presumably due to the way protein inference is performed. - Assert.AreEqual("All target PSMs with q-value <= 0.01: 428", allResults[10]); - Assert.AreEqual("All target peptides with q-value <= 0.01: 174", allResults[11]); - Assert.AreEqual("All target protein groups with q-value <= 0.01 (1% FDR): 165", allResults[12]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target PSMs with q-value <= 0.01: 214", allResults[14]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target peptides with q-value <= 0.01: 174", allResults[15]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 165", allResults[16]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target PSMs with q-value <= 0.01: 214", allResults[18]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target peptides with q-value <= 0.01: 174", allResults[19]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 165", allResults[20]); + Assert.That(allResults[10], Is.EqualTo("All target PSMs with q-value <= 0.01: 428")); + Assert.That(allResults[11], Is.EqualTo("All target peptides with q-value <= 0.01: 174")); + Assert.That(allResults[12], Is.EqualTo("All target protein groups with q-value <= 0.01 (1% FDR): 165")); + Assert.That(allResults[14], Is.EqualTo("TaGe_SA_A549_3_snip - Target PSMs with q-value <= 0.01: 214")); + Assert.That(allResults[15], Is.EqualTo("TaGe_SA_A549_3_snip - Target peptides with q-value <= 0.01: 174")); + Assert.That(allResults[16], Is.EqualTo("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 165")); + Assert.That(allResults[18], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target PSMs with q-value <= 0.01: 214")); + Assert.That(allResults[19], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target peptides with q-value <= 0.01: 174")); + Assert.That(allResults[20], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 165")); string resultsFile = Path.Combine(outputFolder, @"postSearchAnalysisTaskTestOutput\results.txt"); string[] results = File.ReadAllLines(resultsFile); - Assert.AreEqual("All target PSMs with q-value <= 0.01: 428", results[5]); - Assert.AreEqual("All target peptides with q-value <= 0.01: 174", results[6]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target PSMs with q-value <= 0.01: 214", results[9]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target peptides with q-value <= 0.01: 174", results[10]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 165", results[11]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target PSMs with q-value <= 0.01: 214", results[13]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target peptides with q-value <= 0.01: 174", results[14]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 165", results[15]); + Assert.That(results[5], Is.EqualTo("All target PSMs with q-value <= 0.01: 428")); + Assert.That(results[6], Is.EqualTo("All target peptides with q-value <= 0.01: 174")); + Assert.That(results[9], Is.EqualTo("TaGe_SA_A549_3_snip - Target PSMs with q-value <= 0.01: 214")); + Assert.That(results[10], Is.EqualTo("TaGe_SA_A549_3_snip - Target peptides with q-value <= 0.01: 174")); + Assert.That(results[11], Is.EqualTo("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 165")); + Assert.That(results[13], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target PSMs with q-value <= 0.01: 214")); + Assert.That(results[14], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target peptides with q-value <= 0.01: 174")); + Assert.That(results[15], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 165")); // Search TaGe_SA_A549_3_snip_2 by itself. The results from this should be identical to the file specific results above // TaGe_SA_A549_3_snip_2 is searched twice. First with two files being searched simultaneously, then with TaGe_SA_A549_3_snip_2 by itself @@ -66,9 +65,9 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_QValue_BottomUp( resultsFile = Path.Combine(outputFolder, @"postSearchAnalysisTaskTestOutput\results.txt"); string[] singleFileResults = File.ReadAllLines(resultsFile); - 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): 165", singleFileResults[7]); + Assert.That(singleFileResults[5], Is.EqualTo("All target PSMs with q-value <= 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms)); + Assert.That(singleFileResults[6], Is.EqualTo("All target peptides with q-value <= 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPeptides)); + Assert.That(singleFileResults[7], Is.EqualTo("All target protein groups with q-value <= 0.01 (1% FDR): 165")); } [Test] @@ -79,27 +78,27 @@ public static void AllResultsAndResultsTxtContainsCorrectValues_PepQValue_Bottom string outputFolder = testCase.OutputDirectory; var allResultsFile = Path.Combine(outputFolder, "allResults.txt"); var allResults = File.ReadAllLines(allResultsFile); - Assert.AreEqual("All target PSMs with pep q-value <= 0.01: 382", allResults[10]); - Assert.AreEqual("All target peptides with pep q-value <= 0.01: 153", allResults[11]); - Assert.AreEqual("All target protein groups with q-value <= 0.01 (1% FDR): 140", allResults[12]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target PSMs with pep q-value <= 0.01: 190", allResults[14]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target peptides with pep q-value <= 0.01: 153", allResults[15]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 140", allResults[16]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target PSMs with pep q-value <= 0.01: 190", allResults[18]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target peptides with pep q-value <= 0.01: 153", allResults[19]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 140", allResults[20]); + Assert.That(allResults[10], Is.EqualTo("All target PSMs with pep q-value <= 0.01: 382")); + Assert.That(allResults[11], Is.EqualTo("All target peptides with pep q-value <= 0.01: 153")); + Assert.That(allResults[12], Is.EqualTo("All target protein groups with q-value <= 0.01 (1% FDR): 140")); + Assert.That(allResults[14], Is.EqualTo("TaGe_SA_A549_3_snip - Target PSMs with pep q-value <= 0.01: 190")); + Assert.That(allResults[15], Is.EqualTo("TaGe_SA_A549_3_snip - Target peptides with pep q-value <= 0.01: 153")); + Assert.That(allResults[16], Is.EqualTo("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 140")); + Assert.That(allResults[18], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target PSMs with pep q-value <= 0.01: 190")); + Assert.That(allResults[19], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target peptides with pep q-value <= 0.01: 153")); + Assert.That(allResults[20], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 140")); var resultsFile = Path.Combine(outputFolder, @"postSearchAnalysisTaskTestOutput\results.txt"); var results = File.ReadAllLines(resultsFile); - Assert.AreEqual("All target PSMs with pep q-value <= 0.01: 382", results[5]); - Assert.AreEqual("All target peptides with pep q-value <= 0.01: 153", results[6]); - Assert.AreEqual("All target protein groups with q-value <= 0.01 (1% FDR): 140", results[7]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target PSMs with pep q-value <= 0.01: 190", results[9]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target peptides with pep q-value <= 0.01: 153", results[10]); - Assert.AreEqual("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 140", results[11]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target PSMs with pep q-value <= 0.01: 190", results[13]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target peptides with pep q-value <= 0.01: 153", results[14]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 140", results[15]); + Assert.That(results[5], Is.EqualTo("All target PSMs with pep q-value <= 0.01: 382")); + Assert.That(results[6], Is.EqualTo("All target peptides with pep q-value <= 0.01: 153")); + Assert.That(results[7], Is.EqualTo("All target protein groups with q-value <= 0.01 (1% FDR): 140")); + Assert.That(results[9], Is.EqualTo("TaGe_SA_A549_3_snip - Target PSMs with pep q-value <= 0.01: 190")); + Assert.That(results[10], Is.EqualTo("TaGe_SA_A549_3_snip - Target peptides with pep q-value <= 0.01: 153")); + Assert.That(results[11], Is.EqualTo("TaGe_SA_A549_3_snip - Target protein groups within 1 % FDR: 140")); + Assert.That(results[13], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target PSMs with pep q-value <= 0.01: 190")); + Assert.That(results[14], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target peptides with pep q-value <= 0.01: 153")); + Assert.That(results[15], Is.EqualTo("TaGe_SA_A549_3_snip_2 - Target protein groups within 1 % FDR: 140")); } /// @@ -119,8 +118,8 @@ public static void AllResultTxtContainsCorrectNumberOfResultLines(EverythingRunn var summaryPsmLines = allResultTxtLines.Where(p => p.Contains("All target PSMs")).ToArray(); var individualPsmLines = allResultTxtLines.Where(p => p.Contains("Target PSMs") && !p.Contains("All")).ToArray(); - Assert.AreEqual(expectedSummaryLines, summaryPsmLines.Length); - Assert.AreEqual(expectedIndividualFileLines, individualPsmLines.Length); + Assert.That(summaryPsmLines.Length, Is.EqualTo(expectedSummaryLines)); + Assert.That(individualPsmLines.Length, Is.EqualTo(expectedIndividualFileLines)); if (testCase.IsTopDown) { @@ -128,23 +127,23 @@ public static void AllResultTxtContainsCorrectNumberOfResultLines(EverythingRunn allResultTxtLines.Where(p => p.Contains("All target proteoforms")).ToArray(); var individualProteoformLines = allResultTxtLines.Where(p => p.Contains("Target proteoforms") && !p.Contains("All")).ToArray(); - Assert.AreEqual(expectedSummaryLines, summaryProteoformLines.Length); - Assert.AreEqual(expectedIndividualFileLines, individualProteoformLines.Length); + Assert.That(summaryProteoformLines.Length, Is.EqualTo(expectedSummaryLines)); + Assert.That(individualProteoformLines.Length, Is.EqualTo(expectedIndividualFileLines)); } else { var summaryPeptideLines = allResultTxtLines.Where(p => p.Contains("All target peptides")).ToArray(); var individualPeptideLines = allResultTxtLines.Where(p => p.Contains("Target peptides") && !p.Contains("All")).ToArray(); - Assert.AreEqual(expectedSummaryLines, summaryPeptideLines.Length); - Assert.AreEqual(expectedIndividualFileLines, individualPeptideLines.Length); + Assert.That(summaryPeptideLines.Length, Is.EqualTo(expectedSummaryLines)); + Assert.That(individualPeptideLines.Length, Is.EqualTo(expectedIndividualFileLines)); } var summaryProteinLines = allResultTxtLines.Where(p => p.Contains("All target protein groups")).ToArray(); var individualProteinLines = allResultTxtLines.Where(p => p.Contains("Target protein groups") && !p.Contains("All")).ToArray(); - Assert.AreEqual(expectedSummaryLines, summaryProteinLines.Length); - Assert.AreEqual(expectedIndividualFileLines, individualProteinLines.Length); + Assert.That(summaryProteinLines.Length, Is.EqualTo(expectedSummaryLines)); + Assert.That(individualProteinLines.Length, Is.EqualTo(expectedIndividualFileLines)); } /// @@ -167,44 +166,44 @@ public static void CorrectFilesAreWrittenWithCorrectName(EverythingRunnerEngineT var expectedResultFileCount = testCase.WriteIndividualResults && testCase.DataFileList.Count > 1 ? testCase.DataFileList.Count + 1 : 1; - Assert.AreEqual(expectedResultFileCount, psmFiles.Length); - Assert.AreEqual(expectedResultFileCount, proteinGroupFiles.Length); + Assert.That(psmFiles.Length, Is.EqualTo(expectedResultFileCount)); + Assert.That(proteinGroupFiles.Length, Is.EqualTo(expectedResultFileCount)); if (testCase.IsTopDown) { - Assert.AreEqual(expectedResultFileCount, proteoformFiles.Length); - Assert.AreEqual(0, peptideFiles.Length); + Assert.That(proteoformFiles.Length, Is.EqualTo(expectedResultFileCount)); + Assert.That(peptideFiles.Length, Is.EqualTo(0)); } else { - Assert.AreEqual(expectedResultFileCount, peptideFiles.Length); - Assert.AreEqual(0, proteoformFiles.Length); + Assert.That(peptideFiles.Length, Is.EqualTo(expectedResultFileCount)); + Assert.That(proteoformFiles.Length, Is.EqualTo(0)); } if (testCase.WritePepXml) { - Assert.AreEqual(spectraFileCount, pepXmlFiles.Length); + Assert.That(pepXmlFiles.Length, Is.EqualTo(spectraFileCount)); } else { - Assert.AreEqual(0, pepXmlFiles.Length); + Assert.That(pepXmlFiles.Length, Is.EqualTo(0)); } if (testCase.WriteIndividualResults) { - Assert.AreEqual(expectedResultFileCount, percolatorFiles.Length); + Assert.That(percolatorFiles.Length, Is.EqualTo(expectedResultFileCount)); } else { - Assert.AreEqual(1, percolatorFiles.Length); + Assert.That(percolatorFiles.Length, Is.EqualTo(1)); } if (testCase.WriteMzId) { - Assert.AreEqual(spectraFileCount, mzidFiles.Length); + Assert.That(mzidFiles.Length, Is.EqualTo(spectraFileCount)); } else { - Assert.AreEqual(0, mzidFiles.Length); + Assert.That(mzidFiles.Length, Is.EqualTo(0)); } } } diff --git a/MetaMorpheus/Test/ProteaseTests.cs b/MetaMorpheus/Test/ProteaseTests.cs index e573e4a39..071a598aa 100644 --- a/MetaMorpheus/Test/ProteaseTests.cs +++ b/MetaMorpheus/Test/ProteaseTests.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using EngineLayer; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using TaskLayer; @@ -32,7 +30,7 @@ public static void TestChymotrypsinCleaveAfterLeucine() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); PsmFromTsv psm = parsedPsms.First(); - Assert.AreEqual("TTQNQKSQDVELWEGEVVKEL", psm.BaseSeq); //base sequence ends in leucine as expected + Assert.That(psm.BaseSeq, Is.EqualTo("TTQNQKSQDVELWEGEVVKEL")); //base sequence ends in leucine as expected Directory.Delete(outputFolder,true); } } diff --git a/MetaMorpheus/Test/ProteinGroupTest.cs b/MetaMorpheus/Test/ProteinGroupTest.cs index a1a1d0e5b..ccd56139b 100644 --- a/MetaMorpheus/Test/ProteinGroupTest.cs +++ b/MetaMorpheus/Test/ProteinGroupTest.cs @@ -1,5 +1,5 @@ using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using System.Collections.Generic; using System.Linq; @@ -31,7 +31,7 @@ public static void TestProteinGroupEquals() new HashSet(), new HashSet()); //two protein groups with the same protein should be equal - Assert.IsTrue(proteinGroup1.Equals(proteinGroup2)); + Assert.That(proteinGroup1.Equals(proteinGroup2)); Protein prot3 = new Protein("EDEEK", "prot3"); List proteinList3 = new List { prot3 }; @@ -39,7 +39,7 @@ public static void TestProteinGroupEquals() new HashSet(), new HashSet()); //two protein groups with different proteins should not be equal - Assert.IsFalse(proteinGroup1.Equals(proteinGroup3)); + Assert.That(!proteinGroup1.Equals(proteinGroup3)); List proteinList4 = new List { prot1, prot3 }; List proteinList5 = new List { prot3, prot1 }; @@ -49,7 +49,7 @@ public static void TestProteinGroupEquals() new HashSet(), new HashSet()); //protein groups with the same proteins but in different order should be equal - Assert.IsTrue(proteinGroup4.Equals(proteinGroup5)); + Assert.That(proteinGroup4.Equals(proteinGroup5)); PeptideWithSetModifications pwsm1 = new PeptideWithSetModifications(prot1,new DigestionParams(),1,3,CleavageSpecificity.Full,"",0,new Dictionary(),0); PeptideWithSetModifications pwsm2 = new PeptideWithSetModifications(prot1, new DigestionParams(), 4, 6, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); @@ -59,11 +59,11 @@ public static void TestProteinGroupEquals() new HashSet() { pwsm2 }); //protein groups with the same proteins but different peptides should be equal - Assert.IsTrue(proteinGroup6.Equals(proteinGroup7)); + Assert.That(proteinGroup6.Equals(proteinGroup7)); //a protein group that is null should not be equal to a protein group that is not null ProteinGroup nullProteinGroup = null; - Assert.IsFalse(proteinGroup1.Equals(nullProteinGroup)); + Assert.That(!proteinGroup1.Equals(nullProteinGroup)); } [Test] @@ -82,15 +82,15 @@ public static void ProteinGroupToStringTest() //string exectedProteinGroupToString = proteinGroup1.ToString(); string exectedProteinGroupToString = "prot1|prot2\t|\t\t\t779.30073507823|778.3167194953201\t2\t\t\t2\t2\t\t\t\t\t\t0\tT\t0\t0\t0\t0\t0\t"; - Assert.AreEqual(exectedProteinGroupToString, proteinGroup1.ToString()); + Assert.That(proteinGroup1.ToString(), Is.EqualTo(exectedProteinGroupToString)); - Protein prot3 = new Protein("MAAADAAAAAAAAAAAAAAA", "prot3", isDecoy:true); + Protein prot3 = new Protein("MAAADAAAAAAAAAAAAAAA", "prot3", isDecoy: true); List proteinList3 = new List { prot3 }; ProteinGroup proteinGroup3 = new ProteinGroup(new HashSet(proteinList3), new HashSet(), new HashSet()); string exectedProteinGroupWithDecoyToString = "prot1|prot2\t|\t\t\t779.30073507823|778.3167194953201\t2\t\t\t2\t2\t\t\t\t\t\t0\tT\t0\t0\t0\t0\t0\t"; - Assert.AreEqual(exectedProteinGroupWithDecoyToString, proteinGroup1.ToString()); + Assert.That(proteinGroup1.ToString(), Is.EqualTo(exectedProteinGroupWithDecoyToString)); } [Test] @@ -117,14 +117,14 @@ public static void ProteinGroupMergeTest() proteinGroup1.MergeProteinGroupWith(proteinGroup2); //protein group 3 should have all proteins from protein group 1 and 2 - Assert.IsTrue(proteinGroup1.Proteins.Contains(prot1)); - Assert.IsTrue(proteinGroup1.Proteins.Contains(prot2)); - Assert.IsTrue(proteinGroup1.Proteins.Contains(prot3)); - Assert.IsTrue(proteinGroup1.Proteins.Contains(prot4)); + Assert.That(proteinGroup1.Proteins.Contains(prot1)); + Assert.That(proteinGroup1.Proteins.Contains(prot2)); + Assert.That(proteinGroup1.Proteins.Contains(prot3)); + Assert.That(proteinGroup1.Proteins.Contains(prot4)); //protein group 3 should have no peptides - Assert.AreEqual(4, proteinGroup1.AllPeptides.Count); - Assert.AreEqual(4, proteinGroup1.UniquePeptides.Count); + Assert.That(proteinGroup1.AllPeptides.Count, Is.EqualTo(4)); + Assert.That(proteinGroup1.UniquePeptides.Count, Is.EqualTo(4)); } [Test] @@ -212,16 +212,16 @@ public static void TestModificationInfoListInProteinGroupsOutput() // ensures that protein out put contains the correct number of proteins to match the following conditions. // all proteins in DB have baseSequence!=null (not ambiguous) // all proteins that belong to a protein group are written to DB - Assert.AreEqual(18, proteins.Count); + Assert.That(proteins.Count, Is.EqualTo(18)); int totalNumberOfMods = proteins.Sum(p => p.OneBasedPossibleLocalizedModifications.Count + p.SequenceVariations.Sum(sv => sv.OneBasedModifications.Count)); //tests that modifications are being done correctly - Assert.AreEqual(0, totalNumberOfMods); + Assert.That(totalNumberOfMods, Is.EqualTo(0)); List proteinGroupsOutput = File.ReadAllLines(Path.Combine(outputFolder, "task2", "AllQuantifiedProteinGroups.tsv")).ToList(); string firstDataLine = proteinGroupsOutput[2]; string modInfoListProteinTwo = firstDataLine.Split('\t')[14]; - Assert.AreEqual("#aa66[Hydroxylation on K,info:occupancy=0.33(1/3)];#aa71[Oxidation on S,info:occupancy=0.67(2/3)]", modInfoListProteinTwo); + Assert.That(modInfoListProteinTwo, Is.EqualTo("#aa66[Hydroxylation on K,info:occupancy=0.33(1/3)];#aa71[Oxidation on S,info:occupancy=0.67(2/3)]")); Directory.Delete(outputFolder, true); } diff --git a/MetaMorpheus/Test/ProteinLoaderTest.cs b/MetaMorpheus/Test/ProteinLoaderTest.cs index 0b0fc0e2f..3b5fe63fa 100644 --- a/MetaMorpheus/Test/ProteinLoaderTest.cs +++ b/MetaMorpheus/Test/ProteinLoaderTest.cs @@ -1,5 +1,5 @@ using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System.Collections.Generic; using System.IO; using TaskLayer; diff --git a/MetaMorpheus/Test/PsmTsvWriterTests.cs b/MetaMorpheus/Test/PsmTsvWriterTests.cs index 7ef38fea1..d82f9a50f 100644 --- a/MetaMorpheus/Test/PsmTsvWriterTests.cs +++ b/MetaMorpheus/Test/PsmTsvWriterTests.cs @@ -1,7 +1,7 @@ using Chemistry; using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -65,7 +65,7 @@ public static void ResolveModificationsTest() myPsm.ResolveAllAmbiguities(); //Here we have a situation where there are two mods at the same position with different chemical formuala. They cannot be resolved and so the return value is null. - Assert.IsNull(myPsm.ModsChemicalFormula); + Assert.That(myPsm.ModsChemicalFormula, Is.Null); var headerSplits = SpectralMatch.GetTabSeparatedHeader().Split('\t'); string myPsmString = myPsm.ToString(); @@ -74,13 +74,12 @@ public static void ResolveModificationsTest() string ppmErrorString = myPsmStringSplit[ppmErrorIndex]; //The two different mods produce two separate mass errors, which are both then reported - Assert.AreEqual("0.00000|11801.30000", ppmErrorString); + Assert.That(ppmErrorString, Is.EqualTo("0.00000|11801.30000")); //Make sure we see produt ion neutral losses in the output. var matchedIonSeriesIndex = headerSplits.IndexOf(PsmTsvHeader.MatchedIonSeries); string matchedIonSeries = myPsmStringSplit[matchedIonSeriesIndex]; - Assert.AreEqual("[(b1-5.00)+1]", matchedIonSeries); - + Assert.That(matchedIonSeries, Is.EqualTo("[(b1-5.00)+1]")); //removing one of the peptides to reset for the next test myPsm.RemoveThisAmbiguousPeptide(0, pwsm2); @@ -92,13 +91,13 @@ public static void ResolveModificationsTest() //Now we have removed one of the peptides with a different chemical formual and replaced it with a mod that has the same chemical formula as the remaining original best peptide //Here we have a situation where there are two mods at the same position have the same chemical formuala and they can be resolved and so the return value the chemical formual of the mod. - Assert.AreEqual("C", myPsm.ModsChemicalFormula.Formula.ToString()); + Assert.That(myPsm.ModsChemicalFormula.Formula.ToString(), Is.EqualTo("C")); myPsmString = myPsm.ToString(); myPsmStringSplit = myPsmString.Split('\t'); ppmErrorString = myPsmStringSplit[24]; - Assert.AreEqual("0.00000", ppmErrorString); + Assert.That(ppmErrorString, Is.EqualTo("0.00000")); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/PsvTsvTest.cs b/MetaMorpheus/Test/PsvTsvTest.cs index c4c17e0aa..6162f55c5 100644 --- a/MetaMorpheus/Test/PsvTsvTest.cs +++ b/MetaMorpheus/Test/PsvTsvTest.cs @@ -1,7 +1,7 @@ using EngineLayer; using GuiFunctions; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Omics.Digestion; using Omics.Fragmentation; using Omics.Modifications; @@ -24,7 +24,7 @@ public static void ReadOGlycoSinglePsms() { string psmFile = @"TestData\oglycoSinglePsms.psmtsv"; List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(2, parsedPsms.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(2)); } [Test] @@ -32,7 +32,7 @@ public static void ReadOGlycoPsms() { string psmFile = @"TestData\oglyco.psmtsv"; List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(9, parsedPsms.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(9)); } [Test] @@ -40,7 +40,7 @@ public static void ReadExcelEditedPsms() { string psmFile = @"TestData\ExcelEditedPeptide.psmtsv"; List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(1, parsedPsms.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(1)); IEnumerable expectedIons = new string[] { "y3+1", "y4+1", "b4+1", "b5+1", "b6+1", "b8+1" }; Assert.That(6 == parsedPsms[0].MatchedIons.Select(p => p.Annotation).Intersect(expectedIons).Count()); Assert.That("TADDYTWEGDVGNDNAYQKFVK", Is.EqualTo(parsedPsms[0].FullSequence)); @@ -62,7 +62,7 @@ public static void CrosslinkPsmFromTsvTest() { string psmFile = @"XlTestData\XL_Intralinks_MIons.tsv"; List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(1, parsedPsms.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(1)); Assert.That(parsedPsms[0].UniqueSequence, Is.EqualTo("EKVLTSSAR(2)SLGKVGTR(4)")); } @@ -75,8 +75,8 @@ public static void CrosslinkPsmFromTsvToLibrarySpectrumTest() Assert.That(warnings.Count == 0); CrosslinkLibrarySpectrum librarySpectrum = psms[0].ToLibrarySpectrum() as CrosslinkLibrarySpectrum; - Assert.IsNotNull(librarySpectrum); - Assert.AreEqual("Name: EKVLTSSAR(2)SLGKVGTR(4)/4", librarySpectrum.ToString().Split('\n')[0].Trim()); + Assert.That(librarySpectrum, !Is.Null); + Assert.That(librarySpectrum.ToString().Split('\n')[0].Trim(), Is.EqualTo("Name: EKVLTSSAR(2)SLGKVGTR(4)/4")); // This test would be better if MatchedIon.equals method worked, but it breaks because the mz comparison is implemented incorrectly. CollectionAssert.AreEquivalent(librarySpectrum.MatchedFragmentIons.Select(ion => ion.Annotation), psms[0].MatchedIons.Select(ion => ion.Annotation)); @@ -241,8 +241,7 @@ public static void TestSimpleToLibrarySpectrum() string expectedLibrarySpectrum = File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TopDownTestData\simple.msp")); //not a great way to test equality but we are experiencing a great deal of 10th digit rounding differences - Assert.AreEqual(Regex.Matches(expectedLibrarySpectrum, "ppm").Count, Regex.Matches(librarySpectrum, "ppm").Count); - + Assert.That(Regex.Matches(expectedLibrarySpectrum, "ppm").Count, Is.EqualTo(Regex.Matches(librarySpectrum, "ppm").Count)); //the code below tests the addition and correct output for neutral loss fragments Product p = new Product(ProductType.bWaterLoss, FragmentationTerminus.N, 1, 1, 1, 18); @@ -329,24 +328,24 @@ public static void TestPsmSortFunction() List orderedPsms = psms.OrderByDescending(p => p).ToList(); - Assert.AreEqual(10, orderedPsms[0].Score); - Assert.AreEqual(9, orderedPsms[1].Score); - Assert.AreEqual(9, orderedPsms[2].Score); - Assert.AreEqual(8, orderedPsms[3].Score); - Assert.AreEqual(8, orderedPsms[4].Score); - Assert.AreEqual(7, orderedPsms[5].Score); - Assert.AreEqual(7, orderedPsms[6].Score); - - Assert.AreEqual(5, orderedPsms[0].RunnerUpScore); - Assert.AreEqual(8.9, orderedPsms[1].RunnerUpScore); - Assert.AreEqual(8, orderedPsms[2].RunnerUpScore); - Assert.AreEqual(7, orderedPsms[3].RunnerUpScore); - Assert.AreEqual(7, orderedPsms[4].RunnerUpScore); - Assert.AreEqual(6, orderedPsms[5].RunnerUpScore); - Assert.AreEqual(6, orderedPsms[6].RunnerUpScore); - - Assert.IsTrue(Math.Abs(orderedPsms[3].PrecursorMassErrorPpm.First()) < Math.Abs(orderedPsms[4].PrecursorMassErrorPpm.First())); - Assert.IsTrue(orderedPsms[5].ScanNumber < orderedPsms[6].ScanNumber); + Assert.That(orderedPsms[0].Score, Is.EqualTo(10)); + Assert.That(orderedPsms[1].Score, Is.EqualTo(9)); + Assert.That(orderedPsms[2].Score, Is.EqualTo(9)); + Assert.That(orderedPsms[3].Score, Is.EqualTo(8)); + Assert.That(orderedPsms[4].Score, Is.EqualTo(8)); + Assert.That(orderedPsms[5].Score, Is.EqualTo(7)); + Assert.That(orderedPsms[6].Score, Is.EqualTo(7)); + + Assert.That(orderedPsms[0].RunnerUpScore, Is.EqualTo(5)); + Assert.That(orderedPsms[1].RunnerUpScore, Is.EqualTo(8.9)); + Assert.That(orderedPsms[2].RunnerUpScore, Is.EqualTo(8)); + Assert.That(orderedPsms[3].RunnerUpScore, Is.EqualTo(7)); + Assert.That(orderedPsms[4].RunnerUpScore, Is.EqualTo(7)); + Assert.That(orderedPsms[5].RunnerUpScore, Is.EqualTo(6)); + Assert.That(orderedPsms[6].RunnerUpScore, Is.EqualTo(6)); + + Assert.That(Math.Abs(orderedPsms[3].PrecursorMassErrorPpm.First()) < Math.Abs(orderedPsms[4].PrecursorMassErrorPpm.First())); + Assert.That(orderedPsms[5].ScanNumber < orderedPsms[6].ScanNumber); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/RetentionTimeTest.cs b/MetaMorpheus/Test/RetentionTimeTest.cs index 006f9a760..8aa915726 100644 --- a/MetaMorpheus/Test/RetentionTimeTest.cs +++ b/MetaMorpheus/Test/RetentionTimeTest.cs @@ -1,5 +1,4 @@ -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; -using Proteomics; +using NUnit.Framework; using Proteomics.ProteolyticDigestion; using Proteomics.RetentionTimePrediction; using System.Collections.Generic; diff --git a/MetaMorpheus/Test/RobTest.cs b/MetaMorpheus/Test/RobTest.cs index 11f01df6a..afbfa0b0b 100644 --- a/MetaMorpheus/Test/RobTest.cs +++ b/MetaMorpheus/Test/RobTest.cs @@ -2,7 +2,7 @@ using EngineLayer; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -127,13 +127,13 @@ public static void TestParsimony() List parsimonyProteinSequences = psms.SelectMany(p => p.BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide.Parent)).Select(v => v.BaseSequence).Distinct().ToList(); // check that correct proteins are in parsimony list - Assert.Contains("AB--------", parsimonyProteinSequences); - Assert.Contains("--C-------", parsimonyProteinSequences); - Assert.Contains("-B-D---HHH--", parsimonyProteinSequences); - Assert.Contains("-B------I-", parsimonyProteinSequences); - Assert.Contains("----EFG---", parsimonyProteinSequences); - Assert.Contains("----EFG--J", parsimonyProteinSequences); - Assert.AreEqual(6, parsimonyProteinSequences.Count); + Assert.That(parsimonyProteinSequences.Contains("AB--------")); + Assert.That(parsimonyProteinSequences.Contains("--C-------")); + Assert.That(parsimonyProteinSequences.Contains("-B-D---HHH--")); + Assert.That(parsimonyProteinSequences.Contains("-B------I-")); + Assert.That(parsimonyProteinSequences.Contains("----EFG---")); + Assert.That(parsimonyProteinSequences.Contains("----EFG--J")); + Assert.That(parsimonyProteinSequences.Count, Is.EqualTo(6)); // sequence coverage test foreach (var proteinGroup in proteinGroups) @@ -145,11 +145,11 @@ public static void TestParsimony() } // test protein groups - Assert.AreEqual(4, proteinGroups.Count); - Assert.AreEqual(1, proteinGroups.First().Proteins.Count); - Assert.AreEqual("AB--------", proteinGroups.First().Proteins.First().BaseSequence); - Assert.AreEqual(2, proteinGroups.First().AllPsmsBelowOnePercentFDR.Count); - Assert.AreEqual(2, proteinGroups.First().ProteinGroupScore); + Assert.That(proteinGroups.Count, Is.EqualTo(4)); + Assert.That(proteinGroups.First().Proteins.Count, Is.EqualTo(1)); + Assert.That(proteinGroups.First().Proteins.First().BaseSequence, Is.EqualTo("AB--------")); + Assert.That(proteinGroups.First().AllPsmsBelowOnePercentFDR.Count, Is.EqualTo(2)); + Assert.That(proteinGroups.First().ProteinGroupScore, Is.EqualTo(2)); } [Test] @@ -179,25 +179,25 @@ public static void TestPTMOutput() int idx = 0; var pep1 = new HashSet { protDigest[idx++] }; - Assert.AreEqual("MNNNSK", pep1.Single().FullSequence);//this might be base + Assert.That(pep1.Single().FullSequence, Is.EqualTo("MNNNSK"));//this might be base var pep1mod = new HashSet { protDigest[idx++] }; - Assert.AreEqual("MNNNS[HaHa:resMod on S]K", pep1mod.Single().FullSequence);//this might be base + Assert.That(pep1mod.Single().FullSequence, Is.EqualTo("MNNNS[HaHa:resMod on S]K"));//this might be base var pep3 = new HashSet { protDigest[idx++] }; - Assert.AreEqual("NNNSK", pep3.Single().FullSequence);//this might be base + Assert.That(pep3.Single().FullSequence, Is.EqualTo("NNNSK"));//this might be base var pep3mod = new HashSet { protDigest[idx++] }; - Assert.AreEqual("NNNS[HaHa:resMod on S]K", pep3mod.Single().FullSequence);//this might be base + Assert.That(pep3mod.Single().FullSequence, Is.EqualTo("NNNS[HaHa:resMod on S]K"));//this might be base var pep4 = new HashSet { protDigest[idx++] }; - Assert.AreEqual("QQQI", pep4.Single().FullSequence);//this might be base + Assert.That(pep4.Single().FullSequence, Is.EqualTo("QQQI"));//this might be base var pep4mod1 = new HashSet { protDigest[idx++] }; - Assert.AreEqual("QQQI[HaHa:iModOne on I]", pep4mod1.Single().FullSequence);//this might be base + Assert.That(pep4mod1.Single().FullSequence, Is.EqualTo("QQQI[HaHa:iModOne on I]"));//this might be base var pep4mod2 = new HashSet { protDigest[idx++] }; - Assert.AreEqual("QQQI[HaHa:iModTwo on I]", pep4mod2.Single().FullSequence);//this might be base + Assert.That(pep4mod2.Single().FullSequence, Is.EqualTo("QQQI[HaHa:iModTwo on I]"));//this might be base var peptideList = new HashSet(); foreach (var peptide in proteinList.SelectMany(protein => protein.Digest(commonParameters.DigestionParams, new List(), variableModifications))) @@ -252,7 +252,7 @@ public static void TestPTMOutput() ProteinScoringAndFdrEngine f = new ProteinScoringAndFdrEngine(proteinGroups, psms, false, false, true, new CommonParameters(), null, new List()); f.Run(); - Assert.AreEqual("#aa5[resMod on S,info:occupancy=0.67(2/3)];#aa10[iModOne on I,info:occupancy=0.33(2/6)];#aa10[iModTwo on I,info:occupancy=0.33(2/6)]", proteinGroups.First().ModsInfo[0]); + Assert.That(proteinGroups.First().ModsInfo[0], Is.EqualTo("#aa5[resMod on S,info:occupancy=0.67(2/3)];#aa10[iModOne on I,info:occupancy=0.33(2/6)];#aa10[iModTwo on I,info:occupancy=0.33(2/6)]")); } [Test] diff --git a/MetaMorpheus/Test/SearchEngineTests.cs b/MetaMorpheus/Test/SearchEngineTests.cs index 7c3c089a1..8e36405c0 100644 --- a/MetaMorpheus/Test/SearchEngineTests.cs +++ b/MetaMorpheus/Test/SearchEngineTests.cs @@ -7,7 +7,7 @@ using MassSpectrometry; using MzLibUtil; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.AminoAcidPolymer; using Omics.Fragmentation; @@ -53,15 +53,15 @@ public static void TestClassicSearchEngine() proteinList, searchModes, CommonParameters, null, null, new List(), writeSpectralLibrary).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // One scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual("QQQ", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQ")); } [Test] @@ -87,40 +87,40 @@ public static void TestSearchEngineResultsPsmFromTsv() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); PsmFromTsv psm = parsedPsms.First(); - Assert.AreEqual("FTQTSGETTDADKEPAGEDK", psm.BaseSeq); - Assert.AreEqual("T", psm.DecoyContamTarget); - Assert.AreEqual(541.386, psm.DeltaScore); - Assert.AreEqual("FTQTSGETTDADKEPAGEDK", psm.EssentialSeq); - Assert.AreEqual("TaGe_SA_A549_3_snip", psm.FileNameWithoutExtension); - Assert.AreEqual("FTQTSGETTDADKEPAGEDK", psm.FullSequence); - Assert.AreEqual("primary:MKI67", psm.GeneName); - Assert.AreEqual("", psm.IdentifiedSequenceVariations); - Assert.AreEqual("-0.00544", psm.MassDiffDa); - Assert.AreEqual("-2.56000", psm.MassDiffPpm); - Assert.AreEqual(40, psm.MatchedIons.Count); - Assert.AreEqual("1", psm.MissedCleavage); - Assert.AreEqual(56, psm.Ms2ScanNumber); - Assert.AreEqual("G", psm.NextAminoAcid); - Assert.AreEqual("0", psm.Notch); - Assert.AreEqual("Homo sapiens", psm.OrganismName); + Assert.That(psm.BaseSeq, Is.EqualTo("FTQTSGETTDADKEPAGEDK")); + Assert.That(psm.DecoyContamTarget, Is.EqualTo("T")); + Assert.That(psm.DeltaScore, Is.EqualTo(541.386)); + Assert.That(psm.EssentialSeq, Is.EqualTo("FTQTSGETTDADKEPAGEDK")); + Assert.That(psm.FileNameWithoutExtension, Is.EqualTo("TaGe_SA_A549_3_snip")); + Assert.That(psm.FullSequence, Is.EqualTo("FTQTSGETTDADKEPAGEDK")); + Assert.That(psm.GeneName, Is.EqualTo("primary:MKI67")); + Assert.That(psm.IdentifiedSequenceVariations, Is.EqualTo("")); + Assert.That(psm.MassDiffDa, Is.EqualTo("-0.00544")); + Assert.That(psm.MassDiffPpm, Is.EqualTo("-2.56000")); + Assert.That(psm.MatchedIons.Count, Is.EqualTo(40)); + Assert.That(psm.MissedCleavage, Is.EqualTo("1")); + Assert.That(psm.Ms2ScanNumber, Is.EqualTo(56)); + Assert.That(psm.NextAminoAcid, Is.EqualTo("G")); + Assert.That(psm.Notch, Is.EqualTo("0")); + Assert.That(psm.OrganismName, Is.EqualTo("Homo sapiens")); Assert.That(0, Is.EqualTo(psm.PEP).Within(1E-04)); Assert.That(0.005, Is.EqualTo(psm.PEP_QValue).Within(1E-03)); - Assert.AreEqual("full", psm.PeptideDescription); - Assert.AreEqual("2125.92875", psm.PeptideMonoMass); - Assert.AreEqual(3, psm.PrecursorCharge); - Assert.AreEqual(2125.92331, psm.PrecursorMass); - Assert.AreEqual(709.64838, psm.PrecursorMz); - Assert.AreEqual(49, psm.PrecursorScanNum); - Assert.AreEqual("K", psm.PreviousAminoAcid); - Assert.AreEqual("P46013", psm.ProteinAccession); - Assert.AreEqual("Proliferation marker protein Ki-67", psm.ProteinName); + Assert.That(psm.PeptideDescription, Is.EqualTo("full")); + Assert.That(psm.PeptideMonoMass, Is.EqualTo("2125.92875")); + Assert.That(psm.PrecursorCharge, Is.EqualTo(3)); + Assert.That(psm.PrecursorMass, Is.EqualTo(2125.92331)); + Assert.That(psm.PrecursorMz, Is.EqualTo(709.64838)); + Assert.That(psm.PrecursorScanNum, Is.EqualTo(49)); + Assert.That(psm.PreviousAminoAcid, Is.EqualTo("K")); + Assert.That(psm.ProteinAccession, Is.EqualTo("P46013")); + Assert.That(psm.ProteinName, Is.EqualTo("Proliferation marker protein Ki-67")); Assert.That(0.004739, Is.EqualTo(psm.QValue).Within(1E-04)); Assert.That(0.004739, 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); - Assert.AreEqual(159644.25225, psm.TotalIonCurrent); - Assert.AreEqual(0, psm.VariantCrossingIons.Count); + Assert.That(psm.RetentionTime, Is.EqualTo(45.59512)); + Assert.That(psm.Score, Is.EqualTo(662.486)); + Assert.That(psm.StartAndEndResiduesInProtein, Is.EqualTo("[2742 to 2761]")); + Assert.That(psm.TotalIonCurrent, Is.EqualTo(159644.25225)); + Assert.That(psm.VariantCrossingIons.Count, Is.EqualTo(0)); property.SetValue(null, false); } @@ -150,12 +150,12 @@ public static void TestClassicSearchXcorrWithToml() List parsedPsms = PsmTsvReader.ReadTsv(psmFile, out var warnings); - Assert.AreEqual(385, parsedPsms.Count); //total psm count - Assert.AreEqual(218, parsedPsms.Count(p => p.QValue < 0.01)); //psms with q-value < 0.01 as read from psmtsv, including decoys - Assert.AreEqual(0, warnings.Count); + Assert.That(parsedPsms.Count, Is.EqualTo(385)); //total psm count + Assert.That(parsedPsms.Count(p => p.QValue < 0.01), Is.EqualTo(218)); //psms with q-value < 0.01 as read from psmtsv, including decoys + Assert.That(warnings.Count, Is.EqualTo(0)); - int countFromResultsTxt = Convert.ToInt32(File.ReadAllLines(Path.Combine(outputFolder, @"SearchTOML\results.txt")).ToList().FirstOrDefault(l=>l.Contains("All target")).Split(":")[1].Trim()); - Assert.AreEqual(216, countFromResultsTxt); + int countFromResultsTxt = Convert.ToInt32(File.ReadAllLines(Path.Combine(outputFolder, @"SearchTOML\results.txt")).ToList().FirstOrDefault(l => l.Contains("All target")).Split(":")[1].Trim()); + Assert.That(countFromResultsTxt, Is.EqualTo(216)); } [Test] @@ -237,7 +237,7 @@ public static void TestProcessXcorrInMzSpectrumSlicedB6() var scans = MyMsDataFiles[origDataFile].GetAllScansList(); - Assert.AreEqual(912, scans[1].MassSpectrum.XArray.Count()); + Assert.That(scans[1].MassSpectrum.XArray.Count(), Is.EqualTo(912)); Assert.That(200.33052062988281, Is.EqualTo(scans[1].MassSpectrum.XArray[0]).Within(0.00001)); foreach (MsDataScan scan in scans.Where(s => s.MsnOrder > 1)) @@ -250,13 +250,13 @@ public static void TestProcessXcorrInMzSpectrumSlicedB6() scan.MassSpectrum.XCorrPrePreprocessing(0, 1969, scan.IsolationMz.Value); } - Assert.IsTrue(scans[1].MassSpectrum.XcorrProcessed); - Assert.AreEqual(220, scans[1].MassSpectrum.XArray.Count()); + Assert.That(scans[1].MassSpectrum.XcorrProcessed); + Assert.That(scans[1].MassSpectrum.XArray.Count(), Is.EqualTo(220)); Assert.That(201.1020879, Is.EqualTo(scans[1].MassSpectrum.XArray[0]).Within(0.00001)); var bubba = scans[239]; - Assert.AreEqual(459, bubba.MassSpectrum.XArray.Count()); + Assert.That(bubba.MassSpectrum.XArray.Count(), Is.EqualTo(459)); Assert.That(201.102, Is.EqualTo(bubba.MassSpectrum.XArray[0]).Within(0.01)); Assert.That(203.1031037, Is.EqualTo(bubba.MassSpectrum.XArray[1]).Within(0.01)); } @@ -295,7 +295,7 @@ public static void TestClassicSearchEngineXcorr() new ClassicSearchEngine(allPsmsArray, listOfSortedXcorrms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, null, null, new List(), writeSpectralLibrary).Run(); - Assert.IsTrue(listOfSortedXcorrms2Scans[0].TheScan.MassSpectrum.XcorrProcessed); + Assert.That(listOfSortedXcorrms2Scans[0].TheScan.MassSpectrum.XcorrProcessed); List expectedXarray = copyOflistOfSortedXcorrms2Scans[0].TheScan.MassSpectrum.XArray.ToList(); List expectedYarray = copyOflistOfSortedXcorrms2Scans[0].TheScan.MassSpectrum.XArray.ToList(); @@ -307,20 +307,20 @@ public static void TestClassicSearchEngineXcorr() Assert.That(expectedXarray.SequenceEqual(processedXarray)); Assert.That(expectedYarray.SequenceEqual(processedYarray)); - Assert.AreEqual(5, allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.b).ToList().Count); - Assert.AreEqual(5, allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.bWaterLoss).ToList().Count); - Assert.AreEqual(6, allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.y).ToList().Count); - Assert.AreEqual(6, allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.yWaterLoss).ToList().Count); + Assert.That(allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.b).ToList().Count, Is.EqualTo(5)); + Assert.That(allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.bWaterLoss).ToList().Count, Is.EqualTo(5)); + Assert.That(allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.y).ToList().Count, Is.EqualTo(6)); + Assert.That(allPsmsArray[0].MatchedFragmentIons.Where(p => p.NeutralTheoreticalProduct.ProductType == ProductType.yWaterLoss).ToList().Count, Is.EqualTo(6)); - Assert.AreEqual(518.2, Math.Round(allPsmsArray[0].Score, 1)); + Assert.That(Math.Round(allPsmsArray[0].Score, 1), Is.EqualTo(518.2)); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // One scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].Score > 1); } [Test] @@ -349,15 +349,15 @@ public static void TestClassicSearchEngineWithWeirdPeptide() proteinList, searchModes, CommonParameters, null, null, new List(), writeSpectralLibrary).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // One Scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual("QXQ", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QXQ")); } [Test] @@ -394,16 +394,16 @@ public static void TestModernSearchEngine() new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); Assert.That(allPsmsArray[0] != null); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual("QQQ", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQ")); } [Test] @@ -448,16 +448,16 @@ public static void TestModernSearchEngineLowResTrivial() new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); Assert.That(allPsmsArray[0] != null); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual("QQQ", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQ")); } [Test] @@ -489,7 +489,7 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() foreach (var scan in myMsDataFile.GetAllScansList().Where(p => p.MsnOrder > 1)) { - Assert.AreEqual(984, scan.MassSpectrum.XArray.Count()); + Assert.That(scan.MassSpectrum.XArray.Count(), Is.EqualTo(984)); scan.MassSpectrum.XCorrPrePreprocessing(0, 1969, scan.IsolationMz.Value); } @@ -506,7 +506,7 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() var remainingMasses = listOfSortedms2Scans[0].TheScan.MassSpectrum.XArray; - Assert.AreEqual(195, listOfSortedms2Scans[0].TheScan.MassSpectrum.XArray.Count()); + Assert.That(listOfSortedms2Scans[0].TheScan.MassSpectrum.XArray.Count(), Is.EqualTo(195)); var mzs = listOfSortedms2Scans[0].TheScan.MassSpectrum.XArray.ToList(); List mzsRounded = new List(); @@ -521,7 +521,7 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() 650, 652, 655, 657, 658, 664, 670, 672, 674, 676, 679, 682, 688, 690, 691, 694, 697, 698, 700, 704, 708, 722, 745, 747, 755, 763, 765, 771, 772, 773, 782, 789, 795, 805, 809, 823, 828, 831, 839, 866, 867, 868, 874, 876, 885, 886, 906, 914, 916, 924, 951, 959, 965, 966, 973, 977, 982, 983, 988, 996, 1006, 1023, 1024, 1040, 1041, 1137, 1152, 1170}; - Assert.AreEqual(mzsExpected, mzsRounded); + Assert.That(mzsRounded, Is.EqualTo(mzsExpected)); Ms2ScanWithSpecificMass[] losm2 = listOfSortedms2Scans.Where(mass => mass.PrecursorMass > 1410 && mass.PrecursorMass < 1411).ToArray(); @@ -542,7 +542,7 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() 570290, 571290, 576293, 588299, 604307, 622316, 671341, 672341, 675343, 689350, 703357, 721366, 770391, 771392, 776394, 788400, 804408, 822417, 867440, 868441, 877445, 885449, 905460, 923469, 964490, 965490, 976496, 982499, 1004510, 1021519, 1022519, 1039528, 1089553, 1117567, 1135576, 1150584, 1151585, 1168593, 1190604, 1218619, 1236628, 1279650, 1280650, 1297659}; - Assert.AreEqual(expectedIndicies, filledIndicies); + Assert.That(filledIndicies, Is.EqualTo(expectedIndicies)); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); @@ -557,17 +557,17 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() FdrAnalysisResults fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(nonNullPsms, 1, CommonParameters, fsp, new List()).Run()); // Single search mode - Assert.AreEqual(12, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(12)); var goodPsm = nonNullPsms.Where(p => p.FdrInfo.QValue <= 0.01).ToList(); var myMatchedIons = goodPsm[0].MatchedFragmentIons; - Assert.AreEqual(47, myMatchedIons.Count()); + Assert.That(myMatchedIons.Count(), Is.EqualTo(47)); var goodScore = nonNullPsms.Where(p => p.FdrInfo.QValue <= 0.01).Select(s => s.Score).ToList(); goodScore.Sort(); - Assert.AreEqual(2, goodPsm.Count()); + Assert.That(goodPsm.Count(), Is.EqualTo(2)); } [Test] @@ -609,11 +609,11 @@ public static void TestClassicSearchEngineLowResSimple() Ms2ScanWithSpecificMass[] arrayOfMs2ScansSortedByMass = MetaMorpheusTask.GetMs2Scans(myMsDataFile, origDataFile, CommonParameters).OrderBy(b => b.PrecursorMass).ToArray(); - Assert.AreEqual(535, arrayOfMs2ScansSortedByMass.Count()); + Assert.That(arrayOfMs2ScansSortedByMass.Count(), Is.EqualTo(535)); int numSpectra = myMsDataFile.GetAllScansList().Count(p => p.MsnOrder == 2); - Assert.AreEqual(147, numSpectra); + Assert.That(numSpectra, Is.EqualTo(147)); SpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; @@ -650,7 +650,7 @@ public static void TestClassicSearchEngineLowResSimple() var listOfSortedXcorrms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, origDataFile, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - Assert.AreEqual(535, listOfSortedXcorrms2Scans.Count()); + Assert.That(listOfSortedXcorrms2Scans.Count(), Is.EqualTo(535)); SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedXcorrms2Scans.Length]; @@ -658,20 +658,20 @@ public static void TestClassicSearchEngineLowResSimple() fsp.Add(("sliced_b6.mzML", CommonParameters)); bool writeSpectralLibrary = false; - new ClassicSearchEngine(allPsmsArray, listOfSortedXcorrms2Scans, variableModifications, fixedModifications, null, null, null, + new ClassicSearchEngine(allPsmsArray, listOfSortedXcorrms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List(), writeSpectralLibrary).Run(); var nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); - Assert.AreEqual(432, nonNullPsms.Count); //if you run the test separately, it will be 111 because mods won't have been read in a previous test... + Assert.That(nonNullPsms.Count, Is.EqualTo(432)); //if you run the test separately, it will be 111 because mods won't have been read in a previous test... FdrAnalysisResults fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(nonNullPsms, 1, CommonParameters, fsp, new List()).Run()); // Single search mode - Assert.AreEqual(535, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(535)); var goodScore = nonNullPsms.Where(p => p.FdrInfo.QValue <= 0.01).Select(s => s.Score).ToList(); - Assert.AreEqual(181, goodScore.Count()); + Assert.That(goodScore.Count(), Is.EqualTo(181)); Directory.Delete(outputFolder, true); property.SetValue(null, false); } @@ -767,11 +767,11 @@ public static void TestModernSearchEngineLowResSimple() EngineLayer.FdrAnalysis.FdrAnalysisResults fdrResultsModernDelta = (EngineLayer.FdrAnalysis.FdrAnalysisResults)(new EngineLayer.FdrAnalysis.FdrAnalysisEngine(nonNullPsms, 1, CommonParameters, fsp, new List()).Run()); // Single search mode - Assert.AreEqual(535, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(535)); var goodScore = nonNullPsms.Where(p => p.FdrInfo.QValue <= 0.01).Select(s => s.Score).ToList(); - Assert.AreEqual(181, goodScore.Count()); + Assert.That(goodScore.Count(), Is.EqualTo(181)); property.SetValue(null, false); } @@ -892,16 +892,16 @@ public static void TestModernSearchEngineWithWeirdPeptide() var searchResults = engine.Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); Assert.That(allPsmsArray[0] != null); - Assert.IsTrue(allPsmsArray[0].Score > 1); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 1); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); - Assert.AreEqual(3, allPsmsArray[0].NumDifferentMatchingPeptides); + Assert.That(allPsmsArray[0].NumDifferentMatchingPeptides, Is.EqualTo(3)); } [Test] @@ -963,20 +963,20 @@ public static void TestNonSpecificEnzymeSearchEngineSingleN() new NonSpecificEnzymeSearchEngine(allPsmsArrays, listOfSortedms2Scans, coisolationIndex, peptideIndex, fragmentIndexDict, fragmentIndexDict, 0, CommonParameters, null, variableModifications, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 4); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 4); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); CommonParameters = new CommonParameters( digestionParams: new DigestionParams("singleN", minPeptideLength: 1), precursorMassTolerance: new PpmTolerance(5), scoreCutoff: 1); allPsmsArray[0].ResolveAllAmbiguities(); - Assert.AreEqual("QQQGGGG", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQGGGG")); } @@ -1039,20 +1039,20 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNLowCID() new NonSpecificEnzymeSearchEngine(allPsmsArrays, listOfSortedms2Scans, coisolationIndex, peptideIndex, fragmentIndexDict, fragmentIndexDict, 0, CommonParameters, null, variableModifications, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 4); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 4); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); CommonParameters = new CommonParameters( digestionParams: new DigestionParams("singleN", minPeptideLength: 1), precursorMassTolerance: new PpmTolerance(5), scoreCutoff: 1); allPsmsArray[0].ResolveAllAmbiguities(); - Assert.AreEqual("QQQGGGG", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQGGGG")); } @@ -1119,7 +1119,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleCModifications() allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is no modification hanging out on the n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); proteinList = new List { new Protein("CDQPKLLGIETPLPKKEGGGGG", null) }; guiltyPwsm = new PeptideWithSetModifications("C[Common Fixed:Carbamidomethyl on C]DQPKLLGIETPLPKKE", new Dictionary { { "Carbamidomethyl on C", mod2 } }); @@ -1145,7 +1145,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleCModifications() searchResults = engine.Run(); allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is a modification hanging out on the protein n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); proteinList = new List { new Protein("GGGGGCDQPKLLGIETPLPKKEGG", null) }; indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.None, CommonParameters, @@ -1160,7 +1160,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleCModifications() searchResults = engine.Run(); allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is a modification hanging out on the peptide n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); } [Test] @@ -1225,7 +1225,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNModifications() allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is no modification hanging out on the n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); proteinList = new List { new Protein("GGGGGDQPKLLGIETPLPKKEC", null) }; guiltyPwsm = new PeptideWithSetModifications("GGDQPKLLGIETPLPKKEC[Common Fixed:Carbamidomethyl on C]", new Dictionary { { "Carbamidomethyl on C", mod2 } }); @@ -1252,7 +1252,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNModifications() searchResults = engine.Run(); allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is a modification hanging out on the protein n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); proteinList = new List { new Protein("GGDQPKLLGIETPLPKKECGGGGG", null) }; indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.None, CommonParameters, @@ -1267,7 +1267,7 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNModifications() searchResults = engine.Run(); allPsmsArray[0].ResolveAllAmbiguities(); //Check that there is a modification hanging out on the peptide n-terminus - Assert.AreEqual(allPsmsArray[0].FullSequence, guiltyPwsm.FullSequence); + Assert.That(allPsmsArray[0].FullSequence, Is.EqualTo(guiltyPwsm.FullSequence)); } [Test] @@ -1301,7 +1301,7 @@ public static void TestSnesFifteenMer() NonSpecificEnzymeSearchEngine searchEngine = new NonSpecificEnzymeSearchEngine(allPsmsArrays, listOfSortedms2Scans, coisolationIndex, indexingResults.PeptideIndex, indexingResults.FragmentIndex, indexingResults.PrecursorIndex, 1, cp, null, null, massDiffAcceptor, 0, new List()); searchEngine.Run(); - Assert.IsTrue(allPsmsArrays[2][0] != null); + Assert.That(allPsmsArrays[2][0] != null); } [Test] @@ -1369,16 +1369,16 @@ public static void TestNonSpecificEnzymeSearchEngineSingleC() var searchResults = engine.Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); //Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); Assert.That(allPsmsArray[0] != null); - Assert.IsTrue(allPsmsArray[0].Score > 7); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 7); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); allPsmsArray[0].ResolveAllAmbiguities(); - Assert.AreEqual("QQQGGGG", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQGGGG")); } [Test] @@ -1405,11 +1405,11 @@ public static void TestNonSpecificEnzymeVariableModificationHandlingNTerm() var variableModifications = new List { new Modification(_originalId: "16", _target: motifM, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.994915) }; DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 5, maxModsForPeptides: 3); var ListOfModifiedPeptides = protein.Digest(digestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(ListOfModifiedPeptides.Count, 192); + Assert.That(ListOfModifiedPeptides.Count, Is.EqualTo(192)); var protein2 = new Protein(new string("MGGGGGMNNNKQQQMGGGGMGM".ToCharArray().Reverse().ToArray()), "TestProtein"); var ListOfModifiedPeptides2 = protein2.Digest(digestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(ListOfModifiedPeptides2.Count, 132); + Assert.That(ListOfModifiedPeptides2.Count, Is.EqualTo(132)); } [Test] @@ -1435,11 +1435,11 @@ public static void TestNonSpecificEnzymeVariableModificationHandlingCTerm() var variableModifications = new List { new Modification(_originalId: "16", _target: motifM, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.994915) }; DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 5, maxModsForPeptides: 3); var ListOfModifiedPeptides = protein.Digest(digestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(ListOfModifiedPeptides.Count, 132); + Assert.That(ListOfModifiedPeptides.Count, Is.EqualTo(132)); var protein2 = new Protein(new string("MGGGGGMNNNKQQQMGGGGMGM".ToCharArray().Reverse().ToArray()), "TestProtein"); var ListOfModifiedPeptides2 = protein2.Digest(digestionParams, new List(), variableModifications).ToList(); - Assert.AreEqual(ListOfModifiedPeptides2.Count, 192); + Assert.That(ListOfModifiedPeptides2.Count, Is.EqualTo(192)); } [Test] @@ -1511,15 +1511,15 @@ public static void TestSemiSpecificEnzymeEngineSingleN() var searchResults = engine.Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 4); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 4); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); allPsmsArray[0].ResolveAllAmbiguities(); - Assert.AreEqual("QQQGGGG", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQGGGG")); } [Test] @@ -1586,15 +1586,15 @@ public static void TestSemiSpecificEnzymeEngineSingleC() var searchResults = engine.Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray.Length); + Assert.That(allPsmsArray.Length, Is.EqualTo(1)); - Assert.IsTrue(allPsmsArray[0].Score > 4); - Assert.AreEqual(2, allPsmsArray[0].ScanNumber); + Assert.That(allPsmsArray[0].Score > 4); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(2)); allPsmsArray[0].ResolveAllAmbiguities(); - Assert.AreEqual("QQQGGGG", allPsmsArray[0].BaseSequence); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo("QQQGGGG")); } [Test] @@ -1675,20 +1675,20 @@ public static void TestClassicSemiProtease() new ClassicSearchEngine(allPsmsArray2, listOfSortedms2Scans2, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters2, null, null, new List(), writeSpectralLibrary).Run(); // Single search mode - Assert.AreEqual(1, allPsmsArray2.Length); - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray2.Length, Is.EqualTo(1)); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); // Single ms2 scan - Assert.AreEqual(1, allPsmsArray2.Length); - Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); + Assert.That(allPsmsArray2.Length, Is.EqualTo(1)); + Assert.That(allPsmsArray.Length, Is.EqualTo(allPsmsArray2.Length)); - Assert.IsTrue(allPsmsArray2[0].Score > 4); - Assert.IsTrue(allPsmsArray[0].Score > 4); - Assert.AreEqual(2, allPsmsArray2[0].ScanNumber); - Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); + Assert.That(allPsmsArray2[0].Score > 4); + Assert.That(allPsmsArray[0].Score > 4); + Assert.That(allPsmsArray2[0].ScanNumber, Is.EqualTo(2)); + Assert.That(allPsmsArray[0].ScanNumber, Is.EqualTo(allPsmsArray2[0].ScanNumber)); - Assert.AreEqual("QQQGGGG", allPsmsArray2[0].BaseSequence); - Assert.AreEqual(allPsmsArray[0].BaseSequence, allPsmsArray2[0].BaseSequence); + Assert.That(allPsmsArray2[0].BaseSequence, Is.EqualTo("QQQGGGG")); + Assert.That(allPsmsArray[0].BaseSequence, Is.EqualTo(allPsmsArray2[0].BaseSequence)); } [Test] @@ -1745,7 +1745,7 @@ public static void TestClassicSemiProteolysis() } foreach (KeyValuePair kvp in found) { - Assert.IsTrue(kvp.Value); + Assert.That(kvp.Value); } } @@ -1805,7 +1805,7 @@ public static void TestClassicSearchOneNterminalModifiedPeptideOneScan() { massToCharges.Add(mass.ToMz(1)); } - Assert.AreEqual(20, massToCharges.Count()); + Assert.That(massToCharges.Count(), Is.EqualTo(20)); } [Test] @@ -1814,7 +1814,7 @@ public static void TestFileSpecificUpdateMaintainsSpecificProteaseForNonSpecific CommonParameters commonParams = new CommonParameters(digestionParams: new DigestionParams(protease: "Arg-C", searchModeType: CleavageSpecificity.None)); FileSpecificParameters fileSpecificParams = new FileSpecificParameters(); CommonParameters updatedCommonParams = MetaMorpheusTask.SetAllFileSpecificCommonParams(commonParams, fileSpecificParams); - Assert.AreEqual(updatedCommonParams.DigestionParams.SpecificProtease, commonParams.DigestionParams.SpecificProtease); + Assert.That(updatedCommonParams.DigestionParams.SpecificProtease, Is.EqualTo(commonParams.DigestionParams.SpecificProtease)); } [Test] @@ -1879,9 +1879,9 @@ public static void TestTerminalModificationsForSnes() for (int i = 0; i < listOfSortedms2Scans.Length; i++) { SpectralMatch testPsm = allPsmsArrays[2][i]; - Assert.IsTrue(testPsm != null); + Assert.That(testPsm != null); testPsm.ResolveAllAmbiguities(); - Assert.IsTrue(psmAnswer[1 - i].Equals(testPsm.FullSequence)); + Assert.That(psmAnswer[1 - i].Equals(testPsm.FullSequence)); } } } diff --git a/MetaMorpheus/Test/SearchModesTest.cs b/MetaMorpheus/Test/SearchModesTest.cs index 6e5e815f1..d1e014e31 100644 --- a/MetaMorpheus/Test/SearchModesTest.cs +++ b/MetaMorpheus/Test/SearchModesTest.cs @@ -1,6 +1,6 @@ using EngineLayer; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; @@ -14,12 +14,12 @@ public static class SearchModesTest public static void TestSearchModeTest() { MassDiffAcceptor sm = new TestSearchMode("My custom"); - Assert.IsTrue(sm.Accepts(2, 2) >= 0); - Assert.IsTrue(sm.Accepts(0.5, 4) >= 0); - Assert.IsFalse(sm.Accepts(0.5, 0.5) >= 0); - Assert.IsTrue(sm.Accepts(1, 1) >= 0); - Assert.AreEqual(2, sm.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(0.5).First().AllowedInterval.Minimum); - Assert.AreEqual(0.5, sm.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(2).First().AllowedInterval.Minimum); + Assert.That(sm.Accepts(2, 2) >= 0); + Assert.That(sm.Accepts(0.5, 4) >= 0); + Assert.That(!(sm.Accepts(0.5, 0.5) >= 0)); + Assert.That(sm.Accepts(1, 1) >= 0); + Assert.That(sm.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(0.5).First().AllowedInterval.Minimum, Is.EqualTo(2)); + Assert.That(sm.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(2).First().AllowedInterval.Minimum, Is.EqualTo(0.5)); } [Test] @@ -27,48 +27,48 @@ public static void TestDotSearchMode() { var dsm1 = new DotMassDiffAcceptor("test1", new double[] { 0, 1 }, new AbsoluteTolerance(0.1)); - Assert.IsTrue(dsm1.Accepts(1000, 1000) >= 0); - Assert.IsTrue(dsm1.Accepts(1000, 1000 + 0.1 / 2) >= 0); - Assert.IsFalse(dsm1.Accepts(1000, 1000 + 0.1 * 2) >= 0); - Assert.IsTrue(dsm1.Accepts(1000 + 0.1 / 2, 1000) >= 0); - Assert.IsFalse(dsm1.Accepts(1000 + 0.1 * 2, 1000) >= 0); + Assert.That(dsm1.Accepts(1000, 1000) >= 0); + Assert.That(dsm1.Accepts(1000, 1000 + 0.1 / 2) >= 0); + Assert.That(!(dsm1.Accepts(1000, 1000 + 0.1 * 2) >= 0)); + Assert.That(dsm1.Accepts(1000 + 0.1 / 2, 1000) >= 0); + Assert.That(!(dsm1.Accepts(1000 + 0.1 * 2, 1000) >= 0)); - Assert.IsTrue(dsm1.Accepts(1000 + 1, 1000 + 0.1 / 2) >= 0); - Assert.IsFalse(dsm1.Accepts(1000 + 1, 1000 + 0.1 * 2) >= 0); - Assert.IsTrue(dsm1.Accepts(1000 + 1 + 0.1 / 2, 1000) >= 0); - Assert.IsFalse(dsm1.Accepts(1000 + 1 + 0.1 * 2, 1000) >= 0); + Assert.That(dsm1.Accepts(1000 + 1, 1000 + 0.1 / 2) >= 0); + Assert.That(!(dsm1.Accepts(1000 + 1, 1000 + 0.1 * 2) >= 0)); + Assert.That(dsm1.Accepts(1000 + 1 + 0.1 / 2, 1000) >= 0); + Assert.That(!(dsm1.Accepts(1000 + 1 + 0.1 * 2, 1000) >= 0)); var theList = dsm1.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(100).ToList(); - Assert.AreEqual(99.9, theList[0].AllowedInterval.Minimum); - Assert.AreEqual(100.1, theList[0].AllowedInterval.Maximum); - Assert.AreEqual(100.9, theList[1].AllowedInterval.Minimum); - Assert.AreEqual(101.1, theList[1].AllowedInterval.Maximum); + Assert.That(theList[0].AllowedInterval.Minimum, Is.EqualTo(99.9)); + Assert.That(theList[0].AllowedInterval.Maximum, Is.EqualTo(100.1)); + Assert.That(theList[1].AllowedInterval.Minimum, Is.EqualTo(100.9)); + Assert.That(theList[1].AllowedInterval.Maximum, Is.EqualTo(101.1)); var dsm2 = new DotMassDiffAcceptor("test2", new double[] { 0, 1 }, new PpmTolerance(5)); - Assert.IsTrue(dsm2.Accepts(1000, 1000) >= 0); + Assert.That(dsm2.Accepts(1000, 1000) >= 0); - Assert.IsTrue(dsm2.Accepts(1000 * (1 + 5.0 / 1e6 / 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND - Assert.IsTrue(dsm2.Accepts(1000 * (1 - 5.0 / 1e6 / 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND + Assert.That(dsm2.Accepts(1000 * (1 + 5.0 / 1e6 / 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND + Assert.That(dsm2.Accepts(1000 * (1 - 5.0 / 1e6 / 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND - Assert.IsFalse(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 / 1.0000001)) >= 0); // VERY CAREFUL + Assert.That(!(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 / 1.0000001)) >= 0)); // VERY CAREFUL - Assert.IsFalse(dsm2.Accepts(1000 * (1 + 5.0 / 1e6 * 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND - Assert.IsFalse(dsm2.Accepts(1000 * (1 - 5.0 / 1e6 * 1.0000001), 1000) >= 0); // FIRST VARIES WITHIN 5 PPM OF SECOND + Assert.That(!(dsm2.Accepts(1000 * (1 + 5.0 / 1e6 * 1.0000001), 1000) >= 0)); // FIRST VARIES WITHIN 5 PPM OF SECOND + Assert.That(!(dsm2.Accepts(1000 * (1 - 5.0 / 1e6 * 1.0000001), 1000) >= 0)); // FIRST VARIES WITHIN 5 PPM OF SECOND - Assert.IsTrue(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 * 1.0000001)) >= 0); // VERY CAREFUL + Assert.That(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 * 1.0000001)) >= 0); // VERY CAREFUL var theList2 = dsm2.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(1000).ToList(); - Assert.IsTrue(theList2[0].AllowedInterval.Contains(1000)); + Assert.That(theList2[0].AllowedInterval.Contains(1000)); - Assert.IsTrue(1000 * (1 + 5.0 / 1e6 / 1.0000001) < theList2[0].AllowedInterval.Maximum); - Assert.IsTrue(1000 * (1 - 5.0 / 1e6 / 1.0000001) > theList2[0].AllowedInterval.Minimum); - Assert.IsTrue(1000 * (1 + 5.0 / 1e6 * 1.0000001) > theList2[0].AllowedInterval.Maximum); - Assert.IsTrue(1000 * (1 - 5.0 / 1e6 * 1.0000001) < theList2[0].AllowedInterval.Minimum); + Assert.That(1000 * (1 + 5.0 / 1e6 / 1.0000001) < theList2[0].AllowedInterval.Maximum); + Assert.That(1000 * (1 - 5.0 / 1e6 / 1.0000001) > theList2[0].AllowedInterval.Minimum); + Assert.That(1000 * (1 + 5.0 / 1e6 * 1.0000001) > theList2[0].AllowedInterval.Maximum); + Assert.That(1000 * (1 - 5.0 / 1e6 * 1.0000001) < theList2[0].AllowedInterval.Minimum); - Assert.IsTrue(theList2[1].AllowedInterval.Contains(1001)); + Assert.That(theList2[1].AllowedInterval.Contains(1001)); } // Accept if scanPrecursorMass*peptideMass>=1. diff --git a/MetaMorpheus/Test/SearchTaskTest.cs b/MetaMorpheus/Test/SearchTaskTest.cs index 88b06d1d4..b1c928d8f 100644 --- a/MetaMorpheus/Test/SearchTaskTest.cs +++ b/MetaMorpheus/Test/SearchTaskTest.cs @@ -2,7 +2,6 @@ using MassSpectrometry; using MzLibUtil; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -117,7 +116,7 @@ public static void SemiSpecificFullAndSmallMatches() string outputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecificSmall\AllPSMs.psmtsv"); var output = File.ReadAllLines(outputPath); - Assert.IsTrue(output.Length == 3); + Assert.That(output.Length == 3); var mzId = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecificSmall\tinySemi.mzID")); Assert.That(mzId[115].Equals(" ")); @@ -205,17 +204,18 @@ public static void InternalFragmentIonTest() //var output = File.ReadAllLines(outputPath); //read the psmtsv List psms = PsmTsvReader.ReadTsv(outputPath, out var warning); - Assert.IsTrue(psms.Count == 1); + Assert.That(psms.Count == 1); //check that it's been disambiguated - Assert.IsFalse(psms[0].FullSequence.Contains("|")); - Assert.AreEqual(psms[0].MatchedIons.First().Intensity, 161210); - Assert.AreEqual(psms[0].MatchedIons.First().Mz, 585.25292); - Assert.AreEqual(psms[0].MatchedIons.First().Charge, 1); - Assert.AreEqual(psms[0].MatchedIons[4].Intensity, 131546); - Assert.AreEqual(psms[0].MatchedIons[4].Mz, 782.84816); - Assert.AreEqual(psms[0].MatchedIons[4].Charge, 2); + Assert.That(!(psms[0].FullSequence.Contains("|"))); + Assert.That(psms[0].MatchedIons.First().Intensity, Is.EqualTo(161210)); + Assert.That(psms[0].MatchedIons.First().Mz, Is.EqualTo(585.25292)); + Assert.That(psms[0].MatchedIons.First().Charge, Is.EqualTo(1)); + Assert.That(psms[0].MatchedIons[4].Intensity, Is.EqualTo(131546)); + Assert.That(psms[0].MatchedIons[4].Mz, Is.EqualTo(782.84816)); + Assert.That(psms[0].MatchedIons[4].Charge, Is.EqualTo(2)); int numTotalFragments = psms[0].MatchedIons.Count; + //test again but no variable acetyl on K. Make sure that internal fragments are still searched even without ambiguity searchTask = new SearchTask() { @@ -234,8 +234,8 @@ public static void InternalFragmentIonTest() engine = new EverythingRunnerEngine(taskList, new List { myFile }, new List { new DbForTask(myDatabase, false) }, Environment.CurrentDirectory); engine.Run(); psms = PsmTsvReader.ReadTsv(outputPath, out warning); - Assert.IsTrue(psms.Count == 1); - Assert.IsTrue(psms[0].MatchedIons.Count == numTotalFragments); + Assert.That(psms.Count == 1); + Assert.That(psms[0].MatchedIons.Count == numTotalFragments); Directory.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestInternal"), true); } @@ -374,11 +374,11 @@ public static void PeptideFDRTest() // if peptide FDR is calculated, they will be 1,2,3,4, etc. as expected if (lineline[columns.IndexOf("Decoy/Contaminant/Target")] == "D") { - Assert.AreEqual(++cumDecoys, int.Parse(lineline[columns.IndexOf("Cumulative Decoy")])); + Assert.That(++cumDecoys, Is.EqualTo(int.Parse(lineline[columns.IndexOf("Cumulative Decoy")]))); } else { - Assert.AreEqual(++cumTargets, int.Parse(lineline[columns.IndexOf("Cumulative Target")])); + Assert.That(++cumTargets, Is.EqualTo(int.Parse(lineline[columns.IndexOf("Cumulative Target")]))); } finalQValue = Math.Max(finalQValue, (double)cumDecoys / (double)cumTargets); @@ -613,8 +613,8 @@ public static void TestPepFilteringFewerThan100Psms() string resultsFile = Path.Combine(pepTaskFolder, "results.txt"); string[] results = File.ReadAllLines(resultsFile); - Assert.AreEqual("PEP could not be calculated due to an insufficient number of PSMs. Results were filtered by q-value.", results[6]); - Assert.AreEqual("All target PSMs with q-value <= 1: 84", results[7]); + Assert.That(results[6], Is.EqualTo("PEP could not be calculated due to an insufficient number of PSMs. Results were filtered by q-value.")); + Assert.That(results[7], Is.EqualTo("All target PSMs with q-value <= 1: 84")); // clean up Directory.Delete(folderPath, true); diff --git a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs index 64fa0d220..e7c44fe94 100644 --- a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs +++ b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.ProteolyticDigestion; using System; diff --git a/MetaMorpheus/Test/SeqCoverageTest.cs b/MetaMorpheus/Test/SeqCoverageTest.cs index 6605f3d27..dbc34d33b 100644 --- a/MetaMorpheus/Test/SeqCoverageTest.cs +++ b/MetaMorpheus/Test/SeqCoverageTest.cs @@ -1,6 +1,6 @@ using System; using EngineLayer; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -93,17 +93,17 @@ public static void TryFailSequenceCoverage() fjkd.ProteinGroups.First().CalculateSequenceCoverage(); var firstSequenceCoverageDisplayList = fjkd.ProteinGroups.First().SequenceCoverageDisplayList.First(); - Assert.AreEqual("MMKMMK", firstSequenceCoverageDisplayList); + Assert.That(firstSequenceCoverageDisplayList, Is.EqualTo("MMKMMK")); var firstSequenceCoverageDisplayListWithMods = fjkd.ProteinGroups.First().SequenceCoverageDisplayListWithMods.First(); - Assert.AreEqual("[mod1 on M]-MM[mod3 on M]KM[mod3 on M]MK-[mod5 on K]", firstSequenceCoverageDisplayListWithMods); + Assert.That(firstSequenceCoverageDisplayListWithMods, Is.EqualTo("[mod1 on M]-MM[mod3 on M]KM[mod3 on M]MK-[mod5 on K]")); var firstModInfo = fjkd.ProteinGroups.First().ModsInfo.First(); - Assert.IsTrue(firstModInfo.Contains(@"#aa1[mod1 on M,info:occupancy=1.00(2/2)]")); - Assert.IsTrue(firstModInfo.Contains(@"#aa2[mod3 on M,info:occupancy=0.50(1/2)]")); - Assert.IsFalse(firstModInfo.Contains(@"#aa3")); - Assert.IsTrue(firstModInfo.Contains(@"#aa4[mod3 on M,info:occupancy=0.50(1/2)]")); - Assert.IsFalse(firstModInfo.Contains(@"#aa5")); - Assert.IsTrue(firstModInfo.Contains(@"#aa6[mod5 on K,info:occupancy=1.00(2/2)]")); + Assert.That(firstModInfo.Contains(@"#aa1[mod1 on M,info:occupancy=1.00(2/2)]")); + Assert.That(firstModInfo.Contains(@"#aa2[mod3 on M,info:occupancy=0.50(1/2)]")); + Assert.That(!(firstModInfo.Contains(@"#aa3"))); + Assert.That(firstModInfo.Contains(@"#aa4[mod3 on M,info:occupancy=0.50(1/2)]")); + Assert.That(!(firstModInfo.Contains(@"#aa5"))); + Assert.That(firstModInfo.Contains(@"#aa6[mod5 on K,info:occupancy=1.00(2/2)]")); Console.WriteLine("Test output: " + firstSequenceCoverageDisplayList); } @@ -163,7 +163,7 @@ public static void TestFragmentSequenceCoverage() var firstSequenceCoverageDisplayList = fjkd.ProteinGroups.First().FragmentSequenceCoverageDisplayList.First(); - Assert.IsTrue(firstSequenceCoverageDisplayList == "MmkMMK"); + Assert.That(firstSequenceCoverageDisplayList == "MmkMMK"); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/SilacTest.cs b/MetaMorpheus/Test/SilacTest.cs index ea3d0bac9..8ca9d64c6 100644 --- a/MetaMorpheus/Test/SilacTest.cs +++ b/MetaMorpheus/Test/SilacTest.cs @@ -1,7 +1,6 @@ using EngineLayer; using MassSpectrometry; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using Proteomics; using Proteomics.AminoAcidPolymer; using Proteomics.ProteolyticDigestion; @@ -55,31 +54,32 @@ public static void TestSilacNoLightProtein() //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[0].Contains("Modification Info List\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test that two files were made and no light file - Assert.IsTrue(output[1].Contains("875000.0000000009\t437500.00000000047")); //test the heavier intensity is half that of the heavy (per the raw file) + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[0].Contains("Modification Info List\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test that two files were made and no light file + Assert.That(output[1].Contains("875000.0000000009\t437500.00000000047")); //test the heavier intensity is half that of the heavy (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[0].Contains("Organism\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test the two files were made and no light file - Assert.IsTrue(output[1].Contains("875000\t437500")); //test intensity + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[0].Contains("Organism\tIntensity_silac(R+3.988)\tIntensity_silac(R+10.008)")); //test the two files were made and no light file + Assert.That(output[1].Contains("875000\t437500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); - Assert.AreEqual(output.Length, 3); - Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[1].Contains("PEPTIDER(+3.988)\t")); //test light sequence was not modified - Assert.IsTrue(output[2].Contains("PEPTIDER(+10.008)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") - Assert.IsTrue(output[1].Contains("959.44")); //test light mass - Assert.IsTrue(output[2].Contains("965.46")); //test heavy mass + Assert.That(output.Length, Is.EqualTo(3)); + + Assert.That(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[1].Contains("PEPTIDER(+3.988)\t")); //test light sequence was not modified + Assert.That(output[2].Contains("PEPTIDER(+10.008)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") + Assert.That(output[1].Contains("959.44")); //test light mass + Assert.That(output[2].Contains("965.46")); //test heavy mass //test PSMs output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); - Assert.IsTrue(output[1].Contains("959.44")); //test the correct monoisotopic mass - Assert.IsTrue(output[1].Contains("PEPTIDER(+3.988)")); //test the correct psm - Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[1].Contains("959.44")); //test the correct monoisotopic mass + Assert.That(output[1].Contains("PEPTIDER(+3.988)")); //test the correct psm + Assert.That(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) //Clear the old files Directory.Delete(outputFolder, true); @@ -128,28 +128,28 @@ public static void TestSilacMultipleModsPerCondition() //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[0].Contains("Intensity_silac\tIntensity_silac(K+8.014 & R+6.020)")); //test that two files were made - Assert.IsTrue(output[1].Contains("1374999.999999999\t687499.9999999995")); //test the heavy intensity is half that of the light (per the raw file) + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[0].Contains("Intensity_silac\tIntensity_silac(K+8.014 & R+6.020)")); //test that two files were made + Assert.That(output[1].Contains("1374999.999999999\t687499.9999999995")); //test the heavy intensity is half that of the light (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[1].Contains("SEQENEWITHAKANDANR\taccession1\t"));//test the sequence and accession were not modified - Assert.IsTrue(output[1].Contains("1375000")); //test intensity - Assert.IsFalse(output[1].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)")); //test the sequence was not doubled modified - Assert.IsTrue(output[1].Contains("687500")); //test intensity + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[1].Contains("SEQENEWITHAKANDANR\taccession1\t"));//test the sequence and accession were not modified + Assert.That(output[1].Contains("1375000")); //test intensity + Assert.That(!output[1].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)")); //test the sequence was not doubled modified + Assert.That(output[1].Contains("687500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); - Assert.AreEqual(output.Length, 3); - Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[1].Contains("SEQENEWITHAKANDANR\t")); //test light sequence was not modified - Assert.IsTrue(output[2].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") - Assert.IsTrue(output[1].Contains("2111.96")); //test light mass - Assert.IsTrue(output[2].Contains("2125.99")); //test heavy mass - Assert.IsTrue(output[2].Contains("accession1")); //test heavy accesssion is light in output + Assert.That(output.Length, Is.EqualTo(3)); + Assert.That(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[1].Contains("SEQENEWITHAKANDANR\t")); //test light sequence was not modified + Assert.That(output[2].Contains("SEQENEWITHAK(+8.014)ANDANR(+6.020)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") + Assert.That(output[1].Contains("2111.96")); //test light mass + Assert.That(output[2].Contains("2125.99")); //test heavy mass + Assert.That(output[2].Contains("accession1")); //test heavy accesssion is light in output ///Test for when an additional label is the only label on a peptide @@ -211,35 +211,36 @@ public static void TestSilacQuantification() string mzIDPath1 = Path.ChangeExtension(TestContext.CurrentContext.TestDirectory + @"\TestSilac\Individual File Results\" + mzmlName, ".mzID"); string mzIDPath2 = Path.ChangeExtension(TestContext.CurrentContext.TestDirectory + @"\TestSilac\Individual File Results\" + mzmlName2, ".mzID"); - Assert.IsTrue(File.Exists(mzIDPath1)); - Assert.IsTrue(File.Exists(mzIDPath2)); + Assert.That(File.Exists(mzIDPath1)); + Assert.That(File.Exists(mzIDPath2)); - Assert.IsTrue(theStringResult.Contains("All target PSMs with q-value <= 0.01: 2")); //it's not a psm, it's a MBR feature. 2 because there are two files, but not 4 because MBR != psm + Assert.That(theStringResult.Contains("All target PSMs with q-value <= 0.01: 2")); //it's not a psm, it's a MBR feature. 2 because there are two files, but not 4 because MBR != psm ///Normal Peptide //test proteins string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"\TestSilac\AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[0].Contains("Intensity_silac\tIntensity_silacPart2\tIntensity_silac(K+8.014)\tIntensity_silacPart2(K+8.014)")); //test that two files were made - Assert.IsTrue(output[1].Contains("875000.0000000009\t875000.0000000009\t437500.00000000047\t437500.00000000047")); //test the heavy intensity is half that of the light (per the raw file) + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[0].Contains("Intensity_silac\tIntensity_silacPart2\tIntensity_silac(K+8.014)\tIntensity_silacPart2(K+8.014)")); //test that two files were made + Assert.That(output[1].Contains("875000.0000000009\t875000.0000000009\t437500.00000000047\t437500.00000000047")); //test the heavy intensity is half that of the light (per the raw file) //test peptides output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"\TestSilac\AllQuantifiedPeptides.tsv"); - Assert.AreEqual(output.Length, 2); - Assert.IsTrue(output[1].Contains("PEPTIDEK\taccession1\t"));//test the sequence and accession were not modified - Assert.IsTrue(output[1].Contains("875000")); //test intensity - Assert.IsFalse(output[1].Contains("PEPTIDEK(+8.014)")); //test the sequence was not doubled modified - Assert.IsTrue(output[1].Contains("437500")); //test intensity + Assert.That(output.Length, Is.EqualTo(2)); + Assert.That(output[1].Contains("PEPTIDEK\taccession1\t"));//test the sequence and accession were not modified + Assert.That(output[1].Contains("875000")); //test intensity + Assert.That(!output[1].Contains("PEPTIDEK(+8.014)")); //test the sequence was not doubled modified + Assert.That(output[1].Contains("437500")); //test intensity //test peaks output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"\TestSilac\AllQuantifiedPeaks.tsv"); - Assert.AreEqual(output.Length, 5); - Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[1].Contains("PEPTIDEK\t")); //test light sequence was not modified - Assert.IsTrue(output[2].Contains("PEPTIDEK(+8.014)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") - Assert.IsTrue(output[1].Contains("927.45")); //test light mass - Assert.IsTrue(output[2].Contains("935.46")); //test heavy mass + Assert.That(output.Length, Is.EqualTo(5)); + + Assert.That(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[2].Contains("silac\t"));//test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[1].Contains("PEPTIDEK\t")); //test light sequence was not modified + Assert.That(output[2].Contains("PEPTIDEK(+8.014)\t")); //test heavy sequence was output correctly (do NOT want "PEPTIDEa") + Assert.That(output[1].Contains("927.45")); //test light mass + Assert.That(output[2].Contains("935.46")); //test heavy mass ///Ambiguous base sequence peptide //Clear the old files @@ -261,8 +262,8 @@ public static void TestSilacQuantification() _ = task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); - Assert.IsTrue(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) - Assert.IsTrue(output[1].Contains("PEPTIDEK(+8.014)|PEPTLDEK(+8.014)|PEPTIDEK(+8.014)") + Assert.That(output[1].Contains("silac\t")); //test the filename was NOT modified (it was for proteins, but we don't want it for peptides) + Assert.That(output[1].Contains("PEPTIDEK(+8.014)|PEPTLDEK(+8.014)|PEPTIDEK(+8.014)") || output[1].Contains("PEPTIDEK(+8.014)|PEPTIDEK(+8.014)|PEPTLDEK(+8.014)") || output[1].Contains("PEPTLDEK(+8.014)|PEPTIDEK(+8.014)|PEPTIDEK(+8.014)")); //test the heavy ambiguous peptides were all found //Need the options, because output isn't consistent as of 3/26/19 @@ -280,10 +281,10 @@ public static void TestSilacQuantification() _ = task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); - Assert.IsTrue(output[1].Contains("accession1|accession2") + Assert.That(output[1].Contains("accession1|accession2") || output[1].Contains("accession2|accession1")); //test the heavy ambiguous peptides were all found //Need the options, because output isn't consistent as of 3/26/19 - Assert.IsTrue(output[1].Contains("\tPEPTIDEK(+8.014)\t")); //test the heavy ambiguous peptides were all found + Assert.That(output[1].Contains("\tPEPTIDEK(+8.014)\t")); //test the heavy ambiguous peptides were all found //delete files Directory.Delete(outputFolder, true); @@ -376,20 +377,20 @@ public static void TestSilacTurnover() task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName, mzmlName2 }, "taskId1").ToString(); string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.IsTrue(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tIntensity_silacPart2_Original\tIntensity_silacPart2_NewlySynthesized\t" + + Assert.That(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present + Assert.That(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tIntensity_silacPart2_Original\tIntensity_silacPart2_NewlySynthesized\t" + "Detection Type_silac_Original\tDetection Type_silac_NewlySynthesized\tDetection Type_silacPart2_Original\tDetection Type_silacPart2_NewlySynthesized")); //test filename changes - Assert.IsTrue(output[1].Contains("\t1093750\t437500\t")); //test intensities + Assert.That(output[1].Contains("\t1093750\t437500\t")); //test intensities output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); - Assert.AreEqual(output.Length, 7); //header, (unlabeled, mixed, labeled)*2 files - Assert.IsTrue(output[1].Contains("\tPEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[1].Contains("\t875000\t")); //test intensity - Assert.IsTrue(output[2].Contains("\tPEPTK(+8.014)IDEK\t")); //test human readable label (and lack thereof) is present - Assert.IsTrue(output[2].Contains("\t437500\t")); //test intensity - Assert.IsTrue(output[3].Contains("\tPEPTK(+8.014)IDEK(+8.014)\t")); //test the unlabeled is present - Assert.IsTrue(output[3].Contains("\t218750\t")); //test intensity - Assert.IsTrue(output[3].Contains("silac\t")); //test human readable labels are present + Assert.That(output.Length, Is.EqualTo(7)); //header, (unlabeled, mixed, labeled)*2 files + Assert.That(output[1].Contains("\tPEPTKIDEK\t")); //test the unlabeled is present + Assert.That(output[1].Contains("\t875000\t")); //test intensity + Assert.That(output[2].Contains("\tPEPTK(+8.014)IDEK\t")); //test human readable label (and lack thereof) is present + Assert.That(output[2].Contains("\t437500\t")); //test intensity + Assert.That(output[3].Contains("\tPEPTK(+8.014)IDEK(+8.014)\t")); //test the unlabeled is present + Assert.That(output[3].Contains("\t218750\t")); //test intensity + Assert.That(output[3].Contains("silac\t")); //test human readable labels are present //use two turnover labels for start/end Residue heavyishLysine = new Residue("b", 'b', "b", Chemistry.ChemicalFormula.ParseFormula("C6H12N{15}2O"), ModificationSites.All); //+2 lysine @@ -412,22 +413,22 @@ public static void TestSilacTurnover() task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.IsTrue(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes - Assert.IsTrue(output[1].Contains("\t656250\t875000\t")); //test intensities + Assert.That(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present + Assert.That(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes + Assert.That(output[1].Contains("\t656250\t875000\t")); //test intensities output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); - Assert.IsTrue(output[1].Contains("\tPEPTK(+1.994)IDEK(+8.014)\t")); //test the identified sequence is output + Assert.That(output[1].Contains("\tPEPTK(+1.994)IDEK(+8.014)\t")); //test the identified sequence is output output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); - Assert.AreEqual(output.Length, 4); //header, unlabeled, mixed, labeled - Assert.IsTrue(output[3].Contains("\tPEPTK(+8.014)IDEK(+8.014)\t")); //test the original is present - Assert.IsTrue(output[3].Contains("\t218750\t")); //test intensity - Assert.IsTrue(output[1].Contains("\tPEPTK(+1.994)IDEK(+8.014)\t")); //test human readable label (and lack thereof) is present - Assert.IsTrue(output[1].Contains("\t875000\t")); //test intensity - Assert.IsTrue(output[2].Contains("\tPEPTK(+1.994)IDEK(+1.994)\t")); //test other label is present - Assert.IsTrue(output[2].Contains("\t437500\t")); //test intensity - Assert.IsTrue(output[2].Contains("silac\t")); //test human readable labels are present + Assert.That(output.Length, Is.EqualTo(4)); //header, unlabeled, mixed, labeled + Assert.That(output[3].Contains("\tPEPTK(+8.014)IDEK(+8.014)\t")); //test the original is present + Assert.That(output[3].Contains("\t218750\t")); //test intensity + Assert.That(output[1].Contains("\tPEPTK(+1.994)IDEK(+8.014)\t")); //test human readable label (and lack thereof) is present + Assert.That(output[1].Contains("\t875000\t")); //test intensity + Assert.That(output[2].Contains("\tPEPTK(+1.994)IDEK(+1.994)\t")); //test other label is present + Assert.That(output[2].Contains("\t437500\t")); //test intensity + Assert.That(output[2].Contains("silac\t")); //test human readable labels are present //Try with conflicting probability values (have a missed cleavage and a non missed cleavage, but set the non missed cleavage past the equilibrium point) //test that we don't get negative quantification values after the correction @@ -452,17 +453,17 @@ public static void TestSilacTurnover() task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.IsTrue(output[1].Contains("PEPEPEPTK\t")); //test the unlabeled is present - Assert.IsTrue(output[2].Contains("PEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes - Assert.IsTrue(output[1].Contains("\t2625000\t6125000\t")); //test the light intensity is not negative. - Assert.IsTrue(output[2].Contains("\t10500000\t5250000\t")); //test intensities. The observation is 9/6/3. + Assert.That(output[1].Contains("PEPEPEPTK\t")); //test the unlabeled is present + Assert.That(output[2].Contains("PEPTKIDEK\t")); //test the unlabeled is present + Assert.That(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes + Assert.That(output[1].Contains("\t2625000\t6125000\t")); //test the light intensity is not negative. + Assert.That(output[2].Contains("\t10500000\t5250000\t")); //test intensities. The observation is 9/6/3. output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedProteinGroups.tsv"); //test sequence coverage and output worked from multiple labels // Both labels should be included, but the order doesnt matter - Assert.IsTrue(output[1].Contains("PEPTK(+8.014)IDEK(+8.014)|PEPEPEPTK(+1.994)") | output[1].Contains("PEPEPEPTK(+1.994)|PEPTK(+8.014)IDEK(+8.014)")); - Assert.IsTrue(output[1].Contains("PEPEPEPTKidekPEPTKIDEKa\tPEPEPEPTKidekPEPTKIDEKa\tPEPEPEPTKidekPEPTKIDEKa")); + Assert.That(output[1].Contains("PEPTK(+8.014)IDEK(+8.014)|PEPEPEPTK(+1.994)") | output[1].Contains("PEPEPEPTK(+1.994)|PEPTK(+8.014)IDEK(+8.014)")); + Assert.That(output[1].Contains("PEPEPEPTKidekPEPTKIDEKa\tPEPEPEPTKidekPEPTKIDEKa\tPEPEPEPTKidekPEPTKIDEKa")); //try modern search (testing indexing) task = new SearchTask @@ -514,17 +515,17 @@ public static void TestSilacMissingPeaks() var theStringResult = task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); - Assert.IsTrue(output.Length == 4); - Assert.IsTrue(output[1].Contains("\tPEPTK(+8.014)IDEK\t") && output[1].Contains("\t875000\t")); //Doesn't matter where the +8.014 is, just matters that it's mixed (one is light, one is heavy) + Assert.That(output.Length == 4); + Assert.That(output[1].Contains("\tPEPTK(+8.014)IDEK\t") && output[1].Contains("\t875000\t")); //Doesn't matter where the +8.014 is, just matters that it's mixed (one is light, one is heavy) output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedProteinGroups.tsv"); - Assert.IsTrue(output[1].Contains("\t\t\t\t1\t")); //check that no intensity is present when only a single missed cleavage value exists - Assert.IsTrue(output[1].Contains("\t1\tPEPTKIDEK\tPEPTKIDEK\t")); //check that the sequence coverage isn't PEPTaIDEa - Assert.IsTrue(output[1].Contains("\t1\tPEPTKIDEK(+8.014)\t")); //check that the peptide id'd has the +8 + Assert.That(output[1].Contains("\t\t\t\t1\t")); //check that no intensity is present when only a single missed cleavage value exists + Assert.That(output[1].Contains("\t1\tPEPTKIDEK\tPEPTKIDEK\t")); //check that the sequence coverage isn't PEPTaIDEa + Assert.That(output[1].Contains("\t1\tPEPTKIDEK(+8.014)\t")); //check that the peptide id'd has the +8 output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPeptides.psmtsv"); - Assert.IsTrue(output.Length == 2); - Assert.IsTrue(output[1].Contains("\tPEPTKIDEK(+8.014)\t")); //ensure the order is correct here for the id (not PEPTK(+8.014)IDEK) + Assert.That(output.Length == 2); + Assert.That(output[1].Contains("\tPEPTKIDEK(+8.014)\t")); //ensure the order is correct here for the id (not PEPTK(+8.014)IDEK) //delete files Directory.Delete(outputFolder, true); @@ -615,7 +616,7 @@ public static void TestSilacPeakComparisons() Directory.CreateDirectory(outputFolder); task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.IsTrue(output[1].Contains("\t12250000\t6125000\t")); //check that it's 2:1 and not 5:3 like it would be for apex + Assert.That(output[1].Contains("\t12250000\t6125000\t")); //check that it's 2:1 and not 5:3 like it would be for apex //TEST for blips, where two peaks are found for a single identification @@ -624,7 +625,7 @@ public static void TestSilacPeakComparisons() Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); task.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, "taskId1").ToString(); output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); - Assert.IsTrue(output[1].Contains("\t24500000\t12250000\t")); //intensities will be twice as large as before, but still the same ratio + Assert.That(output[1].Contains("\t24500000\t12250000\t")); //intensities will be twice as large as before, but still the same ratio //delete files Directory.Delete(outputFolder, true); @@ -649,19 +650,19 @@ public static void TestSilacHelperMethods() //Test SilacConversions.GetRelevantLabelFromFullSequence SilacLabel relevantLabel = SilacConversions.GetRelevantLabelFromFullSequence(sequence, silacLabels); - Assert.IsTrue(relevantLabel.Equals(silacLabels[0])); + Assert.That(relevantLabel.Equals(silacLabels[0])); //Test SilacConversions.GetAmbiguousLightSequence string asdf = SilacConversions.GetAmbiguousLightSequence("", silacLabels, true); - Assert.IsTrue(asdf.Equals("")); //test that no "|" was added. + Assert.That(asdf.Equals("")); //test that no "|" was added. //Test SilacConversions.GetSilacLightBaseSequence string asdff = SilacConversions.GetSilacLightBaseSequence("ASDF", null); - Assert.IsTrue(asdff.Equals("ASDF")); //test that there's no change if the label's not present + Assert.That(asdff.Equals("ASDF")); //test that there's no change if the label's not present //Test SilacConversions.GetSilacLightFullSequence string asdfff = SilacConversions.GetSilacLightFullSequence(sequence, silacLabels[0], false); - Assert.IsTrue(asdfff.Equals("ASDF[SomeSebuance]GHKASDF")); + Assert.That(asdfff.Equals("ASDF[SomeSebuance]GHKASDF")); //Test no crash in weird situations SilacConversions.SilacConversionsPostQuantification(null, null, null, new List(), null, new HashSet(), null, new List(), new Dictionary(), true); diff --git a/MetaMorpheus/Test/SlicedTest.cs b/MetaMorpheus/Test/SlicedTest.cs index 7a056f57e..a1a759b56 100644 --- a/MetaMorpheus/Test/SlicedTest.cs +++ b/MetaMorpheus/Test/SlicedTest.cs @@ -1,5 +1,5 @@ using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; @@ -27,14 +27,14 @@ public static void SlicedTest1() var peaks = Path.Combine(thisTaskOutputFolder, "Task", "AllQuantifiedPeaks.tsv"); - Assert.AreEqual(2, File.ReadLines(peaks).Count()); + Assert.That(File.ReadLines(peaks).Count(), Is.EqualTo(2)); var psms = Path.Combine(thisTaskOutputFolder, "Task", "AllPSMs.psmtsv"); - Assert.AreEqual(3, File.ReadLines(psms).Count()); + Assert.That(File.ReadLines(psms).Count(), Is.EqualTo(3)); var protGroups = Path.Combine(thisTaskOutputFolder, "Task", "AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(2, File.ReadLines(protGroups).Count()); + Assert.That(File.ReadLines(protGroups).Count(), Is.EqualTo(2)); Directory.Delete(outputFolder, true); } @@ -54,14 +54,14 @@ public static void FaFormatTest() var peaks = Path.Combine(thisTaskOutputFolder, "Task", "AllQuantifiedPeaks.tsv"); - Assert.AreEqual(2, File.ReadLines(peaks).Count()); + Assert.That(File.ReadLines(peaks).Count(), Is.EqualTo(2)); var psms = Path.Combine(thisTaskOutputFolder, "Task", "AllPSMs.psmtsv"); - Assert.AreEqual(3, File.ReadLines(psms).Count()); + Assert.That(File.ReadLines(psms).Count(), Is.EqualTo(3)); var protGroups = Path.Combine(thisTaskOutputFolder, "Task", "AllQuantifiedProteinGroups.tsv"); - Assert.AreEqual(2, File.ReadLines(protGroups).Count()); + Assert.That(File.ReadLines(protGroups).Count(), Is.EqualTo(2)); Directory.Delete(outputFolder, true); } } diff --git a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs index 2fc4b87e3..28df957eb 100644 --- a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs +++ b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System.IO; using System; using System.Linq; @@ -6,7 +6,6 @@ using TaskLayer; using System.Collections.Generic; using Omics.Fragmentation; -using System.Globalization; using Proteomics; using MassSpectrometry; using EngineLayer.ClassicSearch; @@ -31,7 +30,7 @@ public static void SpectralLibraryReaderTest() testLibraryWithoutDecoy.TryGetSpectrum("ALAVDGAGKPGAEE", 2, out var test1); - Assert.AreEqual(test1.ChargeState, 2); + Assert.That(test1.ChargeState, Is.EqualTo(2)); var frags = new List<(double mz, double intensity, ProductType ProductType, int fragmentNumber, int charge, double ppm)> { @@ -98,7 +97,7 @@ public static void SpectralLibraryReaderTest() testLibraryWithoutDecoy.TryGetSpectrum("ALAVDGAGKPGAEE", 2, out test1); - Assert.AreEqual(test1.ChargeState, 2); + Assert.That(test1.ChargeState, Is.EqualTo(2)); for (int i = 0; i < frags.Count; i++) { @@ -184,11 +183,12 @@ public static void AnotherSpectralLibrarySearchTest() bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, commonParameters,null, sl, new List(), writeSpectralLibrary).Run(); - + // Single search mode - Assert.AreEqual(7, allPsmsArray.Length); - Assert.IsTrue(allPsmsArray[5].Score > 38); - Assert.AreEqual("VIHDNFGIVEGLMTTVHAITATQK", allPsmsArray[5].BaseSequence); + Assert.That(allPsmsArray.Length, Is.EqualTo(7)); + Assert.That(allPsmsArray[5].Score > 38); + Assert.That(allPsmsArray[5].BaseSequence, Is.EqualTo("VIHDNFGIVEGLMTTVHAITATQK")); + SpectralLibrarySearchFunction.CalculateSpectralAngles(sl, allPsmsArray, listOfSortedms2Scans, commonParameters); Assert.That(allPsmsArray[5].SpectralAngle, Is.EqualTo(0.82).Within(0.01)); @@ -228,10 +228,10 @@ public static void AnotherSpectralLibrarySearchTestDecoy() proteinList, searchModes, commonParameters, null, sl, new List(), writeSpectralLibrary).Run(); // Single search mode - Assert.AreEqual(7, allPsmsArray.Length); - Assert.IsTrue(allPsmsArray[5].Score > 38); - Assert.AreEqual("VIHDNFGIVEGLMTTVHAITATQK", allPsmsArray[5].BaseSequence); - Assert.IsTrue(allPsmsArray[5].IsDecoy); + Assert.That(allPsmsArray.Length, Is.EqualTo(7)); + Assert.That(allPsmsArray[5].Score > 38); + Assert.That(allPsmsArray[5].BaseSequence, Is.EqualTo("VIHDNFGIVEGLMTTVHAITATQK")); + Assert.That(allPsmsArray[5].IsDecoy); SpectralLibrarySearchFunction.CalculateSpectralAngles(sl, allPsmsArray, listOfSortedms2Scans, commonParameters); Assert.That(allPsmsArray[5].SpectralAngle, Is.EqualTo(0.69).Within(0.01)); @@ -245,13 +245,13 @@ public static void SpectralLibraryReaderTestNeutralLoss() var testLibraryWithoutDecoy = new SpectralLibrary(new List { path }); var librarySpectra = testLibraryWithoutDecoy.GetAllLibrarySpectra().ToList(); - Assert.That(librarySpectra[0].MatchedFragmentIons[9].NeutralTheoreticalProduct.NeutralLoss == 97.976895573); - Assert.That(librarySpectra[0].MatchedFragmentIons[11].NeutralTheoreticalProduct.NeutralLoss == 97.976895573); - Assert.That(librarySpectra[0].MatchedFragmentIons[13].NeutralTheoreticalProduct.NeutralLoss == 97.976895573); - Assert.That(librarySpectra[0].MatchedFragmentIons[23].NeutralTheoreticalProduct.NeutralLoss == 97.976895573); + Assert.That(librarySpectra[0].MatchedFragmentIons[9].NeutralTheoreticalProduct.NeutralLoss, Is.EqualTo(97.976895573)); + Assert.That(librarySpectra[0].MatchedFragmentIons[11].NeutralTheoreticalProduct.NeutralLoss, Is.EqualTo(97.976895573)); + Assert.That(librarySpectra[0].MatchedFragmentIons[13].NeutralTheoreticalProduct.NeutralLoss, Is.EqualTo(97.976895573)); + Assert.That(librarySpectra[0].MatchedFragmentIons[23].NeutralTheoreticalProduct.NeutralLoss, Is.EqualTo(97.976895573)); testLibraryWithoutDecoy.TryGetSpectrum("ASVSELAC[Common Fixed:Carbamidomethyl on C]IYSALILHDDEVTVTEDKINALIKAAGVNVEPFWPGLFAKALANVNIGSLIC[Common Fixed:Carbamidomethyl on C]NVGAGGPAPAAGAAPAGGPAPSTAAAPAEEKKVEAKKEES[Common Biological:Phosphorylation on S]EES[Common Biological:Phosphorylation on S]DDDMGFGLFD", 11, out var test1); - Assert.AreEqual(test1.ChargeState, 11); + Assert.That(test1.ChargeState, Is.EqualTo(11)); var frags = new List<(double mz, double intensity, ProductType ProductType, int fragmentNumber, int charge, double neutralLoss)> { (474.22253552109225, 0.12327031966337068, ProductType.b, 5, 1, 0.0), @@ -309,7 +309,7 @@ public static void SpectralLibraryReaderTestNeutralLoss() testLibraryWithoutDecoy.TryGetSpectrum("ASVSELAC[Common Fixed:Carbamidomethyl on C]IYSALILHDDEVTVTEDKINALIKAAGVNVEPFWPGLFAKALANVNIGSLIC[Common Fixed:Carbamidomethyl on C]NVGAGGPAPAAGAAPAGGPAPSTAAAPAEEKKVEAKKEES[Common Biological:Phosphorylation on S]EES[Common Biological:Phosphorylation on S]DDDMGFGLFD", 11, out test1); - Assert.AreEqual(test1.ChargeState, 11); + Assert.That(test1.ChargeState, Is.EqualTo(11)); double maxOfIntensity = frags.Select(p => p.intensity).ToList().Max(); for (int i = 0; i < frags.Count; i++) { @@ -336,17 +336,17 @@ public static void SpectralLibraryReaderTest_pDeep() var testLibraryWithoutDecoy = new SpectralLibrary(new List { path }); var librarySpectra = testLibraryWithoutDecoy.GetAllLibrarySpectra().ToList(); - Assert.That(librarySpectra.Count == 5); + Assert.That(librarySpectra.Count, Is.EqualTo(5)); Assert.That(testLibraryWithoutDecoy.TryGetSpectrum("VGIVPGEVIAPGM[Common Variable:Oxidation on M]R", 3, out var spectrum1)); Assert.That(testLibraryWithoutDecoy.TryGetSpectrum("C[Common Fixed:Carbamidomethyl on C]TSC[Common Fixed:Carbamidomethyl on C]NGQGIKFVTR", 3, out var spectrum2)); - Assert.AreEqual(spectrum2.PrecursorMz, 543.2608252287667); - Assert.AreEqual(spectrum2.RetentionTime, 2789.812255859375); + Assert.That(spectrum2.PrecursorMz, Is.EqualTo(543.2608252287667)); + Assert.That(spectrum2.RetentionTime, Is.EqualTo(2789.812255859375)); testLibraryWithoutDecoy.TryGetSpectrum("YHPDKNPSEEAAEK", 3, out var test1); - Assert.AreEqual(test1.PrecursorMz, 538.9179945621); - Assert.AreEqual(test1.RetentionTime, 1361.375244140625); - Assert.AreEqual(test1.ChargeState, 3); + Assert.That(test1.PrecursorMz, Is.EqualTo(538.9179945621)); + Assert.That(test1.RetentionTime, Is.EqualTo(1361.375244140625)); + Assert.That(test1.ChargeState, Is.EqualTo(3)); var frags = new List<(double mz, double intensity, ProductType ProductType, int fragmentNumber, int charge, double ppm)> { @@ -386,15 +386,15 @@ public static void SpectralLibraryReaderTest_pDeep() Assert.That(librarySpectra.Count == 5); Assert.That(testLibraryWithoutDecoy.TryGetSpectrum("VGIVPGEVIAPGM[Common Variable:Oxidation on M]R", 3, out var spectrum3)); Assert.That(testLibraryWithoutDecoy.TryGetSpectrum("C[Common Fixed:Carbamidomethyl on C]TSC[Common Fixed:Carbamidomethyl on C]NGQGIKFVTR", 3, out var spectrum4)); - Assert.AreEqual(spectrum4.PrecursorMz, 543.2608252287667); - Assert.AreEqual(spectrum4.RetentionTime, 2789.812255859375); + Assert.That(spectrum4.PrecursorMz, Is.EqualTo(543.2608252287667)); + Assert.That(spectrum4.RetentionTime, Is.EqualTo(2789.812255859375)); testLibraryWithoutDecoy.TryGetSpectrum("YHPDKNPSEEAAEK", 3, out test1); - Assert.AreEqual(test1.PrecursorMz, 538.9179945621); - Assert.AreEqual(test1.RetentionTime, 1361.375244140625); - Assert.AreEqual(test1.ChargeState, 3); + Assert.That(test1.PrecursorMz, Is.EqualTo(538.9179945621)); + Assert.That(test1.RetentionTime, Is.EqualTo(1361.375244140625)); + Assert.That(test1.ChargeState, Is.EqualTo(3)); double maxOfIntensity = frags.Select(p => p.intensity).ToList().Max(); for (int i = 0; i < frags.Count; i++) { diff --git a/MetaMorpheus/Test/SpectralRecoveryTest.cs b/MetaMorpheus/Test/SpectralRecoveryTest.cs index 6a9cbb18b..6d64775d0 100644 --- a/MetaMorpheus/Test/SpectralRecoveryTest.cs +++ b/MetaMorpheus/Test/SpectralRecoveryTest.cs @@ -2,23 +2,18 @@ using EngineLayer.ClassicSearch; using MassSpectrometry; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using Proteomics; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Security.Cryptography; using System.Text; using Omics.Modifications; using TaskLayer; using TaskLayer.MbrAnalysis; using Omics; using UsefulProteomicsDatabases; -using Nett; -using System.DirectoryServices; -using System.Threading.Tasks; using System.Threading; namespace Test @@ -254,10 +249,10 @@ public static void MiniClassicSearchEngineTest() proteinList, searchModes, commonParameters, null, sl, new List(), writeSpectralLibrary).Run(); // Single search mode - Assert.AreEqual(7, allPsmsArray.Length); - Assert.IsTrue(allPsmsArray[5].Score > 38); - Assert.AreEqual("VIHDNFGIVEGLMTTVHAITATQK", allPsmsArray[5].BaseSequence); - Assert.IsTrue(!allPsmsArray[5].IsDecoy); + Assert.That(allPsmsArray.Length, Is.EqualTo(7)); + Assert.That(allPsmsArray[5].Score > 38); + Assert.That(allPsmsArray[5].BaseSequence, Is.EqualTo("VIHDNFGIVEGLMTTVHAITATQK")); + Assert.That(!allPsmsArray[5].IsDecoy); SpectralLibrarySearchFunction.CalculateSpectralAngles(sl, allPsmsArray, listOfSortedms2Scans, commonParameters); Assert.That(allPsmsArray[5].SpectralAngle, Is.EqualTo(0.82).Within(0.01)); @@ -276,7 +271,7 @@ public static void MiniClassicSearchEngineTest() SpectralMatch[] peptideSpectralMatches = mcse.SearchAroundPeak(pwsm, allPsmsArray[5].ScanRetentionTime).ToArray(); - Assert.AreEqual(allPsmsArray[5].BaseSequence, peptideSpectralMatches[0].BaseSequence); + Assert.That(peptideSpectralMatches[0].BaseSequence, Is.EqualTo(allPsmsArray[5].BaseSequence)); Assert.That(peptideSpectralMatches[0].SpectralAngle, Is.EqualTo(allPsmsArray[5].SpectralAngle).Within(0.01)); } sl.CloseConnections(); @@ -409,8 +404,7 @@ public static void SpectralRecoveryHeaderTest() sb.Append('\t'); sb.Append("Initial Search PEP Q-Value"); - Assert.AreEqual(sb.ToString(), SpectralRecoveryPSM.TabSeparatedHeader); - + Assert.That(sb.ToString(), Is.EqualTo(SpectralRecoveryPSM.TabSeparatedHeader)); } [OneTimeTearDown] diff --git a/MetaMorpheus/Test/StefanParsimonyTest.cs b/MetaMorpheus/Test/StefanParsimonyTest.cs index 5de2ad29c..63ec1fe2d 100644 --- a/MetaMorpheus/Test/StefanParsimonyTest.cs +++ b/MetaMorpheus/Test/StefanParsimonyTest.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -144,10 +144,10 @@ public static void ParsimonyDontTreatModifiedFormsAsUnique() // because modified peptides were NOT considered as unique, // then there should be one ambiguous protein group after parsimony, // and two protein accessions for each peptide - Assert.AreEqual(1, countOfProteinGroups); - Assert.AreEqual(2, results.SortedAndScoredProteinGroups.First().Proteins.Count); - Assert.IsNull(psm1.Accession); - Assert.IsNull(psm2.Accession); + Assert.That(countOfProteinGroups, Is.EqualTo(1)); + Assert.That(results.SortedAndScoredProteinGroups.First().Proteins.Count, Is.EqualTo(2)); + Assert.That(psm1.Accession, Is.Null); + Assert.That(psm2.Accession, Is.Null); } [Test] @@ -238,8 +238,8 @@ public static void TopPickedFdrTest() ProteinScoringAndFdrEngine proteinScoringEngine = new ProteinScoringAndFdrEngine(proteinParsimonyResult.ProteinGroups, psms, false, true, true, new CommonParameters(), null, new List()); ProteinScoringAndFdrResults results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); - Assert.IsTrue(results.SortedAndScoredProteinGroups.Count == 3); - Assert.IsTrue(results.SortedAndScoredProteinGroups[1].QValue == 0.5); + Assert.That(results.SortedAndScoredProteinGroups.Count == 3); + Assert.That(results.SortedAndScoredProteinGroups[1].QValue == 0.5); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/TestNGlyco.cs b/MetaMorpheus/Test/TestNGlyco.cs index 67fe9158d..ae330f284 100644 --- a/MetaMorpheus/Test/TestNGlyco.cs +++ b/MetaMorpheus/Test/TestNGlyco.cs @@ -1,7 +1,7 @@ using EngineLayer; using EngineLayer.GlycoSearch; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -82,7 +82,7 @@ public static void GlyTest_GetKindString() { byte[] kind = new byte[] {3, 4, 0, 0, 1, 0, 0, 0, 0, 0, 0 }; string kindString = Glycan.GetKindString(kind); - Assert.AreEqual("H3N4F1", kindString); + Assert.That(kindString, Is.EqualTo("H3N4F1")); } [Test] @@ -131,15 +131,15 @@ public static void GlyTest_GlyGetTheoreticalFragments() var glycanYIons = GlycoPeptides.GetGlycanYIons(listOfSortedms2Scans[0].PrecursorMass, glycan); var matchedGlycanYIons = MetaMorpheusEngine.MatchFragmentIons(listOfSortedms2Scans[0], glycanYIons, commonParameters); - Assert.AreEqual(matchedGlycanYIons.Count, 14); + Assert.That(matchedGlycanYIons.Count, Is.EqualTo(14)); //TO DO: The neutroloss is not annotated well. var matchedFragmentIons = MetaMorpheusEngine.MatchFragmentIons(listOfSortedms2Scans[0], fragmentIons, commonParameters); var coreIons = GlycoPeptides.ScanGetTrimannosylCore(matchedFragmentIons, glycan); - Assert.AreEqual(coreIons.Count, 6); + Assert.That(coreIons.Count, Is.EqualTo(6)); var filter = GlycoPeptides.ScanTrimannosylCoreFilter(matchedFragmentIons, glycan); - Assert.AreEqual(filter, true); + Assert.That(filter, Is.EqualTo(true)); var NGlycans = GlycanDatabase.LoadGlycan(GlobalVariables.NGlycanLocations[0], true, false); var bestGlycans = GlycoPeptides.MatchBestGlycan(listOfSortedms2Scans[0], NGlycans.ToArray(), commonParameters).Where(p => p != null && p.Item2 >= 2).OrderByDescending(p => p.Item2).Take(100).OrderBy(p => p.Item3).ToArray(); ; @@ -183,7 +183,7 @@ public static void GlyTest_AIETD() var XLPrecusorSearchMode = new SinglePpmAroundZeroSearchMode(commonParameters.PrecursorMassTolerance.Value); var precusorMatched = XLPrecusorSearchMode.Accepts(aPeptideWithSetModifications.Last().MonoisotopicMass + (double)glycan.Mass/1E5, listOfSortedms2Scans[0].PrecursorMass); - Assert.AreEqual(precusorMatched, 0); + Assert.That(precusorMatched, Is.EqualTo(0)); var glycanMod = Glycan.NGlycanToModification(glycan); var glycopep = GlycoPeptides.GenerateGlycopeptide(sites[0], aPeptideWithSetModifications.Last(), glycan); @@ -213,7 +213,7 @@ public static void GlyTest_OxoniumIons() //Tips: Using debug mode to check the number of oxoniumIons, in this case will be 7. MassDiffAcceptor massDiffAcceptor = new SinglePpmAroundZeroSearchMode(20); var oxoinumIonsExist = GlycoPeptides.ScanOxoniumIonFilter(listOfSortedms2Scans[0], massDiffAcceptor); - Assert.AreEqual(oxoinumIonsExist.Where(p=>p>0).Count(), 9); + Assert.That(oxoinumIonsExist.Where(p => p > 0).Count(), Is.EqualTo(9)); } [Test] @@ -223,7 +223,7 @@ public static void GlyTest_DistinguishGlycans() Glycan glycan2 = Glycan.Struct2Glycan("(N(N(H(H(H))(H(H(H))(H(H(H(H(H)))))))))", 0); var test = Glycan.Equals(glycan, glycan2); - Assert.AreEqual(test, true); + Assert.That(test, Is.EqualTo(true)); //TO DO: Test the glycan ions. Glycan glycan3 = Glycan.Struct2Glycan("(N(F)(N(H(H(N(H(N(H(N(H))))))(N(H(N(H(N(F)(H(G))))))))(H(N(H(N(H(N(H(A)))))))(N(F)(H(N(F)(H(N(H)(F))))))))))", 8086); @@ -235,10 +235,10 @@ public static void GlyTest_BisectHexNAc() { //The node here is for check the structure of the glycan. Node node = Glycan.Struct2Node("(N(N(H(N)(H(N)(N))(H(N(H))))))"); //This glycan has a bisect hexnac - Assert.That(node.LeftChild.LeftChild.MiddleChild!=null); + Assert.That(node.LeftChild.LeftChild.MiddleChild != null); Glycan glycan = Glycan.Struct2Glycan("(N(N(H(N)(H(N)(N))(H(N(H))))))", 0); - Assert.AreEqual(glycan.Ions.Count, 18); + Assert.That(glycan.Ions.Count, Is.EqualTo(18)); } [Test] @@ -246,10 +246,10 @@ public static void GlyTest_GlycanDecoy() { Glycan glycan = Glycan.Struct2Glycan("(N(N(H(N)(H(N)(N))(H(N(H))))))", 0); var test = Glycan.BuildTargetDecoyGlycans(new Glycan[] { glycan }); - Assert.AreEqual(test.Last().Decoy, true); + Assert.That(test.Last().Decoy, Is.EqualTo(true)); foreach (var ion in test.Last().Ions) { - Assert.AreEqual(ion.IonMass + ion.LossIonMass, test.Last().Mass); + Assert.That(ion.IonMass + ion.LossIonMass, Is.EqualTo(test.Last().Mass)); } } @@ -278,11 +278,11 @@ public static void GlyTest_BinarySearch() var tid = GlycoPeptides.BinarySearchGetIndex(array, t); var tid1 = GlycoPeptides.BinarySearchGetIndex(array, t1); - Assert.AreEqual(xid, 0); - Assert.AreEqual(yid, 2); - Assert.AreEqual(zid, 10); //Index out range - Assert.AreEqual(did, 2); - Assert.AreEqual(tid, 9); + Assert.That(xid, Is.EqualTo(0)); + Assert.That(yid, Is.EqualTo(2)); + Assert.That(zid, Is.EqualTo(10)); //Index out range + Assert.That(did, Is.EqualTo(2)); + Assert.That(tid, Is.EqualTo(9)); } [Test] diff --git a/MetaMorpheus/Test/TestOGlyco.cs b/MetaMorpheus/Test/TestOGlyco.cs index 1ecb85dca..9822fb853 100644 --- a/MetaMorpheus/Test/TestOGlyco.cs +++ b/MetaMorpheus/Test/TestOGlyco.cs @@ -1,7 +1,6 @@ using EngineLayer; using MassSpectrometry; using NUnit.Framework; -using Assert = NUnit.Framework.Legacy.ClassicAssert; using Proteomics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; @@ -40,7 +39,7 @@ public static void Setup() [Test] public static void OGlycoTest_LoadGlycanBox() { - Assert.AreEqual(OGlycanBoxes.Count(), 454); + Assert.That(OGlycanBoxes.Count(), Is.EqualTo(454)); } [Test] @@ -133,34 +132,34 @@ public static void OGlycoTest_GetK() //Combination test var kcombs = Glycan.GetKCombs(input, 3); - Assert.AreEqual(kcombs.Count(), 10); + Assert.That(kcombs.Count(), Is.EqualTo(10)); var allcombs = Glycan.GetKCombs(input, 5); - Assert.AreEqual(allcombs.Count(), 1); + Assert.That(allcombs.Count(), Is.EqualTo(1)); //Combination test with repetition var kcombs_rep = Glycan.GetKCombsWithRept(input, 3); - Assert.AreEqual(kcombs_rep.Count(), 35); + Assert.That(kcombs_rep.Count(), Is.EqualTo(35)); var allcombs_rep = Glycan.GetKCombsWithRept(input, 5); - Assert.AreEqual(allcombs_rep.Count(), 126); + Assert.That(allcombs_rep.Count(), Is.EqualTo(126)); //Permutation test var kperm = Glycan.GetPermutations(input, 3); - Assert.AreEqual(kperm.Count(), 60); + Assert.That(kperm.Count(), Is.EqualTo(60)); var allperm = Glycan.GetPermutations(input, 5).ToList(); - Assert.AreEqual(allperm.Count(), 120); + Assert.That(allperm.Count(), Is.EqualTo(120)); //Permutation test with repetition var kperm_rep = Glycan.GetPermutationsWithRept(input, 3); - Assert.AreEqual(kperm_rep.Count(), 125); + Assert.That(kperm_rep.Count(), Is.EqualTo(125)); } [Test] @@ -220,14 +219,14 @@ public static void OGlycanTest_Kdn() var kind = new byte[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2 }; double mass = Glycan.GetMass(kind) / 1E5; string name = Glycan.GetKindString(kind); - Assert.AreEqual(name, "H1N1K2"); - Assert.AreEqual(mass, 865.27013); + Assert.That(name, Is.EqualTo("H1N1K2")); + Assert.That(mass, Is.EqualTo(865.27013)); string kdnGlycan = "HexNAc(2)Hex(2)Kdn(1)"; string kdnGlycan2 = "N(H)H(N)K"; var expectedKind = new byte[] { 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; - Assert.AreEqual(GlycanDatabase.String2Kind(kdnGlycan), expectedKind); - Assert.AreEqual(Glycan.GetKind(kdnGlycan2), expectedKind); + Assert.That(GlycanDatabase.String2Kind(kdnGlycan), Is.EqualTo(expectedKind)); + Assert.That(Glycan.GetKind(kdnGlycan2), Is.EqualTo(expectedKind)); } [Test] @@ -936,7 +935,7 @@ public static void GlycoTestWithBadExperimentalDesignFile() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolderWithTask, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q9GZM5", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q9GZM5")); Directory.Delete(outputFolder, true); } @@ -1076,7 +1075,7 @@ public static void OGlycoTest_ProteinInference(bool writeContaminants, bool writ string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolder, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q8WXI7.3", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q8WXI7.3")); Directory.Delete(outputFolder, true); } @@ -1143,7 +1142,7 @@ public static void GlycoSearchIndividualFileFolderOutputTest() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolder, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q8WXI7.3", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q8WXI7.3")); Directory.Delete(outputFolder, true); } @@ -1210,7 +1209,7 @@ public static void NandO_GlycoSearchIndividualFileFolderOutputTest() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolder, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q8WXI7.3", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q8WXI7.3")); Directory.Delete(outputFolder, true); } @@ -1284,7 +1283,7 @@ public static void N_GlycoSearchIndividualFileFolderOutputTest() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolder, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q8WXI7.3", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q8WXI7.3")); Directory.Delete(outputFolder, true); } @@ -1361,7 +1360,7 @@ public static void TestGlycoQuant() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolderWithTask, "_AllProteinGroups.tsv")); string[] proteinGroupFields = allProteinGroups[1].Split('\t'); - Assert.AreEqual("Q9GZM5", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q9GZM5")); File.Delete(experimentalDesignFilePath); Directory.Delete(outputFolder, true); @@ -1516,7 +1515,7 @@ public static void GlycoQuantWithNoExperimentalDesignFileTest() string[] allProteinGroups = File.ReadAllLines(Path.Combine(outputFolderWithTask, "AllQuantifiedProteins.tsv")); string[] proteinGroupFields = allProteinGroups[2].Split('\t'); - Assert.AreEqual("Q9GZM5", proteinGroupFields[0]); + Assert.That(proteinGroupFields[0], Is.EqualTo("Q9GZM5")); Directory.Delete(outputFolder, true); } diff --git a/MetaMorpheus/Test/TestPsm.cs b/MetaMorpheus/Test/TestPsm.cs index 3a2c7546f..44c73a7d8 100644 --- a/MetaMorpheus/Test/TestPsm.cs +++ b/MetaMorpheus/Test/TestPsm.cs @@ -4,7 +4,7 @@ using EngineLayer.Localization; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.ProteolyticDigestion; using System; @@ -54,18 +54,18 @@ public static void TestPsmHeader() var t = psm.ToString(); var tabsepheader = SpectralMatch.GetTabSeparatedHeader(); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.That(psm.ToString().Count(f => f == '\t'), Is.EqualTo(SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'))); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.That(psm.ToString().Count(f => f == '\t'), Is.EqualTo(SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'))); Tolerance fragmentTolerance = new PpmTolerance(10); new LocalizationEngine(new List { psm }, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), null, new List()).Run(); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.That(psm.ToString().Count(f => f == '\t'), Is.EqualTo(SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'))); psm.SetFdrValues(6, 6, 6, 6, 6, 0, 0, 0); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.That(psm.ToString().Count(f => f == '\t'), Is.EqualTo(SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'))); } [Test] @@ -174,7 +174,7 @@ public static void TestLongestFragmentIonSequence() } } } - Assert.IsTrue(longestSeriesExpected.SequenceEqual(longestSeriesObserved)); + Assert.That(longestSeriesExpected.SequenceEqual(longestSeriesObserved)); } [Test] @@ -269,12 +269,12 @@ public static void TestPsmMatchingToTargetAndDecoyWithSameSequence() SpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); psm.AddOrReplace(decoy, 1, 0, true, null, 0); - Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(2)); Assert.That(psm.BestMatchingBioPolymersWithSetMods.Any(p => p.Peptide.Parent.IsDecoy)); psm.ResolveAllAmbiguities(); - Assert.AreEqual(1, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(1)); Assert.That(psm.BestMatchingBioPolymersWithSetMods.All(p => !p.Peptide.Parent.IsDecoy)); Assert.That(!psm.IsDecoy); } @@ -295,18 +295,19 @@ public static void TestPsmMatchingToTargetAndDecoyWithDifferentSequences() SpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); psm.AddOrReplace(decoy, 1, 0, true, null, 0); - Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(2)); Assert.That(psm.BestMatchingBioPolymersWithSetMods.Any(p => p.Peptide.Parent.IsDecoy)); psm.ResolveAllAmbiguities(); - Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(2)); Assert.That(psm.IsDecoy); List<(string fileName, CommonParameters fileSpecificParameters)> fsp = new List<(string fileName, CommonParameters fileSpecificParameters)> { ("filename", commonParameters) }; new FdrAnalysisEngine(new List { psm }, 1, new CommonParameters(), fsp, new List()).Run(); - Assert.AreEqual(0.5, psm.FdrInfo.CumulativeDecoy); + Assert.That(psm.FdrInfo.CumulativeDecoy, Is.EqualTo(0.5)); + } [Test] @@ -398,8 +399,7 @@ public static void TestPsmCount2() var unambiguousPsmsLessThanOnePercentFdr = allUnambiguousPsms.Where(psm => psm.QValue <= 0.01) .GroupBy(p => p.FullSequence).ToList(); - Assert.AreEqual(unambiguousPsmsLessThanOnePercentFdr.Count, allPeptidesQvalueBelowCutoff); - + Assert.That(unambiguousPsmsLessThanOnePercentFdr.Count, Is.EqualTo(allPeptidesQvalueBelowCutoff)); // Test for precursorIntensity in PsmFromTsv int scanNumber = 117; @@ -415,7 +415,7 @@ public static void TestPsmCount2() File.WriteAllLines(Path.Combine(outputFolder, @"TestInvalidPSMs.psmtsv"), lines.ToArray()); var psmsFromTsvInvalid = PsmTsvReader.ReadTsv(Path.Combine(outputFolder, @"TestInvalidPSMs.psmtsv"), out var warnings1); var psmInvalid = psmsFromTsvInvalid[psmsFromTsvInvalid.Count - 1]; - Assert.AreEqual(psmInvalid.PrecursorIntensity, null); + Assert.That(psmInvalid.PrecursorIntensity, Is.EqualTo(null)); //Test for precursorIntensity and precursorEnvelopePeakCount in SpectralMatch List proteinList = ProteinDbLoader.LoadProteinFasta(myDatabase, true, DecoyType.Reverse, false, out List errors); @@ -439,7 +439,7 @@ public static void TestPsmCount2() string peptideCountFromResultsString = results.FirstOrDefault(r => r.Contains("All target peptides with q-value <= 0.01: ")); double peptideCountFromResults = Convert.ToDouble(peptideCountFromResultsString?.Split(':')[1].ToString()); - Assert.AreEqual(allPeptidesQvalueBelowCutoff, peptideCountFromResults); + Assert.That(allPeptidesQvalueBelowCutoff, Is.EqualTo(peptideCountFromResults)); Directory.Delete(outputFolder, true); Directory.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Task Settings"), true); } @@ -466,12 +466,12 @@ public static void TestPsmAddOrReplace() psm1.AddOrReplace(pwsm, 11, 1, true, new List(), 0); - Assert.AreEqual(1, psm1.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm1.BestMatchingBioPolymersWithSetMods.Count(), Is.EqualTo(1)); - Assert.AreEqual(11, psm1.Score); + Assert.That(psm1.Score, Is.EqualTo(11)); - Assert.AreEqual(10, psm1.RunnerUpScore); - Assert.AreEqual(1, psm1.DeltaScore); + Assert.That(psm1.RunnerUpScore, Is.EqualTo(10)); + Assert.That(psm1.DeltaScore, Is.EqualTo(1)); } [Test] @@ -490,11 +490,11 @@ public static void TestComplementaryIons() int count = SpectralMatch.GetCountComplementaryIons(psm1.BioPolymersWithSetModsToMatchingFragments, pwsm); //No Matched Fragment Ions Returns 0 - Assert.AreEqual(0, count); + Assert.That(count, Is.EqualTo(0)); count = SpectralMatch.GetCountComplementaryIons(null, pwsm); //BioPolymersWithSetModsToMatchingFragments Null Returns 0 - Assert.AreEqual(0, count); + Assert.That(count, Is.EqualTo(0)); List myProducts = new List(); pwsm.Fragment(DissociationType.HCD, FragmentationTerminus.Both, myProducts); @@ -511,7 +511,7 @@ public static void TestComplementaryIons() count = SpectralMatch.GetCountComplementaryIons(PTMF, pwsm); //BioPolymersWithSetModsToMatchingFragments Contains one N and one C ion so intersection Returns 1 - Assert.AreEqual(1, count); + Assert.That(count, Is.EqualTo(1)); } [Test] @@ -529,14 +529,14 @@ public static void Test_PSM_GetLongestIonSeries_NullChecks() //BioPolymersWithSetModsToMatchingFragments == null returns 1 longestSeries = SpectralMatch.GetLongestIonSeriesBidirectional(null, pwsm); - Assert.AreEqual(1, longestSeries); + Assert.That(longestSeries, Is.EqualTo(1)); //matchedFragments == null returns 1 Dictionary> PeptidesToMatchingFragments = new Dictionary>(); PeptidesToMatchingFragments.Add(pwsm, null); longestSeries = SpectralMatch.GetLongestIonSeriesBidirectional(PeptidesToMatchingFragments, pwsm); - Assert.AreEqual(1, longestSeries); + Assert.That(longestSeries, Is.EqualTo(1)); } [Test] @@ -579,19 +579,19 @@ public static void TestPSMFragmentCoverage() psm1.ResolveAllAmbiguities(); psm1.GetAminoAcidCoverage(); //First amino acid - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(1)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(1)); //sequential N term Frags - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(4)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(4)); //Last amino acid - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(14)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(14)); //Covered from both directions inclusive - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(8)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(8)); //Covered from both directions exclusive - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(7)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(7)); //Sequential C term Frags - Assert.IsTrue(psm1.FragmentCoveragePositionInPeptide.Contains(11)); + Assert.That(psm1.FragmentCoveragePositionInPeptide.Contains(11)); //Not coveredRT - Assert.IsFalse(psm1.FragmentCoveragePositionInPeptide.Contains(5)); + Assert.That(!psm1.FragmentCoveragePositionInPeptide.Contains(5)); SpectralMatch psm2 = new PeptideSpectralMatch(pep2, 0, 0, 0, scan1, commonParameters, mfis1); @@ -615,13 +615,13 @@ public static void TestPrecursorIntensity() var scansWithPrecursors = MetaMorpheusTask._GetMs2Scans(myMsDataFile, filePath, CommonParameters); var Ms2Scan1 = scansWithPrecursors[17][1]; - Assert.IsTrue(Math.Abs(2889051 - Ms2Scan1.PrecursorIntensity) <= 10); + Assert.That(Math.Abs(2889051 - Ms2Scan1.PrecursorIntensity) <= 10); Assert.That(Ms2Scan1.PrecursorEnvelopePeakCount, Is.EqualTo(2)); //might not be the correct number of peaks but use it for now CommonParameters CommonParameters1 = new CommonParameters(useMostAbundantPrecursorIntensity: false); var scansWithPrecursors1 = MetaMorpheusTask._GetMs2Scans(myMsDataFile, filePath, CommonParameters1); var Ms2Scan1_2 = scansWithPrecursors1[17][1]; - Assert.IsTrue(Math.Abs(3405218 - Ms2Scan1_2.PrecursorIntensity) <= 10); + Assert.That(Math.Abs(3405218 - Ms2Scan1_2.PrecursorIntensity) <= 10); //just to look at the envelopes, not relavent to the test var msNScans = myMsDataFile.GetAllScansList().ToArray(); @@ -633,7 +633,7 @@ public static void TestPrecursorIntensity() CommonParameters CommonParameters2 = new CommonParameters(doPrecursorDeconvolution: false, useProvidedPrecursorInfo: true); var scansWithPrecursors2 = MetaMorpheusTask._GetMs2Scans(myMsDataFile, filePath, CommonParameters2); var Ms2Scan2 = scansWithPrecursors2[17][0]; - Assert.IsTrue(Math.Abs(1.14554e7 - Ms2Scan2.PrecursorIntensity) <= 1000); + Assert.That(Math.Abs(1.14554e7 - Ms2Scan2.PrecursorIntensity) <= 1000); Assert.That(Ms2Scan2.PrecursorEnvelopePeakCount, Is.EqualTo(1)); //3: use scan header (selectedIonIntensity) to find precursor info diff --git a/MetaMorpheus/Test/TestToml.cs b/MetaMorpheus/Test/TestToml.cs index 514b26018..048cc72ea 100644 --- a/MetaMorpheus/Test/TestToml.cs +++ b/MetaMorpheus/Test/TestToml.cs @@ -2,7 +2,7 @@ using MassSpectrometry; using MzLibUtil; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.IO; @@ -30,18 +30,18 @@ public static void TestTomlFunction() Toml.WriteFile(searchTask, "SearchTask.toml", MetaMorpheusTask.tomlConfig); var searchTaskLoaded = Toml.ReadFile("SearchTask.toml", MetaMorpheusTask.tomlConfig); - Assert.AreEqual(searchTask.CommonParameters.DeconvolutionMassTolerance.ToString(), searchTaskLoaded.CommonParameters.DeconvolutionMassTolerance.ToString()); - Assert.AreEqual(searchTask.CommonParameters.ProductMassTolerance.ToString(), searchTaskLoaded.CommonParameters.ProductMassTolerance.ToString()); - Assert.AreEqual(searchTask.CommonParameters.PrecursorMassTolerance.ToString(), searchTaskLoaded.CommonParameters.PrecursorMassTolerance.ToString()); + Assert.That(searchTask.CommonParameters.DeconvolutionMassTolerance.ToString(), Is.EqualTo(searchTaskLoaded.CommonParameters.DeconvolutionMassTolerance.ToString())); + Assert.That(searchTask.CommonParameters.ProductMassTolerance.ToString(), Is.EqualTo(searchTaskLoaded.CommonParameters.ProductMassTolerance.ToString())); + Assert.That(searchTask.CommonParameters.PrecursorMassTolerance.ToString(), Is.EqualTo(searchTaskLoaded.CommonParameters.PrecursorMassTolerance.ToString())); - Assert.AreEqual(searchTask.CommonParameters.ListOfModsFixed.Count(), searchTaskLoaded.CommonParameters.ListOfModsFixed.Count()); - Assert.AreEqual(searchTask.CommonParameters.ListOfModsFixed.First().Item1, searchTaskLoaded.CommonParameters.ListOfModsFixed.First().Item1); - Assert.AreEqual(searchTask.CommonParameters.ListOfModsFixed.First().Item2, searchTaskLoaded.CommonParameters.ListOfModsFixed.First().Item2); + Assert.That(searchTask.CommonParameters.ListOfModsFixed.Count(), Is.EqualTo(searchTaskLoaded.CommonParameters.ListOfModsFixed.Count())); + Assert.That(searchTask.CommonParameters.ListOfModsFixed.First().Item1, Is.EqualTo(searchTaskLoaded.CommonParameters.ListOfModsFixed.First().Item1)); + Assert.That(searchTask.CommonParameters.ListOfModsFixed.First().Item2, Is.EqualTo(searchTaskLoaded.CommonParameters.ListOfModsFixed.First().Item2)); - Assert.AreEqual(searchTask.CommonParameters.ListOfModsVariable.Count(), searchTaskLoaded.CommonParameters.ListOfModsVariable.Count()); + Assert.That(searchTask.CommonParameters.ListOfModsVariable.Count(), Is.EqualTo(searchTaskLoaded.CommonParameters.ListOfModsVariable.Count())); - Assert.AreEqual(searchTask.SearchParameters.MassDiffAcceptorType, searchTaskLoaded.SearchParameters.MassDiffAcceptorType); - Assert.AreEqual(searchTask.SearchParameters.CustomMdac, searchTaskLoaded.SearchParameters.CustomMdac); + Assert.That(searchTask.SearchParameters.MassDiffAcceptorType, Is.EqualTo(searchTaskLoaded.SearchParameters.MassDiffAcceptorType)); + Assert.That(searchTask.SearchParameters.CustomMdac, Is.EqualTo(searchTaskLoaded.SearchParameters.CustomMdac)); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestConsistency"); string myFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml"); @@ -111,22 +111,22 @@ public static void TestTomlForSpecficFiles() { var fileSpecificToml = Toml.ReadFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "testFileSpecfic.toml"), MetaMorpheusTask.tomlConfig); var tomlSettingsList = fileSpecificToml.ToDictionary(p => p.Key); - Assert.AreEqual(tomlSettingsList["Protease"].Value.Get(), "Asp-N"); - Assert.AreEqual(tomlSettingsList["DissociationType"].Value.Get(), "ETD"); - Assert.IsFalse(tomlSettingsList.ContainsKey("maxMissedCleavages")); - Assert.IsFalse(tomlSettingsList.ContainsKey("InitiatorMethionineBehavior")); + Assert.That(tomlSettingsList["Protease"].Value.Get(), Is.EqualTo("Asp-N")); + Assert.That(tomlSettingsList["DissociationType"].Value.Get(), Is.EqualTo("ETD")); + Assert.That(!tomlSettingsList.ContainsKey("maxMissedCleavages")); + Assert.That(!tomlSettingsList.ContainsKey("InitiatorMethionineBehavior")); FileSpecificParameters f = new(fileSpecificToml); - Assert.AreEqual("Asp-N", f.Protease.Name); - Assert.AreEqual(DissociationType.ETD, f.DissociationType); - Assert.IsNull(f.MaxMissedCleavages); + Assert.That(f.Protease.Name, Is.EqualTo("Asp-N")); + Assert.That(f.DissociationType, Is.EqualTo(DissociationType.ETD)); + Assert.That(f.MaxMissedCleavages, Is.Null); CommonParameters c = MetaMorpheusTask.SetAllFileSpecificCommonParams(new CommonParameters(), f); - Assert.AreEqual("Asp-N", c.DigestionParams.Protease.Name); - Assert.AreEqual(DissociationType.ETD, c.DissociationType); - Assert.AreEqual(2, c.DigestionParams.MaxMissedCleavages); + Assert.That(c.DigestionParams.Protease.Name, Is.EqualTo("Asp-N")); + Assert.That(c.DissociationType, Is.EqualTo(DissociationType.ETD)); + Assert.That(c.DigestionParams.MaxMissedCleavages, Is.EqualTo(2)); } [Test] @@ -137,8 +137,8 @@ public static void TestBadFileSpecificProtease() //create a toml with a protease that doesn't exist in the protease.tsv dictionary string proteaseNotInDictionary = "aaa"; //arbitrary. If somebody adds a protease with this name, use a different name string proteaseInDictionary = "trypsin"; //just make sure we are doing this right - Assert.IsTrue(!ProteaseDictionary.Dictionary.ContainsKey(proteaseNotInDictionary)); - Assert.IsTrue(ProteaseDictionary.Dictionary.ContainsKey(proteaseInDictionary)); + Assert.That(!ProteaseDictionary.Dictionary.ContainsKey(proteaseNotInDictionary)); + Assert.That(ProteaseDictionary.Dictionary.ContainsKey(proteaseInDictionary)); //write the toml //let's use the datafile ok.mgf (arbitrary) @@ -200,7 +200,7 @@ public static void TestOldModsInToml() Directory.Delete(folderPath, true); // - Assert.IsTrue(wasCalled); + Assert.That(wasCalled); } [Test] @@ -211,15 +211,15 @@ public static void FileSpecificParametersTest() var fileSpecificToml = Toml.ReadFile(filePath, MetaMorpheusTask.tomlConfig); FileSpecificParameters fsp = new(fileSpecificToml); - Assert.AreEqual(DissociationType.CID, fsp.DissociationType); - Assert.AreEqual(0, fsp.MaxMissedCleavages); - Assert.AreEqual(0, fsp.MaxModsForPeptide); - Assert.AreEqual(0, fsp.MaxPeptideLength); - Assert.AreEqual(0, fsp.MinPeptideLength); - Assert.AreEqual(5.0d, fsp.PrecursorMassTolerance.Value); - Assert.AreEqual(5.0d, fsp.ProductMassTolerance.Value); - Assert.AreEqual("Asp-N", fsp.Protease.Name); - Assert.AreEqual("HPLC", fsp.SeparationType.ToString()); + Assert.That(fsp.DissociationType, Is.EqualTo(DissociationType.CID)); + Assert.That(fsp.MaxMissedCleavages, Is.EqualTo(0)); + Assert.That(fsp.MaxModsForPeptide, Is.EqualTo(0)); + Assert.That(fsp.MaxPeptideLength, Is.EqualTo(0)); + Assert.That(fsp.MinPeptideLength, Is.EqualTo(0)); + Assert.That(fsp.PrecursorMassTolerance.Value, Is.EqualTo(5.0d)); + Assert.That(fsp.ProductMassTolerance.Value, Is.EqualTo(5.0d)); + Assert.That(fsp.Protease.Name, Is.EqualTo("Asp-N")); + Assert.That(fsp.SeparationType.ToString(), Is.EqualTo("HPLC")); filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "testFileParams_bad.toml"); diff --git a/MetaMorpheus/Test/TestTopDown.cs b/MetaMorpheus/Test/TestTopDown.cs index 8d83d978a..c76f95057 100644 --- a/MetaMorpheus/Test/TestTopDown.cs +++ b/MetaMorpheus/Test/TestTopDown.cs @@ -7,7 +7,7 @@ using EngineLayer.ModernSearch; using IO.MzML; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Omics.Modifications; using Proteomics; using Proteomics.ProteolyticDigestion; diff --git a/MetaMorpheus/Test/Transcriptomics/TestNegativeModeDeconvolution.cs b/MetaMorpheus/Test/Transcriptomics/TestNegativeModeDeconvolution.cs index e91f0432e..032668f5a 100644 --- a/MetaMorpheus/Test/Transcriptomics/TestNegativeModeDeconvolution.cs +++ b/MetaMorpheus/Test/Transcriptomics/TestNegativeModeDeconvolution.cs @@ -1,15 +1,12 @@ using EngineLayer; using MassSpectrometry; using MzLibUtil; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Readers; -using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Test.Transcriptomics { diff --git a/MetaMorpheus/Test/VariantSearchTests.cs b/MetaMorpheus/Test/VariantSearchTests.cs index 8cc06df6a..57cd11141 100644 --- a/MetaMorpheus/Test/VariantSearchTests.cs +++ b/MetaMorpheus/Test/VariantSearchTests.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.ProteolyticDigestion; using System; @@ -95,7 +95,7 @@ public static void SearchTests(int proteinIdx, int peptideIdx, bool containsVari st.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, ""); var psms = File.ReadAllLines(Path.Combine(outputFolder, "AllPSMs.psmtsv")); - Assert.IsTrue(psms.Any(line => line.Contains(containsVariant ? variantPsmShort : "\t"))); + Assert.That(psms.Any(line => line.Contains(containsVariant ? variantPsmShort : "\t"))); Directory.Delete(outputFolder, true); File.Delete(mzmlName); @@ -137,7 +137,7 @@ public void MoreTests(string filename, DecoyType decoyType = DecoyType.None) st.RunTask(outputFolder, new List { new DbForTask(xmlName, false) }, new List { mzmlName }, ""); var psms = File.ReadAllLines(Path.Combine(outputFolder, "AllPSMs.psmtsv")); - //Assert.IsTrue(psms.Any(line => line.Contains($"\t{variantPsmShort}\t" + (containsVariant ? variantPsmShort : "\t")))); + //Assert.That(psms.Any(line => line.Contains($"\t{variantPsmShort}\t" + (containsVariant ? variantPsmShort : "\t")))); Directory.Delete(outputFolder, true); File.Delete(mzmlName); @@ -218,223 +218,224 @@ public void VariantSpecificOutputFiles() string[] checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_frameshift", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 1", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 1", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 1")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_ambig", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 0", checkResults[5]); - Assert.AreEqual("Number of unique variants: 0", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 0", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 0")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 0")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 0")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_missense", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 1", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 1", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 1")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_SNVmissense", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 2", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 1", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 2", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 2")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 2")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_stopGained", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 1", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 1", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 1")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_conservativeInsertion", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 1", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 1", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 1")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_disruptiveInsertion", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 1", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 1", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 1")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_conservativeDeletion", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 1", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 1", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 1")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_disruptiveDeletion", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 1", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 1", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 0", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 0", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 1")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 0")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); + checkResults = File.ReadAllLines(Path.Combine(thisTaskOutputFolder, "VariantOutput_stopLoss", "VariantAnalysisResultSummary.txt")); - Assert.AreEqual("Number of potential variant containing peptides identified at 1% group FDR: 1", checkResults[4]); - Assert.AreEqual("Number of unqiuely identified variant peptides at 1% group FDR: 1", checkResults[5]); - Assert.AreEqual("Number of unique variants: 1", checkResults[6]); - Assert.AreEqual("Number of SNV missense variant containing peptides at 1% group FDR: 0", checkResults[7]); - Assert.AreEqual("Number of unique SNV missense variants: 0", checkResults[8]); - Assert.AreEqual("Number of MNV missense variant containing peptides at 1% group FDR: 0", checkResults[9]); - Assert.AreEqual("Number of unique MNV missense variants: 0", checkResults[10]); - Assert.AreEqual("Number of frameshift variant containing peptides at 1% group FDR: 0", checkResults[11]); - Assert.AreEqual("Number of unique frameshift variants: 0", checkResults[12]); - Assert.AreEqual("Number of inframe insertion variant containing peptides at 1% group FDR: 0", checkResults[13]); - Assert.AreEqual("Number of unique inframe insertion variants: 0", checkResults[14]); - Assert.AreEqual("Number of inframe deletion variant containing peptides at 1% group FDR: 0", checkResults[15]); - Assert.AreEqual("Number of unique inframe deletion variants: 0", checkResults[16]); - Assert.AreEqual("Number of stop gain variant containing peptides at 1% group FDR: 0", checkResults[17]); - Assert.AreEqual("Number of unique stop gain variants: 0", checkResults[18]); - Assert.AreEqual("Number of stop loss variant containing peptides at 1% group FDR: 1", checkResults[19]); - Assert.AreEqual("Number of unique stop loss variants: 1", checkResults[20]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1", checkResults[21]); - Assert.AreEqual("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0", checkResults[22]); + Assert.That(checkResults[4], Is.EqualTo("Number of potential variant containing peptides identified at 1% group FDR: 1")); + Assert.That(checkResults[5], Is.EqualTo("Number of unqiuely identified variant peptides at 1% group FDR: 1")); + Assert.That(checkResults[6], Is.EqualTo("Number of unique variants: 1")); + Assert.That(checkResults[7], Is.EqualTo("Number of SNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[8], Is.EqualTo("Number of unique SNV missense variants: 0")); + Assert.That(checkResults[9], Is.EqualTo("Number of MNV missense variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[10], Is.EqualTo("Number of unique MNV missense variants: 0")); + Assert.That(checkResults[11], Is.EqualTo("Number of frameshift variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[12], Is.EqualTo("Number of unique frameshift variants: 0")); + Assert.That(checkResults[13], Is.EqualTo("Number of inframe insertion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[14], Is.EqualTo("Number of unique inframe insertion variants: 0")); + Assert.That(checkResults[15], Is.EqualTo("Number of inframe deletion variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[16], Is.EqualTo("Number of unique inframe deletion variants: 0")); + Assert.That(checkResults[17], Is.EqualTo("Number of stop gain variant containing peptides at 1% group FDR: 0")); + Assert.That(checkResults[18], Is.EqualTo("Number of unique stop gain variants: 0")); + Assert.That(checkResults[19], Is.EqualTo("Number of stop loss variant containing peptides at 1% group FDR: 1")); + Assert.That(checkResults[20], Is.EqualTo("Number of unique stop loss variants: 1")); + Assert.That(checkResults[21], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications: 1")); + Assert.That(checkResults[22], Is.EqualTo("Number of variant peptides at 1% group FDR with unambiguous localized modifications at the variant sites : 0")); Directory.Delete(thisTaskOutputFolder, true); } diff --git a/MetaMorpheus/Test/XLSearchOutputTest.cs b/MetaMorpheus/Test/XLSearchOutputTest.cs index 98a685013..80f23c2fc 100644 --- a/MetaMorpheus/Test/XLSearchOutputTest.cs +++ b/MetaMorpheus/Test/XLSearchOutputTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using System.Collections.Generic; using System.IO; using TaskLayer; @@ -28,7 +28,7 @@ public static void WriteTsvTest() var resultsPath = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Intralinks.tsv")); var sections = resultsPath[1].Split('\t'); Assert.That(resultsPath.Length > 1); - Assert.AreEqual(sections.Length, 48); + Assert.That(sections.Length, Is.EqualTo(48)); var resultsPath_Inter = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Interlinks.tsv")); Assert.That(resultsPath_Inter.Length > 1); @@ -67,7 +67,7 @@ public static void WriteXlSpectralLibraryTest() var resultsPath = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Intralinks.tsv")); var sections = resultsPath[1].Split('\t'); Assert.That(resultsPath.Length > 1); - Assert.AreEqual(sections.Length, 48); + Assert.That(sections.Length, Is.EqualTo(48)); var resultsPath_Inter = File.ReadAllLines(Path.Combine(outputFolder, @"XL_Interlinks.tsv")); Assert.That(resultsPath_Inter.Length > 1); @@ -97,9 +97,9 @@ public static void WriteXlSpectralLibraryTest() Assert.That(interLinkSpectrum is CrosslinkLibrarySpectrum); CrosslinkLibrarySpectrum interSpectrum = (CrosslinkLibrarySpectrum)interLinkSpectrum; Assert.That(interSpectrum.BetaPeptideSpectrum.MatchedFragmentIons.Count, Is.EqualTo(13)); - Assert.AreEqual(interSpectrum.AlphaPeptideSequence, "GVTVDKMTELR"); - Assert.AreEqual(interSpectrum.BetaPeptideSequence, "SFTFVTKTPPAAVLLK"); - Assert.True(interSpectrum.BetaPeptideSpectrum.IsBetaPeptide); + Assert.That(interSpectrum.AlphaPeptideSequence, Is.EqualTo("GVTVDKMTELR")); + Assert.That(interSpectrum.BetaPeptideSequence, Is.EqualTo("SFTFVTKTPPAAVLLK")); + Assert.That(interSpectrum.BetaPeptideSpectrum.IsBetaPeptide); interLinkSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(productWithNeutralLoss, 100, 100, 1)); CrosslinkLibrarySpectrum spectrumDup = (CrosslinkLibrarySpectrum)interLinkSpectrum; spectrumDup.BetaPeptideSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(productWithNeutralLoss20, 100, 100, 1)); diff --git a/MetaMorpheus/Test/XLTest.cs b/MetaMorpheus/Test/XLTest.cs index de9c1a72d..0db607563 100644 --- a/MetaMorpheus/Test/XLTest.cs +++ b/MetaMorpheus/Test/XLTest.cs @@ -6,7 +6,7 @@ using MassSpectrometry; using MzLibUtil; using Nett; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.AminoAcidPolymer; using Omics.Fragmentation; @@ -31,12 +31,12 @@ public static class XLTest [Test] public static void TestDissociationTypeGenerateSameTypeOfIons() { - Assert.IsTrue(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.CID)); - Assert.IsTrue(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.HCD)); - Assert.IsTrue(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.HCD, DissociationType.CID)); - Assert.IsTrue(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.ETD, DissociationType.ECD)); - Assert.IsTrue(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.ECD, DissociationType.ETD)); - Assert.IsFalse(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.ETD)); + Assert.That(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.CID)); + Assert.That(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.HCD)); + Assert.That(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.HCD, DissociationType.CID)); + Assert.That(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.ETD, DissociationType.ECD)); + Assert.That(CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.ECD, DissociationType.ETD)); + Assert.That(!CrosslinkSearchEngine.DissociationTypeGenerateSameTypeOfIons(DissociationType.CID, DissociationType.ETD)); } [Test] @@ -62,30 +62,30 @@ public static void XlTestXlPosCal() var ye = prot.Digest(digestionParams, new List(), variableModifications).ToList(); var pep = ye[0]; - Assert.AreEqual(pep.BaseSequence, "MNNNK"); + Assert.That(pep.BaseSequence, Is.EqualTo("MNNNK")); Crosslinker crosslinker = GlobalVariables.Crosslinkers.Where(p => p.CrosslinkerName == "DSS").First(); - Assert.AreEqual(crosslinker.CrosslinkerModSites, "K"); - Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, 128.09496301518999, 1e-9); + Assert.That(crosslinker.CrosslinkerModSites, Is.EqualTo("K")); + Assert.That(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, Is.EqualTo(128.09496301518999).Within(1e-9)); List n = new List(); pep.Fragment(DissociationType.HCD, FragmentationTerminus.N, n); List c = new List(); pep.Fragment(DissociationType.HCD, FragmentationTerminus.C, c); - Assert.AreEqual(n.Count(), 4); - Assert.AreEqual(c.Count(), 4); - Assert.AreEqual(c.First().NeutralMass, 146.10552769899999, 1e-6); + Assert.That(n.Count(), Is.EqualTo(4)); + Assert.That(c.Count(), Is.EqualTo(4)); + Assert.That(c.First().NeutralMass, Is.EqualTo(146.10552769899999).Within(1e-6)); var x = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep, digestionParams.InitiatorMethionineBehavior, false); Assert.That(x == null); var pep2 = ye[2]; - Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); + Assert.That(pep2.BaseSequence, Is.EqualTo("MNNNKQQQQ")); List n2 = new List(); pep2.Fragment(DissociationType.HCD, FragmentationTerminus.N, n2); List c2 = new List(); pep2.Fragment(DissociationType.HCD, FragmentationTerminus.C, c2); - Assert.AreEqual(n2.Count(), 8); - Assert.AreEqual(c2.Count(), 8); + Assert.That(n2.Count(), Is.EqualTo(8)); + Assert.That(c2.Count(), Is.EqualTo(8)); var x2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep2, digestionParams.InitiatorMethionineBehavior, false); - Assert.AreEqual(x2[0], 5); + Assert.That(x2[0], Is.EqualTo(5)); //TestXLPosCal on peptide with modification. var prot_mod = new Protein("KNNNKQRKQQK", null); @@ -129,10 +129,10 @@ public static void XlTestXlPosCal() var protSTC = new Protein("GASTACK", null); var peps = protSTC.Digest(digestionParams, new List(), variableModifications).ToList(); var pepSTC = peps[0]; - Assert.AreEqual(pepSTC.BaseSequence, "GASTACK"); + Assert.That(pepSTC.BaseSequence, Is.EqualTo("GASTACK")); Crosslinker crosslinker2 = new Crosslinker("ST", "C", "crosslinkerSTC", false, "", -18.01056, 0, 0, 0, 0, 0, 0); string crosslinkerModSitesAll = new string((crosslinker2.CrosslinkerModSites + crosslinker2.CrosslinkerModSites2).ToCharArray().Distinct().ToArray()); - Assert.AreEqual(crosslinkerModSitesAll, "STC"); + Assert.That(crosslinkerModSitesAll, Is.EqualTo("STC")); } [Test] @@ -141,7 +141,7 @@ public static void XlTestGenerateIntensityRanks() double[] intensity = new double[] { 1.1, 1.1, 0.5, 3.2, 0.5, 6.0 }; int[] rank = CrosslinkSpectralMatch.GenerateIntensityRanks(intensity); int[] Rank = new int[] { 4, 3, 6, 2, 5, 1 }; - Assert.AreEqual(rank, Rank); + Assert.That(rank, Is.EqualTo(Rank)); } [Test] @@ -174,8 +174,8 @@ public static void XlTest_BSA_DSSO() var indexResults = (IndexingResults)indexEngine.Run(); var indexedFragments = indexResults.FragmentIndex.Where(p => p != null).SelectMany(v => v).ToList(); - Assert.AreEqual(82, indexedFragments.Count); - Assert.AreEqual(3, indexResults.PeptideIndex.Count); + Assert.That(indexedFragments.Count, Is.EqualTo(82)); + Assert.That(indexResults.PeptideIndex.Count, Is.EqualTo(3)); //Get MS2 scans. var myMsDataFile = new XLTestDataFile(); @@ -205,7 +205,7 @@ public static void XlTest_BSA_DSSO() FdrAnalysisEngine fdrAnalysisEngine = new FdrAnalysisEngine(newPsms.ToList(), 0, commonParameters, fsp, new List(), ""); - Assert.AreEqual(4, newPsms.Count); + Assert.That(newPsms.Count, Is.EqualTo(4)); Assert.That(newPsms[0].XlProteinPos == 2 && newPsms[0].BetaPeptide.XlProteinPos == 4); //cross Assert.That(newPsms[1].XlProteinPos == null); //single Assert.That(newPsms[2].XlProteinPos == 4 && newPsms[2].XlProteinPosLoop == 7); //loop @@ -224,8 +224,8 @@ public static void XlTest_BSA_DSSO() var percOut = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, @"perc.txt"), Encoding.UTF8); string header = "SpecId\tLabel\tScannr\tScore\tdScore\tCharge\tMass\tPPM\tLenShort\tLenLong\tLenSum\tPeptide\tProtein"; string dataRow = "T-2-1\t1\t2\t9.080357142857142\t9.080357142857142\t3\t1994.05\t79237.2823474838\t7\t9\t16\t-.EKVLTSSAR2--LSQKFPK4.-\tFake01(2)\tFake02(4)"; - Assert.AreEqual(header, percOut[0]); - Assert.AreEqual(dataRow, percOut[1]); + Assert.That(percOut[0], Is.EqualTo(header)); + Assert.That(percOut[1], Is.EqualTo(dataRow)); File.Delete(@"perc.txt"); } @@ -339,14 +339,14 @@ public static void TestCsmSort() oneCsm.BetaPeptide.ResolveAllAmbiguities(); threeCsm.BetaPeptide.ResolveAllAmbiguities(); - Assert.AreEqual(oneCsm.UniqueSequence, oneCsm.FullSequence); + Assert.That(oneCsm.UniqueSequence, Is.EqualTo(oneCsm.FullSequence)); twoCsm.LinkPositions = new List { 1 }; twoCsm.BetaPeptide.LinkPositions = new List { 2 }; twoCsm.CrossType = PsmCrossType.Cross; - Assert.AreEqual(twoCsm.UniqueSequence, twoCsm.FullSequence + "(1)" + twoCsm.BetaPeptide.FullSequence + "(2)"); + Assert.That(twoCsm.UniqueSequence, Is.EqualTo(twoCsm.FullSequence + "(1)" + twoCsm.BetaPeptide.FullSequence + "(2)")); threeCsm.CrossType = PsmCrossType.Loop; threeCsm.LinkPositions = new List { 1, 3 }; - Assert.AreEqual(threeCsm.UniqueSequence, threeCsm.FullSequence + "(1-3)"); //Because the beta peptide link positions wasn't set, the csm unique sequence is a loop link sequence, not a crosslink sequence + Assert.That(threeCsm.UniqueSequence, Is.EqualTo(threeCsm.FullSequence + "(1-3)")); //Because the beta peptide link positions wasn't set, the csm unique sequence is a loop link sequence, not a crosslink sequence List reverse = new List { twoCsm, oneCsm, threeCsm }; @@ -526,15 +526,15 @@ public static void XlTest_MoreComprehensive() } } - Assert.AreEqual(435, inter); - Assert.AreEqual(215, intra); - Assert.AreEqual(318, single); - Assert.AreEqual(18, loop); - Assert.AreEqual(0, deadend); - Assert.AreEqual(82, deadendH2O); - Assert.AreEqual(0, deadendNH2); - Assert.AreEqual(0, deadendTris); - Assert.AreEqual(0, unnasignedCrossType); + Assert.That(inter, Is.EqualTo(435)); + Assert.That(intra, Is.EqualTo(215)); + Assert.That(single, Is.EqualTo(318)); + Assert.That(loop, Is.EqualTo(18)); + Assert.That(deadend, Is.EqualTo(0)); + Assert.That(deadendH2O, Is.EqualTo(82)); + Assert.That(deadendNH2, Is.EqualTo(0)); + Assert.That(deadendTris, Is.EqualTo(0)); + Assert.That(unnasignedCrossType, Is.EqualTo(0)); // We have pretty high peptide-level q values for crosslinks, so we need to up the cut-off is we want PEP to run commonParameters2.QValueCutoffForPepCalculation = 0.05; @@ -568,10 +568,9 @@ public static void XlTest_MoreComprehensive() } } - Assert.AreEqual(53, inter); - Assert.AreEqual(81, intra); - Assert.AreEqual(0, unnasignedCrossType); - + Assert.That(inter, Is.EqualTo(53)); + Assert.That(intra, Is.EqualTo(81)); + Assert.That(unnasignedCrossType, Is.EqualTo(0)); // We have pretty high peptide-level q values for crosslinks, so we need to up the cut-off is we want PEP to run fdrResultsXLink = new FdrAnalysisEngine(firstCsmsFromListsOfCsms.Where(c => c.CrossType != PsmCrossType.Inter && c.CrossType != PsmCrossType.Intra).ToList(), 1, commonParameters2, fsp, new List(), "standard").Run(); @@ -628,15 +627,15 @@ public static void XlTest_MoreComprehensive() } } - Assert.AreEqual(55, inter); - Assert.AreEqual(83, intra); - Assert.AreEqual(229, single); - Assert.AreEqual(8, loop); - Assert.AreEqual(0, deadend); - Assert.AreEqual(62, deadendH2O); - Assert.AreEqual(0, deadendNH2); - Assert.AreEqual(0, deadendTris); - Assert.AreEqual(0, unnasignedCrossType); + Assert.That(inter, Is.EqualTo(55)); + Assert.That(intra, Is.EqualTo(83)); + Assert.That(single, Is.EqualTo(229)); + Assert.That(loop, Is.EqualTo(8)); + Assert.That(deadend, Is.EqualTo(0)); + Assert.That(deadendH2O, Is.EqualTo(62)); + Assert.That(deadendNH2, Is.EqualTo(0)); + Assert.That(deadendTris, Is.EqualTo(0)); + Assert.That(unnasignedCrossType, Is.EqualTo(0)); var task = new PostXLSearchAnalysisTask(); task.FileSpecificParameters = new List<(string FileName, CommonParameters commonParameters)> { ("filename", new CommonParameters(maxThreadsToUsePerFile: 1)) }; @@ -647,7 +646,7 @@ public static void XlTest_MoreComprehensive() { if (csm.CrossType == PsmCrossType.Intra || csm.CrossType == PsmCrossType.Inter) { - Assert.GreaterOrEqual(csm.Score, csm.BetaPeptide.Score); + Assert.That(csm.Score >= csm.BetaPeptide.Score); } } @@ -699,24 +698,24 @@ public static void XlTest_MoreComprehensive() var intraPsmData = pepEngine.CreateOnePsmDataEntry("crosslink", intraCsm, intraCsm.BestMatchingBioPolymersWithSetMods.First().Peptide, intraCsm.BestMatchingBioPolymersWithSetMods.First().Notch, !intraCsm.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.IsDecoy); Assert.That(intraPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(1.0).Within(0.1)); Assert.That(intraPsmData.AlphaIntensity, Is.EqualTo(1).Within(0.1)); - Assert.AreEqual(intraPsmData.Ambiguity, 0); + Assert.That(intraPsmData.Ambiguity, Is.EqualTo(0)); Assert.That(intraPsmData.BetaIntensity, Is.EqualTo(1).Within(0.1)); Assert.That(intraPsmData.DeltaScore, Is.EqualTo(0).Within(0.1)); - Assert.AreEqual(intraPsmData.HydrophobicityZScore, Double.NaN); - Assert.AreEqual(intraPsmData.Intensity, 0); - Assert.AreEqual(intraPsmData.IsDeadEnd, 0); - Assert.AreEqual(intraPsmData.IsInter, 0); - Assert.AreEqual(intraPsmData.IsIntra, 1); - Assert.AreEqual(intraPsmData.IsLoop, 0); - Assert.AreEqual(intraPsmData.IsVariantPeptide, 0); - Assert.AreEqual(intraPsmData.Label, true); - Assert.AreEqual(intraPsmData.LongestFragmentIonSeries, 0); + Assert.That(intraPsmData.HydrophobicityZScore, Is.EqualTo(Double.NaN)); + Assert.That(intraPsmData.Intensity, Is.EqualTo(0)); + Assert.That(intraPsmData.IsDeadEnd, Is.EqualTo(0)); + Assert.That(intraPsmData.IsInter, Is.EqualTo(0)); + Assert.That(intraPsmData.IsIntra, Is.EqualTo(1)); + Assert.That(intraPsmData.IsLoop, Is.EqualTo(0)); + Assert.That(intraPsmData.IsVariantPeptide, Is.EqualTo(0)); + Assert.That(intraPsmData.Label, Is.EqualTo(true)); + Assert.That(intraPsmData.LongestFragmentIonSeries, Is.EqualTo(0)); Assert.That(intraPsmData.LongestFragmentIonSeries_Alpha, Is.EqualTo(9).Within(0.1)); Assert.That(intraPsmData.LongestFragmentIonSeries_Beta, Is.EqualTo(8).Within(0.1)); - Assert.AreEqual(intraPsmData.MissedCleavagesCount, 0); - Assert.AreEqual(intraPsmData.ModsCount, 0); - Assert.AreEqual(intraPsmData.Notch, 0); - Assert.AreEqual(intraPsmData.PrecursorChargeDiffToMode, -1); + Assert.That(intraPsmData.MissedCleavagesCount, Is.EqualTo(0)); + Assert.That(intraPsmData.ModsCount, Is.EqualTo(0)); + Assert.That(intraPsmData.Notch, Is.EqualTo(0)); + Assert.That(intraPsmData.PrecursorChargeDiffToMode, Is.EqualTo(-1)); Assert.That(intraPsmData.TotalMatchingFragmentCount, Is.EqualTo(11).Within(0.1)); CrosslinkSpectralMatch singleCsm = firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Single).OrderBy(c => -c.Score).First(); @@ -727,50 +726,51 @@ public static void XlTest_MoreComprehensive() singleCsm.BestMatchingBioPolymersWithSetMods.FirstOrDefault().Notch, !singleCsm.BestMatchingBioPolymersWithSetMods.FirstOrDefault().Peptide.Parent.IsDecoy); Assert.That(singleCsmPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(8).Within(0.1)); - Assert.AreEqual(singleCsmPsmData.AlphaIntensity, 0); - Assert.AreEqual(singleCsmPsmData.Ambiguity, 0); - Assert.AreEqual(singleCsmPsmData.BetaIntensity, 0); + Assert.That(singleCsmPsmData.AlphaIntensity, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.Ambiguity, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.BetaIntensity, Is.EqualTo(0)); Assert.That(singleCsmPsmData.ComplementaryIonCount, Is.EqualTo(2).Within(0.1)); Assert.That(singleCsmPsmData.DeltaScore, Is.EqualTo(8).Within(0.1)); Assert.That(singleCsmPsmData.HydrophobicityZScore, Is.EqualTo(5).Within(0.1)); Assert.That(singleCsmPsmData.Intensity, Is.EqualTo(0).Within(0.1)); - Assert.AreEqual(singleCsmPsmData.IsDeadEnd, 0); - Assert.AreEqual(singleCsmPsmData.IsInter, 0); - Assert.AreEqual(singleCsmPsmData.IsIntra, 0); - Assert.AreEqual(singleCsmPsmData.IsLoop, 0); - Assert.AreEqual(singleCsmPsmData.IsVariantPeptide, 0); - Assert.AreEqual(singleCsmPsmData.Label, true); + Assert.That(singleCsmPsmData.IsDeadEnd, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.IsInter, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.IsIntra, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.IsLoop, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.IsVariantPeptide, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.Label, Is.EqualTo(true)); Assert.That(singleCsmPsmData.LongestFragmentIonSeries, Is.EqualTo(4).Within(0.1)); - Assert.AreEqual(singleCsmPsmData.LongestFragmentIonSeries_Alpha, 0); - Assert.AreEqual(singleCsmPsmData.LongestFragmentIonSeries_Beta, 0); - Assert.AreEqual(singleCsmPsmData.MissedCleavagesCount, 0); - Assert.AreEqual(singleCsmPsmData.ModsCount, 1); - Assert.AreEqual(singleCsmPsmData.Notch, 0); - Assert.AreEqual(singleCsmPsmData.PrecursorChargeDiffToMode, -1); + Assert.That(singleCsmPsmData.LongestFragmentIonSeries_Alpha, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.LongestFragmentIonSeries_Beta, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.MissedCleavagesCount, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.ModsCount, Is.EqualTo(1)); + Assert.That(singleCsmPsmData.Notch, Is.EqualTo(0)); + Assert.That(singleCsmPsmData.PrecursorChargeDiffToMode, Is.EqualTo(-1)); Assert.That(singleCsmPsmData.TotalMatchingFragmentCount, Is.EqualTo(8).Within(0.1)); + CrosslinkSpectralMatch loopCsm = firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Loop).OrderBy(c => -c.Score).First(); var loopCsmPsmData = pepEngine.CreateOnePsmDataEntry("standard", loopCsm, loopCsm.BestMatchingBioPolymersWithSetMods.First().Peptide, loopCsm.BestMatchingBioPolymersWithSetMods.First().Notch, !loopCsm.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.IsDecoy); Assert.That(loopCsmPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(6).Within(0.1)); - Assert.AreEqual(loopCsmPsmData.AlphaIntensity, 0); - Assert.AreEqual(loopCsmPsmData.Ambiguity, 0); - Assert.AreEqual(loopCsmPsmData.BetaIntensity, 0); + Assert.That(loopCsmPsmData.AlphaIntensity, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.Ambiguity, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.BetaIntensity, Is.EqualTo(0)); Assert.That(loopCsmPsmData.ComplementaryIonCount, Is.EqualTo(3).Within(0.1)); Assert.That(loopCsmPsmData.DeltaScore, Is.EqualTo(8).Within(0.1)); Assert.That(loopCsmPsmData.HydrophobicityZScore, Is.EqualTo(9).Within(0.1)); Assert.That(loopCsmPsmData.Intensity, Is.EqualTo(1).Within(0.1)); - Assert.AreEqual(loopCsmPsmData.IsDeadEnd, 0); - Assert.AreEqual(loopCsmPsmData.IsInter, 0); - Assert.AreEqual(loopCsmPsmData.IsIntra, 0); - Assert.AreEqual(loopCsmPsmData.IsLoop, 1); - Assert.AreEqual(loopCsmPsmData.IsVariantPeptide, 0); - Assert.AreEqual(loopCsmPsmData.Label, true); + Assert.That(loopCsmPsmData.IsDeadEnd, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.IsInter, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.IsIntra, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.IsLoop, Is.EqualTo(1)); + Assert.That(loopCsmPsmData.IsVariantPeptide, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.Label, Is.EqualTo(true)); Assert.That(loopCsmPsmData.LongestFragmentIonSeries, Is.EqualTo(3).Within(0.1)); - Assert.AreEqual(loopCsmPsmData.LongestFragmentIonSeries_Alpha, 0); - Assert.AreEqual(loopCsmPsmData.LongestFragmentIonSeries_Beta, 0); - Assert.AreEqual(loopCsmPsmData.MissedCleavagesCount, 2); - Assert.AreEqual(loopCsmPsmData.ModsCount, 2); - Assert.AreEqual(loopCsmPsmData.Notch, 0); - Assert.AreEqual(loopCsmPsmData.PrecursorChargeDiffToMode, -1); + Assert.That(loopCsmPsmData.LongestFragmentIonSeries_Alpha, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.LongestFragmentIonSeries_Beta, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.MissedCleavagesCount, Is.EqualTo(2)); + Assert.That(loopCsmPsmData.ModsCount, Is.EqualTo(2)); + Assert.That(loopCsmPsmData.Notch, Is.EqualTo(0)); + Assert.That(loopCsmPsmData.PrecursorChargeDiffToMode, Is.EqualTo(-1)); Assert.That(loopCsmPsmData.TotalMatchingFragmentCount, Is.EqualTo(8).Within(0.1)); unnasignedCrossType = 0; @@ -825,15 +825,15 @@ public static void XlTest_MoreComprehensive() } } - Assert.AreEqual(0, unnasignedCrossType); - Assert.AreEqual(40, inter); - Assert.AreEqual(49, intra); - Assert.AreEqual(231, single); - Assert.AreEqual(0, loop); - Assert.AreEqual(0, deadend); - Assert.AreEqual(0, deadendH2O); - Assert.AreEqual(0, deadendNH2); - Assert.AreEqual(0, deadendTris); + Assert.That(unnasignedCrossType, Is.EqualTo(0)); + Assert.That(inter, Is.EqualTo(40)); + Assert.That(intra, Is.EqualTo(49)); + Assert.That(single, Is.EqualTo(231)); + Assert.That(loop, Is.EqualTo(0)); + Assert.That(deadend, Is.EqualTo(0)); + Assert.That(deadendH2O, Is.EqualTo(0)); + Assert.That(deadendNH2, Is.EqualTo(0)); + Assert.That(deadendTris, Is.EqualTo(0)); property.SetValue(null, false); } @@ -906,7 +906,7 @@ public static void XlTest_DiffCrosslinkSites() XLEngine.Run(); var newPsms = possiblePsms.Where(p => p != null).ToList(); - Assert.AreEqual(1, newPsms.Count); + Assert.That(newPsms.Count, Is.EqualTo(1)); } [Test] @@ -1296,20 +1296,19 @@ public static void XLSearchTastWriteFileTest() string lastRandomString = csmAlpha.BetaPeptide.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.Accession.ToString(CultureInfo.InvariantCulture) + "(" + (csmAlpha.BetaPeptide.XlProteinPos.HasValue ? csmAlpha.BetaPeptide.XlProteinPos.Value.ToString(CultureInfo.InvariantCulture) : string.Empty) + ")"; - Assert.AreEqual("NaN", csmAlpha.ScanRetentionTime.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("2", csmAlpha.ScanNumber.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("3", csmAlpha.XLTotalScore.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("3", csmAlpha.DeltaScore.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("1", csmAlpha.ScanPrecursorCharge.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("98.992723533121", csmAlpha.ScanPrecursorMass.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual(-1657.7310045328791, someSortOfMass); - Assert.AreEqual("7", csmAlpha.BetaPeptide.BaseSequence.Length.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("7", csmAlpha.BaseSequence.Length.ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("14", (csmAlpha.BetaPeptide.BaseSequence.Length + csmAlpha.BaseSequence.Length).ToString(CultureInfo.InvariantCulture)); - Assert.AreEqual("-.PEPTIDE1--PEPTIDE1.-", someLongString); - Assert.AreEqual("ACCESSION()", someOtherString); - Assert.AreEqual("ACCESSION()", lastRandomString); - + Assert.That(csmAlpha.ScanRetentionTime.ToString(CultureInfo.InvariantCulture), Is.EqualTo("NaN")); + Assert.That(csmAlpha.ScanNumber.ToString(CultureInfo.InvariantCulture), Is.EqualTo("2")); + Assert.That(csmAlpha.XLTotalScore.ToString(CultureInfo.InvariantCulture), Is.EqualTo("3")); + Assert.That(csmAlpha.DeltaScore.ToString(CultureInfo.InvariantCulture), Is.EqualTo("3")); + Assert.That(csmAlpha.ScanPrecursorCharge.ToString(CultureInfo.InvariantCulture), Is.EqualTo("1")); + Assert.That(csmAlpha.ScanPrecursorMass.ToString(CultureInfo.InvariantCulture), Is.EqualTo("98.992723533121")); + Assert.That(someSortOfMass, Is.EqualTo(-1657.7310045328791)); + Assert.That(csmAlpha.BetaPeptide.BaseSequence.Length.ToString(CultureInfo.InvariantCulture), Is.EqualTo("7")); + Assert.That(csmAlpha.BaseSequence.Length.ToString(CultureInfo.InvariantCulture), Is.EqualTo("7")); + Assert.That((csmAlpha.BetaPeptide.BaseSequence.Length + csmAlpha.BaseSequence.Length).ToString(CultureInfo.InvariantCulture), Is.EqualTo("14")); + Assert.That(someLongString, Is.EqualTo("-.PEPTIDE1--PEPTIDE1.-")); + Assert.That(someOtherString, Is.EqualTo("ACCESSION()")); + Assert.That(lastRandomString, Is.EqualTo("ACCESSION()")); WriteXlFile.WriteCrosslinkToTxtForPercolator(new List() { csmAlpha }, outputFolder, "percolator.tsv", xlinker); Directory.Delete(outputFolder, true); @@ -1555,7 +1554,7 @@ public static void TestMs2Ms3() csm.BetaPeptide.ResolveAllAmbiguities(); } // test parent scan (CID) - Assert.AreEqual(csm.MatchedFragmentIons.Count, 36); + Assert.That(csm.MatchedFragmentIons.Count, Is.EqualTo(36)); Assert.That(csm.ScanNumber == 2); // test child scan (low-resolution CID, alpha peptide signature ion) @@ -1597,7 +1596,7 @@ public static void TestMs2Ms3() public static void Test_BinarySearchGetIndex(double targetMass, int arrayIndex) { double[] massArray = new double[] { Double.NaN, 5, Double.NaN, 9.999999999, 10.000000000, 10.000000001, 11, 11, Double.NaN, Double.NaN }; - Assert.AreEqual(arrayIndex, CrosslinkSearchEngine.BinarySearchGetIndex(massArray, targetMass)); + Assert.That(CrosslinkSearchEngine.BinarySearchGetIndex(massArray, targetMass), Is.EqualTo(arrayIndex)); } internal class XLTestDataFile : MsDataFile diff --git a/MetaMorpheus/Test/gptmdPrunedBdTests.cs b/MetaMorpheus/Test/gptmdPrunedBdTests.cs index e7c23ff38..d8e5554be 100644 --- a/MetaMorpheus/Test/gptmdPrunedBdTests.cs +++ b/MetaMorpheus/Test/gptmdPrunedBdTests.cs @@ -1,6 +1,6 @@ using EngineLayer; using MassSpectrometry; -using NUnit.Framework; using Assert = NUnit.Framework.Legacy.ClassicAssert; +using NUnit.Framework; using Proteomics; using Proteomics.ProteolyticDigestion; using System; @@ -60,11 +60,11 @@ public static void TestPrunedGeneration() // ensures that protein out put contains the correct number of proteins to match the following conditions. // all proteins in DB have baseSequence!=null (not ambiguous) // all proteins that belong to a protein group are written to DB - Assert.AreEqual(18, proteins.Count); + Assert.That(proteins.Count, Is.EqualTo(18)); int totalNumberOfMods = proteins.Sum(p => p.OneBasedPossibleLocalizedModifications.Count + p.SequenceVariations.Sum(sv => sv.OneBasedModifications.Count)); //tests that modifications are being done correctly - Assert.AreEqual(0, totalNumberOfMods); + Assert.That(totalNumberOfMods, Is.EqualTo(0)); Directory.Delete(outputFolder, true); } @@ -134,15 +134,15 @@ public static void TestPrunedDatabase() DecoyType.Reverse, new List(), false, new List(), out Dictionary ok); //Dictionary 'ok' contains unknown modifications. There are no unknown modifications in this test. - Assert.AreEqual(0, ok.Count); + Assert.That(ok.Count, Is.EqualTo(0)); //One protein is read from the .xml database and one decoy is created. Therefore, the list of proteins contains 2 entries. - Assert.AreEqual(2, protein.Count); + Assert.That(protein.Count, Is.EqualTo(2)); //The original database had two localized mods on the protein. Therefore. both protein and decoy should have two mods. - Assert.AreEqual(2, protein[0].OneBasedPossibleLocalizedModifications.Count); + Assert.That(protein[0].OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(2)); List foundResidueIndicies = protein[0].OneBasedPossibleLocalizedModifications.Select(k => k.Key).ToList(); List expectedResidueIndices = new List() { 1, 3 }; Assert.That(foundResidueIndicies, Is.EquivalentTo(expectedResidueIndices)); - Assert.AreEqual(2, protein[1].OneBasedPossibleLocalizedModifications.Count); + Assert.That(protein[1].OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(2)); foundResidueIndicies = protein[1].OneBasedPossibleLocalizedModifications.Select(k => k.Key).ToList(); expectedResidueIndices = new List() { 4, 6 }; //originally modified residues are now at the end in the decoy Assert.That(foundResidueIndicies, Is.EquivalentTo(expectedResidueIndices)); @@ -152,13 +152,13 @@ public static void TestPrunedDatabase() var digestedList = protein[0].Digest(task1.CommonParameters.DigestionParams, new List { }, variableModifications).ToList(); - Assert.AreEqual(4, digestedList.Count); + Assert.That(digestedList.Count, Is.EqualTo(4)); //Set Peptide with 1 mod at position 3 PeptideWithSetModifications pepWithSetMods1 = digestedList[1]; //Finally Write MZML file - Assert.AreEqual("PEP[ConnorModType:ConnorMod on P]TID", pepWithSetMods1.FullSequence);//this might be base sequence + Assert.That(pepWithSetMods1.FullSequence, Is.EqualTo("PEP[ConnorModType:ConnorMod on P]TID"));//this might be base sequence MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); string mzmlName = @"hello.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); @@ -173,14 +173,14 @@ public static void TestPrunedDatabase() var proteins = ProteinDbLoader.LoadProteinXML(final, true, DecoyType.Reverse, new List(), false, new List(), out ok); //check length - Assert.AreEqual(1, proteins[0].OneBasedPossibleLocalizedModifications.Count); + Assert.That(proteins[0].OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(1)); //check location (key) - Assert.AreEqual(true, proteins[0].OneBasedPossibleLocalizedModifications.ContainsKey(3)); + Assert.That(proteins[0].OneBasedPossibleLocalizedModifications.ContainsKey(3), Is.EqualTo(true)); List listOfMods = proteins[0].OneBasedPossibleLocalizedModifications[3]; //check Type, count, ID - Assert.AreEqual(listOfMods[0].ModificationType, "ConnorModType"); - Assert.AreEqual(listOfMods[0].IdWithMotif, "ConnorMod on P"); - Assert.AreEqual(listOfMods.Count, 1); + Assert.That(listOfMods[0].ModificationType, Is.EqualTo("ConnorModType")); + Assert.That(listOfMods[0].IdWithMotif, Is.EqualTo("ConnorMod on P")); + Assert.That(listOfMods.Count, Is.EqualTo(1)); Directory.Delete(outputFolder, true); File.Delete(xmlName); File.Delete(mzmlName); @@ -304,25 +304,25 @@ public static void TestUserModSelectionInPrunedDB() string final = Path.Combine(MySetUpClass.outputFolder, "task5", "selectedModspruned.xml"); var proteins = ProteinDbLoader.LoadProteinXML(final, true, DecoyType.Reverse, new List(), false, new List(), out ok); var Dlist = proteins[0].GetVariantProteins().SelectMany(vp => vp.Digest(task5.CommonParameters.DigestionParams, fixedModifications, variableModifications)).ToList(); - Assert.AreEqual(Dlist[0].NumFixedMods, 1); + Assert.That(Dlist[0].NumFixedMods, Is.EqualTo(1)); //check length - Assert.AreEqual(proteins[0].OneBasedPossibleLocalizedModifications.Count, 3); + Assert.That(proteins[0].OneBasedPossibleLocalizedModifications.Count, Is.EqualTo(3)); List listOfLocalMods = new List(); listOfLocalMods.AddRange(proteins[0].OneBasedPossibleLocalizedModifications[2]); listOfLocalMods.AddRange(proteins[0].OneBasedPossibleLocalizedModifications[3]); listOfLocalMods.AddRange(proteins[0].OneBasedPossibleLocalizedModifications[11]); //check Type, count, ID - Assert.AreEqual(listOfLocalMods[0].ModificationType, "Common Fixed"); - Assert.AreEqual(listOfLocalMods[2].ModificationType, "missing"); - Assert.IsFalse(listOfLocalMods.Contains(connorMod)); //make sure that mod set not to show up is not in mod list + Assert.That(listOfLocalMods[0].ModificationType, Is.EqualTo("Common Fixed")); + Assert.That(listOfLocalMods[2].ModificationType, Is.EqualTo("missing")); + Assert.That(!listOfLocalMods.Contains(connorMod)); //make sure that mod set not to show up is not in mod list - Assert.AreEqual(listOfLocalMods[0].IdWithMotif, "Default(Mod in DB and Observed) on P"); - Assert.AreEqual(listOfLocalMods[1].IdWithMotif, "ModToAlwaysAppear on P"); + Assert.That(listOfLocalMods[0].IdWithMotif, Is.EqualTo("Default(Mod in DB and Observed) on P")); + Assert.That(listOfLocalMods[1].IdWithMotif, Is.EqualTo("ModToAlwaysAppear on P")); //Makes sure Mod that was not in the DB but was observed is in pruned DB - Assert.AreEqual(listOfLocalMods[2].IdWithMotif, "ModObservedNotinDB on E"); - Assert.AreEqual(listOfLocalMods.Count, 3); + Assert.That(listOfLocalMods[2].IdWithMotif, Is.EqualTo("ModObservedNotinDB on E")); + Assert.That(listOfLocalMods.Count, Is.EqualTo(3)); Directory.Delete(outputFolder, true); File.Delete(mzmlName); File.Delete(xmlName); @@ -517,10 +517,10 @@ public static void TestProteinPrunedWithModSelectionAndVariants() var proteinsLoaded = ProteinDbLoader.LoadProteinXML(path, true, DecoyType.None, GlobalVariables.AllModsKnown, false, new List(), out var unknownMods); // assert that mods on proteins are the same before/after task is run - Assert.AreEqual(protein1Variants.First().Accession, proteinsLoaded.First().Accession); - Assert.AreEqual(protein1Variants.First().OneBasedPossibleLocalizedModifications.Count(), proteinsLoaded.First().OneBasedPossibleLocalizedModifications.Count()); - Assert.AreEqual(protein2.OneBasedPossibleLocalizedModifications.Count(), proteinsLoaded.ElementAt(1).OneBasedPossibleLocalizedModifications.Count()); - + Assert.That(protein1Variants.First().Accession, Is.EqualTo(proteinsLoaded.First().Accession)); + Assert.That(protein1Variants.First().OneBasedPossibleLocalizedModifications.Count(), Is.EqualTo(proteinsLoaded.First().OneBasedPossibleLocalizedModifications.Count())); + Assert.That(protein2.OneBasedPossibleLocalizedModifications.Count(), Is.EqualTo(proteinsLoaded.ElementAt(1).OneBasedPossibleLocalizedModifications.Count())); + // assert that protein pruned DB has correct proteins mods var proteinPruned = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"PrunedDbTest/fakeDbproteinPruned.xml"), true, DecoyType.None, GlobalVariables.AllModsKnown, false, new List(), out var unknownMods1); Assert.That(proteinPruned.Count().Equals(1));