Skip to content

Commit a2d9c55

Browse files
committed
Add unit test for perturbable trajectory reconstruction.
1 parent 3ddb093 commit a2d9c55

6 files changed

Lines changed: 253 additions & 0 deletions

File tree

tests/Sandpit/Exscientia/Trajectory/test_trajectory.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,46 @@ def test_getFrame(system):
191191
assert frame.nMolecules() == system.nMolecules()
192192
assert frame.nResidues() == system.nResidues()
193193
assert frame.nAtoms() == system.nAtoms()
194+
195+
196+
@pytest.mark.skipif(
197+
has_mdanalysis is False or has_mdtraj is False,
198+
reason="Requires MDAnalysis and mdtraj to be installed.",
199+
)
200+
def test_perturbable():
201+
"""
202+
Make sure that trajectory frames can be reconstructed for a perturbable system.
203+
"""
204+
import sire as sr
205+
206+
# First, load the ethane-to-methanol perturbable system.
207+
mols = sr.load_test_files("merged_molecule.s3")
208+
system = BSS._SireWrappers.Molecule(mols["perturbable"].molecules()[0]).toSystem()
209+
210+
# GROMACS files.
211+
trajectory_gromacs = "tests/input/ethane_methanol.xtc"
212+
topology_gromacs = "tests/input/ethane_methanol.tpr"
213+
214+
# Create the trajectory object.
215+
traj = BSS.Trajectory.Trajectory(
216+
trajectory=trajectory_gromacs,
217+
topology=topology_gromacs,
218+
system=system,
219+
)
220+
221+
# Try to extract the first and last frame.
222+
frames = traj.getFrames([0, -1])
223+
224+
# AMBER files.
225+
trajectory_amber = "tests/input/ethane_methanol.nc"
226+
topology_amber = "tests/input/ethane_methanol.prm7"
227+
228+
# Create the trajectory object.
229+
traj = BSS.Trajectory.Trajectory(
230+
trajectory=trajectory_amber,
231+
topology=topology_amber,
232+
system=system,
233+
)
234+
235+
# Try to extract the first and last frame.
236+
frames = traj.getFrames([0, -1])

tests/Trajectory/test_trajectory.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,46 @@ def test_getFrame(system):
182182
assert frame.nMolecules() == system.nMolecules()
183183
assert frame.nResidues() == system.nResidues()
184184
assert frame.nAtoms() == system.nAtoms()
185+
186+
187+
@pytest.mark.skipif(
188+
has_mdanalysis is False or has_mdtraj is False,
189+
reason="Requires MDAnalysis and mdtraj to be installed.",
190+
)
191+
def test_perturbable():
192+
"""
193+
Make sure that trajectory frames can be reconstructed for a perturbable system.
194+
"""
195+
import sire as sr
196+
197+
# First, load the ethane-to-methanol perturbable system.
198+
mols = sr.load_test_files("merged_molecule.s3")
199+
system = BSS._SireWrappers.Molecule(mols["perturbable"].molecules()[0]).toSystem()
200+
201+
# GROMACS files.
202+
trajectory_gromacs = "tests/input/ethane_methanol.xtc"
203+
topology_gromacs = "tests/input/ethane_methanol.tpr"
204+
205+
# Create the trajectory object.
206+
traj = BSS.Trajectory.Trajectory(
207+
trajectory=trajectory_gromacs,
208+
topology=topology_gromacs,
209+
system=system,
210+
)
211+
212+
# Try to extract the first and last frame.
213+
frames = traj.getFrames([0, -1])
214+
215+
# AMBER files.
216+
trajectory_amber = "tests/input/ethane_methanol.nc"
217+
topology_amber = "tests/input/ethane_methanol.prm7"
218+
219+
# Create the trajectory object.
220+
traj = BSS.Trajectory.Trajectory(
221+
trajectory=trajectory_amber,
222+
topology=topology_amber,
223+
system=system,
224+
)
225+
226+
# Try to extract the first and last frame.
227+
frames = traj.getFrames([0, -1])

tests/input/ethane_methanol.nc

2.16 KB
Binary file not shown.

