User 22cecfe2f7
16-05-2016 22:08:06
Chemaxon version: 15.10.26.0
Java version: 1.8.0_65
Summary: I am getting NullPointerException errors when a reactor has a "Nitrogen doubled bonded to a ring structure" in the products side of the reactant. The does not happen when the nitrogen double bonded structure is not in the products side (ie reactor.setReactionString("N=C1CC=CC=C1>>N=C"); works).
Here is a table of when the null pointer exception happens:
Substrate | Products | Fail? |
N=C1CC=CC=C1 | N=C | No |
N=C | N=C1CC=CC=C1 | Yes |
N=C1CC=CC=C1 | N=C1CC=CC=C1 | Yes |
N=C | N=C | No |
Context: We came up with the minimal chemical structure (the nitrogen bonded to a cycle) that did not work based on an actual chemical we had the exact same issue with.
Code:
import chemaxon.formats.MolExporter;
import chemaxon.formats.MolImporter;
import chemaxon.reaction.Reactor;
import chemaxon.struc.Molecule;
public class Test {
public static void main(String[] args) throws Exception {
// Create reactor
Reactor reactor = new Reactor();
reactor.setReactionString("N=C1CC=CC=C1>>N=C1CC=CC=C1");
// Create substarte that is exactly equal to the left side of the reaction
Molecule[] test = new Molecule[1];
test[0] = MolImporter.importMol("N=C1CC=CC=C1");
// Expect the product to be the same as the right side of the reaction
reactor.setReactants(test);
Molecule[] products = reactor.react();
// Fail at this point..
String inchi = MolExporter.exportToFormat(products[0], "inchi");
}
}
Stacktrace:
Exception in thread "main" chemaxon.marvin.io.MolExportException
at chemaxon.marvin.io.formats.inchi.InchiExport.convert(InchiExport.java:152)
at chemaxon.formats.MolExporter.exportToObject(MolExporter.java:1348)
at chemaxon.formats.MolExporter.exportToObject(MolExporter.java:1292)
at chemaxon.formats.MolExporter.exportToFormat(MolExporter.java:1178)
at com.Test.main(Test.java:23)
Caused by: java.lang.NullPointerException
at chemaxon.struc.MoleculeGraph.indexOf(MoleculeGraph.java:5425)
at chemaxon.marvin.io.formats.inchi.InchiExport.convertStructure(InchiExport.java:416)
at chemaxon.marvin.io.formats.inchi.InchiExport.convert(InchiExport.java:87)