Skip to content

Commit

Permalink
#30 : Add bio list tests (#103)
Browse files Browse the repository at this point in the history
* Add testCase "isEqual" to BioList testList

* Add testCase "toString" to testList "BioList"

* Fix "toString" and add "toMonoisotopicMass" test

* Add testCase "toAverageMass"

* Add "toMonoisotopicMassWith"

* Add testCase "toAverageMassWith"

* Add testCase "toCompositionVector"

* Fix error message for "toCompositionVector"

* Change "BioList.ofBioArray" to "List.ofArray"
  • Loading branch information
graemevissers authored Jul 21, 2020
1 parent 00f9b39 commit 92060ff
Showing 1 changed file with 70 additions and 6 deletions.
76 changes: 70 additions & 6 deletions tests/BioFSharp.Tests.NetCore/BioFSharp/BioCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -237,46 +237,110 @@ let bioCollectionsTests =

testCase "complement" (fun () ->
Expect.equal
(testCodingStrand |> BioList.ofBioArray |> BioList.complement)
(testCodingStrand |> List.ofArray |> BioList.complement)
(testTemplateStrand |> List.ofArray)
"BioList.complement did not build the reverse complement of the nucleotide sequence correctly."
)

testCase "reverseComplement" (fun () ->
Expect.equal
(testCodingStrand |> BioList.ofBioArray |> BioList.reverseComplement)
(testCodingStrand |> List.ofArray |> BioList.reverseComplement)
(testCodingStrandRevComplement |> List.ofArray)
"BioList.reverseComplement did not build the reverse complement of the nucleotide sequence correctly."
)

testCase "mapInTriplets" (fun () ->
Expect.equal
(testTemplateStrand |> BioList.ofBioArray |> BioList.mapInTriplets id)
(testTemplateStrand |> List.ofArray |> BioList.mapInTriplets id)
(testTriplets |> List.ofArray)
"BioList.reverseComplement did not build the correct base triplets."
)

testCase "transcribeCodeingStrand" (fun () ->
Expect.equal
(testCodingStrand |> BioList.ofBioArray |> BioList.transcribeCodingStrand)
(testCodingStrand |> List.ofArray |> BioList.transcribeCodingStrand)
(testTranscript |> List.ofArray)
"BioList.transcribeCodeingStrand did not transcribe the coding strand correctly."
)

testCase "transcribeTemplateStrand" (fun () ->
Expect.equal
(testTemplateStrand |> BioList.ofBioArray |> BioList.transcribeTemplateStrand)
(testTemplateStrand |> List.ofArray |> BioList.transcribeTemplateStrand)
(testTranscript |> List.ofArray)
"BioList.transcribeTemplateStrand did not transcribe the template strand correctly."
)

testCase "translate" (fun () ->
Expect.equal
(testTranscript |> BioList.ofBioArray |> BioList.translate 0)
(testTranscript |> List.ofArray |> BioList.translate 0)
(testProt |> List.ofArray)
"BioList.translate did not translate the transcript correctly."
)

testCase "isEqual" (fun () ->
Expect.equal
(testTranscript |> List.ofArray
|> BioList.isEqual (testTranscript |> List.ofArray))
0
"BioList.isEqual did not return correct integer when transcripts were equal."
)

testCase "toString" (fun () ->
Expect.equal
(aminoAcidSetArray |> List.ofArray |> BioList.toString)
"ACDEFGHIKLMNOPQRSTUVWYXJZB-*"
"BioList.toString did not return the correct string"
)

testCase "toMonoisotopicMass" (fun () ->
Expect.floatClose
Accuracy.high
(testProt |> List.ofArray |> BioList.toMonoisotopicMass)
// Masses obtained from University of Washington Proteomics Resource https://proteomicsresource.washington.edu/protocols06/masses.php
(131.04048 + 99.06841 + 113.08406)
"BioList.toMonoisotopicMass did not return correct mass"
)

testCase "toAverageMass" (fun() ->
Expect.floatClose
Accuracy.medium // High accuracy was not passing test
(testProt |> List.ofArray |> BioList.toAverageMass)
// Masses obtained from University of Washington Proteomics Resource https://proteomicsresource.washington.edu/protocols06/masses.php
(131.19606 + 99.13106 + 113.15764)
"BioList.toAverageMass did not return correct mass"
)

testCase "toMonoisotopicMassWith" (fun () ->
Expect.floatClose
Accuracy.high
(testProt |> List.ofArray |> BioList.toMonoisotopicMassWith 18.0) // 18 = mass of one water molecule
// Masses obtained from University of Washington Proteomics Resource https://proteomicsresource.washington.edu/protocols06/masses.php
(131.04048 + 99.06841 + 113.08406 + 18.0)
"BioList.toMonoisotopicMassWith did not return correct mass"
)

testCase "toAverageMassWith" (fun () ->
Expect.floatClose
Accuracy.medium
(testProt |> List.ofArray |> BioList.toAverageMassWith 18.0) // 18 = mass of one water molecule
// Masses obtained from University of Washington Proteomics Resource https://proteomicsresource.washington.edu/protocols06/masses.php
(131.19606 + 99.13106 + 113.15764 + 18.0)
"BioList.toAverageMassWith did not return correct mass"
)

testCase "toCompositionVector" (fun () ->
let testCompVec = Array.zeroCreate 26
let metIndex = 12 // Value of (int(BioItem.symbol Met)) - 65
let valIndex = 21 // Value of (int(BioItem.symbol Val)) - 65
let leuIndex = 11 // Value of (int(BioItem.symbol Leu)) - 65
testCompVec.[metIndex] <- testCompVec.[metIndex] + 1
testCompVec.[valIndex] <- testCompVec.[valIndex] + 1
testCompVec.[leuIndex] <- testCompVec.[leuIndex] + 1
Expect.equal
(testProt |> List.ofArray |> BioList.toCompositionVector)
testCompVec
"BioList.toCompositionVector did not return correct vector"
)
]

testList "BioSeq" [
Expand Down

0 comments on commit 92060ff

Please sign in to comment.