User e469f67125
29-11-2010 16:47:26
Hello,
I'm trying to use chemaxon.util.MolAligner to align 2D coordinates according to a smarts match. My example code is attached. When the input file is as follows:
CC1CN1
CN1CC1
CCC1CN1
CC1C(C)N1C
CCN1C(C)C1C
CC1CN1C1=CC=CC=C1
and the command line is
java molalign -smarts 'N1CC1' -i z.smi -o z.sdf
the exception is
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at chemaxon.util.MolAligner.calculate(Unknown Source)
at chemaxon.util.MolAligner.align(Unknown Source)
at molalign.main(molalign.java:174)
This is the same for JChem 5.4.0 and 5.3.6.
However, when the longest smiles is first in the file, the programs runs and produces an output file with 2D coordinates, but not aligned.
So I wonder if this is my error in understanding the API, or a JChem bug. If there is another recommended way to implement this task please advise.
Thanks,
Jeremy
ChemAxon 8407015329
01-12-2010 08:55:07
Hello Jeremy,
We are trying to reproduce the issue with the data provided. We'll get back to You soon.
Regards,
Vencel
ChemAxon 8407015329
01-12-2010 11:06:33
Hello Jeremy,
We were able to reproduce the issue You had. If I understood it correctly You have a query and a series of targets and You want the targets if they contain the query as a substructure to be alignem according to the hit mapping.
To obtain the expected behaviour the MolAligner's pattern needs to be the query not the first molecule from the target list. And there is no need for special transformations of the hit indices(ex. matchatoms int array used in the code).
I attached your code with my modifications and it aligns the targets(except the first one - it is not in the loop). I also added a // CHEMAXON MODIFCATION comment before the lines I changed.
Please review the source code and feel free to ask if questions should arise.
Best regards,
Vencel
User e469f67125
01-12-2010 18:31:48
Dear Vencel,
Thank you very much. This is very great and solves my problem. Sorry I did not understand the API correctly.
I have added one feature which may be worth mentioning. Users may have a reference compound with 2D to which they wish to align other molecules. So I added these lines:
for (int i=0;i<qmol.getAtomCount();++i)
{
qmol.getAtom(i).setX(mols.get(0).getAtom(hitatoms).getX());
qmol.getAtom(i).setY(mols.get(0).getAtom(hitatoms).getY());
}
This aligns the query to the first input molecule.
Best Regards,
Jeremy
ChemAxon 8407015329
03-12-2010 09:19:26
Hello Jeremy,
Thanks for the idea, we'll consider putting it in a future release.
Regards,
Vencel