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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion foyer/tests/test_graph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import parmed as pmd

from foyer.forcefield import generate_topology
from foyer.smarts_graph import SMARTSGraph
from foyer.smarts_graph import SMARTSGraph, _prepare_atoms
from foyer.tests.utils import get_fn


Expand Down Expand Up @@ -37,3 +37,13 @@ def test_lazy_cycle_finding():
rule = SMARTSGraph(smarts_string='[C;{}]'.format(token))
list(rule.find_matches(top))
assert all([hasattr(a, 'cycles') for a in top.atoms()])


def test_cycle_finding_multiple():
fullerene = pmd.load_file(get_fn('fullerene.pdb'), structure=True)
top, _ = generate_topology(fullerene)

_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

assert all(sorted(lengths) == expected for lengths in cycle_lengths)