Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bio array tests #101

Merged
merged 9 commits into from
Jul 16, 2020
63 changes: 63 additions & 0 deletions tests/BioFSharp.Tests.NetCore/BioFSharp/BioCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,69 @@ let bioCollectionsTests =
"BioArray.translate did not translate the transcript correctly."
)

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

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

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

testCase "toAverageMass" (fun() ->
Expect.floatClose
Accuracy.medium // High accuracy was not passing test
(testProt |> BioArray.toAverageMass)
// Masses obtained from University of Washington Proteomics Resource https://proteomicsresource.washington.edu/protocols06/masses.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like that you included sources here, so when we have to revisit these tests we have the references in the code.

(131.19606 + 99.13106 + 113.15764)
"BioArray.toAverageMass did not return correct mass"
)

testCase "toMonoisotopicMassWith" (fun () ->
Expect.floatClose
Accuracy.high
(testProt |> BioArray.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)
"BioArray.toMonoisotopicMassWith did not return correct mass"
)

testCase "toAverageMassWith" (fun () ->
Expect.floatClose
Accuracy.medium
(testProt |> BioArray.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)
"BioArray.toAverageMassWith did not return correct mass"
)

testCase "toCompositionVector" (fun () ->
let testCompVec = Array.zeroCreate 26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test you are also dependent on BioItem.symbol working as expected. It would make the test more isolated if you initialize the test composition vector without being dependent on other code (e.g. using the correct characters in lines 182-184).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add changes to this PR, the only thing you have to do is add new commits to your branch, they will be automatically added to the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kMutagene,

Thanks for the suggestions. I updated the code to no longer be dependent on BioItem.symbol and committed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

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 |> BioArray.toCompositionVector)
testCompVec
"BioArray.toCompositionVector did not return correct vector"
)
]

testList "BioList" [
Expand Down