tests/input/ethane_methanol.prm7

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
%VERSION VERSION_STAMP = V0001.000 DATE = 10/07/25 13:21:29
2+
%FLAG TITLE
3+
%FORMAT(20a4)
4+
BioSimSpace_System
5+
%FLAG POINTERS
6+
%FORMAT(10I8)
7+
14 5 10 2 19 0 12 0 0 0
8+
45 2 2 0 0 4 5 2 5 0
9+
0 0 0 0 0 0 0 0 8 0
10+
0 0 0
11+
%FLAG ATOM_NAME
12+
%FORMAT(20a4)
13+
C1 C2 H3 H4 H5 H6 H7 H8 C1 C2 H4 H6 H7 H8
14+
%FLAG CHARGE
15+
%FORMAT(5E16.8)
16+
-1.71927400e+00 -1.71927400e+00 5.73091335e-01 5.73091335e-01 5.73091335e-01
17+
5.73091335e-01 5.73091335e-01 5.73091335e-01 -1.09115132e+01 2.12654240e+00
18+
7.21603079e+00 5.22980003e-01 5.22980003e-01 5.22980003e-01
19+
%FLAG ATOMIC_NUMBER
20+
%FORMAT(10I8)
21+
6 6 1 1 1 1 1 1 8 6
22+
1 1 1 1
23+
%FLAG MASS
24+
%FORMAT(5E16.8)
25+
1.20100000e+01 1.20100000e+01 1.00800000e+00 1.00800000e+00 1.00800000e+00
26+
1.00800000e+00 1.00800000e+00 1.00800000e+00 1.60000000e+01 1.20100000e+01
27+
1.00800000e+00 1.00800000e+00 1.00800000e+00 1.00800000e+00
28+
%FLAG ATOM_TYPE_INDEX
29+
%FORMAT(10I8)
30+
1 1 2 2 2 2 2 2 3 1
31+
4 5 5 5
32+
%FLAG NUMBER_EXCLUDED_ATOMS
33+
%FORMAT(10I8)
34+
7 6 5 4 3 2 1 1 5 4
35+
3 2 1 1
36+
%FLAG NONBONDED_PARM_INDEX
37+
%FORMAT(10I8)
38+
1 2 4 7 11 2 3 5 8 12
39+
4 5 6 9 13 7 8 9 10 14
40+
11 12 13 14 15
41+
%FLAG RESIDUE_LABEL
42+
%FORMAT(20a4)
43+
LIG LIG
44+
%FLAG RESIDUE_POINTER
45+
%FORMAT(10I8)
46+
1 9
47+
%FLAG BOND_FORCE_CONSTANT
48+
%FORMAT(5E16.8)
49+
3.00900000e+02 3.16700000e+02 3.30600000e+02 3.71400000e+02
50+
%FLAG BOND_EQUIL_VALUE
51+
%FORMAT(5E16.8)
52+
1.53750000e+00 1.42330000e+00 1.09690000e+00 9.73000000e-01
53+
%FLAG ANGLE_FORCE_CONSTANT
54+
%FORMAT(5E16.8)
55+
3.92000000e+01 3.94000000e+01 4.63000000e+01 4.74000000e+01 5.09000000e+01
56+
%FLAG ANGLE_EQUIL_VALUE
57+
%FORMAT(5E16.8)
58+
1.89298492e+00 1.87762601e+00 1.91637234e+00 1.87204096e+00 1.92440086e+00
59+
%FLAG DIHEDRAL_FORCE_CONSTANT
60+
%FORMAT(5E16.8)
61+
1.50000000e-01 1.66666667e-01
62+
%FLAG DIHEDRAL_PERIODICITY
63+
%FORMAT(5E16.8)
64+
3.00000000e+00 3.00000000e+00
65+
%FLAG DIHEDRAL_PHASE
66+
%FORMAT(5E16.8)
67+
0.00000000e+00 0.00000000e+00
68+
%FLAG SCEE_SCALE_FACTOR
69+
%FORMAT(5E16.8)
70+
1.20000000e+00 1.20000000e+00
71+
%FLAG SCNB_SCALE_FACTOR
72+
%FORMAT(5E16.8)
73+
2.00000000e+00 2.00000000e+00
74+
%FLAG SOLTY
75+
%FORMAT(5E16.8)
76+
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
77+
%FLAG LENNARD_JONES_ACOEF
78+
%FORMAT(5E16.8)
79+
1.04308023e+06 9.71708117e+04 7.51607703e+03 7.91544156e+05 6.82786631e+04
80+
5.81803229e+05 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
81+
6.78771368e+04 4.98586847e+03 4.66922514e+04 0.00000000e+00 3.25969625e+03
82+
%FLAG LENNARD_JONES_BCOEF
83+
%FORMAT(5E16.8)
84+
6.75612247e+02 1.26919150e+02 2.17257828e+01 6.93079947e+02 1.25287819e+02
85+
6.99746810e+02 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
86+
1.06076943e+02 1.76949863e+01 1.03606917e+02 0.00000000e+00 1.43076527e+01
87+
%FLAG BONDS_INC_HYDROGEN
88+
%FORMAT(10I8)
89+
0 6 3 0 9 3 0 12 3 3
90+
15 3 3 18 3 3 21 3 24 30
91+
4 27 33 3 27 36 3 27 39 3
92+
%FLAG BONDS_WITHOUT_HYDROGEN
93+
%FORMAT(10I8)
94+
0 3 1 24 27 2
95+
%FLAG ANGLES_INC_HYDROGEN
96+
%FORMAT(10I8)
97+
0 3 15 3 0 3 18 3 0 3
98+
21 3 3 0 6 3 3 0 9 3
99+
3 0 12 3 6 0 9 2 6 0
100+
12 2 9 0 12 2 15 3 18 2
101+
15 3 21 2 18 3 21 2 24 27
102+
33 5 24 27 36 5 24 27 39 5
103+
27 24 30 4 33 27 36 1 33 27
104+
39 1 36 27 39 1
105+
%FLAG ANGLES_WITHOUT_HYDROGEN
106+
%FORMAT(10I8)
107+
108+
%FLAG DIHEDRALS_INC_HYDROGEN
109+
%FORMAT(10I8)
110+
6 0 3 15 1 6 0 3 18 1
111+
6 0 3 21 1 9 0 3 15 1
112+
9 0 3 18 1 9 0 3 21 1
113+
12 0 3 15 1 12 0 3 18 1
114+
12 0 3 21 1 30 24 27 33 2
115+
30 24 27 36 2 30 24 27 39 2
116+
%FLAG DIHEDRALS_WITHOUT_HYDROGEN
117+
%FORMAT(10I8)
118+
119+
%FLAG EXCLUDED_ATOMS_LIST
120+
%FORMAT(10I8)
121+
2 3 4 5 6 7 8 3 4 5
122+
6 7 8 4 5 6 7 8 5 6
123+
7 8 6 7 8 7 8 8 0 10
124+
11 12 13 14 11 12 13 14 12 13
125+
14 13 14 14 0
126+
%FLAG HBOND_ACOEF
127+
%FORMAT(5E16.8)
128+
129+
%FLAG HBOND_BCOEF
130+
%FORMAT(5E16.8)
131+
132+
%FLAG HBCUT
133+
%FORMAT(5E16.8)
134+
135+
%FLAG AMBER_ATOM_TYPE
136+
%FORMAT(20a4)
137+
c3 c3 hc hc hc hc hc hc oh c3 ho h1 h1 h1
138+
%FLAG TREE_CHAIN_CLASSIFICATION
139+
%FORMAT(20a4)
140+
BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA
141+
%FLAG JOIN_ARRAY
142+
%FORMAT(10I8)
143+
0 0 0 0 0 0 0 0 0 0
144+
0 0 0 0
145+
%FLAG IROTAT
146+
%FORMAT(10I8)
147+
0 0 0 0 0 0 0 0 0 0
148+
0 0 0 0
149+
%FLAG RADIUS_SET
150+
%FORMAT(1a80)
151+
unknown
152+
%FLAG RADII
153+
%FORMAT(5E16.8)
154+
1.70000000e+00 1.70000000e+00 1.30000000e+00 1.30000000e+00 1.30000000e+00
155+
1.30000000e+00 1.30000000e+00 1.30000000e+00 1.50000000e+00 1.70000000e+00
156+
8.00000000e-01 1.30000000e+00 1.30000000e+00 1.30000000e+00
157+
%FLAG SCREEN
158+
%FORMAT(5E16.8)
159+
7.20000000e-01 7.20000000e-01 8.50000000e-01 8.50000000e-01 8.50000000e-01
160+
8.50000000e-01 8.50000000e-01 8.50000000e-01 8.50000000e-01 7.20000000e-01
161+
8.50000000e-01 8.50000000e-01 8.50000000e-01 8.50000000e-01
162+
%FLAG ATOMS_PER_MOLECULE
163+
%FORMAT(10I8)
164+
8 6
165+
%FLAG IPOL
166+
%FORMAT(1I8)
167+
0

tests/input/ethane_methanol.tpr

5.49 KB
Binary file not shown.

tests/input/ethane_methanol.xtc

1.63 KB
Binary file not shown.

0 commit comments

Comments
 (0)