From 071225f5a019807ee22a116e46a6db7c935a78be Mon Sep 17 00:00:00 2001 From: Laura Malo <44496034+laumalo@users.noreply.github.com> Date: Wed, 13 Jan 2021 10:21:38 +0100 Subject: [PATCH 1/4] Add error message --- peleffy/forcefield/parameters.py | 7 +++++++ peleffy/tests/test_parameters.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/peleffy/forcefield/parameters.py b/peleffy/forcefield/parameters.py index 2826b841..fb1712ca 100644 --- a/peleffy/forcefield/parameters.py +++ b/peleffy/forcefield/parameters.py @@ -530,6 +530,13 @@ def reindex_atom_idx(list_params, dict_index): ordered_pdb_atom_names = [pdb_name.replace(' ', '_') for pdb_name in molecule.get_pdb_atom_names()] + # Check up that the Molecule representation and the Impact template + # represent the same chemical entity + if not set(ordered_pdb_atom_names) == set(atom_names_list): + raise ValueError( + "The Impact template file {} ".format(impact_template_path) + + "not does represent the same chemical entity as the molecule.") + # Molecule object and Impact template have the atoms in the same order if ordered_pdb_atom_names == atom_names_list: # Assign parameters from Impact template to the BaseParameterWrapper diff --git a/peleffy/tests/test_parameters.py b/peleffy/tests/test_parameters.py index e598d8d5..6ff23ba9 100644 --- a/peleffy/tests/test_parameters.py +++ b/peleffy/tests/test_parameters.py @@ -237,9 +237,17 @@ def test_generate_OPLS2005ParameterWrapper(molecule, # Load molecule, parameterize and generate Impact template molecule = Molecule(smiles='c1c(c(n(n1)S(=O)(=O)C))O') impact_template_path = get_data_file_path('tests/unlz') - # Test from_impact_template method test_generate_OpenForceFieldParameterWrapper(molecule, - impact_template_path) + impact_template_path) + + # The molecule and Impact template do no represent the same chemical + # entity + with pytest.raises(ValueError): + pdb_path = get_data_file_path('ligands/ethylene.pdb') + molecule = Molecule(pdb_path, tag='ETL') + impact_template_path = get_data_file_path('tests/metz') + test_generate_OpenForceFieldParameterWrapper(molecule, + impact_template_path) class TestBonds(object): From ae01caf1ea3e5ace686f4001fc2576140667af21 Mon Sep 17 00:00:00 2001 From: Laura Malo <44496034+laumalo@users.noreply.github.com> Date: Wed, 13 Jan 2021 10:53:05 +0100 Subject: [PATCH 2/4] Suport OpenFF 0.8.3 --- devtools/conda/meta.yaml | 2 +- devtools/envs/standard.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devtools/conda/meta.yaml b/devtools/conda/meta.yaml index e858c968..f5e73c09 100644 --- a/devtools/conda/meta.yaml +++ b/devtools/conda/meta.yaml @@ -26,7 +26,7 @@ requirements: - networkx - rdkit - ambertools - - openforcefield==0.8.0 + - openforcefield==0.8.3 about: home: https://github.com/martimunicoy/peleffy diff --git a/devtools/envs/standard.yaml b/devtools/envs/standard.yaml index 725992d4..a247706a 100644 --- a/devtools/envs/standard.yaml +++ b/devtools/envs/standard.yaml @@ -13,4 +13,4 @@ dependencies: - coverage < 5.0 - ambertools - rdkit - - openforcefield ==0.8.0 + - openforcefield ==0.8.3 From 0e716c702638f00bc9029d929a443ff2a0661e6e Mon Sep 17 00:00:00 2001 From: Laura Malo <44496034+laumalo@users.noreply.github.com> Date: Wed, 13 Jan 2021 11:24:34 +0100 Subject: [PATCH 3/4] Update releasehistory.rst --- docs/releasehistory.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/releasehistory.rst b/docs/releasehistory.rst index e8201075..26c49579 100644 --- a/docs/releasehistory.rst +++ b/docs/releasehistory.rst @@ -14,11 +14,15 @@ New features """""""""""" - `PR #117 `_: New method to assign external partial charges. - `PR #118 `_: New method to load parameters from an Impact Template. +- `PR #119 `_: Adds explanatory error message when using an invalid Impact Template in the from_impact_template method. +- `PR #119 `_: Supports Openforcefield-0.8.3 . + Tests added """"""""""" - `PR #117 `_: Adds tests to validate the MAE parse for external partial charges. - `PR #118 `_: Adds tests to validate the new method to load parameters from an Impact Template. +- `PR #119 `_: Adds tests for the new error message when using an invalid Impact Template in the from_impact_template method. 1.1.0 - Improvements in parameterization API, OBC template for OPLS2005 and Molecule initializators From c32b1bc1ef55526d3a322a676b316bd5ae35600c Mon Sep 17 00:00:00 2001 From: Marti Municoy Date: Wed, 13 Jan 2021 12:59:18 +0100 Subject: [PATCH 4/4] Minor fix --- peleffy/forcefield/parameters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peleffy/forcefield/parameters.py b/peleffy/forcefield/parameters.py index fb1712ca..ad1c7265 100644 --- a/peleffy/forcefield/parameters.py +++ b/peleffy/forcefield/parameters.py @@ -535,7 +535,7 @@ def reindex_atom_idx(list_params, dict_index): if not set(ordered_pdb_atom_names) == set(atom_names_list): raise ValueError( "The Impact template file {} ".format(impact_template_path) + - "not does represent the same chemical entity as the molecule.") + "does not represent the same chemical entity as the molecule.") # Molecule object and Impact template have the atoms in the same order if ordered_pdb_atom_names == atom_names_list: