-
Notifications
You must be signed in to change notification settings - Fork 7
add new dihedrals indentified by grappa to top #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,8 +197,9 @@ def apply_parameters(top: 'Topology', parameters: Parameters, apply_nrs: Set[str | |
|
|
||
| # find the proper dihedral tuple in the topology that is equivalent to the given tuple | ||
| tup = find_proper(tup, top) | ||
| if not tup: | ||
| raise ValueError(f"Invalid proper dihedral tuple {tup}") | ||
| if tup is None: | ||
| tup = tuple(idx) | ||
| logging.warning(f"Adding new proper dihedral {tup} that was not in the original topology.") | ||
|
|
||
| dihedral_dict = {} | ||
| for ii in range(len(parameters.proper_ks[i])): | ||
|
|
@@ -295,10 +296,10 @@ def parameterize_topology( | |
| apply_parameters(current_topology, parameters, build_nrs) | ||
| return current_topology | ||
|
|
||
| def find_angle(tup: tuple, top: 'Topology') -> Tuple[int, int, int]: | ||
| def find_angle(tup: tuple, top: 'Topology') -> Tuple[int, int, int] | None: | ||
| """ | ||
| Find the angle tuple in the topology that is equivalent to the given tuple. | ||
|
Comment on lines
+299
to
301
|
||
| If no equivalent tuple is found, it logs a warning and returns False. | ||
| If no equivalent tuple is found, it logs a warning and returns None. | ||
| """ | ||
| if not top.angles.get(tup): | ||
| # try equivalent tuples using the symmetries of the angle: | ||
|
|
@@ -311,21 +312,21 @@ def find_angle(tup: tuple, top: 'Topology') -> Tuple[int, int, int]: | |
|
|
||
| if len(tups_in_topology) == 0: | ||
| logging.warning( | ||
| f"Ignored parameters with invalid ids: {tup} for angles" | ||
| f"No equivalent tuple found for {tup} in angles from topology." | ||
| ) | ||
| return None | ||
| elif len(tups_in_topology) > 1: | ||
| logging.warning( | ||
| f"Multiple equivalent tuples found for {tup} in angles" | ||
| f"Multiple equivalent tuples found for {tup} in angles from topology." | ||
| ) | ||
| else: | ||
| tup = tups_in_topology[0] | ||
| return tup | ||
|
|
||
| def find_bond(tup: tuple, top: 'Topology') -> Tuple[int, int]: | ||
| def find_bond(tup: tuple, top: 'Topology') -> Tuple[int, int] | None: | ||
| """ | ||
| Find the bond tuple in the topology that is equivalent to the given tuple. | ||
| If no equivalent tuple is found, it logs a warning and returns False. | ||
| If no equivalent tuple is found, it logs a warning and returns None. | ||
| """ | ||
| if not top.bonds.get(tup): | ||
| # try equivalent tuples using the symmetries of the bond: | ||
|
|
@@ -338,22 +339,22 @@ def find_bond(tup: tuple, top: 'Topology') -> Tuple[int, int]: | |
|
|
||
| if len(tups_in_topology) == 0: | ||
| logging.warning( | ||
| f"Ignored parameters with invalid ids: {tup} for bonds" | ||
| f"No equivalent tuple found for {tup} in bonds from topology." | ||
| ) | ||
| return None | ||
| elif len(tups_in_topology) > 1: | ||
| logging.warning( | ||
| f"Multiple equivalent tuples found for {tup} in bonds" | ||
| f"Multiple equivalent tuples found for {tup} in bonds from topology." | ||
| ) | ||
| else: | ||
| tup = tups_in_topology[0] | ||
| return tup | ||
|
|
||
|
|
||
| def find_proper(tup: tuple, top: 'Topology') -> Tuple[int, int, int, int]: | ||
| def find_proper(tup: tuple, top: 'Topology') -> Tuple[int, int, int, int] | None: | ||
| """ | ||
| Find the proper dihedral tuple in the topology that is equivalent to the given tuple. | ||
| If no equivalent tuple is found, it logs a warning and returns False. | ||
| If no equivalent tuple is found, it logs a warning and returns None. | ||
| """ | ||
|
|
||
| if not top.proper_dihedrals.get(tup): | ||
|
|
@@ -370,12 +371,12 @@ def find_proper(tup: tuple, top: 'Topology') -> Tuple[int, int, int, int]: | |
|
|
||
| if len(tups_in_topology) == 0: | ||
| logging.warning( | ||
| f"Ignored parameters with invalid ids: {tup} for proper dihedrals" | ||
| f"No equivalent tuple found for {tup} in proper dihedrals from topology." | ||
| ) | ||
|
Comment on lines
372
to
375
|
||
| return None | ||
| elif len(tups_in_topology) > 1: | ||
| logging.warning( | ||
| f"Multiple equivalent tuples found for {tup} in proper dihedrals" | ||
| f"Multiple equivalent tuples found for {tup} in proper dihedrals from topology." | ||
| ) | ||
| else: | ||
| tup = tups_in_topology[0] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces new behavior (adding proper dihedrals that weren’t present in the input topology) but there doesn’t appear to be a targeted test asserting that: (1) parameterization no longer raises, (2) the new dihedral is present in the written topology, and (3) a warning is emitted. Adding a small unit/integration test that constructs a minimal Topology+Parameters case would help prevent regressions (especially around tuple ordering/equivalence).