JavaGrins with SMARTS

Ragu Bharadwaj

Daylight CIS Inc.

JavaGrins is a Java-based chemical sketcher. With it  one can sketch molecules and reactions and obtain unique SMILES for the sketched entities. Stereochemical information and reaction atom mapping may also be specified.


JavaGrins with SMARTS: Background

SMILES Example:
CCCO matches
CCCN matches

SMARTS Example:
CCC[O,N] matches both 

For those new to SMILES & SMARTS, SMILES is a way to represent chemical information in a molecule in a compact string. 

SMARTS is a way to include chemical variabilities in a SMILES string, so as to enable queries. SMARTS is loosely similar to the regexp model that the UNIX operating system uses for queries.

Being boolean-based SMARTS is very expressive, since all queries are essentially combinations of boolean operations. This is also very useful at the OS level in fast searches, since regular expressions are fundamental to many OS'es and are therefore well researched. Hence corresponding advances are easily applied for fast chemical searching.
SMARTS Logicals
Boolean Symbol
, OR
; Low-Order AND


JavaGrins with SMARTS: SMARTS Limitations

SMARTS does not allow constructs for variable numbers of an atom or group
UNIX regular expressions vs. SMARTS
In UNIX regular expressions "xyxx*z" would match "xyxxx....z"

No way to make the analogous query in SMARTS to match all molecules with 

A nitro group Nitrogen has the 
SMARTS [$([NX3](=O)=O)].
While this is trivial, creating such
template SMARTS on the fly 
is not error-free. Inserting this 
SMARTS in a steroid can 
yield a SMARTS like:


Unfortunately, it is not practical to use SMARTS without a computer, since chemical queries can translate to very complex boolean operations and therefore very long SMARTS. Since we think in terms of chemical groups rather than their boolean definitions, this problem is further exacerbated without graphical tools. 

Despite these limitations SMARTS provides a powerful mechanism to construct complex queries. In the past we have received several requests to produce a more chemically intuitive interface for SMARTS


JavaGrins with SMARTS: A graphical interface

SMARTS-enabled JavaGrins addresses some of these problems via usage of a SMARTSTool, that can be used to create SMARTS at any atomic position using predefined templates and logicals to connect them. As shown here, SMARTSTool is basically a tree composer. Predefined template palettes appear on the left and may be dragged and dropped on to the right to compose a parse tree for an atomic SMARTS. At any stage the user may also directly edit the atomic SMARTS or the SMARTS associated with any node in the parse tree.


JavaGrins with SMARTS: Try it!




Select SMARTS from the Mode menu to enter SMARTS Mode. To transfer the SMARTS for a drawn structure to the invoking form select Grins->SMARTS from the File menu. 

To edit the SMARTS for an atom click the symbol  from the icons below the menu in SMARTS mode and then select the atom. The clock cursor appears for a while, while the SMARTSTool is being created for the first time. The Atom SMARTS may be textually edited either at the textfield on the atom or in the SMARTSTool. The SMARTS may alternately be graphically composed by dragging and dropping templates from the Template Palette onto the Atom Description tree, and altering the logicals connecting the templates. The logicals can be toggled between OR and AND by clicking on them.


JavaGrins with SMARTS: Say what you mean



The Templates in the Template palette may be changed to a different set by choosing the appropriate set from the Templates Menu in the SMARTSTool window. The selections in the menu and the templates and their descriptions are all stored on the server as TDTs and can easily be edited and altered by the applet administrator.

The SMARTS in any node in the depicted parse tree may be seen by clicking on the accompanying SMARTS symbol when that tree is selected. Clicking back on the symbol toggles back to the description. Either the description or the SMARTS may be edited by clicking on them in the Atom description tree. Editing the SMARTS will result in a reparsing of the entered SMARTS.


JavaGrins with SMARTS: Mean what you say





After composing the SMARTS parse tree, clicking the Apply button will transfer the newly composed SMARTS to the atom in the JavaGrins window. The JavaGrins window may contain a molecule or a reaction with SMARTS, thus yielding Molecule or Reaction SMILES.

The entire applet with SMARTS support is under 200K and runs on Netscape Communicator 4.04 or above.

Integrating JavaGrins into a web page is accomplished via LiveConnect, a very simple mechanism, usage of which requires no knowledge of Java. The procedure will be available in the documentation which comes along with the application.


JavaGrins with SMARTS: Templates

  Mapped SMARTS, bond SMARTS and chiralities are not dealt with optimally in the available demonstration beta. These issues will be addressed prior to release.

Using a combination of Java and JavaScript, the applet will be able to save and read from template files locally on the user's disk. This capability will be in addition to the templates available on the server. This will enable users to have their own template files while avoiding the administrative hassle of storing these individual files on the server.

A Find Templates menu will be implemented in the SMARTSTool. This will enable search capabilities on a database of templates (customizable to be either on the server or to point to the Daylight web site) The mechanism for the implementation will be via a cgi on the web server. The cgi will forward the request to one on the Daylight web site or can be altered to the requirements of the organization. The Daylight web site will contain a SMARTS database that is continually updated. The only requirement for this capability is that the search will have to be done with English words if forwarded to the Daylight web site.

JavaGrins with SMARTS: Works everywhere

  JavaGrins with SMARTS will be licensed differently for the corporate and small-business environments. Corporate users can opt for an unlimited corporate-wide license giving them unlimited access to the applet. Others can opt for a simultaneous user license where a predefined number of

clients can access the applet at any time. This scheme is implemented via a heartbeat associated with the applet on the client, which will be checked for every 5 minutes.

JavaGrins with SMARTS: Acknowlegements


For more specific enquiries such as availability and betas, please contact

I'm indebted to Dave for his constant encouragement through this work and to Norah MacCuish for pointers on the user-interface. I would also like to thank the designers of the NeXTStep operating system (now at Apple) for their wonderful User Interfaces which provided a lot of ideas.