MolSearch problem after removeAtom()

User e469f67125

12-01-2011 15:54:37

Dear ChemAxon,


 


It appears that MolSearch can be broken after atoms are removed.  The attached example program is designed to remove all non-ring chain atoms.  As designed, with an input molecule of all ring atoms, none are removed:


 


$ java test_dynosearch "N1CC1"
JChem version: 5.4.0.0
DEBUG: n_del = 0



But, when a chain atoms,


 


$ java test_dynosearch "OCCN1CC1"
JChem version: 5.4.0.0
DEBUG: mol: OCCN1CC1
DEBUG: matchA = 0,1
DEBUG: atom: O nbr: C
DEBUG: mol: CCN1CC1
DEBUG: matchA = 0,1
DEBUG: atom: C nbr: C
DEBUG: mol: CN1CC1
DEBUG: matchA = 0,1
DEBUG: atom: C nbr: N
DEBUG: mol: C1CN1
DEBUG: matchA = 0,1
DEBUG: atom: N nbr: C
DEBUG: mol: CC
DEBUG: matchA = 0,1
DEBUG: atom: C nbr: C
DEBUG: mol: C
DEBUG: matchA = 0,1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
        at chemaxon.struc.MoleculeGraph.getAtom(Unknown Source)
        at test_dynosearch.main(test_dynosearch.java:29)


 


The smarts used is "[D1&!R]-*" which seems to work correctly for a molecule until atoms are removed.  But above it is matching even when all are ring-atoms.


Perhaps the molecule or search needs to be "re-rationalized"?  But I don't see a method for that.  The example program uses findFirst() but I have tried findNext() and findAll() with the same result.


 


Thanks,


 


Jeremy


 

ChemAxon 42004978e8

18-01-2011 15:15:20

Hi Jeremy,


 


Thank you for the report, we are checking it.


Bye,


Robert

ChemAxon 8407015329

25-01-2011 11:30:09

Hi Jeremy,


 


We analyzed the issue and found the cause and a solution. Due to performance concerns our searcher classes such as MolSearch cache(build maps and arrays) the molecules given as query and target. We assume that if the target or query changes it will be reset using the setQuery() or setTarget() methods. The API documentation lacks this information, I will add it.


To make Your code run as desired please use the setTarget() method after removing the atom. This will cause the searcher class to reinitialize its data for the changed molecule.


Best regards,


Vencel

User e469f67125

26-01-2011 00:06:34

Vencel,



Thank you very much; calling setTarget() after each atom removal works fine.


 


Best Regards,


Jeremy