Skip to content

Indexing issues in Sgroups created as match to query molecule with unfolded hydrogens #3544

@NadezhdaKatcman

Description

@NadezhdaKatcman

Summary
Sgroup created based on match have issues with atoms indexing, if it is created using query molecule with unfolded hydrogens

Steps to Reproduce

  1. Have molecule uploaded or created using indigo (later called: Target molecule)
  2. Have query molecule that is also a part of the target molecule
  3. Unfold hydrogens in query molecule ("query.unfoldHydrogens()")
  4. Use matcher to search query molecule in the target molecule
  5. Create sgroup using found match
  6. Iterate through sgroup's atoms trying to use their labels

Python script to reproduce the issue:
`indigo = Indigo()

mol = indigo.createMolecule()
mol.addAtom("C")

query = indigo.createQueryMolecule()
query.addAtom("C")

query.unfoldHydrogens()

matcher = indigo.substructureMatcher(mol)
match = matcher.match(query)

if match:
sgroup = mol.createSGroup("SUP", match, "TEST")

for atom in sgroup.iterateAtoms():
print(f"matched atom found {atom.symbol()}")`

Actual behavior
Match is found and sgroup is created but error is thrown during iterate through sgroup atoms:

print(f"matched atom found {atom.symbol()}")
File "...\Python313\site-packages\indigo\indigo\indigo_object.py", line 1057, in symbol
return IndigoLib.checkResultString(self._lib().indigoSymbol(self.id))
File "...\Python313\site-packages\indigo\indigo\indigo_lib.py", line 1178, in checkResultString
return IndigoLib.checkResultPtr(result, exception_class).decode()
File "...\Python313\site-packages\indigo\indigo\indigo_lib.py", line 1171, in checkResultPtr
raise exception_class(IndigoLib.lib.indigoGetLastError())
indigo.indigo.indigo_exception.IndigoException: array: invalid index -3 (size=1)

Expected behavior
There should be no error, all atoms from sgroup should be successfully processed and their labels printed

Environment details:

  • indigo: 1.40.0
  • python 3.13
  • Windows 11 Enterprise. Version 25H2

Additional context

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions