-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIN: Apply suggestions from code review
Signed-off-by: Thomas Kemmer <[email protected]>
- Loading branch information
Showing
4 changed files
with
99 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# File formats | ||
```@meta | ||
CurrentModule = BiochemicalAlgorithms | ||
``` | ||
|
||
```@index | ||
Pages = ["fileformats.md"] | ||
``` | ||
|
||
```@docs | ||
load_hinfile | ||
write_hinfile | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,56 @@ | ||
@testitem "reading HIN files" begin | ||
sys = load_hinfile(ball_data_path("../test/data/hinfile_test.hin")) | ||
|
||
@test natoms(sys) == 648 | ||
@test nmolecules(sys) == 216 | ||
@test nfragments(sys) == 0 | ||
|
||
a = first(atoms(sys)) | ||
@test a.name == "O" | ||
@test a.element == Elements.O | ||
@test a.charge ≈ -0.834 | ||
@test a.r ≈ Vector3(0.59038, -0.410275, -0.860515) | ||
@test nbonds(a) == 2 | ||
|
||
@test get_property(sys, :temperature) ≈ 297.5626 | ||
|
||
@test get_property(sys, :periodic_box_width) ≈ 18.70136 | ||
@test get_property(sys, :periodic_box_height) ≈ 18.70136 | ||
@test get_property(sys, :periodic_box_depth) ≈ 18.70136 | ||
|
||
sys = load_hinfile(ball_data_path("../test/data/AlaGlySer.hin")) | ||
|
||
@test natoms(sys) == 31 | ||
@test nmolecules(sys) == 1 | ||
@test nfragments(sys) == 3 | ||
@test nresidues(sys) == 3 | ||
@test nchains(sys) == 1 | ||
@test nbonds(sys) == 30 | ||
|
||
@test_throws SystemError load_hinfile(ball_data_path("../test/data/ASDFASDFASEFADSFASDFAEW.hin")) | ||
@test_throws MethodError load_hinfile(ball_data_path("../test/data/hinfile_test_invalid.hin")) | ||
for T in [Float32, Float64] | ||
sys = load_hinfile(ball_data_path("../test/data/hinfile_test.hin"), T) | ||
|
||
@test natoms(sys) == 648 | ||
@test nmolecules(sys) == 216 | ||
@test nfragments(sys) == 0 | ||
|
||
a = first(atoms(sys)) | ||
@test a.name == "O" | ||
@test a.element == Elements.O | ||
@test a.charge ≈ -0.834 | ||
@test a.r ≈ Vector3{T}(0.5903809, -0.4102751, -0.8605154) | ||
@test nbonds(a) == 2 | ||
|
||
@test get_property(sys, :temperature) ≈ 297.5626 | ||
|
||
@test get_property(sys, :periodic_box_width) ≈ 18.70136 | ||
@test get_property(sys, :periodic_box_height) ≈ 18.70136 | ||
@test get_property(sys, :periodic_box_depth) ≈ 18.70136 | ||
|
||
sys = load_hinfile(ball_data_path("../test/data/AlaGlySer.hin"), T) | ||
|
||
@test natoms(sys) == 31 | ||
@test nmolecules(sys) == 1 | ||
@test nfragments(sys) == 3 | ||
@test nresidues(sys) == 3 | ||
@test nchains(sys) == 1 | ||
@test nbonds(sys) == 30 | ||
|
||
@test_throws SystemError load_hinfile(ball_data_path("../test/data/ASDFASDFASEFADSFASDFAEW.hin"), T) | ||
@test_throws MethodError load_hinfile(ball_data_path("../test/data/hinfile_test_invalid.hin"), T) | ||
end | ||
end | ||
|
||
@testitem "writing HIN files" begin | ||
sys = load_hinfile(ball_data_path("../test/data/hinfile_test.hin")) | ||
for T in [Float32, Float64] | ||
sys = load_hinfile(ball_data_path("../test/data/hinfile_test.hin"), T) | ||
|
||
outfname = tempname() | ||
write_hinfile(outfname, sys) | ||
outfname = tempname() | ||
write_hinfile(outfname, sys) | ||
|
||
sys2 = load_hinfile(outfname) | ||
sys2 = load_hinfile(outfname, T) | ||
|
||
@test sys == sys2 | ||
@test sys == sys2 | ||
|
||
# test name truncation | ||
first(atoms(sys)).name = "TEST NAME" | ||
# test name truncation | ||
first(atoms(sys)).name = "TEST NAME" | ||
|
||
write_hinfile(outfname, sys) | ||
write_hinfile(outfname, sys) | ||
|
||
sys2 = load_hinfile(outfname) | ||
sys2 = load_hinfile(outfname, T) | ||
|
||
@test first(atoms(sys2)).name == "TEST" | ||
end | ||
@test first(atoms(sys2)).name == "TEST" | ||
end | ||
end |