RgMolecule converting to Images with MarvinBeans

User 4ceb4fe234

05-09-2008 14:06:02

Dear all,





I've successfully imported a molecule with R-Group into a RgMolecule object using MarvinBeans (we're using MarvinBeans 5.0.7).





Now, I want to convert this Molecule into an image including all R-Groups. This image should look like the display of the Molecule in MarvinSketch, i.e. especially I want the String "R1" marking the groups appear in it.





But If I use toBinFormat() I only get the main molecule without R-Groups. If I import it into a Molecule object, I get the R-Groups but no maker named "R1".





Can you help me with that?





Thanks in advance!





Helge

ChemAxon 909aee4527

08-09-2008 10:35:06

Hello Helge,





you are right, in 5.0.7 the simple image conversion doesn't seem to include the R-group definitions, though it works nicely with 5.1.x


( using mol.toBinFormat("jpeg:w200,h200"); ).





A quick 5.0.7 solution can be:





Code:
            // getting the actual scale factor of the canvas


            double currentScale = sketchPane.getScale();


            // getting the image of the canvas with


            // the current scale factor


            Image canvasImage = sketchPane.getImage(currentScale);








I hope you can use this or it's possible for you to upgrade.


Kind regards,


Judit

User 4ceb4fe234

09-09-2008 05:05:14

Hi Judit,





thanks for your response.





I've replaced 5.0.7 with the actual version 5.1.1 and everything works fine! Thank you very much!





Helge

User 4ceb4fe234

10-09-2008 05:02:13

Hi Judit,





the exchange of MarvinBeans 5.0.7 with 5.1.1 solves the problem with Rgroups but arises another problem.





If you load the reaction defined in 0rea.mol (or 0rea.mrv) in MarvinSketch, everything looks fine. But when I render it in MarvinBeans 5.1.1. (after loading it as an RgMolecule) the arrow is missing. The same rendering code with MarvinBeans 5.0.7. works fine. Marvin Beans is always fed with the Molfile V3 format.





Do you have any idea? Or a workaround?





Helge

ChemAxon 909aee4527

11-09-2008 10:43:42

Hi Helge,





thank you for the code example you've sent in e-mail, it helped us to reproduce the problem.





We will fix it by 5.1.2, but until then here is a quick&dirty workaround:





Code:
      if (molecule.getDocument() == null) {


          new MDocument(molecule);


      }


      if(molecule.getRoot() instanceof RxnMolecule) {


          RxnMolecule root = (RxnMolecule)molecule.getRoot();


          MRArrow arrow = (MRArrow) root.getReactionArrow(true);


          arrow.setType(RxnMolecule.REGULAR_SINGLE);


      }






Please add this code after the molecule importing part and before the conditional cleaning of the molecule.





Should you have any more problems, please contact us.





Kind regards,


Judit

User 4ceb4fe234

11-09-2008 11:40:29

Hi Judit,





this code snippet seems to solve our problems, thank you very much!





Best regards





Helge