Installation package contains all sources required for work.
Extract files and place where you need remaining internal structure of a ketcher directory.
To run Ketcher in a separate window you can just add 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>
To access Ketcher from JavaScript you should obtain 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.
This method updates current structure in the editor. You can pass to it either SMILES string or Molfile, for example:
ketcher.setMolecule('c1ccccc1');
Note: SMILES loading doesn't work in the standalone mode.
Get a SMILES string of the current structure. Return value is a string.
Get Molfile of the current structure. Return value is a string.
Current version of Ketcher has a sample implementation of the server side. It's a simple Python script ketcher-server.py which 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 | GET | smiles |
Server requires the Python wrappers of Indigo used to perform automatic layout.
Another version of the Python server, intended to run under WSGI, is provided under the name of ketcher-server-wsgi.py.