Skip to content

Commit 3627bfc

Browse files
authored
Merge pull request #436 from OpenBioSim/backport_435
Backport fix from PR #435
2 parents 0754b20 + bb1500d commit 3627bfc

2 files changed

Lines changed: 142 additions & 52 deletions

File tree

python/BioSimSpace/Process/_atm_utils.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,31 @@ def findAbsoluteCoreIndices(self):
5151
import numpy as np
5252

5353
self.lig1_first_atomnum = self.data["first_ligand_bound_atom_index"]
54-
self.lig1_rigid_atoms = list(
55-
np.add(self.lig1_first_atomnum, self.data["ligand_bound_rigid_core"])
56-
)
54+
self.lig1_rigid_atoms = np.add(
55+
self.lig1_first_atomnum, self.data["ligand_bound_rigid_core"]
56+
).tolist()
5757
self.lig2_first_atomnum = self.data["first_ligand_free_atom_index"]
58-
self.lig2_rigid_atoms = list(
59-
np.add(self.lig2_first_atomnum, self.data["ligand_free_rigid_core"])
60-
)
58+
self.lig2_rigid_atoms = np.add(
59+
self.lig2_first_atomnum, self.data["ligand_free_rigid_core"]
60+
).tolist()
6161

6262
def findAbsoluteCOMAtoms(self):
6363
import numpy as np
6464

6565
self.protein_first_atomnum = self.data["first_protein_atom_index"]
66-
self.protein_com_atoms = list(
67-
np.add(self.protein_first_atomnum, self.data["protein_com_atoms"])
68-
)
66+
self.protein_com_atoms = np.add(
67+
self.protein_first_atomnum, self.data["protein_com_atoms"]
68+
).tolist()
6969

7070
self.lig1_first_atomnum = self.data["first_ligand_bound_atom_index"]
71-
self.lig1_com_atoms = list(
72-
np.add(self.lig1_first_atomnum, self.data["ligand_bound_com_atoms"])
73-
)
71+
self.lig1_com_atoms = np.add(
72+
self.lig1_first_atomnum, self.data["ligand_bound_com_atoms"]
73+
).tolist()
7474

7575
self.lig2_first_atomnum = self.data["first_ligand_free_atom_index"]
76-
self.lig2_com_atoms = list(
77-
np.add(self.lig2_first_atomnum, self.data["ligand_free_com_atoms"])
78-
)
76+
self.lig2_com_atoms = np.add(
77+
self.lig2_first_atomnum, self.data["ligand_free_com_atoms"]
78+
).tolist()
7979

8080
def getATMForceConstants(self, index=None):
8181
self.lig1_atoms = self.getLigandBoundAtomsAsList()
@@ -300,22 +300,18 @@ def createAlignmentForce(self, force_group=None):
300300
def getLigandBoundAtomsAsList(self):
301301
import numpy as np
302302

303-
return list(
304-
np.arange(
305-
self.data["first_ligand_bound_atom_index"],
306-
self.data["last_ligand_bound_atom_index"] + 1,
307-
)
308-
)
303+
return np.arange(
304+
self.data["first_ligand_bound_atom_index"],
305+
self.data["last_ligand_bound_atom_index"] + 1,
306+
).tolist()
309307

310308
def getLigandFreeAtomsAsList(self):
311309
import numpy as np
312310

313-
return list(
314-
np.arange(
315-
self.data["first_ligand_free_atom_index"],
316-
self.data["last_ligand_free_atom_index"] + 1,
317-
)
318-
)
311+
return np.arange(
312+
self.data["first_ligand_free_atom_index"],
313+
self.data["last_ligand_free_atom_index"] + 1,
314+
).tolist()
319315

