From acc78f9fd2033fc598c64512f3556764d308e61b Mon Sep 17 00:00:00 2001 From: graemevissers <51211544+graemevissers@users.noreply.github.com> Date: Fri, 7 Aug 2020 01:26:29 -0700 Subject: [PATCH] #30: Add AminoAcids tests (#107) * Add "teset_rangePpm" to testList "BioFSharp.Mass" * Add testCase "formula" to testList "AminoAcids" * Add "formulaModifiedAA" to testList "AminoAcids" * Fix "formulaModifiedAA" testCase * Add "isTerminator" to testList "AminoAcids" * Add "isGap" to testList "AminoAcids" * Add "setModification" to testList "AminoAcids" * Clean up tests * Change error message for test "setModification" * Add "setModifications" to "AminoAcids" testList * Add "getModifications" to "AminoAcids" testList --- .../BioFSharp/AminoAcidTests.fs | 67 +++++++++++++++++-- .../BioFSharp/BioItemTests.fs | 6 ++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/tests/BioFSharp.Tests.NetCore/BioFSharp/AminoAcidTests.fs b/tests/BioFSharp.Tests.NetCore/BioFSharp/AminoAcidTests.fs index 988c4168..8a5993fa 100644 --- a/tests/BioFSharp.Tests.NetCore/BioFSharp/AminoAcidTests.fs +++ b/tests/BioFSharp.Tests.NetCore/BioFSharp/AminoAcidTests.fs @@ -16,6 +16,16 @@ let allNames = [ "Glutamine/glutamic acid" ; "Asparagine/aspartic acid" ; "Gap" ; "Ter" ] +let allFormulas = [ + Formula.Table.Ala ; Formula.Table.Cys ; Formula.Table.Asp ; Formula.Table.Glu + Formula.Table.Phe ; Formula.Table.Gly ; Formula.Table.His ; Formula.Table.Ile + Formula.Table.Lys ; Formula.Table.Leu ; Formula.Table.Met ; Formula.Table.Asn + Formula.Table.Pyl ; Formula.Table.Pro ; Formula.Table.Gln ; Formula.Table.Arg + Formula.Table.Ser ; Formula.Table.Thr ; Formula.Table.Sel ; Formula.Table.Sec; Formula.Table.Val + Formula.Table.Trp ; Formula.Table.Tyr ; Formula.Table.Xaa ; Formula.Table.Xle + Formula.Table.Glx ; Formula.Table.Asx ; Formula.emptyFormula ; Formula.emptyFormula +] + let testModifiedAA = AminoAcid.Mod (AminoAcid.Ala,[ModificationInfo.Table.N15]) let allAAs = [ @@ -28,6 +38,9 @@ let allAAs = [ AminoAcid.Glx; AminoAcid.Asx; AminoAcid.Gap; AminoAcid.Ter ] +let allSingleModAAs = allAAs |> List.map (fun aa -> AminoAcids.Mod (aa, [ModificationInfo.Table.N15])) +let allDoubleModAAs = allAAs |> List.map (fun aa -> AminoAcids.Mod (aa, [ModificationInfo.Table.N15; ModificationInfo.Table.H2O])) + [] let aminoAcidTests = testList "AminoAcids" [ @@ -52,9 +65,53 @@ let aminoAcidTests = "AminoAcids.name did not return the correct name for all AminoAcids" ) testCase "nameModifiedAA" (fun () -> - Expect.equal - (testModifiedAA |> AminoAcids.name) - "Alanine[#N15]" - "AminoAcids.symbol did not return the correct symbols for a 15N modified Alanine" - ) + Expect.equal + (testModifiedAA |> AminoAcids.name) + "Alanine[#N15]" + "AminoAcids.symbol did not return the correct symbols for a 15N modified Alanine" + ) + testCase "formula" (fun () -> + let testFormulas = allAAs |> List.map (fun aa -> AminoAcids.formula aa) + Expect.equal + testFormulas + allFormulas + "AminoAcids.formula did not return the correct formula for all AminoAcids" + ) + testCase "formulaModifiedAA" (fun () -> + let modFormula = Formula.replaceElement Formula.Table.Ala Elements.Table.N Elements.Table.Heavy.N15 + Expect.equal + (testModifiedAA |> AminoAcids.formula) + modFormula + "AminoAcids.formula did not return the correct formula for a 15N modified Alanine" + ) + testCase "isTerminator" (fun () -> + Expect.isTrue + (AminoAcids.isTerminator AminoAcid.Ter) + "AminoAcids.isTerminator did not return true for a Terminator" + ) + testCase "isGap" (fun () -> + Expect.isTrue + (AminoAcids.isGap AminoAcid.Gap) + "AminoAcids.isGap did not return true for a Gap" + ) + testCase "setModification" (fun () -> + Expect.equal + (allAAs |> List.map (fun aa -> AminoAcids.setModification ModificationInfo.Table.N15 aa)) + allSingleModAAs + "AminoAcids.setModification did not return the correct Modifications for all AminoAcids" + ) + testCase "setModifications" (fun () -> + let modList = [ModificationInfo.Table.N15; ModificationInfo.Table.H2O] + Expect.equal + (allAAs |> List.map (fun aa -> AminoAcids.setModifications modList aa)) + allDoubleModAAs + "AminoAcids.setModifications did not return the correct Modifications for all AminoAcids" + ) + testCase "getModifications" (fun () -> + let allMods = [for i in 1 .. 29 -> [ModificationInfo.Table.N15]] + Expect.equal + (allSingleModAAs |> List.map (fun aa -> AminoAcids.getModifications aa)) + allMods + "AminoAcids.getModifications did not return correct Modifications for all modified AminoAcids" + ) ] \ No newline at end of file diff --git a/tests/BioFSharp.Tests.NetCore/BioFSharp/BioItemTests.fs b/tests/BioFSharp.Tests.NetCore/BioFSharp/BioItemTests.fs index 0e12780f..9531a930 100644 --- a/tests/BioFSharp.Tests.NetCore/BioFSharp/BioItemTests.fs +++ b/tests/BioFSharp.Tests.NetCore/BioFSharp/BioItemTests.fs @@ -362,6 +362,12 @@ let testMass = let exp = 0.1 Expect.floatClose Accuracy.high res exp "Delta mass calculation failed." + testCase "test_rangePpm" <| fun () -> + let mass = 1000. + let ppm = 100. + let res = rangePpm ppm mass + let exp = (999.9,1000.1) + Expect.equal res exp "Range of ppm calculation failed" ]