SMILES to Molecule

ChemAxon 587f88acea

27-07-2005 13:52:39

What is the quickest way to create a single Molecule from a single


SMILES string?

ChemAxon 7c2d26e5cf

27-07-2005 14:05:47

There are two ways to do it.


1.:


Code:
String smiles = ...;


Molecule mol = MolImporter.importMol(smiles);



2.


Code:
String smiles = ...;


ByteArrayInputStream in = new ByteArrayInputStream(smiles.getBytes());


MolImporter importer = new MolImporter(in);


Molecule mol = importer.read();






(You can also use the MolHandler class in JChem for this.)

ChemAxon 587f88acea

27-07-2005 14:22:39

Thanks. I knew about 2 but I had overlooked 1.





What about RgMolecules? With MOL files I had to code


Molecule mol = mi.readMol(new RgMolecule()) instead


of mi.read() to avoid getting execeptions with some


files. Will that be an issue with SMILES also?

ChemAxon 587f88acea

27-07-2005 15:07:23

With 1. I get a "file format not recognized" IOException for a perfectly


valid SMILES string: C1CCCC1.

ChemAxon 7c2d26e5cf

27-07-2005 15:23:03

No, there will be no problem with SMILES.





RgMolecue is the extension of Molecule. RgMolecule can store R-groups and reactions unlike Molecule.


http://www.chemaxon.com/marvin/doc/api/chemaxon/struc/RgMolecule.html


I suggest you to use the RgMolecule class because it can handle all kinds of structures.





If you use MolImporter.read() to import multiple molecules from the same source, the output type will be determined at the first call for efficiency reasons. If the first structure does not contain r-groups and/or reactions, Marvin will use Molecule objects for importing. If it contains a reaction, it will be recognised as RxnMolecue. If the structure contains r-groups Marvin will return with RgMolecule. MolImporter.read() presumes that the multiple molecule source contains similar type of structures.

ChemAxon 7c2d26e5cf

27-07-2005 15:32:48

Quote:
With 1. I get a "file format not recognized" IOException for a perfectly


valid SMILES string: C1CCCC1.
Probably, you have mistyped something. I have managed to import this SMILES with the latest Marvin:


Code:
Molecule mol = MolImporter.importMol("C1CCCC1");


System.err.println(mol.toFormat("mrv"));

ChemAxon 587f88acea

27-07-2005 16:07:34

Indeed I cannot reproduce it.