Skip to content

Commit a264e97

Browse files
committed
Added comments explaining the handling of radicals in the kekulization.
1 parent 979f221 commit a264e97

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

selfies/mol_graph.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,17 @@ def _prune_from_ds(self, node):
301301
else:
302302
valence = valences[-1] - atom.charge
303303
used_electrons += atom.h_count
304+
305+
# count the total number of bound electrons of each atom
304306
bound_electrons = (max(0, atom.charge) + atom.h_count
305307
+ int(self._bond_counts[node])
306308
+ int(2 * (self._bond_counts[node] % 1)))
309+
310+
# calculate the number of unpaired electrons of each atom
307311
radical_electrons = (max(0, VALENCE_ELECTRONS[atom.element]
308312
- bound_electrons) % 2)
313+
314+
# unpaired electrons do not contribute to the aromatic system
309315
free_electrons = valence - used_electrons - radical_electrons
310316

311317
if any(used_electrons == v - atom.charge for v in valences):

0 commit comments

Comments
 (0)