Reaction SMARTS on SD file seems broken

46 views
Skip to first unread message

vince.le...@gmail.com

unread,
Jun 19, 2013, 11:16:38 AM6/19/13
to indig...@googlegroups.com
Hello there,

I'm trying to apply a set of reactions encoded as SMIRKS on molecules read from a SD file using indigo (JAVA wrapper, tested on 1.1.7 and 1.1.10), and I got the following error at the first molecule:

Exception in thread "main" com.ggasoftware.indigo.IndigoException: core: <type 12> is not a molecule or array of molecules
at com.ggasoftware.indigo.Indigo.checkResult(Indigo.java:62)
at com.ggasoftware.indigo.Indigo.transform(Indigo.java:475)
at com.dng.gga.SMIRKSIssue.main(SMIRKSIssue.java:40)
Java Result: 1

It seems that the error only appears when the reaction is performed on molecules read from a SD file (attached). I've no problem if I load the molecule with a SMILES or with the exact same molfile text. 

Test code snippet:

package com.dng.gga;
import com.ggasoftware.indigo.Indigo;
import com.ggasoftware.indigo.IndigoObject;
import java.io.IOException;
import java.util.Iterator;
public class SMIRKSIssue {
    
    public static void main(String [] args) 
            throws IOException, Exception {
        Indigo indigo = new Indigo();
        
        IndigoObject rs    = indigo.loadReactionSmarts("[S-:1]>>[S:1][H]");
        
        // Works fine
        IndigoObject mol = indigo.loadMolecule("\n  -INDIGO-06191316532D\n" +
                            "\n" +
                            "  3  2  0  0  0  0  0  0  0  0999 V2000\n" +
                            "    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                            "    0.0000    0.0000    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                            "    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                            "  1  2  1  0  0  0  0\n" +
                            "  2  3  1  0  0  0  0\n" +
                            "M  CHG  1   2  -1\n" +
                            "M  RAD  1   2   2\n" +
                            "M  END\n$$$$");
        indigo.transform(rs, mol);
        System.out.println("Transformed: "+mol.canonicalSmiles());
        System.out.flush();
        
        // Doesn't work
        Iterator<IndigoObject> reader = indigo.iterateSDFile("C:\\Users\\localadmin\\Desktop\\DISCNGINE DATA\\input.sdf").iterator() ;
        while(reader.hasNext()) {
            mol = reader.next();
            indigo.transform(rs, mol);
        }
    }
}

Any idea ?

Best,
Vincent

input.sdf

Mikhail Rybalkin

unread,
Jun 19, 2013, 11:27:56 AM6/19/13
to indig...@googlegroups.com, vince.le...@gmail.com
Hi Vincent,

The problem is that a molecule from file in not a simple molecule, but a proxy object that loads molecule from the data on demand. Probably in the transformation method we didn't check this case, and this is our bug. Workaround is to clone a molecule before transformation:
mol = reader.next().clone()

PS: you can use Java foreach loops on indigo iterators:
for (IndigoObject mol : reader)
...

Best regards,
Mikhail

vince.le...@gmail.com

unread,
Jun 20, 2013, 2:29:21 AM6/20/13
to indig...@googlegroups.com, vince.le...@gmail.com
OK great, I was doing something similar as a workaround but cloning is probably faster. 

Thanks Mikhail :)

Mikhail Rybalkin

unread,
Jul 3, 2013, 7:25:30 PM7/3/13
to indig...@googlegroups.com, vince.le...@gmail.com
Hi Vincent,

We've just release a new version where this issue was resolved. Look either to the announcement on the indigo-general, or directly to the documentation preview

Best regards,
Mikhail

vince.le...@gmail.com

unread,
Jul 4, 2013, 8:37:27 AM7/4/13
to indig...@googlegroups.com, vince.le...@gmail.com
Thanks Mikhail, and great idea to Mavenize your JARs ;)
Reply all
Reply to author
Forward
0 new messages