3D JPEGs

User 870ab5b546

23-08-2005 12:54:28

Hi,





We have some 3D MOL files that we want to convert into JPEGs with wireframe and white background. Currently they are being converted into ball & stick models with black background, the default. We think the Java code that generates the JPEG is the following:





Code:



   public static void molToImage(String mol, String imgfile) {


      try {





      DataOutputStream op =


               new DataOutputStream(new FileOutputStream(imgfile));


      InputStream ip = new ByteArrayInputStream( mol.getBytes() );


      /* Options:


            width=200


            height=80


            bg=#b7b7b7 mono


            H_hetero


      */





      MolConverter mcv = new MolConverter


         //(ip,op,"jpeg:w247,h150,mono,H_heteroterm",false);


         (ip,op,"jpeg:scale040,mono,H_heteroterm,wireframe,#ffffff",false);


      mcv.convert();


      op.close();


      ip.close();





      } catch (FileNotFoundException e1) {


         e1.printStackTrace();


         return;


      } catch (MolFormatException e2) {


         System.out.println(" MOLFORMAT EXCEPTION FOR " + mol);


         e2.printStackTrace();


         return;


      } catch (IOException e3) {


         e3.printStackTrace();


         return;


      } catch( Exception e4) {


         e4.printStackTrace();


      }


   }








It seems that the code has the correct parameters set, but they have no effect in the case of the 3D MOL file. Are we doing something wrong? Do we need to use molecule.toBinFormat instead of MolConverter?

User ef5e605ae6

24-08-2005 07:26:23

Hi,





It works perfectly here:


Code:



    public static void main(String[] args) throws Exception {


        FileInputStream in = new FileInputStream("mols-3d/suprofen.mol");


        ByteArrayOutputStream baos = new ByteArrayOutputStream();


        byte[] buf = new byte[1024];


        int l;


        while((l = in.read(buf)) > 0) {


            baos.write(buf, 0, l);


        }


        molToImage(new String(baos.toByteArray()), "a.jpg");


    }








Wireframe and white background. Molecule.toBinFormat and exportToBinFormat should work too.


Please attach a full test code with the molfile which does not work.

ChemAxon 9c0afc9aaf

24-08-2005 08:17:11

Hi Bob,





Please also tell us which version of Marvin or JChem you are using.





Best regards,





Szilard

User 870ab5b546

24-08-2005 12:29:25

It's Marvin 3.5.5 and JChem 3.0.10.





I don't know how to include a complete copy of the test code. I've attached several jsp and Java files for you to peruse, and you can tell me whether they tell you what you need to know. If not, tell me what files you need to complete your investigation. Also, you can see the images that are generated by following this procedure:





Go to http://epoch.chem.uky.edu:9080/lite


Login as nfolchetti, pwd prenhall


Click on Nicole


Click on Assignments


Click on Conformations -- you'll see some 3D-looking PNGs


Click on Solve -- you'll see some 3D-looking JPEGs

User ef5e605ae6

24-08-2005 12:57:29

Hi Bob,


I thought you have a short test program like mine, which contains only a few line main method and your molToImage method. I attached my test code (Test3d.java). Could you modify it to show the bug?

User 870ab5b546

24-08-2005 13:48:02

Ack. I downloaded your Java file and double-clicked on it, and it opened a Java editor, but I can't figure out how to run it as a program. I suppose I need to use the command-line interface? If so, tell me how to formulate that command. I'm not a Unix aficionado.

User 870ab5b546

24-08-2005 16:20:10

There was nothing wrong with MolConverter or our Java method. Our program was caching old images and not erasing them until much later. So it took a while for images created with the new parameters to start appearing to the user. Sorry to bother you.