problem in marvin view..

User 7c5d5fc97e

23-02-2010 18:37:25

I'm developing marvin view. but I faced with a strange error .


this is original code ( view.html )


mview_param("cell1", "|Ethane\n"
+"  Marvin  07119915552D\n"
+"\n"
+"  2  1  0  0  0  0  0  0  0  0999 V2000\n"
+"   -0.5625    1.2500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"
+"   -0.5625    0.2500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"
+"  1  2  1  0  0  0  0\n"
+"M  END");


this code is well operated in html 


but in python this code is a error(?)


when inserting this code, I find a error..


what is the problem..?


[ python code ]



#!/usr/bin/epd
import cgitb; cgitb.enable()
print "Content-Type: text/html\n\n"
print "<body>"


out = '''
<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1">
<!--
mview_begin("../../..", 300, 300);
mview_param("rows", "4");
mview_param("cols", "1");
mview_param("cell0", "|../../../mols-2d/caffeine.csmol");
mview_param("cell2", "|Ethane\n  Marvin  07119915552D\n\n  2  1  0  0  0  0  0  0  0  0999 V2000\n   -0.5625    1.2500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  -0.5625    0.2500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\nM  END");
mview_end()
//-->
</script>
'''
print out
print "</body>"


 


 

ChemAxon 5433b8e56b

25-02-2010 16:06:21

Hi,


I have tried to run the python script, and found the following:


the out variable is written to the generated html code with new line characters, not with \n. So the given inline molfile parameter will be invalid in javascript. You have to ensure that the inline molfile is printed with \n not with newline characters.


The example will work if you change \n cahracters in "out" variable to \\n.


Regards,
Istvan

ChemAxon 7c2d26e5cf

25-02-2010 16:41:53

The following code sniplet demonstrates how you can encode molecule string as applet parameter if you embed applet definition into JavaScript (there is no linebreak by the "mol" parameter):


<script language="JavaScript" src="http://www.chemaxon.com/marvin/marvin.js"></script>
<script language="JavaScript">
<!--
msketch_begin("http://www.chemaxon.com/marvin", 500, 480);
msketch_param("mol", "\n Marvin 02091014372D \n\n 5 5 0 0 0 0 999 V2000\n -1.2375 -0.6895 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n -1.9519 -0.2770 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.9519 0.5480 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.5230 0.5480 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.5230 -0.2770 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1 2 1 0 0 0 0\n 1 5 1 0 0 0 0\n 2 3 2 0 0 0 0\n 3 4 1 0 0 0 0\n 4 5 2 0 0 0 0\nM END");
msketch_end();
//-->
</script>