Skip to content

Commit 91fc6dd

Browse files
committed
Post merge fixes.
1 parent bf317bd commit 91fc6dd

13 files changed

Lines changed: 97 additions & 73 deletions

File tree

nodes/playground/BSSSetup/FESetup_parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def parse_fesetup_input(filename):
77

88

99
def validate_fesetup_input(fe_dictionary):
10-
1110
return False
1211

1312

python/BioSimSpace/Sandpit/Exscientia/Process/_amber.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def __init__(
283283
self._config_file = "%s/%s.cfg" % (self._work_dir, name)
284284

285285
# Set the reference system
286-
self._ref_file = f"{self._work_dir}/{name}_ref.rst7"
286+
self._ref_file = f"{self._work_dir}/{name}_ref"
287287
self._ref_system = reference_system
288288

289289
# Create the list of input files.
@@ -302,8 +302,9 @@ def _setup(self):
302302

303303
# Create the reference file
304304
if self._ref_system is not None and self._protocol.getRestraint() is not None:
305-
self._write_system(self._ref_system, coord_file=self._ref_file)
305+
self._write_system(self._ref_system, ref_file=self._ref_file)
306306
else:
307+
self._ref_file += ".rst7"
307308
_shutil.copy(self._rst_file, self._ref_file)
308309

309310
# Generate the AMBER configuration file.
@@ -320,7 +321,7 @@ def _setup(self):
320321
# Return the list of input files.
321322
return self._input_files
322323

323-
def _write_system(self, system, coord_file=None, topol_file=None):
324+
def _write_system(self, system, coord_file=None, topol_file=None, ref_file=None):
324325
"""Validates an input system and makes some internal modifications to it,
325326
if needed, before writing it out to a coordinate and/or a topology file.
326327
@@ -336,6 +337,9 @@ def _write_system(self, system, coord_file=None, topol_file=None):
336337
topol_file : str or None
337338
The topology file to which to write out the system.
338339
340+
ref_file : str or None
341+
The coordinate file for the reference system used for position restraints.
342+
339343
Returns
340344
-------
341345
@@ -377,6 +381,21 @@ def _write_system(self, system, coord_file=None, topol_file=None):
377381
else:
378382
raise IOError(msg) from None
379383

384+
# RST file (reference for position restraints).
385+
if ref_file is not None:
386+
try:
387+
_IO.saveMolecules(
388+
self._ref_file, system, "rst7", property_map=self._property_map
389+
)
390+
self._ref_file += ".rst7"
391+
self._input_files.append(self._ref_file)
392+
except Exception as e:
393+
msg = "Failed to write system to 'RST7' format."
394+
if _isVerbose():
395+
raise IOError(msg) from e
396+
else:
397+
raise IOError(msg) from None
398+
380399
# PRM file (topology).
381400
if topol_file is not None:
382401
try:

python/BioSimSpace/Sandpit/Exscientia/Process/_gromacs.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def __init__(
208208
self._config_file = "%s/%s.mdp" % (self._work_dir, name)
209209

210210
# Set the reference system
211-
self._ref_file = f"{self._work_dir}/{name}_ref.gro"
211+
self._ref_file = f"{self._work_dir}/{name}_ref"
212212
self._ref_system = reference_system
213213

214214
# Create the list of input files.
@@ -243,8 +243,9 @@ def _setup(self):
243243

244244
# Create the reference file
245245
if self._ref_system is not None and self._protocol.getRestraint() is not None:
246-
self._write_system(self._ref_system, coord_file=self._ref_file)
246+
self._write_system(self._ref_system, ref_file=self._ref_file)
247247
else:
248+
self._ref_file += ".gro"
248249
_shutil.copy(self._gro_file, self._ref_file)
249250

250251
# Create the binary input file name.
@@ -265,7 +266,7 @@ def _setup(self):
265266
# Return the list of input files.
266267
return self._input_files
267268

268-
def _write_system(self, system, coord_file=None, topol_file=None):
269+
def _write_system(self, system, coord_file=None, topol_file=None, ref_file=None):
269270
"""Validates an input system and makes some internal modifications to it,
270271
if needed, before writing it out to a coordinate and/or a topology file.
271272
@@ -280,6 +281,9 @@ def _write_system(self, system, coord_file=None, topol_file=None):
280281
281282
topol_file : str or None
282283
The topology file to which to write out the system.
284+
285+
ref_file : str or None
286+
The file to which to write out the reference system for position restraints.
283287
"""
284288
# Create a copy of the system.
285289
system = system.copy()
@@ -328,17 +332,23 @@ def _write_system(self, system, coord_file=None, topol_file=None):
328332
self._property_map.get("space", "space"), space
329333
)
330334

331-
# GRO87 file.
335+
# GRO87 coordinate files.
332336
if coord_file is not None:
333337
_IO.saveMolecules(
334338
coord_file, system, "gro87", property_map=self._property_map
335339
)
336340
self._gro_file += ".gro"
337341
self._input_files.append(self._gro_file)
338342

343+
# GRO87 reference files.
344+
if ref_file is not None:
345+
_IO.saveMolecules(
346+
ref_file, system, "gro87", property_map=self._property_map
347+
)
348+
self._ref_file += ".gro"
349+
339350
# TOP file.
340351
if topol_file is not None:
341-
top.writeToFile(topol_file)
342352
_IO.saveMolecules(
343353
topol_file, system, "grotop", property_map=self._property_map
344354
)
@@ -2260,7 +2270,6 @@ def _sanitise_energy_term(key):
22602270
-------
22612271
str
22622272
The formatted name of the energy term.
2263-
22642273
"""
22652274
# Convert to upper case.
22662275
key = key.upper()

python/BioSimSpace/Sandpit/Exscientia/Protocol/_position_restraint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def getForceConstant(self):
136136
Returns
137137
-------
138138
139-
force_constant :class:`GeneralUnit <BioSimSpace.Types._GeneralUnit>`
139+
force_constant : class:`GeneralUnit <BioSimSpace.Types._GeneralUnit>`
140140
The force constant for the restraint, in units of
141141
kcal_per_mol/angstrom**2.
142142
"""

python/BioSimSpace/_Config/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"""
2323
.. currentmodule:: BioSimSpace._Config
2424
25-
2625
Classes
2726
=======
2827

python/BioSimSpace/_Config/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def reportInterval(self):
128128

129129
def isRestart(self):
130130
"""
131-
Return whether this is a restart simulation
131+
Return whether this is a restart simulation.
132132
133133
Returns
134134
-------

test/Align/test_align.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@
99
url = BSS.tutorialUrl()
1010

1111

12-
def test_flex_align():
13-
# Load the ligands.
14-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
15-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
12+
@pytest.fixture(scope="session")
13+
def system0():
14+
return BSS.IO.readMolecules(
15+
[f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"]
16+
)
17+
18+
19+
@pytest.fixture(scope="session")
20+
def system1():
21+
return BSS.IO.readMolecules(
22+
[f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"]
23+
)
24+
1625

26+
def test_flex_align(system0, system1):
1727
# Extract the molecules.
18-
m0 = s0.getMolecules()[0]
19-
m1 = s1.getMolecules()[0]
28+
m0 = system0.getMolecules()[0]
29+
m1 = system1.getMolecules()[0]
2030

2131
# Get the best mapping between the molecules that contains the prematch.
2232
mapping = BSS.Align.matchAtoms(
@@ -49,14 +59,10 @@ def test_flex_align():
4959

5060
# Parameterise the function with a set of valid atom pre-matches.
5161
@pytest.mark.parametrize("prematch", [{3: 1}, {5: 9}, {4: 5}, {1: 0}])
52-
def test_prematch(prematch):
53-
# Load the ligands.
54-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
55-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
56-
62+
def test_prematch(system0, system1, prematch):
5763
# Extract the molecules.
58-
m0 = s0.getMolecules()[0]
59-
m1 = s1.getMolecules()[0]
64+
m0 = system0.getMolecules()[0]
65+
m1 = system1.getMolecules()[0]
6066

6167
# Get the best mapping between the molecules that contains the prematch.
6268
mapping = BSS.Align.matchAtoms(
@@ -70,14 +76,10 @@ def test_prematch(prematch):
7076

7177
# Parameterise the function with a set of invalid atom pre-matches.
7278
@pytest.mark.parametrize("prematch", [{-1: 1}, {50: 9}, {4: 48}, {1: -1}])
73-
def test_invalid_prematch(prematch):
74-
# Load the ligands.
75-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
76-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
77-
79+
def test_invalid_prematch(system0, system1, prematch):
7880
# Extract the molecules.
79-
m0 = s0.getMolecules()[0]
80-
m1 = s1.getMolecules()[0]
81+
m0 = system0.getMolecules()[0]
82+
m1 = system1.getMolecules()[0]
8183

8284
# Assert that the invalid prematch raises a ValueError.
8385
with pytest.raises(ValueError):

test/Sandpit/Exscientia/Align/test_align.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@
1010
url = BSS.tutorialUrl()
1111

1212

13-
def test_flex_align():
14-
# Load the ligands.
15-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
16-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
13+
@pytest.fixture(scope="session")
14+
def system0():
15+
return BSS.IO.readMolecules(
16+
[f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"]
17+
)
18+
19+
20+
@pytest.fixture(scope="session")
21+
def system1():
22+
return BSS.IO.readMolecules(
23+
[f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"]
24+
)
25+
1726

27+
def test_flex_align(system0, system1):
1828
# Extract the molecules.
19-
m0 = s0.getMolecules()[0]
20-
m1 = s1.getMolecules()[0]
29+
m0 = system0.getMolecules()[0]
30+
m1 = system1.getMolecules()[0]
2131

2232
# Get the best mapping between the molecules that contains the prematch.
2333
mapping = BSS.Align.matchAtoms(
@@ -50,14 +60,10 @@ def test_flex_align():
5060

5161
# Parameterise the function with a set of valid atom pre-matches.
5262
@pytest.mark.parametrize("prematch", [{3: 1}, {5: 9}, {4: 5}, {1: 0}])
53-
def test_prematch(prematch):
54-
# Load the ligands.
55-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
56-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
57-
63+
def test_prematch(system0, system1, prematch):
5864
# Extract the molecules.
59-
m0 = s0.getMolecules()[0]
60-
m1 = s1.getMolecules()[0]
65+
m0 = system0.getMolecules()[0]
66+
m1 = system1.getMolecules()[0]
6167

6268
# Get the best mapping between the molecules that contains the prematch.
6369
mapping = BSS.Align.matchAtoms(
@@ -71,14 +77,10 @@ def test_prematch(prematch):
7177

7278
# Parameterise the function with a set of invalid atom pre-matches.
7379
@pytest.mark.parametrize("prematch", [{-1: 1}, {50: 9}, {4: 48}, {1: -1}])
74-
def test_invalid_prematch(prematch):
75-
# Load the ligands.
76-
s0 = BSS.IO.readMolecules([f"{url}/ligand01.prm7.bz2", f"{url}/ligand01.rst7.bz2"])
77-
s1 = BSS.IO.readMolecules([f"{url}/ligand02.prm7.bz2", f"{url}/ligand02.rst7.bz2"])
78-
80+
def test_invalid_prematch(system0, system1, prematch):
7981
# Extract the molecules.
80-
m0 = s0.getMolecules()[0]
81-
m1 = s1.getMolecules()[0]
82+
m0 = system0.getMolecules()[0]
83+
m1 = system1.getMolecules()[0]
8284

8385
# Assert that the invalid prematch raises a ValueError.
8486
with pytest.raises(ValueError):
@@ -264,16 +266,14 @@ def test_merge():
264266

265267
@pytest.fixture(scope="module")
266268
def roi_mol0():
267-
return BSS.IO.readMolecules(
268-
BSS.IO.glob("test/Sandpit/Exscientia/input/ligands/wild*")
269-
)[0]
269+
files = BSS.IO.expand(url, ["wild.prmtop", "wild.inpcrd"], ".bz2")
270+
return BSS.IO.readMolecules(files)[0]
270271

271272

272273
@pytest.fixture(scope="module")
273274
def roi_mol1():
274-
return BSS.IO.readMolecules(
275-
BSS.IO.glob("test/Sandpit/Exscientia/input/ligands/mutated*")
276-
)[0]
275+
files = BSS.IO.expand(url, ["mutated.prmtop", "mutated.inpcrd"], ".bz2")
276+
return BSS.IO.readMolecules(files)[0]
277277

278278

279279
@pytest.fixture(scope="module")

test/Sandpit/Exscientia/IO/test_openff_gromacs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def test_molecule_combine():
4444
protocol = BSS.Protocol.Minimisation(steps=1)
4545

4646
# Create processes to single point calculations with GROMACS.
47-
p0 = BSS.Process.Gromacs(m0.toSystem(), protocol, extra_options={"nsteps" : 0})
48-
p1 = BSS.Process.Gromacs(m1.toSystem(), protocol, extra_options={"nsteps" : 0})
47+
p0 = BSS.Process.Gromacs(m0.toSystem(), protocol, extra_options={"nsteps": 0})
48+
p1 = BSS.Process.Gromacs(m1.toSystem(), protocol, extra_options={"nsteps": 0})
4949
p01 = BSS.Process.Gromacs(
5050
(m0 + m1).toSystem(), protocol, extra_options={"nsteps": 0}
5151
)

test/Sandpit/Exscientia/Process/test_gromacs.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import shutil
23
import pytest
34

45
import BioSimSpace.Sandpit.Exscientia as BSS
@@ -214,17 +215,17 @@ def run_process(system, protocol, **kwargs):
214215
class TestGetRecord:
215216
@staticmethod
216217
@pytest.fixture()
217-
def setup(system, tmpdir_factory):
218-
workdir = tmpdir_factory.mktemp("out")
219-
(workdir / "gromacs.edr").mklinkto(
220-
"test/Sandpit/Exscientia/output/gromacs/gromacs.edr"
221-
)
218+
def setup(system):
222219
protocol = BSS.Protocol.Production(
223220
runtime=BSS.Types.Time(60, "picosecond"),
224221
timestep=BSS.Types.Time(4, "femtosecond"),
225222
report_interval=200,
226223
)
227-
process = BSS.Process.Gromacs(system, protocol, work_dir=str(workdir))
224+
process = BSS.Process.Gromacs(system, protocol)
225+
shutil.copyfile(
226+
"test/Sandpit/Exscientia/output/gromacs.edr",
227+
process.workDir() + "/gromacs.edr",
228+
)
228229
process._update_energy_dict()
229230
return process
230231

0 commit comments

Comments
 (0)