Initializing sketch applet with MRV?

User 4b347806a7

27-10-2010 11:01:05

Is there a way to start the skech applet loaded with a mrv sketch?  I know you can set sketch_param("mol"...) to a SMILES or mol file, but it doesn't seem to work for mrv.  Would the only way be to put the mrv in a text field on the web page (or maybe in session variaable), and then call document.MSketch.setMol? What I'm trying to do is: retrieve a reaction in mrv from a database and start applet on jsp page. Thank you!

ChemAxon 5433b8e56b

28-10-2010 00:48:20

Hi,


can you show me a problematic jsp or html source where it is not working? As far as i know it should work, so it is maybe an applet configuration issue or an import issue in Marvin.


If this problem is specific for some molecules then a problematic molecule source example can also be useful.


If the requested information is confidential, then you can write it in an e-mail for me.


Thank you for your cooperation.


Regards,
Istvan

User 761d9eb85b

03-02-2012 08:22:06

Hello,


I have just met the same problem : when I use sketch_param("mol"...) to initailize sketch with a mrv string, it doesn't work.


Do you already have the solution ?


Thanks,


Ning


 

User 4b347806a7

03-02-2012 13:42:20

Yes, this actually works.  You first have to format the MRV for use in Javascript (convert line terminators to UNIX style,escape new line characters,escape single quotes).


This Java method works:


/**



    * Converts a string to a format that can be used as a


    * value of JavaScript variable in an HTML page.


    * Converts line separators to UNIX style and replaces


    * new line characters with a backslash and an "n"


    * character.


    * @param input original string containing line terminators


    * @return the modified string.


    */


   public static String convertForJavaScript(String input) {


       String value = input;


       //Converting Windows style string to UNIX style


       value = replaceString(value, "\r\n", "\n");


       //Converting Macintosh style string to UNIX style


       value = replaceString(value, "\r", "\n");


       //Converting special characters


       value = replaceString(value, "\\", "\\\\");


       value = replaceString(value, "\n", "\\n");


       value = replaceString(value, "\"", "\\\"");


       value = replaceString(value, "'", "\\'");


       return value;


   }


 


-John