Skip to content

Introduce Axes for Branched Residues - #502

Open
ioanaapapa wants to merge 36 commits into
mainfrom
425-branched-resids-all-atom-MOI-update
Open

ioanaapapa wants to merge 36 commits into
mainfrom
425-branched-resids-all-atom-MOI-update

Conversation

@ioanaapapa

@ioanaapapa ioanaapapa commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Treatment for branched residues (i.e. non-terminal residues with three or more neighbouring residues) was introduced. This closes #425.

Changes

  • A new case for residues with three or more edge atoms is introduced. The three edges (A 1-3) are used to define axes and find the centre of rotation. This is consistent with the method for defining axes for linear residues in a polymer: the third edge (A3) now takes the place of the centre of the backbone.
image
  • Edge atoms and neighbour residues definition is no longer dependent on residue index. The data_container used for calculating vibrational entropy at the UA level now consists of residue of interest + heavy atoms bonded to residue of interest in neighbour residues. The res_position argument is no longer used and get_UA_axes now has the resindex argument, which corresponds to the residue index of the residue of interest.

  • Science section of docs was updated to reflect changed and match labels and terminology used in upcoming paper about axes.

Testing

Impact

  • Residues which are tethered to more than two other residues are now more rigorously treated.

Checklist

  • Tests added or updated
  • Documentation updated
  • If dependencies in pyproject.toml changed, the lower bounds were reviewed deliberately

…bour atom), removed res_position, removed redundant test for 2 point terminal residue case, was the same as test_get_ua_axes_bonded_terminal_2_points

@harryswift01 harryswift01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this, it's really nice to see the res_position logic gone, and finding edges from bonds is much cleaner. I've left a few comments, mostly from the code side. The main one is whether the topology caching should pick up these changes, since I think --axes local and --axes topology might give different results at the moment. The rest are small tidy-ups.

return trans_axes, rot_axes, center, moment_of_inertia

def get_UA_axes(self, data_container, index: int, res_position):
def get_UA_axes(self, data_container, index: int, resindex: int):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since get_UA_axes is called for every UA bead in every frame, we're recalculating the same edges for each bead in a residue. Could we work them out once per residue and pass them in? Also, the docstring calls this parameter res_index but it's resindex.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that would be good. Would it then be best to find the edges in the covariance node, then pass them as an argument to get_res/UA_axes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've just had a look at the topology caching and I'm not sure it's picking up these changes. _has_neighbor_bonds still uses resindex ± 1, and get_residue_axes_from_topology / get_UA_axes_from_topology don't use the edge logic at all, so I think --axes topology and --axes local will give different results for branched residues. Is updating the cached path in scope for this one, or should we pick it up as a follow-up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I haven't changed the topology caching -- axes topology and --axes local already give different results as the topology caching still uses the principal axes of a residue so we could follow up when we match those, as well. They should however match for UA rotation axes and that's where there might now be an issue that means we need to update it now. I'll have a look.

f"resindex {resindex} and bonded resindex {resindex_prev}"
)
residue = data_container.select_atoms(f"resindex {resindex}")
neighbours = data_container.select_atoms(f"not resindex {resindex}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the edge atoms only depend on the bonds, could we work them out once in the axes topology node and cache them (e.g. edge_indices on ResidueAxesTopology)? That would save redoing the selections every frame and keep the local and topology paths in sync.

f"or resindex {local_res_i + relative_id} "
f"or resindex {local_res_i + 1 + relative_id}"
)
resindex = local_res_i + relative_res_i

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we just use res.resindex here instead of local_res_i + relative_res_i? It avoids assuming the residues are numbered consecutively, and we wouldn't need to pass relative_res_i through.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I remember this leading to an issue for systems with multiple molecules but I'll check again

@jkalayan jkalayan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Using the bonds instead of the residue indices to find terminal/non-terminal/branched neighbours makes the implementation general to any polymer, happy to see this merged.

This branch has not been deployed

No deployments
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.

[Feature]: Branched Residues

3 participants