Skip to content

Commit

Permalink
address remaining failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 committed Sep 1, 2023
1 parent 4ea8536 commit c7c9727
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
24 changes: 12 additions & 12 deletions gmso/parameterization/topology_parameterizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TopologyParameterizationConfig(GMSOBase):
default=False,
description="A flag to determine whether or not to look at site.molecule "
"to look parameterize each molecule only once. Will only be used if "
"identify_connected_components=False",
"speedup_by_molgraph=False",
)

ignore_params: list = Field(
Expand Down Expand Up @@ -114,7 +114,7 @@ def get_ff(self, key=None):
else:
return self.forcefields

def _parameterize_sites(self, sites, typemap, ff, use_molecule_info=None):
def _parameterize_sites(self, sites, typemap, ff, speedup_by_moltag=None):
"""Parameterize sites with appropriate atom-types from the forcefield."""
for j, site in enumerate(sites):
site.atom_type = ff.get_potential(
Expand Down Expand Up @@ -215,7 +215,7 @@ def _apply_connection_parameters(
)

def _parameterize(
self, top, typemap, label_type=None, label=None, use_molecule_info=False
self, top, typemap, label_type=None, label=None, speedup_by_moltag=False
):
"""Parameterize a topology/subtopology based on an atomtype map."""
if label and label_type:
Expand All @@ -226,7 +226,7 @@ def _parameterize(
sites = top.sites

self._parameterize_sites(
sites, typemap, forcefield, use_molecule_info=use_molecule_info
sites, typemap, forcefield, speedup_by_moltag=speedup_by_moltag
)
self._parameterize_connections(
top,
Expand Down Expand Up @@ -337,27 +337,27 @@ def run_parameterization(self):
self.topology,
self.config.match_ff_by,
label,
self.config.use_molecule_info,
self.config.identify_connected_components,
self.config.speedup_by_moltag,
self.config.speedup_by_molgraph,
)
self._parameterize(
self.topology,
typemap,
label_type=self.config.match_ff_by,
label=label,
use_molecule_info=self.config.use_molecule_info, # This will be removed from the future iterations
speedup_by_moltag=self.config.speedup_by_moltag, # This will be removed from the future iterations
)
else:
typemap = self._get_atomtypes(
self.get_ff(),
self.topology,
use_molecule_info=self.config.use_molecule_info,
use_isomorphic_checks=self.config.identify_connected_components,
speedup_by_moltag=self.config.speedup_by_moltag,
use_isomorphic_checks=self.config.speedup_by_molgraph,
)
self._parameterize(
self.topology,
typemap,
use_molecule_info=self.config.use_molecule_info,
speedup_by_moltag=self.config.speedup_by_moltag,
)

self._set_scaling_factors() # Set global or per molecule scaling factors
Expand Down Expand Up @@ -401,7 +401,7 @@ def _get_atomtypes(
topology,
label_type=None,
label=None,
use_molecule_info=False,
speedup_by_moltag=False,
use_isomorphic_checks=False,
):
"""Run atom-typing in foyer and return the typemap."""
Expand All @@ -412,7 +412,7 @@ def _get_atomtypes(
label,
)

if use_molecule_info:
if speedup_by_moltag:
# Iterate through foyer_topology_graph, which is a subgraph of label_type
typemap, reference = dict(), dict()
for connected_component in nx.connected_components(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestImpropersParameterization(ParameterizationBaseTest):
def test_improper_parameterization(self, fake_improper_ff_gmso, ethane):
ethane.identify_connections()
apply(ethane, fake_improper_ff_gmso, assert_improper_params=True)
apply(ethane, fake_improper_ff_gmso, ignore_params=list())

lib = PotentialTemplateLibrary()
template_improper_type = lib["PeriodicImproperPotential"]
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_improper_parameterization(self, fake_improper_ff_gmso, ethane):

def test_improper_assertion_error(self, ethane_methane_top, oplsaa_gmso):
with pytest.raises(ParameterizationError):
apply(ethane_methane_top, oplsaa_gmso, assert_improper_params=True)
apply(ethane_methane_top, oplsaa_gmso, ignore_params=list())

@pytest.mark.parametrize(
"mol2_loc",
Expand Down
2 changes: 1 addition & 1 deletion gmso/tests/parameterization/test_opls_gmso.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_foyer_oplsaa_files(

gmso_top_from_pmd = from_parmed(struct, refer_type=True)
gmso_top = from_parmed(struct, refer_type=False)
apply(gmso_top, oplsaa_gmso, identify_connected_components=False)
apply(gmso_top, oplsaa_gmso, speedup_by_molgraph=False)

assert_same_atom_params(gmso_top, gmso_top_from_pmd)
assert_same_connection_params(gmso_top, gmso_top_from_pmd)
Expand Down
28 changes: 14 additions & 14 deletions gmso/tests/parameterization/test_parameterization_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ def test_empty_top_parameterization(self, oplsaa_gmso):
apply(top=Topology(), forcefields=oplsaa_gmso)

@pytest.mark.parametrize(
"identify_connected_components, use_molecule_info",
"speedup_by_molgraph, speedup_by_moltag",
[(False, False), (True, False), (False, True), (True, True)],
)
def test_speedup_options(
self,
ethane_box_with_methane,
oplsaa_gmso,
identify_connected_components,
use_molecule_info,
speedup_by_molgraph,
speedup_by_moltag,
):
ethane_box_with_methane.identify_connections()
apply(
ethane_box_with_methane,
oplsaa_gmso,
identify_connections=False,
identify_connected_components=identify_connected_components,
use_molecule_info=use_molecule_info,
speedup_by_molgraph=speedup_by_molgraph,
speedup_by_moltag=speedup_by_moltag,
)

molecule_labels = ethane_box_with_methane.unique_site_labels("molecule")
Expand Down Expand Up @@ -214,8 +214,8 @@ def test_match_ff_by_molecule(self, ethane_box_with_methane, oplsaa_gmso):
ff_dict,
match_ff_by="molecule",
identify_connections=False,
identify_connected_components=True,
use_molecule_info=True,
speedup_by_molgraph=True,
speedup_by_moltag=True,
)
assert ethane_box_with_methane.atom_types is not None

Expand All @@ -231,13 +231,13 @@ def test_match_ff_by_group(self, ethane_box_with_methane, oplsaa_gmso):
ff_dict,
match_ff_by="group",
identify_connections=False,
identify_connected_components=True,
use_molecule_info=True,
speedup_by_molgraph=True,
speedup_by_moltag=True,
)
assert ethane_box_with_methane.atom_types is not None

@pytest.mark.parametrize(
"identify_connected_components, use_molecule_info, match_ff_by",
"speedup_by_molgraph, speedup_by_moltag, match_ff_by",
[
(False, False, "group"),
(True, False, "group"),
Expand All @@ -253,8 +253,8 @@ def test_hierarchical_mol_structure(
self,
oplsaa_gmso,
hierarchical_top,
identify_connected_components,
use_molecule_info,
speedup_by_molgraph,
speedup_by_moltag,
match_ff_by,
):
top = deepcopy(hierarchical_top)
Expand All @@ -274,7 +274,7 @@ def test_hierarchical_mol_structure(
apply(
top,
ff_dict,
identify_connected_components=identify_connected_components,
use_molecule_info=use_molecule_info,
speedup_by_molgraph=speedup_by_molgraph,
speedup_by_moltag=speedup_by_moltag,
match_ff_by=match_ff_by,
)
2 changes: 1 addition & 1 deletion gmso/tests/parameterization/test_trappe_gmso.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_foyer_trappe_files(
apply(
gmso_top,
trappe_ua_gmso,
identify_connected_components=False,
speedup_by_molgraph=False,
identify_connections=True,
)
gmso_top_from_parmeterized_pmd = from_parmed(struct_pmd)
Expand Down
4 changes: 2 additions & 2 deletions gmso/utils/specific_ff_to_residue.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ def specific_ff_to_residue(
gmso_apply(
new_gmso_topology,
gmso_compatible_forcefield_selection,
identify_connected_components=True,
speedup_by_molgraph=True,
identify_connections=True,
match_ff_by=gmso_match_ff_by,
use_molecule_info=True,
speedup_by_moltag=True,
remove_untyped=True,
)
new_gmso_topology.update_topology()
Expand Down

0 comments on commit c7c9727

Please sign in to comment.