Converting an imported molecule to smiles

User a18e201107

01-10-2013 18:33:01

Hello


I am working on trying to import an SD file and iterate through the molecules/contents contained.  As I iterate I would like to convert each molecule to smiles so I can check against a database for duplicates.  I have the following code so far:


 


      while (recordCount > -1){


            File file = new File(sdfFilePath);


            FileInputStream inputStream = new FileInputStream(file)


            MolImporter moleculeImporter = new MolImporter(inputStream, "sdf:MULTISET,Usg")


            moleculeImporter.seekRecord(recordCount, null)


            Molecule molecule = moleculeImporter.read()


   String mySMILES


            try {


               mySMILES = MolExporter.exportToFormat(molecule, "smiles");


                } catch (IOException e){


                println(e)


                }


            println(mySMILES)


            recordCount--


        }


 


However I am getting a ClassNotFoundException (Message: chemaxon.util.concurrent.ConcurrentProcessor) at the following line


   mySMILES = MolExporter.exportToFormat(molecule, "smiles");


Which I do not understand as I have imported the MolExporter class, does the code above look ok otherwise?  Are there multiple MolExporter classes in the Chemaxon libs?  I was going off of this API doc 


Thank you for any help


Dennis

User a18e201107

01-10-2013 21:02:40

Ok I figured out what was going on, I did not have the MarvinBeans-formats-smiles.jar or MarvinBeans-smarts.jar in my lib folder. 


At this point I changed the code a bit and I am a bit stuck on how I can then get access to the smiles string?


 


  MolImporter importer = new MolImporter(inputStream);


        Molecule mol;


        while ((mol = importer.read()) != null) {


            MolHandler molHandler = new MolHandler(mol)


            molHandler.clean(true, null)


            molHandler.toFormat("smiles")


            Molecule smiles = molHandler.getMolecule()


            ....


}


Thank you for any help you can provide,



Dennis

User a18e201107

01-10-2013 21:25:24

Got everything working with the following (probably no need to have the molHandler function).


  MolImporter importer = new MolImporter(inputStream);


        Molecule mol;


        while ((mol = importer.read()) != null) {


            // do something with the molecule


            println(mol)


            MolHandler molHandler = new MolHandler(mol)


            molHandler.clean(true, null)


            molHandler.toFormat("smiles")


            Molecule smiles = molHandler.getMolecule()


            println(MolExporter.exportToFormat(mol, "smiles"));


        }


 


Here is my question....what libraries do I need for this?  It seems a bit overkill to add ALL Marvin libraries to a project (which is what I did to resolve the issue).



Thanks


 


dennis

ChemAxon 712bc8fcf4

02-10-2013 08:04:49

Hello Dennis,


You are right,  the MolHandler is not needed in this case.


Necessary libraries: 
com.chemaxon-io.jar
com.chemaxon-core.jar
com.chemaxon-license.jar
com.chemaxon-common.jar
com.chemaxon-concurrent.jar
com.chemaxon-io-mdl.jar
com.chemaxon-io-smiles.jar


Regards,
Mate 

User a18e201107

02-10-2013 13:21:23

Thank you for the reply. Concurrent.jar!  That is what was throwing me, I thought that was a regular java issue! 


Dennis