320316
def createATMForce(
321317
self,

python/BioSimSpace/Protocol/_atm.py

Lines changed: 119 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,6 @@ def __init__(
130130
# Set the postition restraint.
131131
_PositionRestraintMixin.__init__(self, restraint, force_constant)
132132

133-
def __str__(self):
134-
d = self.getData()
135-
"""Return a string representation of the protocol."""
136-
string = "<BioSimSpace.Protocol.ATM>: "
137-
string += "timestep=%s " % self.getTimeStep()
138-
string += ", runtime=%s " % self.getRunTime()
139-
string += ", temperature=%s " % self.getTemperature()
140-
if self._pressure is not None:
141-
string += ", pressure=%s, " % self.getPressure()
142-
string += ", lambda1=%s " % self.getLambda1()
143-
string += ", lambda2=%s " % self.getLambda2()
144-
string += ", ligand_bound core atoms=%s" % d["ligand_bound_rigid_core"]
145-
string += ", ligand_free core atoms=%s" % d["ligand_free_rigid_core"]
146-
string += ", report_interval=%s " % self.getReportInterval()
147-
string += ", restart_interval=%s " % self.getRestartInterval()
148-
string += ">"
149-
150-
return string
151-
152-
def __repr__(self):
153-
"""Return a string showing how to instantiate the object."""
154-
return self.__str__()
155-
156133
def getData(self):
157134
"""
158135
Return the ATM data dictionary.
@@ -778,6 +755,27 @@ def __init__(
778755
# Store the number of minimisation steps.
779756
self.setSteps(steps)
780757

758+
def __str__(self):
759+
"""Return a string representation of the protocol."""
760+
string = "<BioSimSpace.Protocol.ATMMinimisation>: "
761+
string += "steps=%s " % self.getSteps()
762+
string += ", core_alignment=%s " % self.getCoreAlignment()
763+
string += ", com_distance_restraint=%s " % self.getCOMDistanceRestraint()
764+
string += ", align_k_distance=%s " % self.getAlignKDistance()
765+
string += ", align_k_theta=%s " % self.getAlignKTheta()
766+
string += ", align_k_psi=%s " % self.getAlignKPsi()
767+
string += ", com_k=%s " % self.getCOMk()
768+
string += ", com_restraint_width=%s " % self.getCOMWidth()
769+
string += ", positional_restraint_width=%s " % self.getPosRestWidth()
770+
string += ", soft_core_umax=%s " % self.getSoftCoreUmax()
771+
string += ", soft_core_u0=%s " % self.getSoftCoreU0()
772+
string += ", soft_core_a=%s " % self.getSoftCoreA()
773+
return string
774+
775+
def __repr__(self):
776+
"""Return a string showing how to instantiate the object."""
777+
return self.__str__()
778+
781779
def getSteps(self):
782780
"""
783781
Return the number of minimisation steps.
@@ -939,7 +937,6 @@ def __init__(
939937
soft_core_a : int, float, str, :class:`Energy <BioSimSpace.Types.Energy>`
940938
The a value for the ATM softcore potential.
941939
942-
943940
use_atm_force : bool
944941
Whether to apply the ATM force within the equilibration protocol.
945942
@@ -1031,6 +1028,41 @@ def __init__(
10311028

10321029
self.setW0(W0)
10331030

1031+
def __str__(self):
1032+
"""Return a string representation of the protocol."""
1033+
string = "<BioSimSpace.Protocol.ATMEquilibration>: "
1034+
string += "timestep=%s " % self.getTimeStep()
1035+
string += ", runtime=%s " % self.getRunTime()
1036+
string += ", temperature_start=%s " % self.getStartTemperature()
1037+
string += ", temperature_end=%s " % self.getEndTemperature()
1038+
string += ", pressure=%s " % self.getPressure()
1039+
string += ", thermostat_time_constant=%s " % self.getThermostatTimeConstant()
1040+
string += ", report_interval=%s " % self.getReportInterval()
1041+
string += ", restart_interval=%s " % self.getRestartInterval()
1042+
string += ", core_alignment=%s " % self.getCoreAlignment()
1043+
string += ", com_distance_restraint=%s " % self.getCOMDistanceRestraint()
1044+
string += ", align_k_distance=%s " % self.getAlignKDistance()
1045+
string += ", align_k_theta=%s " % self.getAlignKTheta()
1046+
string += ", align_k_psi=%s " % self.getAlignKPsi()
1047+
string += ", com_k=%s " % self.getCOMk()
1048+
string += ", com_restraint_width=%s " % self.getCOMWidth()
1049+
string += ", positional_restraint_width=%s " % self.getPosRestWidth()
1050+
string += ", soft_core_umax=%s " % self.getSoftCoreUmax()
1051+
string += ", soft_core_u0=%s " % self.getSoftCoreU0()
1052+
string += ", soft_core_a=%s " % self.getSoftCoreA()
1053+
string += ", use_atm_force=%s " % self.getUseATMForce()
1054+
string += ", direction=%s " % self.getDirection()
1055+
string += ", lambda1=%s " % self.getLambda1()
1056+
string += ", lambda2=%s " % self.getLambda2()
1057+
string += ", alpha=%s " % self.getAlpha()
1058+
string += ", uh=%s " % self.getUh()
1059+
string += ", W0=%s " % self.getW0()
1060+
return string
1061+
1062+
def __repr__(self):
1063+
"""Return a string showing how to instantiate the object."""
1064+
return self.__str__()
1065+
10341066
def getTimeStep(self):
10351067
"""
10361068
Return the time step.
@@ -1827,6 +1859,41 @@ def __init__(
18271859
# Set the number of annealing cycles.
18281860
self.setAnnealNumCycles(anneal_numcycles)
18291861

1862+
def __str__(self):
1863+
"""Return a string representation of the protocol."""
1864+
string = "<BioSimSpace.Protocol.ATMAnnealing>: "
1865+
string += "timestep=%s " % self.getTimeStep()
1866+
string += ", runtime=%s " % self.getRunTime()
1867+
string += ", temperature=%s " % self.getTemperature()
1868+
string += ", pressure=%s " % self.getPressure()
1869+
string += ", thermostat_time_constant=%s " % self.getThermostatTimeConstant()
1870+
string += ", report_interval=%s " % self.getReportInterval()
1871+
string += ", restart_interval=%s " % self.getRestartInterval()
1872+
string += ", core_alignment=%s " % self.getCoreAlignment()
1873+
string += ", com_distance_restraint=%s " % self.getCOMDistanceRestraint()
1874+
string += ", align_k_distance=%s " % self.getAlignKDistance()
1875+
string += ", align_k_theta=%s " % self.getAlignKTheta()
1876+
string += ", align_k_psi=%s " % self.getAlignKPsi()
1877+
string += ", com_k=%s " % self.getCOMk()
1878+
string += ", com_restraint_width=%s " % self.getCOMWidth()
1879+
string += ", positional_restraint_width=%s " % self.getPosRestWidth()
1880+
string += ", soft_core_umax=%s " % self.getSoftCoreUmax()
1881+
string += ", soft_core_u0=%s " % self.getSoftCoreU0()
1882+
string += ", soft_core_a=%s " % self.getSoftCoreA()
1883+
string += ", direction=%d " % self.getDirection()
1884+
string += ", lambda1=%.2f " % self.getLambda1()
1885+
string += ", lambda2=%.2f " % self.getLambda2()
1886+
string += ", alpha=%s " % self.getAlpha()
1887+
string += ", uh=%s " % self.getUh()
1888+
string += ", W0=%s " % self.getW0()
1889+
string += ", anneal_values=%s " % self.getAnnealValues()
1890+
string += ", anneal_numcycles=%d " % self.getAnnealNumCycles()
1891+
return string
1892+
1893+
def __repr__(self):
1894+
"""Return a string showing how to instantiate the object."""
1895+
return self.__str__()
1896+
18301897
def getTimeStep(self):
18311898
"""
18321899
Return the time step.
@@ -2320,7 +2387,7 @@ def setAnnealValues(self, anneal_values):
23202387

23212388
def capitalise_keys(input_dict):
23222389
# The first letter of each key needs to be captilised
2323-
# so that it can be properly passed to openMM later
2390+
# so that it can be properly passed to OpenMM later
23242391
capitalized_dict = {}
23252392
for key, value in input_dict.items():
23262393
capitalized_key = key.capitalize()
@@ -2666,6 +2733,33 @@ def __init__(
26662733

26672734
self.setAnalysisMethod(analysis_method)
26682735

2736+
def __str__(self):
2737+
"""Return a string representation of the protocol."""
2738+
string = "<BioSimSpace.Protocol.ATMProduction>: "
2739+
string += "timestep=%s " % self.getTimeStep()
2740+
string += ", runtime=%s " % self.getRunTime()
2741+
string += ", temperature=%s " % self.getTemperature()
2742+
string += ", pressure=%s " % self.getPressure()
2743+
string += ", thermostat_time_constant=%s " % self.getThermostatTimeConstant()
2744+
string += ", report_interval=%s " % self.getReportInterval()
2745+
string += ", restart_interval=%s " % self.getRestartInterval()
2746+
string += ", core_alignment=%s " % self.getCoreAlignment()
2747+
string += ", com_distance_restraint=%s " % self.getCOMDistanceRestraint()
2748+
string += ", align_k_distance=%s " % self.getAlignKDistance()
2749+
string += ", align_k_theta=%s " % self.getAlignKTheta()
2750+
string += ", align_k_psi=%s " % self.getAlignKPsi()
2751+
string += ", com_k=%s " % self.getCOMk()
2752+
string += ", com_restraint_width=%s " % self.getCOMWidth()
2753+
string += ", positional_restraint_width=%s " % self.getPosRestWidth()
2754+
string += ", soft_core_umax=%s " % self.getSoftCoreUmax()
2755+
string += ", soft_core_u0=%s " % self.getSoftCoreU0()
2756+
string += ", soft_core_a=%s " % self.getSoftCoreA()
2757+
return string
2758+
2759+
def __repr__(self):
2760+
"""Return a string showing how to instantiate the object."""
2761+
return self.__str__()
2762+
26692763
def getTimeStep(self):
26702764
"""
26712765
Return the time step.

0 commit comments

Comments
 (0)