Skip to content

Conversation

CalCraven
Copy link
Contributor

PR Summary:

This PR should allow for matching of forcefield connection parameters for Bonds and Angles. This was already usable with Dihedrals, the functionality has just been extended to dihedrals using the "*" syntax.

Additionally, the ability to match connections by the bond_order of the internal bonds of the connection is also included, using the "~" syntax to designate wildcard bonds, and the SMILES tokens for single, double, triple, and aromatic bonds.

PR Checklist


  • Includes appropriate unit test(s)
  • Appropriate docstring(s) are added/updated
  • Code is (approximately) PEP8 compliant
  • Issue(s) raised/addressed?

return f"<{self.__class__.__name__} {self.name}, id: {id(self)}> "

def get_connection_identifiers(self):
from gmso.core.bond import Bond

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
gmso.core.bond
begins an import cycle.
Comment on lines +539 to +541
def _get_virtual_type(
self, atom_types, return_match_order=False, exact_match=False
):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.
Copy link

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 84.45378% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.89%. Comparing base (c38c522) to head (0d62054).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
gmso/core/forcefield.py 81.03% 22 Missing ⚠️
gmso/utils/misc.py 7.69% 12 Missing ⚠️
gmso/core/angle.py 95.00% 1 Missing ⚠️
gmso/core/dihedral.py 95.00% 1 Missing ⚠️
gmso/core/improper.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #928      +/-   ##
==========================================
- Coverage   94.17%   93.89%   -0.29%     
==========================================
  Files          67       67              
  Lines        7536     7646     +110     
==========================================
+ Hits         7097     7179      +82     
- Misses        439      467      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@chrisjonesBSU chrisjonesBSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments, mostly related to doc strings. So far this is looking great. I'll try and get some minimal working examples going to further test it out.


__members_creator__: ClassVar[Callable] = Atom.model_validate

connectivity: ClassVar[Tuple[Tuple[int]]] = ((0, 1), (1, 2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a description here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we need an alias?


@bonds.setter
def bonds(self, bonds):
"""Return the bonds that makeup this Improper.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these doc strings aren't correct for this setter method?


@model_validator(mode="before")
@classmethod
def set_dependent_value_default(cls, data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a concise doc string for this method would be helpful.


__members_creator__: ClassVar[Callable] = Atom.model_validate

connectivity: ClassVar[Tuple[Tuple[int]]] = ((0, 1),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in angle.py. Do we need a description and alias here?


@property
def bonds(self):
"""Return the bond_order symbol of this bond."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the doc string to say that it returns a tuple of gmso.core.Bond instances that make up this angle.


@bonds.setter
def bonds(self, bonds):
"""Return the bonds that makeup this Improper.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update doc strings here.


@model_validator(mode="before")
@classmethod
def set_dependent_value_default(cls, data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a concise doc string for this method would be helpful.


@model_validator(mode="before")
@classmethod
def set_dependent_value_default(cls, data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a concise doc string for this method would be helpful.


@bonds.setter
def bonds(self, new_bonds):
"""Return the bonds that makeup this Improper.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the doc strings here.

return virtual_type_graph


def create_pattern(combination):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick doc string here would be helpful.

raise MissingPotentialError(msg)

def _get_angle_type(self, atom_types, return_match_order=False, warn=False):
for i in range(1, 3):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: This masking schema won't work, should try masking outside in, i.e. -opls_135- should be masked before opls_135--.

@CalCraven
Copy link
Contributor Author

This PR will not work until mosdef-hub/foyer#640 is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants