Skip to content

Commit

Permalink
Add test cases for MOF_descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf-meyer committed Dec 16, 2023
1 parent 7861aae commit 06040bf
Show file tree
Hide file tree
Showing 12 changed files with 1,473 additions and 176 deletions.
392 changes: 216 additions & 176 deletions molSimplify/Informatics/MOF/MOF_descriptors.py

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions tests/informatics/test_MOF_descriptors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import pytest
import json
import numpy as np
from molSimplify.Informatics.MOF.MOF_descriptors import get_MOF_descriptors
from molSimplify.utils.timer import DebugTimer


@pytest.fixture
def ref_names(depth=3):

def RACs_names(starts, properties, depth, scope="all"):
names = []
for start in starts:
for prop in properties:
for d in range(depth + 1):
if scope is None:
names.append(f"{start}-{prop}-{d}")
else:
names.append(f"{start}-{prop}-{d}-{scope}")
return names

properties = ["chi", "Z", "I", "T", "S", "Gval"]

names = RACs_names(["f", "mc", "D_mc"], properties, depth)
# f-lig does not include the "scope"
names.extend(RACs_names(["f-lig"], properties, depth, scope=None))

# Same for the starts that include the additional property alpha
properties.append("alpha")
names.extend(
RACs_names(["lc", "D_lc", "func", "D_func"], properties, depth))
return names


@pytest.mark.parametrize(
"name",
["odac-21383.cif",
"odac-21433.cif",
"odac-21478.cif",
"odac-21735.cif",
"odac-21816.cif"])
def test_get_MOF_descriptors(resource_path_root, tmpdir, name, ref_names):
with DebugTimer("get_MOF_descriptors()"):
full_names, full_descriptors = get_MOF_descriptors(
str(resource_path_root / "inputs" / "cif_files" / name),
depth=3,
path=str(tmpdir),
xyzpath=str(tmpdir / "test.xyz"),
Gval=True,
)

with open(resource_path_root / "refs" / "MOF_descriptors"
/ name.replace("cif", "json"), "r") as fin:
ref = json.load(fin)

assert full_names == ref_names
np.testing.assert_allclose(full_descriptors, ref["descriptors"], atol=1e-6)
261 changes: 261 additions & 0 deletions tests/testresources/inputs/cif_files/odac-21383.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
data_image0
_chemical_formula_structural Ga36P36O148F16
_chemical_formula_sum "Ga36 P36 O148 F16"
_cell_length_a 17.7002
_cell_length_b 32.7061
_cell_length_c 10.1684
_cell_angle_alpha 90
_cell_angle_beta 90
_cell_angle_gamma 90

_space_group_name_H-M_alt "P 1"
_space_group_IT_number 1

loop_
_space_group_symop_operation_xyz
'x, y, z'

