target.toFormat("smiles") ERROR
User f564ccf382
20-08-2008 12:08:14
To whom it concerns,
Here is a snippet of my code:
try{
MolImporter mi = new MolImporter("Individual.sdf");
Molecule target = null;
.
.
.
.
while((target = mi.read()) !=null)
{
.
.
String smForm = target.toFormat("smiles");
.
.
.
}
mi.close();
}catch(IOException ioe)
{ ioe.printStackTrace();
}
.
.
}
}
Now in most cases if the SMILES string is invalid for example
(CCCC(CCC)CCC
the code throws an exception which is caught and this piece of code is exited. But, in one particular case when the SMILES string is as follows;
C1CCCC2CCC3CCC3(C1CCCCC2)C21C21
the code was left 'hanging'
I know that this SMILES string is Invalid but, I'd like the code to be able to handle any Invalid SMILES string.
I would appreciate any suggestions as to how I can ensure that if an Invalid SMILES is found then the code exits and returns a message(e.g. -999) to the calling function.
Thanks,
Miriam O'Riordan
....
String smForm = target.toFormat("smiles")
ChemAxon 25dcd765a3
25-08-2008 12:58:28
Dear Miriam,
There are some things which are not clear for me.
It seems from your code snippet that you import an sdf file and export it to SMILES format.
But later, if I understand well, you have problem with SMILES import.
So let me focus on the part which I think I have understood.
You have two invalid smiles strings
(CCCC(CCC)CCC
C1CCCC2CCC3CCC3(C1CCCCC2)C21C21
and the problem is that the code hangs.
I actually cannot reproduce the 'hanging', only exceptions.
I have written a simple test code which can handle invalid smiles strings by catching the exceptions.
Code: |
java Test invalid.smi
The 0th molecule is invalid smiles
The 1th molecule is invalid smiles
CCCC
The 3th molecule is invalid smiles
|
Andras
User f564ccf382
08-09-2008 18:16:44
Hi Andras,
Thanks for replying to my query. I'm sorry for not getting back to you sooner but, I've been away since the 22nd Aug.
When I compared you're code Test.java with mine the most obvious difference was the following;
MyCODE:
Molecule target ;
MolImporter mi = new MolImporter("Individual.sdf");
target = mi.read();
YourCODE:
Molecule m = new Molecule();
MolImporter molimp = new MolImporter(s);
if(!molimp.read(m));
WHY is the previous line of code NOT as follows
if(!m=molimp.read())
Thanks,
Miriam
ChemAxon 25dcd765a3
08-09-2008 19:11:00
User f564ccf382
09-09-2008 16:30:51
Hi Andras,
Thanks for your explanation but,I'm confused with respect to the following point.
In your code Test.java the SMILES string is imported and 'stored' in the MolImporter data structure molimp. Then, an empty Molecule data structure 'm' is created.
In my opinion, the code snippet,
molimp.read(m);
is saying read the empty molecule m.
Thanks,
Miriam
ChemAxon 25dcd765a3
09-09-2008 19:24:34
Dear Miriam,
The read method reads the SMILES string into the molecule m.
In other word it parses the SMILES string and generates the molecule representation in molecule m.If the method reaches the end of the file it returns false otherwise true.
Quote: |
molimp.read(m);
is saying read the empty molecule m.
|
No it says parse the input and generate the corresponding molecule structure in m.
Andras
User f564ccf382
10-09-2008 09:31:50
Hi Andras,
Thanks for that explanation. It makes sense to me now.
All the best,
Miriam
User f564ccf382
12-09-2008 14:52:37
Hi Andras,
In my original message under this topic I had assumed that the problem originated at the line of code
String smForm = target.toFormat("smiles")
But, my problem has reappeared and it would seem to be located at the line
try{
mol = nmi.read();
When Individual.sdf is as follows;
Oc1cncc2C=CC(Cc3nccc4CCc5c(C=O)c(CONN(C(=O))SC(c7ccccc7)SCN)c(Cc3nccc4C(CF)NOc5\
cc(Cc7ccccc7)c(Nccc(C)CNcnc(C=N)cSC(C=N)C)c(c7ccccc7Cl)c5Nc43)c(C=N)c5N(C=N)c43\
)CC(Br)c2
I get the following message
java.io.IOException: Unmatched ring closure number 1 in SMILES string Oc1cncc2C=CC(Cc3nccc4CCc5c(C=O)c(CONN(C(=O))SC(c7ccccc7)SCN)c(Cc3nccc4C(CF)NOc5cc(Cc7ccccc7)c(Nccc(C)CNcnc(C=N)cSC(C=N)C)c(c7ccccc7Cl)c5Nc43)c(C=N)c5N(C=N)c43)CC(Br)c2
at chemaxon.marvin.modules.SmilesImport.readMol0(Unknown Source)
at chemaxon.marvin.modules.SmilesImport.readMol(Unknown Source)
at chemaxon.marvin.modules.SmilesImport.readMol(Unknown Source)
at chemaxon.formats.MolImporter.readMol(Unknown Source)
at chemaxon.formats.MolImporter.read(Unknown Source)
at chemaxon.formats.MolImporter.read(Unknown Source)
at chemaxon.marvin.calculations.My_MolCalculator_Two_Rack17.main(My_MolCalculator_Two_Rack17.java:56)
This is what I'd expect to happen.
The PROBLEM is
when the molecule(Individual.sdf) is as follows the system just hangs
Oc1cncc2C=CC(Cc3nccc4CCc5c(C=O)c(CONN(C(=O))SC(c7ccccc7)SCN)c(Cc3nccc4C(CF)NOc5\
cc(Cc7ccccc7)c(Nccc(C)CNcnc(C=N)cSC(C=N)C)c(c7ccccc7Cl)c5Nc43)c(C=N)c5N(C=N)c43\
)CC(Br)c21
I want to ensure that if an INVALID SMILES molecule is encountered by the Java code that it(the Java code) will exit. I am aware that in the both examples of the molecule above that the Rings are numbered correctly the CORRECT Molecule should be
Oc1cncc2C=CC(Cc3nccc4CCc5c(C=O)c(CONN(C(=O))SC(c7ccccc7)SCN)c(Cc6nccc7C(CF)NOc8\
cc(Cc7ccccc7)c(Nccc(C)CNcnc(C=N)cSC(C=N)C)c(c7ccccc7Cl)c8Nc76)c(C=N)c5N(C=N)c43\
)CC(Br)c21
This molecule is passed to the java code with no problems/exceptions.
I would be very grateful if you could suggest a way that I could guarantee that ANY Invalid SMILES would cause the Java code to exit/return an error message to the calling function.
Kind Regards,
Miriam
ChemAxon 25dcd765a3
16-09-2008 16:03:08
Hi Miriam,
The solution is simple: change the catch exception type from MolFormatException to Exception. In this case any type of exception will generate the error printout.
Please let me know if it solves your problem.
Andras
User f564ccf382
17-09-2008 13:39:46
Hi Andras,
I tried that but, the code is still hanging.
thanks,
Miriam
ChemAxon 25dcd765a3
18-09-2008 08:31:50
Hi,
Could you attach the sdf file which contains the molecule that hangs.
In that case I can check the problem more deeply.
Andras
User f564ccf382
18-09-2008 09:44:49
Hi Andras,
Please find attached the file Individual.sdf.
Thanks,
Miriam
User f564ccf382
18-09-2008 11:58:06
Hi Andras,
I thought that my problem may be due to the version of MarvinBeans that I was running. When I tried to install version marvinbeans-5_1_01-linux.sh I got the following error message:
testing JVM in /usr ...
testing JVM in /usr/java/jre1.6.0_07 ...
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 1.4.2.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
You can also try to delete the JVM cache file /home/miriam/.install4j
I tried everything but, I still can't install MarvinBeans. Have you any suggestions as to what I could do next?
thanks,
Miriam
ChemAxon 25dcd765a3
18-09-2008 19:23:15
Hi Miriam,
At first, the given Individual.sdf is not an sdf file but smiles, so you should rename it to Individual.smi to have Test.java working.
On the other hand, if you modify the Test.java as I we have discussed earlier:
form
Code: |
} catch (chemaxon.formats.MolFormatException e){
|
to
Code: |
} catch (Exception e){
|
then it works as you would expect: Quote: |
java Test Individual.smi
The 0th molecule is invalid smiles
|
Andras
User f564ccf382
19-09-2008 13:45:02
Hi Andras,
Thanks for that. It's working fine now. One other question when I tried to install version 5.1.1 of marvinbeans (current version is 4.1.13) I get the following Error message:
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 1.4.2.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
You can also try to delete the JVM cache file /home/miriam/.install4j
I tried everything and I re-installed the latest version of Java.
Using version 4.1.13 I typed
javac -d ./ MyFile.java
now I get a list of WARNINGS(which I never got before) e.g.,
WARNING in MyFile.java (at line 4)
import chemaxon.marvin*;
The import chemaxon.marvin is never used.
When I then type
java chemaxon.marvin.calculations.MyFile
I get the Exception message that I'd expect for the molecule in Individual.smi.
Are the WARNINGS a result of the newer version of Java and is it ok to ignore the Warnings?
Thanks again for all your help it is very much appreciated.
Miriam
ChemAxon 25dcd765a3
19-09-2008 13:50:40
Hi,
I think you can ignore the warnings. These are rather java programming specific questions but Tamas will tell you more about this.
Andras
ChemAxon 7c2d26e5cf
19-09-2008 18:33:08
The Marvin Beans installer works fine for me on my Linux.
Probably, your default Java is not Sun distributed one or it is earlier than 1.4.2.
Please check your configuration. Type "
java -version", you should get something like that:
Code: |
vertset@asus-laptop:java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
|
This description can be also useful: Installation Guid for Marvin Beans
I also recommend to read the linking forum topics:
installation error on linux
installation error on Mandriva 2007
If you do not manage to launch installer, I can suggest to use the cross-platform version of Marvin Beans package.
http://www.chemaxon.com/marvin/download-user.html
It is a zip archive, just download and extract it somewhere.
User f564ccf382
19-09-2008 18:47:26
Hi Tamas,
I checked the Java version (the message is below) and you're right it is not a SUN one.
I will try to install marvinbeans using the crossplatform version.
Thanks,
Miriam
java -version
java full version "kaffe-1.4.2"
kaffe VM "1.1.7"
Copyright (c) 1996-2005 Kaffe.org project contributors (please see
the source code for a full list of contributors). All rights reserved.
Portions Copyright (c) 1996-2002 Transvirtual Technologies, Inc.
The Kaffe virtual machine is free software, licensed under the terms of
the GNU General Public License. Kaffe.org is a an independent, free software
community project, not directly affiliated with Transvirtual Technologies,
Inc. Kaffe is a Trademark of Transvirtual Technologies, Inc. Kaffe comes
with ABSOLUTELY NO WARRANTY.
Engine: Just-in-time v3 Version: 1.1.7 Java Version: 1.4
Heap defaults: minimum size: 5 MB, maximum size: unlimited
Stack default size: 256 KB
ChemAxon 7c2d26e5cf
22-09-2008 09:22:21
Actually, downloading the crossplatform version is not enough.
Under Linux, Marvin uses the default Java in all cases.
Marvin (like any other ChemAxon product and the installer)
does not support kaffe Java. It is not a Sun compatible Java distribution.
If kaffe is your default one, you can get unexpected errors by running Marvin.
See the
System requirements
To be able to use Marvin, install a
Sun distributed Java version and
change the
default Java to Sun's one.
The simplest way is the following:
Modify the PATH variable: start your PATH variable with the reference to Sun's Java. (In this case, This Java will be used instead of "
/usr/bin/java".)
To do this, just modify your bash profile (if you use other shell modify the proper script of your shell):
Code: |
export JAVA_HOME=/opt/jre1.6.0_07
export PATH=$JAVA_HOME/bin:$PATH |