My initial idea to use a react-based solution fell short when I encountered lot of callback errors for incomplete smiles strings. Now we have just about everything we need on the chemistry side - a smiles parser, a coordinate generator, and a way to depict the compounds but we need some control code. (let [viewer (new ChemDoodle.ViewerCanvas id 500 500)Ĭhemmol (-> (new ChemDoodle.io.JSONInterpreter) "put your chemdoodle JSON into Chemdoodle" Chemdoodle needs the ID of an html canvas or it will create a new canvas where it is called. We make a molecule, chemmol and associate it with the viewercanvas while setting the bond width (we can add more options at a later point). Once we have chemdoodle-compatible json, we can use chemdoodle to parse the JSON and associate the newly created ChemDoodle molecule with a viewer canvas. "b" (map #(process_bond % Mol) bonds)}))) "take a kemia Bond and return json ready for chemdoodle" "take a kemia Atom and return json ready for chemdoodle" Note the clj->js function at the end which will convert the clojurescript data structures into pure JS. Kemia has already calculated x/y positions for each atom so we are simply feeding chemdoodle the atom positions and the bond information. Fortunately the chemdoodle and kemia documentation make it a straightforward problem. To do so I would need to convert kemia’s molecule information into the ChemDoodle-ready JSON. I wanted to use it instead of Kemia’s drawing methods. Mol2 ( mol)]ĬhemDoodle is a great opensource library for drawing molecules. You can see how this is done below - all in a single function, parsesmiles. Once kemia was packaged I needed to use it to generate coordinates from a smiles string which would require using the smiles parser and the coordinate generation. Google Closure library, the source is included using the :libs option - which allows kemia modules and namespaces to be used just as if they were cljs files. (right now they are pull requests - if you need them you can install them from my clsjsjs/packages branches) Because kemia uses the I decided to package both the kemia and chemdoodle webcomponents libraries for cljsjs. By providing a standardĬonvention for packaging, these libraries can be included in new clojure/clojurescript projects using a simple :require The cljsjs team is working to provide an easy way to use JS libraries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |