converting an entire sdf file into png images

User ddf03b522f

26-06-2006 12:45:11

How do I convert an entire sdf file into png images of molecules as a batch program?

ChemAxon 7c2d26e5cf

26-06-2006 13:51:19

Please, see the attached example.

User ddf03b522f

26-06-2006 14:42:04

what is the syntax for invoking the convert2image.java file?





Is it possible to provide a quick example?

ChemAxon 7c2d26e5cf

26-06-2006 14:54:49

Code:
java -classpath .:marvinbeans/lib/MarvinBeans.jar test.image.Convert2image "png:w300,h300" input.sdf



By the way, if you call the application without parameter, the help of the application will be printed.

ChemAxon 7c2d26e5cf

26-06-2006 19:20:19

I have created a binary package for this application.


If you are not familiar in Java compiling use this package instead of the Java source.


You can download it from the following URL (the further description about it is available there):


http://www.chemaxon.com/forum/viewpost6728.html#6728

User ddf03b522f

28-06-2006 20:07:27

I have a microsoft access database of structures stored as blob fields imported from an sdf file using the jchem manager.





Is there a script avialable to convert the structures into png or jpeg images as a batch program so that the name of the output image file is the same as the cd_id of each structure record in the database?





Alternatively is it possible to adapt the convert2image script so that the name of the output image file starts from 1 and increments as it reads and creates the image files from the sdf file? e.g 1.png, 2.png etc as opposed to the current format of mols1.sdf.png, mols1.sdf_1.png etc?

ChemAxon 7c2d26e5cf

29-06-2006 10:18:16

If you want to generate output file name from the value of an SD field, you can do it by the following way:


Code:
Molecule mol; // the current molecule


String outputfile; // the name of the image file


...


String fieldname = "cd_id" // the name of the property field


String fieldvalue = mol.getProperty(fieldname);


if(fieldvalue != null) {


    outputfile = fieldvalue+".png";


}



You can use and modify freely the code of Convert2Image example.


We are planning to create a more sophisticated example for batch conversion in the future.

User ddf03b522f

29-06-2006 11:16:33

Is there a working example of the convert2image script with the above code for generating output file names from the value of an sd field?





I have tried to edit the convert2image file but unsure where the above code needs to go? Its been a while since i did any Java programming! Any help would be greatly appreciated :-)

ChemAxon 7c2d26e5cf

07-07-2006 11:12:45

I have updated the application. You can find it on the same place (among Contributed softwares). Its help is already available there.


http://www.chemaxon.com/forum/viewpost6728.html#6728


In the current version, there is a new option: an SD field can be specified to create output file name from the field's current value.