From 025a7aa76da950fa04023d261d084e7133a81d22 Mon Sep 17 00:00:00 2001 From: Fabian Gruenewald Date: Wed, 8 May 2024 16:07:24 +0200 Subject: [PATCH] remove triangle exception --- pysmiles/smiles_helper.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pysmiles/smiles_helper.py b/pysmiles/smiles_helper.py index b9498e2..0e5f371 100644 --- a/pysmiles/smiles_helper.py +++ b/pysmiles/smiles_helper.py @@ -477,19 +477,13 @@ def mark_aromatic_atoms(mol, atoms=None): for sub_ds in nx.connected_components(ds_graph): sub_ds_graph = mol.subgraph(sub_ds) max_match = nx.max_weight_matching(sub_ds_graph) - # if the subgraph is three nodes it might be - # a triangle, which is the only special case - # where there is no maximum match but - is_triangle = (len(sub_ds_graph.nodes) == 3 and nx.cycle_basis(sub_ds_graph)) - if not is_triangle: - max_match = nx.max_weight_matching(sub_ds_graph) - # we check if a maximum matching exists and - # if it is perfect. if it is not perfect, - # this graph originates from a completely invalid - # smiles and we raise an error - if not nx.is_perfect_matching(sub_ds_graph, max_match): - msg = "Your molecule is invalid and cannot be kekulized." - raise SyntaxError(msg) + # we check if a maximum matching exists and + # if it is perfect. if it is not perfect, + # this graph originates from a completely invalid + # smiles and we raise an error + if not nx.is_perfect_matching(sub_ds_graph, max_match): + msg = "Your molecule is invalid and cannot be kekulized." + raise SyntaxError(msg) # we consider a node aromatic if it can take part in DIME # to do so all nodes in a delocalized subgraph have to be