MarvinSketch Example - Working with inline, compressed molfiles

To speed up the downloading, you can specify the molfile inline instead of as a URL. This requires the browser to perform fewer http GET requests.

<script type="text/javascript" SRC="../../../marvin.js"></script>
<script type="text/javascript">
<!--
msketch_begin("../../..", 540, 480);
msketch_param("mol", "3,7-Dihydro-1,3,7-trimethyl-1H-purine-2,6-dione\n"+
"  Marvin  07099920012D\n"+
"\n"+
" 14 15  0  0  0  0  0  0  0  0999 V2000\n"+
"   -2.0245   -2.6287    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -2.0245   -1.0107    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -1.7156   -0.0596    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -1.4367   -1.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -3.8415   -0.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -5.5735   -0.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -4.7075   -2.3196    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -3.8415   -3.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -2.9755   -2.3196    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -2.9755   -1.3197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -3.8415    0.1803    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -5.5735   -2.8197    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -4.7075   -1.3197    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"   -3.8415   -2.8197    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n"+
"  5 13  1  0  0  0  0\n"+
" 13  7  1  0  0  0  0\n"+
"  7 14  1  0  0  0  0\n"+
" 14  9  1  0  0  0  0\n"+
"  9 10  2  0  0  0  0\n"+
"  5 10  1  0  0  0  0\n"+
"  4  2  1  0  0  0  0\n"+
"  2 10  1  0  0  0  0\n"+
"  9  1  1  0  0  0  0\n"+
"  4  1  2  0  0  0  0\n"+
"  2  3  1  0  0  0  0\n"+
"  5 11  2  0  0  0  0\n"+
" 13  6  1  0  0  0  0\n"+
"  7 12  2  0  0  0  0\n"+
" 14  8  1  0  0  0  0\n"+
"M  END");
msketch_param("scale", "60");
msketch_param("viewonly", "true");
msketch_end();
//-->
</script>

You can further decrease the download time by compressing the molfile:

msketch_param("mol", "3,7-Dihydro-1,3,7-trimethyl-1H-purine-2,6-dione\n"+
"  Marvin  07099920012D\n\n 14 15  0  0  0  0  0  0  0  0999 V2000\n"+
"h3xVHbvV70\nh3xV5YzV70\nypxVis-V60\nXVyVhZxV60\nndsVx-zV60\n9PoVx-zV60\n"+
"TWqVaLwV60\nndsVBhsV60\n5luVaLwV60\n5luVpnyV60\nndsVBS0W80\n9PoVR7vV80\n"+
"TWqVpnyV70\nndsVR7vV70\n50D01\nD0701\n70E01\nE0901\n90A02\n50A01\n40201\n"+
"20A01\n90101\n40102\n20301\n50B02\nD0601\n70C02\nE0801\nM  END\n");
You can create this type of JavaScript string from an existing molecule using the "Edit Source " window of MarvinSketch or MarvinView (Edit -> Source). Choose Format -> Compressed mol, then Format -> Convert to Java String.

If you decide not to use the utility functions in marvin.js, then the corresponding MarvinSketch applet tag is the following:

<applet CODEBASE="../../.." ARCHIVE="jmarvin.jar" CODE="JMSketch.class"
        WIDTH=540 HEIGHT=480>
<param NAME="mol" VALUE="3,7-Dihydro-1,3,7-trimethyl-1H-purine-2,6-dione\
  Marvin  07099920012D\
\
 14 15  0  0  0  0  0  0  0  0999 V2000\
h3xVHbvV70\
h3xV5YzV70\
ypxVis-V60\
XVyVhZxV60\
ndsVx-zV60\
9PoVx-zV60\
TWqVaLwV60\
ndsVBhsV60\
5luVaLwV60\
5luVpnyV60\
ndsVBS0W80\
9PoVR7vV80\
TWqVpnyV70\
ndsVR7vV70\
50D01\
D0701\
70E01\
E0901\
90A02\
50A01\
40201\
20A01\
90101\
40102\
20301\
50B02\
D0601\
70C02\
E0801\
M  END">
<param NAME="scale" VALUE="60">
<param NAME="viewonly" VALUE="true">
<strong>(YOU CANNOT SEE A JAVA APPLET HERE)</strong>
</applet>
Don't forget to end each line with a backslash. The reason for ending the lines with this special character is that web browsers filter out the real linebreaks from such multiline strings.

 

In the previous examples the applet loaded the molecule at startup. However, in some cases it is necessary to load a molecule at runtime.