Skip to content

Commit

Permalink
Add test cases and fix reference geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf-meyer committed Apr 30, 2024
1 parent 9378d27 commit ae35599
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 48 deletions.
12 changes: 6 additions & 6 deletions molSimplify/Data/tbp.dat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0.0 0.0 0.0
-1.7865930597 -0.0003546225 -0.0007425232
1.7865967124 -0.0003546332 -0.0007425118
2.86499999724e-07 1.382576768 -1.1498771629
2.92799999801e-07 0.2985354596 1.7728580026
4.09099999654e-07 -1.6828658296 -0.6318871017
0.00000 0.00000 0.00000
2.00000 0.00000 0.00000
-1.00000 1.73205 0.00000
-1.00000 -1.73205 0.00000
0.00000 0.00000 2.00000
0.00000 0.00000 -2.00000
6 changes: 3 additions & 3 deletions molSimplify/Data/tpl.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.00000 0.00000 0.00000
-1.58487 0.39844 0.52472
0.77037 -1.41380 0.59470
0.78682 0.99734 -1.17123
2.00000 0.00000 0.00000
-1.00000 1.73205 0.00000
-1.00000 -1.73205 0.00000
66 changes: 66 additions & 0 deletions tests/test_mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from molSimplify.Classes.mol3D import mol3D
from molSimplify.Classes.atom3D import atom3D
from molSimplify.Classes.globalvars import globalvars


def test_adding_and_deleting_atoms():
Expand Down Expand Up @@ -335,3 +336,68 @@ def test_mol3D_from_smiles_benzene():

np.testing.assert_allclose(mol.graph, ref_graph)
np.testing.assert_allclose(mol.bo_graph, ref_bo_graph)


@pytest.mark.parametrize(
"geo_type, key",
[
('linear', 'linear'),
('trigonal_planar', 'trigonal planar'),
('t_shape', 'T shape'),
('trigonal_pyramidal', 'trigonal pyramidal'),
('tetrahedral', 'tetrahedral'),
('square_planar', 'square planar'),
('seesaw', 'seesaw'),
('trigonal_bipyramidal', 'trigonal bipyramidal'),
('square_pyramidal', 'square pyramidal'),
('pentagonal_planar', 'pentagonal planar'),
('octahedral', 'octahedral'),
('pentagonal_pyramidal', 'pentagonal pyramidal'),
# ('trigonal_prismatic', 'trigonal prismatic'),
# ('pentagonal_bipyramidal', 'pentagonal bipyramidal'),
# ('square_antiprismatic', 'square antiprismatic'),
# ('tricapped_trigonal_prismatic', 'tricapped trigonal prismatic'),
]
)
def test_dev_from_ideal_geometry(resource_path_root, geo_type, key):
mol = mol3D()
mol.readfromxyz(resource_path_root / "inputs" / "geometry_type" / f"{geo_type}.xyz")

globs = globalvars()
polyhedra = globs.get_all_polyhedra()
rmsd, max_dev = mol.dev_from_ideal_geometry(polyhedra[key])

print(polyhedra[key])

assert rmsd < 1e-3
assert max_dev < 1e-3


@pytest.mark.parametrize(
"geo_type, ref",
[
('linear', 'linear'),
('trigonal_planar', 'trigonal planar'),
('t_shape', 'T shape'),
('trigonal_pyramidal', 'trigonal pyramidal'),
('tetrahedral', 'tetrahedral'),
('square_planar', 'square planar'),
('seesaw', 'seesaw'),
('trigonal_bipyramidal', 'trigonal bipyramidal'),
('square_pyramidal', 'square pyramidal'),
('pentagonal_planar', 'pentagonal planar'),
('octahedral', 'octahedral'),
('pentagonal_pyramidal', 'pentagonal pyramidal'),
('trigonal_prismatic', 'trigonal prismatic'),
# ('pentagonal_bipyramidal', 'pentagonal bipyramidal'),
# ('square_antiprismatic', 'square antiprismatic'),
# ('tricapped_trigonal_prismatic', 'tricapped trigonal prismatic'),
]
)
def test_geo_geometry_type_distance(resource_path_root, geo_type, ref):
mol = mol3D()
mol.readfromxyz(resource_path_root / "inputs" / "geometry_type" / f"{geo_type}.xyz")

