diff --git a/moldesign/models/amber.py b/moldesign/models/amber.py index 1e19f87..f4a933c 100644 --- a/moldesign/models/amber.py +++ b/moldesign/models/amber.py @@ -11,26 +11,47 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from moldesign.utils import exports -from .base import MMBase -from .jsonmodel import JsonModelBase +import moldesign as mdt +from moldesign.parameters import Parameter, WhenParam +from moldesign.utils import exports -IMAGE = 'nwchem' +from . import ForceField @exports -class SanderMM(JsonModelBase, MMBase): - """ Interface with NWChem package (QM only) +class GAFF(ForceField): + """ Model the energy using the GAFF forcefield - Note: - This is the first interface based on our new wrapping strategy. This is slightly hacked, - but has the potential to become very general; very few things here are NWChem-specific + This is implemented as a special case of the ForceField energy model; it automates small + parameterization process """ - IMAGE = 'ambertools' - MODELNAME = 'sander' - DEFAULT_PROPERTIES = ['potential_energy'] - ALL_PROPERTIES = DEFAULT_PROPERTIES + ['forces'] + # TODO: mechanism to store partial charges so they don't need to be constantly recomputed + + PARAMETERS = [Parameter('partial_charges', + 'Partial charge model', + type=str, + default='am1-bcc', + choices=['am1-bcc', 'gasteiger', 'esp']), + Parameter('gaff_version', + 'GAFF version', + type=str, + choices='gaff gaff2'.split(), + default='gaff2') + ] + ForceField.PARAMETERS + + def prep(self, force=False): + self._parameterize() + return super(GAFF, self).prep() + + def calculate(self, requests=None): + if not self._prepped: + self._parameterize() + return super(GAFF, self).calculate(requests=requests) + + def _parameterize(self): + if not self.mol.ff: + mdt.parameterize(self.mol, + charges=self.params.partial_charges, + ffname=self.params.gaff_version) - RUNNER = 'runsander.py' - PARSER = 'parsesander.py'