loop_
_atom_site_type_symbol
_atom_site_label
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
Ga Ga1 1.0 0.43059 0.92287 0.05643 1.0000
Ga Ga2 1.0 0.48410 0.02595 0.02197 1.0000
Ga Ga3 1.0 0.15815 0.98867 0.88183 1.0000
Ga Ga4 1.0 0.34659 0.50676 0.58670 1.0000
Ga Ga5 1.0 0.08393 0.57961 0.42319 1.0000
Ga Ga6 1.0 0.02252 0.47611 0.45525 1.0000
Ga Ga7 1.0 0.34114 0.66620 0.58927 1.0000
Ga Ga8 1.0 0.17185 0.82627 0.88792 1.0000
Ga Ga9 1.0 0.30408 0.75647 0.92147 1.0000
Ga Ga10 1.0 0.57037 0.07744 0.55502 1.0000
Ga Ga11 1.0 0.51611 0.97446 0.52138 1.0000
Ga Ga12 1.0 0.84196 0.01129 0.38288 1.0000
Ga Ga13 1.0 0.65341 0.49313 0.08664 1.0000
Ga Ga14 1.0 0.91594 0.42029 0.92329 1.0000
Ga Ga15 1.0 0.97747 0.52383 0.95523 1.0000
Ga Ga16 1.0 0.65877 0.33342 0.08974 1.0000
Ga Ga17 1.0 0.82830 0.17378 0.38821 1.0000
Ga Ga18 1.0 0.69648 0.24360 0.42307 1.0000
Ga Ga19 1.0 0.92996 0.07736 0.05544 1.0000
Ga Ga20 1.0 0.98407 0.97427 0.02212 1.0000
Ga Ga21 1.0 0.65807 0.01135 0.88314 1.0000
Ga Ga22 1.0 0.84658 0.49311 0.58664 1.0000
Ga Ga23 1.0 0.58408 0.42027 0.42331 1.0000
Ga Ga24 1.0 0.52254 0.52381 0.45523 1.0000
Ga Ga25 1.0 0.84123 0.33342 0.58976 1.0000
Ga Ga26 1.0 0.67187 0.17378 0.88815 1.0000
Ga Ga27 1.0 0.80356 0.24360 0.92309 1.0000
Ga Ga28 1.0 0.07041 0.92272 0.55490 1.0000
Ga Ga29 1.0 0.01582 0.02574 0.52223 1.0000
Ga Ga30 1.0 0.34172 0.98885 0.38206 1.0000
Ga Ga31 1.0 0.15340 0.50686 0.08665 1.0000
Ga Ga32 1.0 0.41599 0.57969 0.92325 1.0000
Ga Ga33 1.0 0.47749 0.47615 0.95522 1.0000
Ga Ga34 1.0 0.15876 0.66660 0.08951 1.0000
Ga Ga35 1.0 0.32817 0.82575 0.38620 1.0000
Ga Ga36 1.0 0.19617 0.75627 0.42252 1.0000
P P1 1.0 0.31337 0.99434 0.05803 1.0000
P P2 1.0 0.52467 0.95466 0.82822 1.0000
P P3 1.0 0.06651 0.90510 0.84888 1.0000
P P4 1.0 0.98376 0.54782 0.64882 1.0000
P P5 1.0 0.19351 0.50343 0.40645 1.0000
P P6 1.0 0.43845 0.59028 0.62901 1.0000
P P7 1.0 0.34400 0.75646 0.60991 1.0000
P P8 1.0 0.32414 0.83918 0.05928 1.0000
P P9 1.0 0.30802 0.66116 0.89815 1.0000
P P10 1.0 0.68688 0.00560 0.55914 1.0000
P P11 1.0 0.47548 0.04576 0.32815 1.0000
P P12 1.0 0.93349 0.09497 0.34958 1.0000
P P13 1.0 0.01619 0.45214 0.14882 1.0000
P P14 1.0 0.80646 0.49652 0.90645 1.0000
P P15 1.0 0.56162 0.40957 0.12895 1.0000
P P16 1.0 0.65635 0.24318 0.11197 1.0000
P P17 1.0 0.67615 0.16085 0.56051 1.0000
P P18 1.0 0.69209 0.33884 0.39813 1.0000
P P19 1.0 0.81321 0.00562 0.05928 1.0000
P P20 1.0 0.02477 0.04560 0.82869 1.0000
P P21 1.0 0.56658 0.09505 0.84935 1.0000
P P22 1.0 0.48383 0.45210 0.64886 1.0000
P P23 1.0 0.69355 0.49651 0.40640 1.0000
P P24 1.0 0.93839 0.40956 0.62898 1.0000
P P25 1.0 0.84372 0.24318 0.61195 1.0000
P P26 1.0 0.82395 0.16081 0.06056 1.0000
P P27 1.0 0.80794 0.33884 0.89816 1.0000
P P28 1.0 0.18650 0.99472 0.55712 1.0000
P P29 1.0 0.97498 0.95435 0.32876 1.0000
P P30 1.0 0.43347 0.90507 0.34924 1.0000
P P31 1.0 0.51619 0.54784 0.14887 1.0000
P P32 1.0 0.30646 0.50345 0.90646 1.0000
P P33 1.0 0.06160 0.59043 0.12887 1.0000
P P34 1.0 0.15658 0.75695 0.11105 1.0000
P P35 1.0 0.17591 0.83898 0.55953 1.0000
P P36 1.0 0.19176 0.66107 0.39794 1.0000
O O1 1.0 0.36930 0.56124 0.63882 1.0000
O O2 1.0 0.13538 0.93385 0.83366 1.0000
O O3 1.0 0.13323 0.47188 0.45118 1.0000
O O4 1.0 0.35030 0.77223 0.75240 1.0000
O O5 1.0 0.02578 0.50758 0.62007 1.0000
O O6 1.0 0.20934 0.77214 0.83963 1.0000
O O7 1.0 0.37244 0.02727 0.02004 1.0000
O O8 1.0 0.48241 0.99468 0.85946 1.0000
O O9 1.0 0.26051 0.74525 0.58022 1.0000
O O10 1.0 0.25240 0.85096 0.98186 1.0000
O O11 1.0 0.26725 0.49188 0.47540 1.0000
O O12 1.0 0.34503 0.70353 0.92025 1.0000
O O13 1.0 0.24142 0.00420 0.98193 1.0000
O O14 1.0 0.00114 0.92187 0.93177 1.0000
O O15 1.0 0.35517 0.79645 0.02209 1.0000
O O16 1.0 0.50873 0.57242 0.56275 1.0000
O O17 1.0 0.49419 0.91819 0.90872 1.0000
O O18 1.0 0.02066 0.58375 0.57395 1.0000
O O19 1.0 0.61031 0.95927 0.85926 1.0000
O O20 1.0 0.33849 0.95034 0.02262 1.0000
O O21 1.0 0.17320 0.54790 0.44401 1.0000
O O22 1.0 0.89885 0.54430 0.60927 1.0000
O O23 1.0 0.29692 0.65271 0.74928 1.0000
O O24 1.0 0.51714 0.94311 0.68271 1.0000
O O25 1.0 0.29712 0.99885 0.20677 1.0000
O O26 1.0 0.20409 0.49766 0.25662 1.0000
O O27 1.0 0.30596 0.84210 0.20712 1.0000
O O28 1.0 0.45944 0.60410 0.77088 1.0000
O O29 1.0 0.98309 0.55794 0.79664 1.0000
O O30 1.0 0.41696 0.62880 0.54922 1.0000
O O31 1.0 0.03144 0.89719 0.71005 1.0000
O O32 1.0 0.09016 0.86348 0.90607 1.0000
O O33 1.0 0.38689 0.86952 0.02345 1.0000
O O34 1.0 0.35971 0.62936 0.96217 1.0000
O O35 1.0 0.37646 0.78989 0.51811 1.0000
O O36 1.0 0.22762 0.65917 0.95502 1.0000
O O37 1.0 0.39109 0.71673 0.59096 1.0000
O O38 1.0 0.63080 0.43859 0.13845 1.0000
O O39 1.0 0.86463 0.06617 0.33478 1.0000
O O40 1.0 0.86677 0.52806 0.95121 1.0000
O O41 1.0 0.65035 0.22706 0.25425 1.0000
O O42 1.0 0.97419 0.49239 0.12012 1.0000
O O43 1.0 0.79109 0.22794 0.34040 1.0000
O O44 1.0 0.62792 0.97264 0.52061 1.0000
O O45 1.0 0.51828 0.00588 0.35879 1.0000
O O46 1.0 0.73962 0.25472 0.08150 1.0000
O O47 1.0 0.74868 0.14943 0.48499 1.0000
O O48 1.0 0.73273 0.50809 0.97540 1.0000
O O49 1.0 0.65515 0.29645 0.42014 1.0000
O O50 1.0 0.75906 0.99570 0.48383 1.0000
O O51 1.0 0.99891 0.07817 0.43222 1.0000
O O52 1.0 0.64543 0.20379 0.52464 1.0000
O O53 1.0 0.49140 0.42745 0.06253 1.0000
O O54 1.0 0.50551 0.08228 0.40883 1.0000
O O55 1.0 0.97927 0.41620 0.07401 1.0000
O O56 1.0 0.38972 0.04098 0.35840 1.0000
O O57 1.0 0.66225 0.04962 0.52348 1.0000
O O58 1.0 0.82674 0.45206 0.94402 1.0000
O O59 1.0 0.10110 0.45567 0.10921 1.0000
O O60 1.0 0.70310 0.34730 0.24929 1.0000
O O61 1.0 0.48190 0.05759 0.18258 1.0000
O O62 1.0 0.70271 0.00112 0.70804 1.0000
O O63 1.0 0.79589 0.50230 0.75663 1.0000
O O64 1.0 0.69299 0.15733 0.70856 1.0000
O O65 1.0 0.54054 0.39589 0.27094 1.0000
O O66 1.0 0.01692 0.44200 0.29663 1.0000
O O67 1.0 0.58300 0.37090 0.04979 1.0000
O O68 1.0 0.96869 0.10281 0.21083 1.0000
O O69 1.0 0.90998 0.13662 0.40655 1.0000
O O70 1.0 0.61388 0.13072 0.52021 1.0000
O O71 1.0 0.64035 0.37061 0.46216 1.0000
O O72 1.0 0.62400 0.20954 0.02083 1.0000
O O73 1.0 0.77248 0.34088 0.45509 1.0000
O O74 1.0 0.60895 0.28284 0.09347 1.0000
O O75 1.0 0.86921 0.43858 0.63850 1.0000
O O76 1.0 0.63547 0.06626 0.83488 1.0000
O O77 1.0 0.63325 0.52804 0.45116 1.0000
O O78 1.0 0.84968 0.22707 0.75423 1.0000
O O79 1.0 0.52585 0.49234 0.62010 1.0000
O O80 1.0 0.70899 0.22793 0.84042 1.0000
O O81 1.0 0.87235 0.97278 0.02073 1.0000
O O82 1.0 0.98231 0.00562 0.85957 1.0000
O O83 1.0 0.76046 0.25473 0.58146 1.0000
O O84 1.0 0.75143 0.14937 0.98501 1.0000
O O85 1.0 0.76727 0.50808 0.47539 1.0000
O O86 1.0 0.84486 0.29644 0.92017 1.0000
O O87 1.0 0.74119 0.99564 0.98348 1.0000
O O88 1.0 0.50101 0.07834 0.93188 1.0000
O O89 1.0 0.85465 0.20374 0.02451 1.0000
O O90 1.0 0.00861 0.42743 0.56256 1.0000
O O91 1.0 0.99443 0.08214 0.90892 1.0000
O O92 1.0 0.52079 0.41616 0.57408 1.0000
O O93 1.0 0.11043 0.04089 0.85990 1.0000
O O94 1.0 0.83796 0.04964 0.02387 1.0000
O O95 1.0 0.67328 0.45204 0.44394 1.0000
O O96 1.0 0.39893 0.45560 0.60918 1.0000
O O97 1.0 0.79690 0.34730 0.74932 1.0000
O O98 1.0 0.01811 0.05723 0.68309 1.0000
O O99 1.0 0.79723 0.00104 0.20807 1.0000
O O100 1.0 0.70412 0.50230 0.25658 1.0000
O O101 1.0 0.80705 0.15737 0.20863 1.0000
O O102 1.0 0.95948 0.39588 0.77098 1.0000
O O103 1.0 0.48312 0.44200 0.79669 1.0000
O O104 1.0 0.91700 0.37090 0.54982 1.0000
O O105 1.0 0.53158 0.10289 0.71045 1.0000
O O106 1.0 0.59001 0.13674 0.90626 1.0000
O O107 1.0 0.88625 0.13064 0.02064 1.0000
O O108 1.0 0.85968 0.37061 0.96216 1.0000
O O109 1.0 0.87609 0.20956 0.52077 1.0000
O O110 1.0 0.72755 0.34089 0.95513 1.0000
O O111 1.0 0.89111 0.28285 0.59352 1.0000
O O112 1.0 0.13077 0.56141 0.13839 1.0000
O O113 1.0 0.36486 0.93401 0.33335 1.0000
O O114 1.0 0.36679 0.47193 0.95124 1.0000
O O115 1.0 0.15043 0.77288 0.25355 1.0000
O O116 1.0 0.47419 0.50759 0.12012 1.0000
O O117 1.0 0.29075 0.77159 0.33906 1.0000
O O118 1.0 0.12760 0.02776 0.51858 1.0000
O O119 1.0 0.01726 0.99438 0.35953 1.0000
O O120 1.0 0.23993 0.74567 0.08037 1.0000
O O121 1.0 0.24902 0.85001 0.48481 1.0000
O O122 1.0 0.23275 0.49191 0.97548 1.0000
O O123 1.0 0.15479 0.70345 0.41987 1.0000
O O124 1.0 0.25878 0.00476 0.48239 1.0000
O O125 1.0 0.49850 0.92183 0.43293 1.0000
O O126 1.0 0.14485 0.79620 0.52319 1.0000
O O127 1.0 0.99139 0.57256 0.06240 1.0000
O O128 1.0 0.00537 0.91783 0.40898 1.0000
O O129 1.0 0.47925 0.58378 0.07409 1.0000
O O130 1.0 0.88932 0.95902 0.35999 1.0000
O O131 1.0 0.16143 0.95090 0.52064 1.0000
O O132 1.0 0.32676 0.54793 0.94387 1.0000
O O133 1.0 0.60110 0.54432 0.10925 1.0000
O O134 1.0 0.20291 0.65263 0.24910 1.0000
O O135 1.0 0.98165 0.94277 0.18305 1.0000
O O136 1.0 0.20119 0.99946 0.70616 1.0000
O O137 1.0 0.29586 0.49760 0.75667 1.0000
O O138 1.0 0.19274 0.84238 0.70777 1.0000
O O139 1.0 0.04040 0.60406 0.27087 1.0000
O O140 1.0 0.51691 0.55794 0.29670 1.0000
O O141 1.0 0.08297 0.62912 0.04986 1.0000
O O142 1.0 0.46941 0.89718 0.21113 1.0000
O O143 1.0 0.40903 0.86353 0.40577 1.0000
O O144 1.0 0.11446 0.86961 0.51959 1.0000
O O145 1.0 0.13998 0.62932 0.46198 1.0000
O O146 1.0 0.12400 0.79067 0.02045 1.0000
O O147 1.0 0.27211 0.65893 0.45496 1.0000
O O148 1.0 0.10925 0.71727 0.09222 1.0000
F F1 1.0 0.59454 0.01931 0.03888 1.0000
F F2 1.0 0.03282 0.52842 0.36063 1.0000
F F3 1.0 0.47617 0.97356 0.12043 1.0000
F F4 1.0 0.41305 0.51613 0.43540 1.0000
F F5 1.0 0.40605 0.98157 0.53697 1.0000
F F6 1.0 0.96715 0.47151 0.86070 1.0000
F F7 1.0 0.52466 0.02671 0.61962 1.0000
F F8 1.0 0.58697 0.48383 0.93532 1.0000
F F9 1.0 0.09449 0.98073 0.03817 1.0000
F F10 1.0 0.53286 0.47150 0.36075 1.0000
F F11 1.0 0.97607 0.02672 0.11986 1.0000
F F12 1.0 0.91305 0.48380 0.43533 1.0000
F F13 1.0 0.90545 0.01913 0.53909 1.0000
F F14 1.0 0.46722 0.52847 0.86074 1.0000
F F15 1.0 0.02440 0.97339 0.61988 1.0000
F F16 1.0 0.08695 0.51615 0.93532 1.0000
Loading

0 comments on commit 06040bf

Please sign in to comment.