result = mol.get_geometry_type_distance()
print(result)
assert result['geometry'] == ref
26 changes: 13 additions & 13 deletions tests/testresources/inputs/geometry_type/seesaw.xyz
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
13
07/15/2022 21:19, XYZ structure generated by mol3D Class, molSimplify
04/30/2024 13:23, XYZ structure generated by mol3D Class, molSimplify
Fe 0.000000 0.000000 0.000000
O -2.120000 -0.000421 -0.000881
H -2.730515 0.026086 0.779322
H -2.727124 -0.028395 -0.783794
O 2.120000 -0.000421 -0.000881
H 2.728823 -0.572514 -0.533990
H 2.728652 0.572801 0.531233
O 0.000000 1.629945 -1.355611
H 0.153088 1.607265 -2.334413
H -0.153473 2.588291 -1.155199
O 0.000000 -1.984703 -0.745222
H 0.126817 -2.825828 -0.236778
H -0.126096 -2.282875 -1.681767
O 2.120000 0.000000 0.000000
H 2.726198 0.027327 -0.782547
H 2.726184 -0.027327 0.782547
O -1.060000 1.835974 0.000000
H -1.410402 2.333646 -0.781116
H -1.315789 2.388255 0.781116
O 0.000000 0.000000 2.120000
H -0.293326 -0.726007 2.726198
H 0.293326 0.726007 2.726184
O 0.000000 -0.000000 -2.120000
H 0.222961 0.750609 -2.726198
H -0.222961 -0.750609 -2.726184
32 changes: 16 additions & 16 deletions tests/testresources/inputs/geometry_type/trigonal_bipyramidal.xyz
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
16
07/15/2022 21:19, XYZ structure generated by mol3D Class, molSimplify
04/30/2024 13:23, XYZ structure generated by mol3D Class, molSimplify
Fe 0.000000 0.000000 0.000000
O -2.120000 -0.000421 -0.000881
H -2.730515 0.026086 0.779322
H -2.727124 -0.028395 -0.783794
O 2.120000 -0.000421 -0.000881
H 2.728823 -0.572514 -0.533990
H 2.728652 0.572801 0.531233
O 0.000000 1.629945 -1.355611
H 0.153088 1.607265 -2.334413
H -0.153473 2.588291 -1.155199
O 0.000000 0.352035 2.090567
H 0.153533 1.209399 2.563291
H -0.153710 -0.303124 2.818062
O 0.000000 -1.984703 -0.745222
H 0.126817 -2.825828 -0.236778
H -0.126096 -2.282875 -1.681767
O 2.120000 0.000000 0.000000
H 2.726198 0.027327 -0.782547
H 2.726184 -0.027327 0.782547
O -1.060000 1.835974 0.000000
H -1.410402 2.333646 -0.781116
H -1.315789 2.388255 0.781116
O -1.060000 -1.835974 0.000000
H -1.292217 -2.401880 -0.778734
H -1.433975 -2.320020 0.778734
O 0.000000 0.000000 2.120000
H -0.293326 -0.726007 2.726198
H 0.293326 0.726007 2.726184
O 0.000000 -0.000000 -2.120000
H 0.222961 0.750609 -2.726198
H -0.222961 -0.750609 -2.726184
20 changes: 10 additions & 10 deletions tests/testresources/inputs/geometry_type/trigonal_planar.xyz
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
10
07/15/2022 21:12, XYZ structure generated by mol3D Class, molSimplify
04/30/2024 13:14, XYZ structure generated by mol3D Class, molSimplify
Fe 0.000000 0.000000 0.000000
O -1.957585 0.492141 0.648119
H -2.404883 0.225459 1.491371
H -2.634735 1.041484 0.176951
O 0.951527 -1.746264 0.734547
H 1.923472 -1.917547 0.825504
H 0.526130 -2.578001 1.065509
O 0.965381 1.223677 -1.437030
H 0.569473 1.950860 -1.981760
H 1.915622 1.199311 -1.717647
O 2.120000 0.000000 0.000000
H 2.726198 0.027327 -0.782547
H 2.726184 -0.027327 0.782547
O -1.060000 1.835974 0.000000
H -1.410402 2.333646 -0.781116
H -1.315789 2.388255 0.781116
O -1.060000 -1.835974 0.000000
H -1.292217 -2.401880 -0.778734
H -1.433975 -2.320020 0.778734

0 comments on commit ae35599

Please sign in to comment.