MarvinSketch Example 3.4

Press the Import button to import the molfile into MarvinSketch. Change the molecule (delete some atoms or bonds, draw new ones), select a molecule format from the list, then try the Export buttons. You can import a SMARTS string from the text box by using the Import SMARTS button. To import or export a molecule in myformat, press the Import myformat or Export myformat button.

Export format:

Several Marvin supported file formats demonstrated here. "Myformat" is a user defined file format, see Java sources in the MolImportIface and MolExportModule API examples.

<script LANGUAGE="JavaScript">
<!--
//-->
</script>

<form NAME=MolForm onSubmit="return false">
<textarea NAME="MolTxt" ROWS=20 COLS=70>
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
   -2.0245   -2.6287    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -2.0245   -1.0107    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -1.7156   -0.0596    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.4367   -1.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.8415   -0.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -5.5735   -0.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.7075   -2.3196    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.8415   -3.8197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.9755   -2.3196    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.9755   -1.3197    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.8415    0.1803    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -5.5735   -2.8197    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -4.7075   -1.3197    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -3.8415   -2.8197    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
  5 13  1  0  0  0  0
 13  7  1  0  0  0  0
  7 14  1  0  0  0  0
 14  9  1  0  0  0  0
  9 10  2  0  0  0  0
  5 10  1  0  0  0  0
  4  2  1  0  0  0  0
  2 10  1  0  0  0  0
  9  1  1  0  0  0  0
  4  1  2  0  0  0  0
  2  3  1  0  0  0  0
  5 11  2  0  0  0  0
 13  6  1  0  0  0  0
  7 12  2  0  0  0  0
 14  8  1  0  0  0  0
M  END
</textarea>
<p>
<input TYPE=BUTTON VALUE="Import" onClick="importMol('null')">
<input TYPE=BUTTON VALUE="Import SMARTS" onClick="importMol('smarts:')">
<input TYPE=BUTTON VALUE="Import myformat" onClick="importMol('myformat:')">
</p>
<p>Export format:
<select NAME="molformat">
<option VALUE="cml">cml</option>
<option VALUE="csmol">csmol</option>
<option VALUE="csrdf">csrdf</option>
<option VALUE="csrxn">csrxn</option>
<option VALUE="cssdf">cssdf</option>
<option SELECTED VALUE="mol">mol</option>
<option VALUE="mrv">mrv</option>
<option VALUE="rdf">rdf</option>
<option VALUE="rxn">rxn</option>
<option VALUE="smarts">smarts</option>
<option VALUE="smiles">smiles</option>
<option VALUE="sdf">sdf</option>
<option VALUE="sybyl">sybyl</option>
</select>
<input TYPE=BUTTON VALUE="Export" onClick="exportMol(document.MolForm.molformat.value)">
<input TYPE=BUTTON VALUE="Export myformat" onClick="exportMol('myformat')">
</p>
</form>
<script LANGUAGE="JavaScript1.1" SRC="../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1">
<!--
function importMol(opts) {
	if(document.MSketch != null) {
		var s = document.MolForm.MolTxt.value;
		document.MSketch.setMol(s, opts);
	} else {
		alert("Cannot import molecule:\n"+
		      "no JavaScript to Java communication in your browser.\n");
	}
}
function exportMol(format) {
	if(document.MSketch != null) {
		var s = document.MSketch.getMol(format);
		s = unix2local(s); // Convert "\n" to local line separator
		document.MolForm.MolTxt.value = s;
	} else {
		alert("Cannot import molecule:\n"+
		      "no JavaScript to Java communication in your browser.\n");
	}
}
msketch_name = "MSketch";
msketch_begin("../..", 460, 380);
msketch_param("preload", "MolExport,Parity,SmilesExport,Clean2D,MyformatExport");
msketch_end();
//-->
</script>
The preload parameter is only needed if you call getMol() from JavaScript and want your page to work with some buggy browser/JVM combinations. Without it, Netscape 6 (Sun Java 1.3) might freeze at the moment the user presses an Export button. The error message in Netscape 3 would be: uncaught Java exception java/lang/InternalError ("Can't call network functions from JavaScript yet.").


It may happen that you want to save space on the web page and visualize your molecule in a small area. But the sketcher does not fit into that small area so you are in trouble. At least you think you are in trouble. You are wrong.