Indigo.exactMatch() result depends on molecule arguments order
- Dominant language
- C++
- Stars
- 406
- Forks
- 134
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 24
Description
**Summary**
For certain molecules, the result of the Indigo.exactMatch() method depends on the order in which the molecule arguments are passed.
**Steps to Reproduce**
1. Download the .mol file from the Attachments section below (attached as .txt; please change its extension to .mol before usage).
2. Run the following Python reproduction script:
```
from indigo import Indigo
indigo = Indigo()
mol = indigo.loadMoleculeFromFile(str('path/to/mol_file.mol'))
smiles_string = 'C1[C@@H]([C@H](O[C@H]1N2C=C(C(=O)NC2=O)F)CO)O'
smiles_mol = indigo.loadMolecule(smiles_string)
direct_match = indigo.exactMatch(mol, smiles_mol)
if direct_match is not None:
print('Direct match found.')
else:
print('Direct match not found.')
# Reversed order of arguments
opposite_match = indigo.exactMatch(smiles_mol, mol)
if opposite_match is not None:
print('Opposite match found.')
else:
print('Opposite match not found.')
```
**Actual behavior**
The result of exactMatch() differs when the order of the molecule arguments is reversed:
- indigo.exactMatch(mol_1, mol_2) results in None (no match).
- indigo.exactMatch(mol_2, mol_1) results in a correct match.
**Expected behavior**
The result of exactMatch() should be symmetric and independent of the order of the molecule arguments.
**Environment details:**
- Indigo version: 1.47.0.rc1
- Python version: 3.12.11
- OS version: Ubuntu 24.04.3 LTS running under WSL2 on Windows 11 Enterprise version 25H2
**Attachments**
.mol file to reproduce the issue (please, change extension from '.txt' to '.mol'):
[Opposite_match.txt](https://github.com/user-attachments/files/32003958/Opposite_match.txt)
Opposite_match
```
-INDIGO-09092612272D
0 0 0 0 0 0 0 0 0 0 0 V3000
M V30 BEGIN CTAB
M V30 COUNTS 19 20 0 0 0
M V30 BEGIN ATOM
M V30 1 N -1.0 -1.5 0.0 0
M V30 2 C -0.5 -2.366 0.0 0
M V30 3 C 0.5 -2.366 0.0 0
M V30 4 C 1.0 -1.5 0.0 0
M V30 5 N 0.5 -0.634 0.0 0
M V30 6 C -0.5 -0.634 0.0 0
M V30 7 O -1.0 0.232 0.0 0
M V30 8 O 2.0 -1.5 0.0 0
M V30 9 F 1.0 -3.232 0.0 0
M V30 10 C 0.294 -1.026 0.0 0 CFG=1
M V30 11 C 1.103 -0.438 0.0 0
M V30 12 C 0.794 0.513 0.0 0 CFG=1
M V30 13 C -0.206 0.513 0.0 0 CFG=2
M V30 14 O -0.515 -0.438 0.0 0
M V30 15 O 1.382 1.322 0.0 0
M V30 16 H 2.376 1.217 0.0 0
M V30 17 C -0.794 1.322 0.0 0
M V30 18 O -1.788 1.217 0.0 0
M V30 19 H -2.376 2.026 0.0 0
M V30 END ATOM
M V30 BEGIN BOND
M V30 1 1 6 1
M V30 2 1 1 2
M V30 3 2 2 3
M V30 4 1 3 4
M V30 5 1 4 5
M V30 6 1 5 6
M V30 7 2 6 7
M V30 8 2 4 8
M V30 9 1 3 9
M V30 10 1 10 14
M V30 11 1 14 13
M V30 12 1 13 12
M V30 13 1 12 11
M V30 14 1 11 10
M V30 15 1 10 1 CFG=3
M V30 16 1 12 15 CFG=1
M V30 17 1 15 16
M V30 18 1 13 17 CFG=3
M V30 19 1 17 18
M V30 20 1 18 19
M V30 END BOND
M V30 BEGIN COLLECTION
M V30 MDLV30/STEABS ATOMS=(3 10 12 13)
M V30 END COLLECTION
M V30 END CTAB
M END
```
**Additional context**
Calling layout() on the molecules prior to matching does not change the result of exactMatch().
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the Python reproduction with the attached Opposite_match.mol file and compare both Indigo.exactMatch() argument orders. Trace the exactMatch entry point and its molecule-matching path; done means both calls return the same correct result, with a regression check for this molecule.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100