- Open Access
Chemozart: a web-based 3D molecular structure editor and visualizer platform
Journal of Cheminformatics volume 7, Article number: 56 (2015)
In the field of computational chemistry, applications which are capable of constructing and viewing 3D structures of molecules play an important role. Such software can be used to by students to understand stereochemical concepts . There are numerous desktop applications available for viewing and building 3D molecules. Avogadro , JMol , QuteMol  and PyMol are few such examples. When it comes to web applications capable of constructing 3D chemical structures, there are not many available.
Today web-based tools are becoming extremely popular. There are numerous benefits which can be derived from them; accessibility, flexible core technologies, platform independency and compatibility are some of them. Most of the web applications which are used for building chemical structures have limited capabilities and most of them are two-dimensional editors such as ChemDoodle . There are several chemical structure editors available powered by Java applets such as JME a free 2D molecule editor java applet ; however, they are not compatible with all the browsers. Besides, JAVA needs to be separately installed on the system in order to run these applications. This issue exists for other embedded objects like Flash and Flame , a Flash molecular editor is a case in point. There is another web application available to build 3D chemical structures, it is called CH5M3D . It portrays a 3D picture with HTML5 however, it fails to deliver optimum results as it uses canvas 2D context. Because of its limitation, it does not use any shader program. As a result of which three-dimensional rendering cannot be portrayed in the truest sense. Today, it is possible to draw sophisticated graphics that are hardware accelerated by GPU; thanks to HTML5 and WebGL. Furthermore, these components are supported by all modern web browsers, especially mobile browsers.
A chemical toolbox is also needed in order to read different chemical file formats, calculate energy, etc. OpenBabel is considered to be one of the best chemical toolkit which is open-source and it can be easily ported to different languages. There are bindings of OpenBabel in some languages such as Rubabel  for Ruby and Pybel  for Python. We also made OpenBabel-Node http://mohebifar.github.io/OpenBabel-Node/ to port OpenBabel  to node.js. It exposes OpenBabel application programming interfaces (APIs) to many available packages in node.js via a convenient interface. We bundled it with express.js web framework to create a chemical representational state transfer style (REST)ful API. OpenBabel-Node is used to read and write a variety of chemical file formats. Apart from this, it also supports various molecular mechanics force fields and provides optimization of geometry of the molecules.
Software architecture and interactivity
One of the most important aims of Chemozart is to provide a good user experience. So it facilitates building molecules with the help of mouse and keyboard actions or by touch screens devices. Changing the position of atoms is also as simple as dragging them around. All the hidden elements such as periodic table appear with an animation effect that provides a better user experience.
While this application focuses on educational purposes, more educational functionalities are planned to be included in future versions. The most important feature is to attach a database to the server-side application to make it possible to share a molecule via a link so that students can share their mind and questions with their teachers. It also facilitates the process of teaching for teachers given that this application works on mobile devices. In addition, more OpenBabel features will be used such as force field clean-up. More complete support for chemical file formats is also planned to be included in future versions (Fig. 1).
One of the unique features of this application is the fact that it does not require any installation process and can be accessed online. However, it can be installed locally too. The application requires an existing installation of node.js, npm, bower and grunt. The code is developed and maintained on a Git repository https://github.com/mohebifar/chemozart available on Github. After cloning this repository in any convenient location, dependencies are required to be installed. Note that the client-side dependencies are managed by bower and the server-side dependencies are managed by npm. It is required to run “npm install” and “bower install” commands in a terminal window to install both frontend and backend dependencies. By running “grunt serve” the application will be started and it starts listening on port 9000 by default while a web browser will show up automatically. It is also possible to change the port by changing the OS environment variable “PORT”.
This application requires a web server since it has some functions that use OpenBabel-node. However, it can also be accessed without web server installation but some functionalities that require OpenBabel will not be available such as energy calculation, adding Hydrogens and 3D build, export and import different chemical languages. The different versions of this application are distributed as compressed zip archives and are accessible in the releases menu on the Github page.
The client-side consists of the user interface along with a variety of logical modules. It helps to view or edit the structures interactively. The user interface is composed in CSS and HTML, a dynamic stylesheet language called LESS is used in this software. These stylesheets are compiled into CSS which makes it easier to write and maintain stylesheets in big projects. For the views, JADE platform is used that offers inheritance and re-usable functions. Based on MVVM architectural pattern, the molecular models are two-way bound as ViewModel between the controllers and view. It exposes the data objects in such a way that user can view the model structure without being bothered about the back end logic of the model. Working under a framework of Angular.js which is based on MV* architecture, the application firstly reads the view and interprets it as directives and binds the data to a model. The models here are a representation of a molecule drawn or structured by the user working. Further, the models discussed above are originally the atoms and bonds.
The 3D molecule editor and visualizer works on three modes which are as follows:
In this mode user can rotate any molecular structure just by holding the left button of the mouse and moving it. Its function Pan can also be used just by holding the right button of the mouse and moving it according to requirements. The zoom function of this mode can be accessed when user scroll by holding the middle button of the mouse. This mode works with touch screen devices as well.
Editing any molecular structure is quite easy because of the array of options available in this mode. To add atom to any structure user have to click on the empty space while to delete any atom while to delete any atom just right click on the atom itself. By dragging from one atom to another user can add bond. Clicking on a bond adjusts their order. Removing a bond is also possible by right clicking on it.
This mode offers proper positioning of the molecular structure is. In this mode, dragging the atoms on the screen changes the position of them.
The menu option of this chemical structure viewing software comprises of three main options which are known as File, Build and Energy.
The file option of this web application comprises of an array of options which includes New, Open, Save, Delete, Import, Export and Print. User can save or delete a structure easily or even import one from the desktop with the help of these options available in File menu. It supports wide range of file formats to read and write. All the drawn structures are also saved in browser’s local storage.
The Build menu comprises of two options which are known as Build 3D and Add Hydrogens. The Build 3D option helps user to generate 3D coordinates for the drawn molecule. Adding Hydrogen functionality to the existing structure is also provided in order to fill out implicit valence spots. The Builder and Hydrogen Adder options use OpenBabel-Node via a RESTful API.
Different molecular mechanics force-field methods like MMFF94, UFF and Ghemical are available to evaluate the energy. By creating the structure and using any of these options the energy shows up on a dialog. Further, this is a common feature of the OpenBabel-Node too.
Result and discussion
Technologies and components
Creating web pages
This application can be accessed in two different environments; development and production. To create a web page development files should be used which make it easier to develop and extend the application. After changing the code files, by running “grunt build” production files will be created in a folder named “dist”. It basically concatenates and compresses the scripts and stylesheets to prevent networks delay caused by transferring all unnecessary characters in the code such as white spaces. To create a chemical editor web page using Chemozart, it is required to determine the angular.js that this web page belongs to a Chemozart application. This can be accomplished by adding the following line to the <body> statement:
<body ng-app = “chemartApp”>
The main element to create a Chemozart web page is the div element with ui-view attribute. It will automatically include the tool bar, status bar, menu and the drawing window to show and edit the molecule. It is accomplished by using angular.js templates.
<div ui-view = “”> </div>
At the end of the body tag, it is required to include all the dependencies in the right order that vary from vendor libraries to each Chemozart modules.
Each template can be customized as well as the stylesheets. Templates in JADE and their corresponding stylesheets in LESS are located inside the app or components folder inside the client folder based on their role. Components such as menu bar, tool bar, status bar, periodic table, help window and about window are located in the components folder and the main template that puts these components together is located in the app folder (Fig. 3).
This application is built with Angular.js on client-side. All the components and libraries are a directive, a service or a controller. For example, to create a button in the menu bar that adds a carbon on the drawing window the following steps could be used. In the first step, a service must be created.
This service returns a function that creates an instance of “Chem.Atom” that is a class of mol.js module. Then the atomic number should be determined by assigning the value to the “atomicNumber” property. To “position” property determines the atom’s position that should be an instance of “Three Vector”. A singleton of the canvas object can be accessed via a service named “canvas”. To add the created to the drawing window, the atom should be passed to the “addAtom” method on the canvas object. This service should be injected to the main controller (client/app/main/main.controller.js) by adding “addCarbon” to the list of arguments of the main controller function. After injecting the service, it should be assigned to the controller’s scope so it can be accessed in the view.
Finally, a button in the view is needed. To add this button in the menu bar view the JADE file of the menu bar (client/components/menubar/menubar.jade) should be altered as following:
It can be concluded that Chemozart is a chemical web-based application and component which provides the ability to create 3D structure of molecules. The most important feature is that there’s no need to install anything and it can be accessed easily via a URL. Also, it can be beneficial for the educational purposes as well. To catch up with the technology, Chemozart has been designed in a way that it is compatible with the mobile devices. The most up-to-date version of this application is available on the project home page. For the purpose of smooth functioning it is advisable to access Chemozart using the latest versions of browsers across different operating systems (Fig. 4)
Availability and requirements
Project name: Chemozart
Project home page: https://chemozart.com
Operating system(s): Platform independent
Other requirements: An up-to-date web browser
License: Apache2 License
Any restrictions to use by non-academics: None.
Abraham M, Varghese V, Tang Hui (2010) Using molecular representations to aid student understanding of stereochemical concepts. J Chem Educ 87(12):1425–1429
Hanwell MD, Curtis DE, Lonie DC, Vandermeersch T, Zurek E, Hutchison GR (2012) Avogadro: an advanced semantic chemical editor, visualization, and analysis platform. J Cheminformatics 4:17
Jmol: an open-source java viewer for chemical structures in. http://jmol.sourceforge.net/. Accessed 1 Nov 2015
Tarini M, Cignoni P, Montani C (2006) Ambient occlusion and edge cueing for enhancing real time molecular visualization. IEEE Trans Visualization Comput Graph 12(5):1237–1244
Burger MC (2015) ChemDoodle web components: HTML5 toolkit for chemical graphics, interfaces, and informatics. J Cheminform 7:35. doi:10.1186/s13321-015-0085-3
Ertl P (2010) Molecular structure input on the web. J Chem 2:1
Dallakian P, Haider N (2011) Flame: flash molecular editor—a 2D structure input tool for the web. J Chem 3:6
Earley CW (2013) CH5M3D: an HTML5 program for creating 3D molecular structures. J Chem 5:46
Libman D, Huang L (2013) Chemistry on the go: review of chemistry apps on smartphones. J Chem Educ 90(3):320–325
Smith R et al (2013) Rubabel: wrapping openbabel with ruby. J Chem 5:35
O’Boyle NM, Morley C, Hutchison GR (2008) Pybel: a python wrapper for the OpenBabel cheminformatics toolkit. Chem Cent J 2:5
O’Boyle NM et al (2011) OpenBabel: an open chemical toolbox. J Chem 3:33
Weininger D (1988) SMILES, a chemical language and information system. 1. Introduction to methodology and encoding rules. J Chem Inf Comput Sci 28(1):31–36
Murray-Rust P, Rzepa HS (2003) Chemical markup, XML, and the World Wide Web. 4. CML schema. J Chem Inf Comput Sci 43(3):757–772
Arthur Dalby et al (1992) Description of several chemical structure file formats used by computer programs developed at molecular design limited. J Chem Inf Comput Sci 32(3):244–255
Homer RW et al (2008) SYBYL line notation (SLN): a single notation to represent chemical structures, queries, reactions, and virtual libraries. J Chem Inf Model 48(12):2294–2307
Berman HM (2007) The protein data bank: a historical perspective. Acta Crystallogr A 64(1):88–95
MM developed the applications and drafted the manuscript. FS participated in the design of study, helped to write Chem.js and Mol3D and helped to draft the manuscript. Both authors read and approved the final manuscript.
The authors are grateful to Shant Shahbazian for reading a previous draft of this paper and some helpful suggestions.
The authors declare that they have no competing interests.
About this article
Cite this article
Mohebifar, M., Sajadi, F. Chemozart: a web-based 3D molecular structure editor and visualizer platform. J Cheminform 7, 56 (2015). https://doi.org/10.1186/s13321-015-0101-7