Skip to content

Commit

Permalink
new amide and sulfamide standardize rules.
Browse files Browse the repository at this point in the history
query atom fixed.
  • Loading branch information
stsouko committed Dec 2, 2020
1 parent 6a82e0d commit d415734
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
50 changes: 48 additions & 2 deletions CGRtools/algorithms/standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from ..containers import molecule, query # cyclic imports resolve
from ..containers.bonds import Bond
from ..exceptions import ValenceError
from ..periodictable import ListElement


class Standardize:
Expand Down Expand Up @@ -1026,11 +1027,12 @@ def __standardize_rules():

# Amide
#
# OH O
# [O,S]H [O,S]
# / //
# N = C >> NH - C
#
atoms = ({'atom': 'C', 'hybridization': 2}, {'atom': 'O', 'neighbors': 1}, {'atom': 'N', 'hybridization': 2})
atoms = ({'atom': 'C', 'hybridization': 2}, {'atom': ListElement(['O', 'S']), 'neighbors': 1},
{'atom': 'N', 'hybridization': 2})
bonds = ((1, 2, 1), (1, 3, 2))
atom_fix = {2: {'hybridization': 2}, 3: {'hybridization': 1}}
bonds_fix = ((1, 2, 2), (1, 3, 1))
Expand Down Expand Up @@ -1215,6 +1217,50 @@ def __standardize_rules():
bonds_fix = ((1, 2, 2),)
rules.append((atoms, bonds, atom_fix, bonds_fix))

# amide S
#
# A1,3 A1,3
# | |
# N = S - [OH] >> [NH] - S = O
#
atoms = ({'atom': 'S', 'neighbors': (3, 5), 'hybridization': 2},
{'atom': 'O', 'neighbors': 1}, {'atom': 'N', 'neighbors': (1, 2), 'hybridization': 2})
bonds = ((1, 2, 1), (1, 3, 2))
atom_fix = {2: {'hybridization': 2}, 3: {'hybridization': 1}}
bonds_fix = ((1, 2, 2), (1, 3, 1))
rules.append((atoms, bonds, atom_fix, bonds_fix))

# amide S(VI)
#
# [OH] O
# | //
# N = S = N >> [NH] - S - [NH]
# | \\
# [OH] O
#
atoms = ({'atom': 'S', 'neighbors': 4}, {'atom': 'O', 'neighbors': 1},
{'atom': 'N', 'neighbors': (1, 2), 'hybridization': 2}, {'atom': 'O', 'neighbors': 1},
{'atom': 'N', 'neighbors': (1, 2), 'hybridization': 2})
bonds = ((1, 2, 1), (1, 3, 2), (1, 4, 1), (1, 5, 2))
atom_fix = {2: {'hybridization': 2}, 3: {'hybridization': 1}, 4: {'hybridization': 2}, 5: {'hybridization': 1}}
bonds_fix = ((1, 2, 2), (1, 3, 1), (1, 4, 2), (1, 5, 1))
rules.append((atoms, bonds, atom_fix, bonds_fix))

# amide S(VI)
#
# [OH] O
# | //
# N = S = A >> [NH] - S = A
# | |
# A A
#
atoms = ({'atom': 'S', 'neighbors': 4}, {'atom': 'O', 'neighbors': 1},
{'atom': 'N', 'neighbors': (1, 2), 'hybridization': 2}, {'atom': 'A'}, {'atom': 'A'})
bonds = ((1, 2, 1), (1, 3, 2), (1, 4, 2), (1, 5, 1))
atom_fix = {2: {'hybridization': 2}, 3: {'hybridization': 1}}
bonds_fix = ((1, 2, 2), (1, 3, 1))
rules.append((atoms, bonds, atom_fix, bonds_fix))

# Silicate Selenite
#
# O O
Expand Down
2 changes: 1 addition & 1 deletion CGRtools/periodictable/element/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def ring_sizes(self) -> Tuple[int, ...]:
Atom rings sizes.
"""
try:
return self._graph()._rings_sizes[self._map] or self._graph().atoms_rings_sizes[self._map]
return self._graph()._rings_sizes[self._map]
except AttributeError:
raise IsNotConnectedAtom
except KeyError:
Expand Down

0 comments on commit d415734

Please sign in to comment.