From 001dd26e0aa4662b298c0a44f281a016ff416b99 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 12 Jun 2019 11:50:38 -0500 Subject: [PATCH 01/11] Add private function to update defs in smarts graph --- foyer/xml_writer.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/foyer/xml_writer.py b/foyer/xml_writer.py index 8fdbdc45..acde34f0 100644 --- a/foyer/xml_writer.py +++ b/foyer/xml_writer.py @@ -2,6 +2,8 @@ import collections from lxml import etree as ET +from foyer.smarts_graph import SMARTSGraph +import networkx as nx import numpy as np @@ -108,6 +110,37 @@ def _write_atoms(self, root, atoms, forcefield, unique): nb_force.set('sigma', str(round(atom.atom_type.sigma/10, 4))) nb_force.set('epsilon', str(round(atom.atom_type.epsilon * 4.184, 6))) + _update_defs(atomtypes, nonbonded, forcefield) + +def _update_defs(atomtypes, nonbonded, forcefield): + def_list = [i.get('def') for i in atomtypes.iterchildren()] + name_list = [i.get('name') for i in atomtypes.iterchildren()] + smarts_list = list() + smarts_parser = forcefield.parser + for smarts_string, name in zip(def_list, name_list): + smarts_graph = SMARTSGraph(smarts_string, parser=smarts_parser, + name=name) + for atom_expr in nx.get_node_attributes(smarts_graph, name='atom').values(): + labels = atom_expr.find_data('has_label') + for label in labels: + atom_type = label.children[0][1:] + smarts_list.append(atom_type) + smarts_list = list(set(smarts_list)) + extra_types = [i for i in smarts_list if i not in name_list] + + for extra in extra_types: + for definition in def_list: + if extra in definition: + extra_edit = '%' + extra + extra_index = definition.find(extra_edit) + if definition[extra_index-1] == ';': + new_def = definition.replace(extra_edit + ',', '') + else: + new_def = definition.replace(',' + extra_edit, '') + for i in atomtypes: + if extra in i.get('def'): + i.set('def', new_def) + def _write_bonds(root, bonds, unique): bond_forces = ET.SubElement(root, 'HarmonicBondForce') for bond in bonds: From 50f837a89a2303d89a7831e0cf5a4afc99eb7026 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 12 Jun 2019 11:57:20 -0500 Subject: [PATCH 02/11] Add nonworking tests for xml writer --- foyer/tests/test_xml_writer.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 foyer/tests/test_xml_writer.py diff --git a/foyer/tests/test_xml_writer.py b/foyer/tests/test_xml_writer.py new file mode 100644 index 00000000..6e46d379 --- /dev/null +++ b/foyer/tests/test_xml_writer.py @@ -0,0 +1,25 @@ +import glob +import itertools as it +import os + +import parmed as pmd +from pkg_resources import resource_filename +import pytest + +from foyer import Forcefield +from foyer.tests.utils import atomtype +from foyer.xml_writer import write_foyer + +def test_write_xml(filename, ff_file): + structure = pmd.loadfile(filename) + forcefield = Forcefield(ff_file) + + structure.write_foyer('test.xml', forcefield=forcefield) + +def test_load_xml(): + structure = pmd.loadfile(filename) + forcefield = Forcefield(ff_file) + + structure.write_foyer('test.xml', forcefield=forcefield) + + generated_ff = Forcefield('text.xml') From 1e5ec4a2923757ca79c8a55b056fd13872cac963 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 12 Jun 2019 13:34:37 -0500 Subject: [PATCH 03/11] Update xml writer test to work --- foyer/tests/test_xml_writer.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/foyer/tests/test_xml_writer.py b/foyer/tests/test_xml_writer.py index 6e46d379..308e5a13 100644 --- a/foyer/tests/test_xml_writer.py +++ b/foyer/tests/test_xml_writer.py @@ -1,25 +1,30 @@ -import glob -import itertools as it -import os - import parmed as pmd -from pkg_resources import resource_filename import pytest +import os +from pkg_resources import resource_filename from foyer import Forcefield -from foyer.tests.utils import atomtype from foyer.xml_writer import write_foyer -def test_write_xml(filename, ff_file): - structure = pmd.loadfile(filename) - forcefield = Forcefield(ff_file) - structure.write_foyer('test.xml', forcefield=forcefield) +OPLS_TESTFILES_DIR = resource_filename('foyer', 'opls_validation') + +def test_write_xml(): + top = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.top') + gro = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.gro') + structure = pmd.load_file(top, xyz=gro) + forcefield = Forcefield(name='oplsaa') + param_struc = forcefield.apply(structure) + + param_struc.write_foyer('test.xml', forcefield=forcefield) def test_load_xml(): - structure = pmd.loadfile(filename) - forcefield = Forcefield(ff_file) + top = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.top') + gro = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.gro') + structure = pmd.load_file(top, xyz=gro) + forcefield = Forcefield(name='oplsaa') + param_struc = forcefield.apply(structure) - structure.write_foyer('test.xml', forcefield=forcefield) + param_struc.write_foyer('test.xml', forcefield=forcefield) - generated_ff = Forcefield('text.xml') + generated_ff = Forcefield('test.xml') From c329b7a14c962fc16fa1f8b74117c8ce46bd44d0 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 12 Jun 2019 16:42:20 -0500 Subject: [PATCH 04/11] Remove tracking of test_xml_writer.py and migrate tests to test_forcefield.py --- foyer/tests/test_forcefield.py | 9 +++++++++ foyer/tests/test_xml_writer.py | 30 ------------------------------ 2 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 foyer/tests/test_xml_writer.py diff --git a/foyer/tests/test_forcefield.py b/foyer/tests/test_forcefield.py index 51ba06f7..9d4b5efb 100644 --- a/foyer/tests/test_forcefield.py +++ b/foyer/tests/test_forcefield.py @@ -348,3 +348,12 @@ def test_write_xml_multiple_periodictorsions(filename): assert 'k2' in periodic_element[0].attrib assert 'phase2' in periodic_element[0].attrib +@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2']) +def test_load_xml(filename): + mol = pmd.load_file(get_fn(filename), structure=True) + oplsaa = Forcefield(name='oplsaa') + typed = oplsaa.apply(mol) + + typed.write_foyer(filename='opls-snippet.xml', forcefield=oplsaa, unique=True) + + generated_ff = Forcefield('opls-snippet.xml') diff --git a/foyer/tests/test_xml_writer.py b/foyer/tests/test_xml_writer.py deleted file mode 100644 index 308e5a13..00000000 --- a/foyer/tests/test_xml_writer.py +++ /dev/null @@ -1,30 +0,0 @@ -import parmed as pmd -import pytest -import os - -from pkg_resources import resource_filename -from foyer import Forcefield -from foyer.xml_writer import write_foyer - - -OPLS_TESTFILES_DIR = resource_filename('foyer', 'opls_validation') - -def test_write_xml(): - top = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.top') - gro = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.gro') - structure = pmd.load_file(top, xyz=gro) - forcefield = Forcefield(name='oplsaa') - param_struc = forcefield.apply(structure) - - param_struc.write_foyer('test.xml', forcefield=forcefield) - -def test_load_xml(): - top = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.top') - gro = os.path.join(OPLS_TESTFILES_DIR, 'benzene/benzene.gro') - structure = pmd.load_file(top, xyz=gro) - forcefield = Forcefield(name='oplsaa') - param_struc = forcefield.apply(structure) - - param_struc.write_foyer('test.xml', forcefield=forcefield) - - generated_ff = Forcefield('test.xml') From 64af108e21d81da8c6f59be25991dd1055b08309 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 12 Jun 2019 16:55:59 -0500 Subject: [PATCH 05/11] Change for loop to Alex's method --- foyer/xml_writer.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/foyer/xml_writer.py b/foyer/xml_writer.py index acde34f0..3c8d102a 100644 --- a/foyer/xml_writer.py +++ b/foyer/xml_writer.py @@ -129,17 +129,15 @@ def _update_defs(atomtypes, nonbonded, forcefield): extra_types = [i for i in smarts_list if i not in name_list] for extra in extra_types: - for definition in def_list: + for i, definition in enumerate(def_list): if extra in definition: extra_edit = '%' + extra extra_index = definition.find(extra_edit) if definition[extra_index-1] == ';': - new_def = definition.replace(extra_edit + ',', '') + new_def = definition.replace(extra_edit + ',' , '') else: new_def = definition.replace(',' + extra_edit, '') - for i in atomtypes: - if extra in i.get('def'): - i.set('def', new_def) + atomtypes[i].set('def', new_def) def _write_bonds(root, bonds, unique): bond_forces = ET.SubElement(root, 'HarmonicBondForce') From 237d9997f5086abf689a04f73f5a27f543f538ee Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Thu, 3 Oct 2019 15:56:11 -0500 Subject: [PATCH 06/11] Add IL test case ti increase codecov --- foyer/tests/files/bmim.mol2 | 58 +++++++++++++ foyer/tests/files/bmim.xml | 144 +++++++++++++++++++++++++++++++++ foyer/tests/test_forcefield.py | 13 +-- 3 files changed, 210 insertions(+), 5 deletions(-) create mode 100644 foyer/tests/files/bmim.mol2 create mode 100644 foyer/tests/files/bmim.xml diff --git a/foyer/tests/files/bmim.mol2 b/foyer/tests/files/bmim.mol2 new file mode 100644 index 00000000..eb201ccd --- /dev/null +++ b/foyer/tests/files/bmim.mol2 @@ -0,0 +1,58 @@ +@MOLECULE +***** + 25 25 0 0 0 +SMALL +GASTEIGER + +@ATOM + 1 C -0.2264 1.8642 0.3237 C.3 1 RES1 0.0461 + 2 C -0.7608 0.5182 -0.1908 C.3 1 RES1 0.0458 + 3 N 1.2364 1.7738 0.2153 N.3 1 RES1 -0.2786 + 4 N 0.4032 -0.1931 -0.7534 N.3 1 RES1 -0.2817 + 5 C 1.4756 0.8123 -0.8730 C.3 1 RES1 0.0939 + 6 C 0.7981 -1.3291 0.1045 C.3 1 RES1 -0.0109 + 7 H -0.0282 -2.0415 0.1783 H 1 RES1 0.0391 + 8 H 1.0578 -0.9781 1.1075 H 1 RES1 0.0391 + 9 H 1.6624 -1.8386 -0.3305 H 1 RES1 0.0391 + 10 C 1.8701 3.0925 -0.0017 C.3 1 RES1 0.0008 + 11 C 3.4082 3.0113 0.1000 C.3 1 RES1 -0.0404 + 12 H 1.5096 3.7864 0.7633 H 1 RES1 0.0427 + 13 H 1.5828 3.4823 -0.9830 H 1 RES1 0.0427 + 14 C 4.0449 4.4051 -0.0769 C.3 1 RES1 -0.0548 + 15 H 3.7999 2.3370 -0.6654 H 1 RES1 0.0277 + 16 H 3.6853 2.6033 1.0756 H 1 RES1 0.0277 + 17 C 5.5785 4.3413 0.0466 C.3 1 RES1 -0.0652 + 18 H 3.6517 5.0891 0.6792 H 1 RES1 0.0263 + 19 H 3.7789 4.8085 -1.0571 H 1 RES1 0.0263 + 20 H 5.8709 3.9718 1.0323 H 1 RES1 0.0230 + 21 H 6.0099 5.3356 -0.0886 H 1 RES1 0.0230 + 22 H 5.9999 3.6784 -0.7127 H 1 RES1 0.0230 + 23 H -0.5301 2.0469 1.3578 H 1 RES1 0.0495 + 24 H -1.5031 0.6976 -0.9730 H 1 RES1 0.0495 + 25 H 2.4778 0.3609 -0.8123 H 1 RES1 0.0662 +@BOND + 1 3 1 1 + 2 6 7 1 + 3 14 19 1 + 4 10 12 1 + 5 17 14 1 + 6 5 4 1 + 7 11 10 1 + 8 6 4 1 + 9 17 22 1 + 10 2 4 1 + 11 13 10 1 + 12 14 18 1 + 13 5 25 1 + 14 6 9 1 + 15 17 20 1 + 16 16 11 1 + 17 2 1 1 + 18 11 14 1 + 19 2 24 1 + 20 6 8 1 + 21 17 21 1 + 22 5 3 1 + 23 3 10 1 + 24 15 11 1 + 25 1 23 1 diff --git a/foyer/tests/files/bmim.xml b/foyer/tests/files/bmim.xml new file mode 100644 index 00000000..a4f08e60 --- /dev/null +++ b/foyer/tests/files/bmim.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/foyer/tests/test_forcefield.py b/foyer/tests/test_forcefield.py index 96c53976..58908b23 100644 --- a/foyer/tests/test_forcefield.py +++ b/foyer/tests/test_forcefield.py @@ -358,15 +358,18 @@ def test_write_xml_multiple_periodictorsions(filename): assert 'k2' in periodic_element[0].attrib assert 'phase2' in periodic_element[0].attrib -@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2']) +@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2', 'bmim.mol2']) def test_load_xml(filename): mol = pmd.load_file(get_fn(filename), structure=True) - oplsaa = Forcefield(name='oplsaa') - typed = oplsaa.apply(mol) + if filename == 'bmim.mol2': + ff = Forcefield(get_fn('bmim.xml')) + else: + ff = Forcefield(name='oplsaa') + typed = ff.apply(mol) - typed.write_foyer(filename='opls-snippet.xml', forcefield=oplsaa, unique=True) + typed.write_foyer(filename='snippet.xml', forcefield=ff, unique=True) - generated_ff = Forcefield('opls-snippet.xml') + generated_ff = Forcefield('snippet.xml') def test_write_xml_overrides(): #Test xml_writer new overrides and comments features From a0b5bd0f7971ee0e63d91f427559d68bfb61ddab Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Fri, 4 Oct 2019 10:41:36 -0500 Subject: [PATCH 07/11] Update xml loading test with pf6 --- foyer/tests/files/pf6.xml | 18 ++++++++++-------- foyer/tests/test_forcefield.py | 9 ++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/foyer/tests/files/pf6.xml b/foyer/tests/files/pf6.xml index f0c88c71..bd506cae 100644 --- a/foyer/tests/files/pf6.xml +++ b/foyer/tests/files/pf6.xml @@ -2,15 +2,10 @@ - - + + + - - - - - - @@ -24,4 +19,11 @@ + + + + + + + diff --git a/foyer/tests/test_forcefield.py b/foyer/tests/test_forcefield.py index 58908b23..bce59c23 100644 --- a/foyer/tests/test_forcefield.py +++ b/foyer/tests/test_forcefield.py @@ -358,14 +358,17 @@ def test_write_xml_multiple_periodictorsions(filename): assert 'k2' in periodic_element[0].attrib assert 'phase2' in periodic_element[0].attrib -@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2', 'bmim.mol2']) +@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2', 'pf6.mol2']) def test_load_xml(filename): mol = pmd.load_file(get_fn(filename), structure=True) - if filename == 'bmim.mol2': - ff = Forcefield(get_fn('bmim.xml')) + #if filename == 'bmim.mol2': + # ff = Forcefield(get_fn('bmim.xml')) + if filename == 'pf6.mol2': + ff = Forcefield(get_fn('pf6.xml')) else: ff = Forcefield(name='oplsaa') typed = ff.apply(mol) + #if filename == 'pf6.mol2': typed.write_foyer(filename='snippet.xml', forcefield=ff, unique=True) From f99abcd74353d778534bf9751a0f1ef5496b1723 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Fri, 4 Oct 2019 13:14:44 -0500 Subject: [PATCH 08/11] Add ethane test case --- foyer/tests/files/ethane-multiple.xml | 24 ++++++++++++++++++++++++ foyer/tests/test_forcefield.py | 10 +++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 foyer/tests/files/ethane-multiple.xml diff --git a/foyer/tests/files/ethane-multiple.xml b/foyer/tests/files/ethane-multiple.xml new file mode 100644 index 00000000..88ada44d --- /dev/null +++ b/foyer/tests/files/ethane-multiple.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/foyer/tests/test_forcefield.py b/foyer/tests/test_forcefield.py index bce59c23..10139e61 100644 --- a/foyer/tests/test_forcefield.py +++ b/foyer/tests/test_forcefield.py @@ -358,18 +358,14 @@ def test_write_xml_multiple_periodictorsions(filename): assert 'k2' in periodic_element[0].attrib assert 'phase2' in periodic_element[0].attrib -@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2', 'pf6.mol2']) +@pytest.mark.parametrize("filename", ['ethane.mol2', 'benzene.mol2']) def test_load_xml(filename): mol = pmd.load_file(get_fn(filename), structure=True) - #if filename == 'bmim.mol2': - # ff = Forcefield(get_fn('bmim.xml')) - if filename == 'pf6.mol2': - ff = Forcefield(get_fn('pf6.xml')) + if filename == 'ethane.mol2': + ff = Forcefield(get_fn('ethane-multiple.xml')) else: ff = Forcefield(name='oplsaa') typed = ff.apply(mol) - #if filename == 'pf6.mol2': - typed.write_foyer(filename='snippet.xml', forcefield=ff, unique=True) generated_ff = Forcefield('snippet.xml') From 02b8abe78deac658b78a091bae3bbb0a029f1484 Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Fri, 4 Oct 2019 13:15:28 -0500 Subject: [PATCH 09/11] Remove bmim files --- foyer/tests/files/bmim.mol2 | 58 --------------- foyer/tests/files/bmim.xml | 144 ------------------------------------ 2 files changed, 202 deletions(-) delete mode 100644 foyer/tests/files/bmim.mol2 delete mode 100644 foyer/tests/files/bmim.xml diff --git a/foyer/tests/files/bmim.mol2 b/foyer/tests/files/bmim.mol2 deleted file mode 100644 index eb201ccd..00000000 --- a/foyer/tests/files/bmim.mol2 +++ /dev/null @@ -1,58 +0,0 @@ -@MOLECULE -***** - 25 25 0 0 0 -SMALL -GASTEIGER - -@ATOM - 1 C -0.2264 1.8642 0.3237 C.3 1 RES1 0.0461 - 2 C -0.7608 0.5182 -0.1908 C.3 1 RES1 0.0458 - 3 N 1.2364 1.7738 0.2153 N.3 1 RES1 -0.2786 - 4 N 0.4032 -0.1931 -0.7534 N.3 1 RES1 -0.2817 - 5 C 1.4756 0.8123 -0.8730 C.3 1 RES1 0.0939 - 6 C 0.7981 -1.3291 0.1045 C.3 1 RES1 -0.0109 - 7 H -0.0282 -2.0415 0.1783 H 1 RES1 0.0391 - 8 H 1.0578 -0.9781 1.1075 H 1 RES1 0.0391 - 9 H 1.6624 -1.8386 -0.3305 H 1 RES1 0.0391 - 10 C 1.8701 3.0925 -0.0017 C.3 1 RES1 0.0008 - 11 C 3.4082 3.0113 0.1000 C.3 1 RES1 -0.0404 - 12 H 1.5096 3.7864 0.7633 H 1 RES1 0.0427 - 13 H 1.5828 3.4823 -0.9830 H 1 RES1 0.0427 - 14 C 4.0449 4.4051 -0.0769 C.3 1 RES1 -0.0548 - 15 H 3.7999 2.3370 -0.6654 H 1 RES1 0.0277 - 16 H 3.6853 2.6033 1.0756 H 1 RES1 0.0277 - 17 C 5.5785 4.3413 0.0466 C.3 1 RES1 -0.0652 - 18 H 3.6517 5.0891 0.6792 H 1 RES1 0.0263 - 19 H 3.7789 4.8085 -1.0571 H 1 RES1 0.0263 - 20 H 5.8709 3.9718 1.0323 H 1 RES1 0.0230 - 21 H 6.0099 5.3356 -0.0886 H 1 RES1 0.0230 - 22 H 5.9999 3.6784 -0.7127 H 1 RES1 0.0230 - 23 H -0.5301 2.0469 1.3578 H 1 RES1 0.0495 - 24 H -1.5031 0.6976 -0.9730 H 1 RES1 0.0495 - 25 H 2.4778 0.3609 -0.8123 H 1 RES1 0.0662 -@BOND - 1 3 1 1 - 2 6 7 1 - 3 14 19 1 - 4 10 12 1 - 5 17 14 1 - 6 5 4 1 - 7 11 10 1 - 8 6 4 1 - 9 17 22 1 - 10 2 4 1 - 11 13 10 1 - 12 14 18 1 - 13 5 25 1 - 14 6 9 1 - 15 17 20 1 - 16 16 11 1 - 17 2 1 1 - 18 11 14 1 - 19 2 24 1 - 20 6 8 1 - 21 17 21 1 - 22 5 3 1 - 23 3 10 1 - 24 15 11 1 - 25 1 23 1 diff --git a/foyer/tests/files/bmim.xml b/foyer/tests/files/bmim.xml deleted file mode 100644 index a4f08e60..00000000 --- a/foyer/tests/files/bmim.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From e0b41bae2e0a5419fb87c591a348a5b3276f061a Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Fri, 4 Oct 2019 13:22:59 -0500 Subject: [PATCH 10/11] Manually revert pf6.xml back to original --- foyer/tests/files/pf6.xml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/foyer/tests/files/pf6.xml b/foyer/tests/files/pf6.xml index bd506cae..f0c88c71 100644 --- a/foyer/tests/files/pf6.xml +++ b/foyer/tests/files/pf6.xml @@ -2,10 +2,15 @@ - - - + + + + + + + + @@ -19,11 +24,4 @@ - - - - - - - From 1365fd8aa3da5c4833c8a2b6e717b5c82376f87e Mon Sep 17 00:00:00 2001 From: "Ray A. Matsumoto" Date: Wed, 9 Oct 2019 13:25:45 -0500 Subject: [PATCH 11/11] Add warning for removing undefined atomtype --- foyer/xml_writer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/foyer/xml_writer.py b/foyer/xml_writer.py index 6f97f920..17cbe6cc 100644 --- a/foyer/xml_writer.py +++ b/foyer/xml_writer.py @@ -4,6 +4,7 @@ from lxml import etree as ET from foyer.smarts_graph import SMARTSGraph import networkx as nx +import warnings import numpy as np @@ -147,6 +148,9 @@ def _update_defs(atomtypes, nonbonded, forcefield): for extra in extra_types: for i, definition in enumerate(def_list): if extra in definition: + warnings.warn('Removing undefined atom type `{}`' + ' from SMARTS string `{}`'.format( + extra, definition)) extra_edit = '%' + extra extra_index = definition.find(extra_edit) if definition[extra_index-1] == ';':