coverting compr output to sdf

User e34a92cce5

08-03-2005 17:23:14

Hi


I use the compare() JChem API to compare two libraries and generate an output file. Is there an API that will help me create an SDF out of the statistics file that's generated from the compare() class output? The analog to this is the crview() class in client.


Thanks!

ChemAxon 9c0afc9aaf

10-03-2005 09:05:31

Hi,





Currently we do not have such an API.


Since Compr cannot return the cd_is values in the API (we plan to implement this later), you should do the following:





1. Generate the output file as usual


2. Parse the text file to get out the cd_id values (should not be hard to code this)


3. Get the appropriate molecules from the database and export them into an SDF. (I assume you are running compr on a database)





Some additional information for step 3:





You should read the "cd_structure" field from the appropriate structure table with a SELECT through JDBC.


I recommend getting the field with one of the following methods from the ResultSet for maximum compatibility:





http://www.jchem.com/doc/api/chemaxon/util/DatabaseTools.html#readBytes(java.sql.ResultSet,%20int)





http://www.jchem.com/doc/api/chemaxon/util/DatabaseTools.html#readBytes(java.sql.ResultSet,%20java.lang.String)





Once you have the structure, you should import it into a Molecule object.


Use chemaxon.util.MolHandler for this:


Molecule m=new MolHandler(molecule_as_bytes).getMolecule()





You can write molecules into a file with MolExporeter:








Code:



FileOutputStream fos= new FileOutputStream("out.sdf");


MolExporter me =new MolExporter(fos, "sdf");


...


me.write(mol); //this should be in a loop


....


me.close();








Best regards,





Szilard