Skip to content

Commit

Permalink
remove is_aromatic from ring's attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxayheee committed Dec 10, 2024
1 parent b7ced6c commit 573a366
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
4 changes: 1 addition & 3 deletions meeko/macrocycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def collect_rings(self, setup):
setup.rings.keys()
): # ring_id are the atom indices in each ring
size = len(ring_id)
if setup.rings[ring_id].is_aromatic:
rigid_rings.append(ring_id)
elif size < self._min_ring_size:
if size < self._min_ring_size:
rigid_rings.append(ring_id)
# do not add rings > _max_ring_size to rigid_rings
# because bonds in rigid rings will not be breakable
Expand Down
10 changes: 2 additions & 8 deletions meeko/molsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

DEFAULT_BOND_ROTATABLE = False

DEFAULT_RING_IS_AROMATIC = False
DEFAULT_RING_CLOSURE_BONDS_REMOVED = []
DEFAULT_RING_CLOSURE_PSEUDOS_BY_ATOM = defaultdict
# endregion
Expand Down Expand Up @@ -346,7 +345,6 @@ def from_json(obj: dict):
@dataclass
class Ring:
ring_id: tuple
is_aromatic: bool = DEFAULT_RING_IS_AROMATIC

@staticmethod
def from_json(obj: dict):
Expand All @@ -370,14 +368,13 @@ def from_json(obj: dict):
return obj

# Check that all the keys we expect are in the object dictionary as a safety measure
expected_json_keys = {"ring_id", "is_aromatic"}
expected_json_keys = {"ring_id"}
if set(obj.keys()) != expected_json_keys:
return obj

# Constructs a Ring object from the provided keys.
ring_id = string_to_tuple(obj["ring_id"], int)
is_aromatic = obj["is_aromatic"]
output_ring = Ring(ring_id, is_aromatic)
output_ring = Ring(ring_id)
return output_ring


Expand Down Expand Up @@ -1965,8 +1962,6 @@ def perceive_rings(self, keep_chorded_rings: bool, keep_equivalent_rings: bool):
rings = hjk_ring_detection.scan(keep_chorded_rings, keep_equivalent_rings)
for ring_atom_indices in rings:
ring_to_add = Ring(ring_atom_indices)
if self._is_ring_aromatic(ring_atom_indices):
ring_to_add.is_aromatic = True
self.rings[ring_atom_indices] = ring_to_add
return

Expand Down Expand Up @@ -2264,7 +2259,6 @@ def default(self, obj):
if isinstance(obj, Ring):
return {
"ring_id": tuple_to_string(obj.ring_id),
"is_aromatic": obj.is_aromatic,
}
return json.JSONEncoder.default(self, obj)

Expand Down
2 changes: 0 additions & 2 deletions test/json_serialization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ def check_ring_equality(decoded_obj: Ring, starting_obj: Ring):
"""
assert isinstance(decoded_obj.ring_id, tuple)
assert decoded_obj.ring_id == starting_obj.ring_id
assert isinstance(decoded_obj.is_aromatic, bool)
assert decoded_obj.is_aromatic == starting_obj.is_aromatic
return


Expand Down

0 comments on commit 573a366

Please sign in to comment.