Skip to content
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

Replace ring finding code #171

Merged
merged 7 commits into from
Aug 17, 2018
Merged

Conversation

summeraz
Copy link
Contributor

Our previous approach to finding the rings that each atom is included within, which relied upon NetworkX's cycle_basis function, did not guarantee that all rings would be found for multi-cyclic systems. This function would return a set of rings from which the full bond graph could be recreated, but this would not necessarily be all rings in the system.

This PR replaces cycle_basis with a function that should find all (chordless) cycles (i.e. rings) that each atom is included within, loosely based off of this StackOverflow post.

Resolves #170

@summeraz
Copy link
Contributor Author

This is still a WIP. I need to set up some unit tests and check to see how much of a performance hit this takes. The code included now was just the first successful attempt, so I'm sure there are plenty of optimizations that can be made.

@mikemhenry I tested this code locally on your system (from #170) and all atom types were assigned correctly, so you can checkout this branch if you need to atom type similar systems in the meantime before this is merged.

@summeraz summeraz added WIP Work in Progress, not ready for merging bug labels Jun 12, 2018
@mikemhenry
Copy link
Member

mikemhenry commented Jun 12, 2018

This is great, works for me and will be REALLY useful in other compounds I'm working with! Also I really wouldn't worry about performance hits since with the residue mapping, each residue is only typed once.

@summeraz summeraz mentioned this pull request Jun 13, 2018
@summeraz
Copy link
Contributor Author

I still need to go through and clean up this code. As far as unit tests go, I'm thinking about setting up tests that atomtype a few different systems (e.g. a polymer, a surface, and a buckyball) and marking the tests with a timeout using pytest-timeout. This will help alert us if any changes to the code (such as this case where we're replacing the ring-finding algorithm) are significantly reducing performance.

@mikemhenry
Copy link
Member

mikemhenry commented Aug 17, 2018 via email


_prepare_atoms(top, compute_cycles=True)
cycle_lengths = [list(map(len, atom.cycles)) for atom in top.atoms()]
expected = [5, 6, 6]
Copy link
Member

Choose a reason for hiding this comment

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

I might be thinking about this incorrectly but isn't this an entire fullerene structure? How can there only be 3 cycles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expected here is the expected cycle lengths for the cycles each atom is included within. Every atom in the fullerene should be included in two six-membered rings and one five-membered ring. In the assertion I'm looping over cycle_lengths and performing the comparison on the cycles for each atom.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! Nice - LGTM

@summeraz
Copy link
Contributor Author

Performance tests have been added. I'm not sure we actually need additional tests for correct atom-typing and deterministic behavior since we already test those aspects with test_opls.py and test_trappe.py and this test ensures that the ring-finding is deterministic.

@summeraz summeraz removed the WIP Work in Progress, not ready for merging label Aug 17, 2018
@ctk3b
Copy link
Member

ctk3b commented Aug 17, 2018

This looks fantastic - thanks @summeraz!

@summeraz summeraz merged commit 94b1b2f into mosdef-hub:master Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants