From d17de677154d3c0b0d5cf989b59a95a21bb0a153 Mon Sep 17 00:00:00 2001 From: Marti Municoy Date: Mon, 23 Nov 2020 18:20:07 +0100 Subject: [PATCH] Change openff output for PELE --- .../data/tests/MET_parameters_to_string.txt | 83 ++++++++++++++++++- peleffy/forcefield/forcefield.py | 2 + peleffy/forcefield/parameters.py | 2 - peleffy/tests/test_parameters.py | 14 +++- peleffy/tests/test_utils.py | 12 +-- peleffy/tests/utils.py | 2 + peleffy/utils/output.py | 2 +- 7 files changed, 105 insertions(+), 12 deletions(-) diff --git a/peleffy/data/tests/MET_parameters_to_string.txt b/peleffy/data/tests/MET_parameters_to_string.txt index 2439fe42..d27199bf 100644 --- a/peleffy/data/tests/MET_parameters_to_string.txt +++ b/peleffy/data/tests/MET_parameters_to_string.txt @@ -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']} diff --git a/peleffy/forcefield/forcefield.py b/peleffy/forcefield/forcefield.py index bafae21c..fa1e6112 100644 --- a/peleffy/forcefield/forcefield.py +++ b/peleffy/forcefield/forcefield.py @@ -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'] diff --git a/peleffy/forcefield/parameters.py b/peleffy/forcefield/parameters.py index c30bdf04..1bf1e0dd 100644 --- a/peleffy/forcefield/parameters.py +++ b/peleffy/forcefield/parameters.py @@ -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 diff --git a/peleffy/tests/test_parameters.py b/peleffy/tests/test_parameters.py index f56970a3..2bc2e2fd 100644 --- a/peleffy/tests/test_parameters.py +++ b/peleffy/tests/test_parameters.py @@ -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.""" diff --git a/peleffy/tests/test_utils.py b/peleffy/tests/test_utils.py index d8df086b..40b3d7f4 100644 --- a/peleffy/tests/test_utils.py +++ b/peleffy/tests/test_utils.py @@ -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() == \ @@ -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', @@ -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() == \ @@ -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', diff --git a/peleffy/tests/utils.py b/peleffy/tests/utils.py index 62c225c7..299cb15a 100644 --- a/peleffy/tests/utils.py +++ b/peleffy/tests/utils.py @@ -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) diff --git a/peleffy/utils/output.py b/peleffy/utils/output.py index 1ced77e5..2359f158 100644 --- a/peleffy/utils/output.py +++ b/peleffy/utils/output.py @@ -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/'