Summary
Sgroup created based on match have issues with atoms indexing, if it is created using query molecule with unfolded hydrogens
Steps to Reproduce
- Have molecule uploaded or created using indigo (later called: Target molecule)
- Have query molecule that is also a part of the target molecule
- Unfold hydrogens in query molecule ("query.unfoldHydrogens()")
- Use matcher to search query molecule in the target molecule
- Create sgroup using found match
- 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
Summary
Sgroup created based on match have issues with atoms indexing, if it is created using query molecule with unfolded hydrogens
Steps to Reproduce
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:
Expected behavior
There should be no error, all atoms from sgroup should be successfully processed and their labels printed
Environment details:
Additional context
-- Two V3000 export issues: implict H cause wrong index on s groups, and reversed order for COLLECTON / SGroup Blocks. #2109
-- After clicking the 'Save as...' button, an error message appears: (array: invalid index -2 (size=0)) #1318