Skip to content

Commit

Permalink
#30: Add AminoAcids tests (#107)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
graemevissers authored Aug 7, 2020
1 parent af6ef09 commit acc78f9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
67 changes: 62 additions & 5 deletions tests/BioFSharp.Tests.NetCore/BioFSharp/AminoAcidTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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]))

[<Tests>]
let aminoAcidTests =
testList "AminoAcids" [
Expand All @@ -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"
)
]
6 changes: 6 additions & 0 deletions tests/BioFSharp.Tests.NetCore/BioFSharp/BioItemTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]


Expand Down

0 comments on commit acc78f9

Please sign in to comment.