Skip to content

Commit

Permalink
check_valence added to reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
stsouko committed Jan 21, 2021
1 parent 59948ab commit fdb814f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CGRtools/algorithms/standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,22 @@ def fix_positions(self: Union['ReactionContainer', 'StandardizeReaction']):
self._signs = tuple(signs)
self.flush_cache()

def check_valence(self: 'ReactionContainer') -> List[Tuple[int, Tuple[int, ...]]]:
"""
Check valences of all atoms of all molecules.
Works only on molecules with aromatic rings in Kekule form.
:return: list of invalid molecules with invalid atoms lists
"""
out = []
for n, m in enumerate(self.molecules()):
if not isinstance(m, Standardize):
raise TypeError('Only Molecules supported')
c = m.check_valence()
if c:
out.append((n, tuple(c)))
return out

@class_cached_property
def __standardize_compiled_rules(self):
rules = []
Expand Down

0 comments on commit fdb814f

Please sign in to comment.