diff --git a/.gitignore b/.gitignore index 93318c3..abd3af2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ doc/modules tmp/ *.xtcindex .spyproject/ -/test/data/water/.traj.xtc_offsets.lock -/test/data/water/.traj.xtc_offsets.npz +.traj.xtc_offsets.lock +.traj.xtc_offsets.npz +*.npy diff --git a/src/mdevaluate/free_energy_landscape.py b/src/mdevaluate/free_energy_landscape.py index 93abbb9..726d48e 100644 --- a/src/mdevaluate/free_energy_landscape.py +++ b/src/mdevaluate/free_energy_landscape.py @@ -1,13 +1,14 @@ +from functools import partial +import os.path + import numpy as np import math import scipy +from scipy import spatial as sp import cmath import pandas as pd - -from functools import partial -import os.path import multiprocessing as mp -from scipy import spatial as sp + VALID_GEOMETRY = {"cylindrical", "slab"} diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/data/pore/topol.tpr b/test/data/pore/topol.tpr new file mode 100644 index 0000000..c08a58c Binary files /dev/null and b/test/data/pore/topol.tpr differ diff --git a/test/data/pore/traj.xtc b/test/data/pore/traj.xtc new file mode 100644 index 0000000..5908edc Binary files /dev/null and b/test/data/pore/traj.xtc differ diff --git a/test/test_free_energy_landscape.py b/test/test_free_energy_landscape.py new file mode 100644 index 0000000..dc51631 --- /dev/null +++ b/test/test_free_energy_landscape.py @@ -0,0 +1,54 @@ +import os + +import pytest +import numpy as np + +import mdevaluate +from mdevaluate import free_energy_landscape as fel + + +@pytest.fixture +def trajectory(request): + return mdevaluate.open(os.path.join(os.path.dirname(__file__), 'data/pore')) + + +def test_get_fel(trajectory): + test_array = np.array( + [ + 0.0, + 13.162354034697204, + 5.327100985208421, + 9.558746399158396, + 4.116475238453127, + 6.305715728953043, + 3.231102391108276, + 5.896478799115712, + 8.381981206446293, + 5.1191684352849816, + 5.361112857237105, + 8.053932845998895, + 6.895396051256847, + 7.588888886900885, + 11.223429636542576, + 3.779149304024221, + 40.64319010769286, + 93.1120609754045, + 136.99287780099627, + 171.4403749377496, + ] + ) + + oxygens_water = trajectory.subset(atom_name="OW", residue_name="SOL") + data = fel.get_fel( + oxygens_water, + os.path.join(os.path.dirname(__file__), 'data/pore'), + "cylindrical", + 225, + edge=0.05, + radiusmin=0.05, + radiusmax=2.05, + z=[-np.inf, np.inf], + overwrite=True, + ) + + assert (np.array(data) == test_array).all()