Skip to content

Preserve residue IDs, insertion codes, and bond orders in OpenMM topology conversions #1316

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

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

jpthompson17
Copy link
Contributor

This PR modifies parmed.openmm.load_topology() and Structure.topology.getter() in order to preserve additional topology information.

Changes to parmed.openmm.load_topology():

  • If an OpenMM residue id is the string representation of an integer, set the corresponding ParmEd residue number to that integer.
  • ParmEd residue insertion_code <- OpenMM residue insertionCode
  • If an OpenMM bond carries type data, use it to set the corresponding ParmEd bond order. Otherwise, use the OpenMM bond order (converted to a float).

Changes to Structure.topology.getter():

  • OpenMM residue id <- string representation of ParmEd residue number
  • OpenMM residue insertionCode <- ParmEd residue insertion_code
  • Use ParmEd bond order to determine OpenMM bond type and order.

order = n
top.addBond(
atoms[bond.atom1.idx], atoms[bond.atom2.idx], type=type, order=order
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I've also recently added a qualitative_type that is basically a translation of the RDKit bond types. Not sure if that would be useful here or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... maybe. Would it make sense to add

qualitative_type = None
if b.type is not None:
    name = repr(b.type).upper()
    if hasattr(QualitativeBondType, name):
        qualitative_type = getattr(QualitativeBondType, name)

to parmed.openmm.load_topology(), and do something like

type = None
if bond.qualitative_type is not None:
    name = bond.qualitative_type.name.lower().capitalize()
    if hasattr(app, name):
        t = getattr(app, name)
        if t in bond_orders_by_openmm_type:  # ensure t is a recognized type
            type = t
else:  # try determining the type from the bond order
    for t, o in bond_orders_by_openmm_type.items():
        if math.isclose(bond.order, o):
            type = t

in Structure.topology.getter()?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm tempted to say let's hold off on that until and unless it proves useful, and let's just get this change merged.

Copy link
Contributor

@swails swails left a comment

Choose a reason for hiding this comment

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

Thanks!

@swails
Copy link
Contributor

swails commented Sep 12, 2023

The build failures are fixed in #1315, so once that is merged this can be rebased and should run to completion.

The failures are a result of downstream updates in dependencies (scipy, AmberTools, and OpenMM).

@swails swails merged commit a414ca9 into ParmEd:master Sep 14, 2023
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