Editor Mode
Installation
The installation package contains all of the sources required for work.
-
To run Ketcher in a separate window you can just add the the link to
ketcher/ketcher.html:<a href="ketcher/ketcher.html">Ketcher</a> -
To embed Ketcher in your page you should use IFrame:
<iframe id="ifKetcher" src="ketcher/ketcher.html" width="800" height="600"></iframe>
Ketcher Object
To access Ketcher from JavaScript you should obtain the ketcher object:
var ketcher = ketcherWindow.ketcher;
where ketcherWindow is a separate Ketcher window or
var ketcherFrame = document.getElementById('ifKetcher');
var ketcher = null;
if ('contentDocument' in ketcherFrame)
ketcher = ketcherFrame.contentWindow.ketcher;
else // IE7
ketcher = document.frames['ifKetcher'].window.ketcher;
where ifKetcher is an Ketcher IFrame.
ketcher.setMolecule()
This method updates the current structure in the editor. You can pass to it either a SMILES string or Molfile/Rxnfile, for example:
ketcher.setMolecule('c1ccccc1');
Note: SMILES loading does not work in the standalone mode.
ketcher.getSmiles()
Get a SMILES string of the current structure. The return value is a string.
ketcher.getMolfile()
Get a Molfile/Rxnfile of the current structure. The return value is a string.
Ketcher Server
The current version of Ketcher has a sample implementation of the server side. A simple Python script ketcher-server.py listens to the port 8080 and has four interfaces:
| Query | Action | Type | Parameters |
|---|---|---|---|
/knocknock |
Server availability check | GET | - |
/open |
Query for loading files from disk | POST | filedata |
/save |
Query for saving files to disk | POST | filedata |
/layout |
Query for converting SMILES to Molfile | POST | moldata |
/automap |
Query for reaction auto-mapping | POST | moldata, mode |
The server requires the Python wrappers of Indigo to be used to perform the automatic layout.
Another version of the Python server, intended to run under WSGI, is provided under the name of ketcher-server-wsgi.py.