-
Notifications
You must be signed in to change notification settings - Fork 56
SMILES ligands with -smicat [atoms,pi] fail: original atom indices lost in mcomplex #526
Description
Hi guys, I'm running on a bug when plotting organometallic compounds with η5 haptic coordination.
This does not happen when one use the alias 'cyclopentadienly', but really limits when starting from SMILES ligands.
Description:
When using SMILES-based ligands with explicit -smicat containing pi for haptic coordination (e.g., ferrocene),
structure generation fails with IndexError because the original atom indices are discarded.
Reproduction:
molsimplify -core Fe -geometry sandwich \
-lig "C1=CC=CC1,C1=CC=CC1" -ligocc 1,1 \
-smicat "[1,2,3,4,5,pi],[1,2,3,4,5,pi]" \
-coord 2 -skipANN True
Error:
IndexError: list index out of range
File "structgen.py", line 473, in init_ligand
Hs = lig3D.getHsbyIndex(cat)
Root Cause:
In structgen.py lines 2293-2294 (mcomplex function):
if 'pi' in args.smicat[smilesligs]:
cats0.append(['c']) # Original indices [0,1,2,3,4,'pi'] are LOST
When 'pi' is detected, only ['c'] is appended to cats0, discarding the atom indices. Later in init_ligand, tcats[i]
is ['c'] instead of [0,1,2,3,4,'pi'], so the check if 'pi' in lig.cat: (line 447) fails and haptic coordination is
never applied.
Proposed Fix:
Preserve the original smicat instead of replacing with ['c']:
Line 2293-2294 in structgen.py
if 'pi' in args.smicat[smilesligs]:
cats0.append(args.smicat[smilesligs]) # Keep [0,1,2,3,4,'pi']
else:
cats0.append(args.smicat[smilesligs])