User dfeb81947d
25-10-2012 14:41:14
Dear support,
While generating IUPAC Name for some molecules I was reading from a sdfile, I got different kind of error.
To show you the different kind of error I made a new SDFile with the structures and a field in which I pu the EXception generated.
It's not that I need a correction, but I wanted to show you those issues in case you haven't got already them.
Some structures are too big to be named and shouldn't be discribed as molfile but rather as sequence. So I shouldn't have added them, I apologize for running out of time, and to haven't removed those structures from SDFile.
I thought this SDFile could be of an interest for you.
I'm using JChem 5.11.3 with JDK 1.6.0_26 on Windows XP SP3.
I wish you a nice end of afternoon and a good evening.
All the Best,
Jacques
My Code
String CRLF = System.getProperty("line.separator");
StringBuilder BUILDER = new StringBuilder();
String iupac = null;
Exception exception = null;
String molfile = ... // get molfile from SDFile
try {
Molecule mol = (new MolImporter(new MolInputStream(new ByteArrayInputStream(molfile.getBytes())))).read();
if(mol!=null) {
iupac = MolExporter.exportToFormat(m, "name");
}
} catch (Exception e) {
exception = e;
}
if(exception!=null) {
BUILDER.setLength(0);
BUILDER.append(exception.getLocalizedMessage()).append(CRLF);
StackTraceElement[] stackTrace = exception.getStackTrace();
for (int i=0;i<stackTrace.length;i++) {
BUILDER.append(stackTrace);
if(i<stackTrace.length-1) {BUILDER.append(CRLF);}
}
}
// here I write in a new SDFile the molfile and add the BUILDER.toString() to show the Exception