Skip to content

Commit

Permalink
Change openff output for PELE
Browse files Browse the repository at this point in the history
  • Loading branch information
martimunicoy committed Nov 23, 2020
1 parent 4e59391 commit d17de67
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 12 deletions.
83 changes: 82 additions & 1 deletion peleffy/data/tests/MET_parameters_to_string.txt
Original file line number Diff line number Diff line change
@@ -1 +1,82 @@
{'atom_names': ['_C1_', '_H1_', '_H2_', '_H3_', '_H4_'], 'atom_types': ['OFFT', 'OFFT', 'OFFT', 'OFFT', 'OFFT'], 'charges': '[-0.077576, 0.019394, 0.019394, 0.019394, 0.019394] * elementary_charge', 'sigmas': ['3.3996695084235347 * angstrom', '2.649532787749369 * angstrom', '2.649532787749369 * angstrom', '2.649532787749369 * angstrom', '2.649532787749369 * angstrom'], 'epsilons': ['0.1094 * mole**-1 * kilocalorie', '0.0157 * mole**-1 * kilocalorie', '0.0157 * mole**-1 * kilocalorie', '0.0157 * mole**-1 * kilocalorie', '0.0157 * mole**-1 * kilocalorie'], 'SGB_radii': [None, None, None, None, None], 'vdW_radii': ['1.6998347542117673 * angstrom', '1.3247663938746845 * angstrom', '1.3247663938746845 * angstrom', '1.3247663938746845 * angstrom', '1.3247663938746845 * angstrom'], 'gammas': [None, None, None, None, None], 'alphas': [None, None, None, None, None], 'GBSA_radii': [], 'GBSA_scales': [], 'bonds': [{'atom1_idx': 0, 'atom2_idx': 1, 'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * kilocalorie', 'eq_dist': '1.094223427522 * angstrom'}, {'atom1_idx': 0, 'atom2_idx': 2, 'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * kilocalorie', 'eq_dist': '1.094223427522 * angstrom'}, {'atom1_idx': 0, 'atom2_idx': 3, 'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * kilocalorie', 'eq_dist': '1.094223427522 * angstrom'}, {'atom1_idx': 0, 'atom2_idx': 4, 'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * kilocalorie', 'eq_dist': '1.094223427522 * angstrom'}], 'angles': [{'atom1_idx': 1, 'atom2_idx': 0, 'atom3_idx': 2, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}, {'atom1_idx': 1, 'atom2_idx': 0, 'atom3_idx': 3, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}, {'atom1_idx': 1, 'atom2_idx': 0, 'atom3_idx': 4, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}, {'atom1_idx': 2, 'atom2_idx': 0, 'atom3_idx': 3, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}, {'atom1_idx': 2, 'atom2_idx': 0, 'atom3_idx': 4, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}, {'atom1_idx': 3, 'atom2_idx': 0, 'atom3_idx': 4, 'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * kilocalorie', 'eq_angle': '110.2468561538 * degree'}], 'propers': [], 'impropers': []}
{'GBSA_radii': [],
'GBSA_scales': [],
'SGB_radii': [None, None, None, None, None],
'alphas': [None, None, None, None, None],
'angles': [{'atom1_idx': 1,
'atom2_idx': 0,
'atom3_idx': 2,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'},
{'atom1_idx': 1,
'atom2_idx': 0,
'atom3_idx': 3,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'},
{'atom1_idx': 1,
'atom2_idx': 0,
'atom3_idx': 4,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'},
{'atom1_idx': 2,
'atom2_idx': 0,
'atom3_idx': 3,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'},
{'atom1_idx': 2,
'atom2_idx': 0,
'atom3_idx': 4,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'},
{'atom1_idx': 3,
'atom2_idx': 0,
'atom3_idx': 4,
'eq_angle': '110.2468561538 * degree',
'spring_constant': '33.78875634641 * mole**-1 * radian**-2 * '
'kilocalorie'}],
'atom_names': ['_C1_', '_H1_', '_H2_', '_H3_', '_H4_'],
'atom_types': ['OFFT', 'OFFT', 'OFFT', 'OFFT', 'OFFT'],
'bonds': [{'atom1_idx': 0,
'atom2_idx': 1,
'eq_dist': '1.094223427522 * angstrom',
'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * '
'kilocalorie'},
{'atom1_idx': 0,
'atom2_idx': 2,
'eq_dist': '1.094223427522 * angstrom',
'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * '
'kilocalorie'},
{'atom1_idx': 0,
'atom2_idx': 3,
'eq_dist': '1.094223427522 * angstrom',
'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * '
'kilocalorie'},
{'atom1_idx': 0,
'atom2_idx': 4,
'eq_dist': '1.094223427522 * angstrom',
'spring_constant': '376.8940758588 * angstrom**-2 * mole**-1 * '
'kilocalorie'}],
'charges': '[-0.077576, 0.019394, 0.019394, 0.019394, 0.019394] * '
'elementary_charge',
'epsilons': ['0.1094 * mole**-1 * kilocalorie',
'0.0157 * mole**-1 * kilocalorie',
'0.0157 * mole**-1 * kilocalorie',
'0.0157 * mole**-1 * kilocalorie',
'0.0157 * mole**-1 * kilocalorie'],
'gammas': [None, None, None, None, None],
'impropers': [],
'propers': [],
'sigmas': ['3.3996695084235347 * angstrom',
'2.649532787749369 * angstrom',
'2.649532787749369 * angstrom',
'2.649532787749369 * angstrom',
'2.649532787749369 * angstrom'],
'vdW_radii': ['1.6998347542117673 * angstrom',
'1.3247663938746845 * angstrom',
'1.3247663938746845 * angstrom',
'1.3247663938746845 * angstrom',
'1.3247663938746845 * angstrom']}
2 changes: 2 additions & 0 deletions peleffy/forcefield/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ def _get_parameters(self, molecule):

openff_parameters = self._openff.parameterize(molecule,
charge_method='dummy')
print(openff_parameters['sigmas'])
oplsff_parameters = self._oplsff.parameterize(molecule)
print(oplsff_parameters['sigmas'])

if self._nonbonding == 'openff':
hybrid_parameters['atom_names'] = openff_parameters['atom_names']
Expand Down
2 changes: 0 additions & 2 deletions peleffy/forcefield/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def __eq__(self, other):
if not isinstance(other, BaseParameterWrapper):
return False

print(self.forcefield_name, other.forcefield_name)

return super().__eq__(other) and \
self.forcefield_name == other.forcefield_name

Expand Down
14 changes: 12 additions & 2 deletions peleffy/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,18 @@ def test_to_string(self):
with open(ref_string_file) as f:
ref_string = f.read().strip('\n')

assert str(p_string) == str(ref_string), \
'Unexpected string representation of the parameter wrapper'
p_lines = p_string.split('\n')
ref_lines = ref_string.split('\n')

assert len(p_lines) == len(ref_lines), \
'Unexpected number of lines: ' \
+ str(len(p_lines)) + ', expected ' + str(len(ref_lines))

for p_line, ref_line in zip(p_lines, ref_lines):
assert p_line == ref_line, \
'Unexpected string representation found in line: ' \
+ '\'{}\' '.format(p_line) \
+ 'which does not match with \'{}\''.format(ref_line)

def test_to_json(self):
"""It tests the json representation of the parameter wrapper."""
Expand Down
12 changes: 6 additions & 6 deletions peleffy/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def test_datalocal_paths_for_openff(self):
+ '{}.rot.assign'.format(tag.upper()), \
'Unexpected default rotamer library path'
assert output_handler.get_impact_template_path() == \
'./DataLocal/Templates/OFF/Parsley/HeteroAtoms/' \
'./DataLocal/Templates/OpenFF/Parsley/' \
+ '{}z'.format(tag.lower()), \
'Unexpected default Impact template path'
assert output_handler.get_solvent_template_path() == \
Expand All @@ -253,8 +253,8 @@ def test_datalocal_paths_for_openff(self):
+ '{}.rot.assign'.format(tag.upper())), \
'Unexpected default rotamer library path'
assert output_handler.get_impact_template_path() == \
os.path.join(tmpdir, 'output', 'DataLocal/Templates/OFF/Pars'
+ 'ley/HeteroAtoms/{}z'.format(tag.lower())), \
os.path.join(tmpdir, 'output', 'DataLocal/Templates/'
+ 'OpenFF/Parsley/{}z'.format(tag.lower())), \
'Unexpected default Impact template path'
assert output_handler.get_solvent_template_path() == \
os.path.join(tmpdir, 'output',
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_datalocal_paths_for_offopls(self):
+ '{}.rot.assign'.format(tag.upper()), \
'Unexpected default rotamer library path'
assert output_handler.get_impact_template_path() == \
'./DataLocal/Templates/OFF/Parsley/HeteroAtoms/' \
'./DataLocal/Templates/OpenFF/Parsley/' \
+ '{}z'.format(tag.lower()), \
'Unexpected default Impact template path'
assert output_handler.get_solvent_template_path() == \
Expand All @@ -358,8 +358,8 @@ def test_datalocal_paths_for_offopls(self):
+ '{}.rot.assign'.format(tag.upper())), \
'Unexpected default rotamer library path'
assert output_handler.get_impact_template_path() == \
os.path.join(tmpdir, 'output', 'DataLocal/Templates/OFF/Pars'
+ 'ley/HeteroAtoms/{}z'.format(tag.lower())), \
os.path.join(tmpdir, 'output', 'DataLocal/Templates/'
+ 'OpenFF/Parsley/{}z'.format(tag.lower())), \
'Unexpected default Impact template path'
assert output_handler.get_solvent_template_path() == \
os.path.join(tmpdir, 'output',
Expand Down
2 changes: 2 additions & 0 deletions peleffy/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def parameterize_openffopls2005(openffopls2005, molecule, ffld_file):
# Set mock class to the OpenFFOPLS2005ForceField class
openffopls2005._oplsff = oplsff

print(parameters['sigmas'])

return openffopls2005.parameterize(molecule)


Expand Down
2 changes: 1 addition & 1 deletion peleffy/utils/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OutputPathHandler(object):
It handles the output paths of peleffy parameter files.
"""

OFF_IMPACT_TEMPLATE_PATH = 'DataLocal/Templates/OFF/Parsley/HeteroAtoms/'
OFF_IMPACT_TEMPLATE_PATH = 'DataLocal/Templates/OpenFF/Parsley/'
OPLS_IMPACT_TEMPLATE_PATH = 'DataLocal/Templates/OPLS2005/HeteroAtoms/'
ROTAMER_LIBRARY_PATH = 'DataLocal/LigandRotamerLibs/'
SOLVENT_TEMPLATE_PATH = 'DataLocal/OBC/'
Expand Down

0 comments on commit d17de67

Please sign in to comment.