Skip to content

Commit

Permalink
fixed implicit hydrogens calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
stsouko committed Jun 27, 2021
1 parent 7f52426 commit 9521aaa
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions CGRtools/containers/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ def add_atom(self, atom: Union[Element, int, str], *args, charge=0, is_radical=F
except ValenceError:
self._hydrogens[_map] = None
else:
for s, d, h in rules:
if h and not s:
self._hydrogens[_map] = h
break
else:
self._hydrogens[_map] = 0
self._hydrogens[_map] = rules[0][2] # first rule without neighbors
else:
self._hydrogens[_map] = 0
return _map
Expand Down Expand Up @@ -541,7 +536,7 @@ def _calc_implicit(self, n: int):
self._hydrogens[n] = None
return
for s, d, h in rules:
if h and s.issubset(explicit_dict) and all(explicit_dict[k] >= c for k, c in d.items()):
if s.issubset(explicit_dict) and all(explicit_dict[k] >= c for k, c in d.items()):
self._hydrogens[n] = h
return
self._hydrogens[n] = 0
Expand Down

0 comments on commit 9521aaa

Please sign in to comment.