XML To Be, VRML To See
by B.Arun and A.D.Ganguly
Introduction
XML is a strict subset of Standard Generalized Markup Language (SGML) which can be described as mother of the markup languages. The XML Specification [1] describes rules which enable user communities to define the tags they require. Since the XML specification's release in February 1998, there has been active development of numerous XML applications and tools. Mathematical Markup Language (MathML), Synchronized Multimedia Markup Language (SMIL), Web Interface Description Language (WIDL), to name just a few, are some of the XML applications that are most popular. XML is currently not as prevalent as HTML due to lack of adequate development in related technologies like Extensible Style Language (XSL) and Document Object Model (DOM). Once these technologies are ready for use, XML will become more common on the world wide web.
Virtual Reality Modelling Language (VRML) [3] is the ISO standard for representing 3D content on the Web. It is a text based file format for describing 3D objects and worlds. Along with 3D graphics, it also combines multimedia - audio and video. VRML already has extensive usage in medicine, engineering visualization, scientific visualization, entertainment and education. VRML worlds can be viewed within browsers using one of the many VRML plugins. A variety of standalone VRML viewers also exist.
A transition from two dimensional paper to a dynamic 3D world would most benefit the field of Chemistry. Chemical simulations output enormous amounts of data; making sense out of it is a herculean task. Being able to visualize a simulation, like following the trajectory of one molecule as it moves within other molecular structures can provide a better understanding of the various concepts at work and provide new insights.
We are trying to combine XML and VRML to allow visualization of chemical simulations over the web. The simulation data is marked up in a new XML application which is then converted to VRML for display on a Web browser using a plugin.
Related Work
Among the first community of users of XML were the Chemists. The Chemical Markup Language (CML) [4] that predates XML, is a powerful generic tool for management of molecular and technical information. Although it is possible to view 2D and 3D structures using a CML viewer, visualization is not a design goal of CML. Moreover, it does not provide support for chemical reactions or molecular dynamics in its present state of development. CML is still evolving and efforts are on to make its scope as wide as possible.
Programs like MolScript and Prolet [2] generate VRML from popular chemical data formats like MOL and PDB. Other tools like Rasmol can read in many file formats and display the structure in various forms like ball-stick and space-filling. It also provides the option of saving the structure as an image file like GIF. All the packages mentioned above deal only with static structures. X-Mol is a package that allows dynamics to be viewed. Using this software, users can view dynamic simulations given the coordinates of various atoms/molecules over the simulation period. X-Mol also allows the simulations to be saved as a movie.
XML-VRML combination has been used previously for some stock-exchange data visualization and web-site maps. In the latter case, the web page is described using a set of tags and this data is then converted into a VRML world that allows users to navigate the page in the 3D space.
Molecular Dynamics Language (MoDL)
MoDL (pronounced as Model) allows very simple constructs like atom, molecule, radical, bond, etc. Using these building blocks, chemists can build very complex macromolecules easily. There is a DEFINE construct which allows users to define particular types of atoms, molecules, bonds or radicals and then use them later to instantiate objects of that type. For example, oxygen and hydrogen atoms can be defined like this:
<DEFINE type='atom' name='O' radius='0.3' color='0 0 1' /> <DEFINE type='atom' name='H' radius='0.2' color='1 0 0' />
Here oxygen atoms are blue and have radius 0.3, hydrogen atoms are red and have radius 0.2. Using this we can now define a water molecule:
<DEFINE type='molecule' name='Water' > <atom type='O' id='o1' position='0 0 0' /> <atom type='H' id='h1' position='-2 1 0.5' /> <atom type='H' id='h2' position='2 1 0.5' /> <bond from='h1' to='o1' /> <bond from='h2' to='o1' /> </DEFINE>
Note that specifying bonds between atoms is very simple; just specifying the id's of the two atoms to bond is sufficient.
Until now, everything has been static. To introduce dynamism to the visualization, we need to specify things like period of the clock and whether the clock should loop or stop after one period. For this purpose the MoDL document is divided into a head and a body. The clock period and looping are specified in the head. Meta elements and DEFINE constructs also appear in the head. The body holds the elements for visualization. To place two water molecules in 3D space we write the following in the body:
<molecule type='Water' id='w1' position='0 0 0' />
<molecule type='Water' id='w2' position='4 0 2' />
Now to move the water molecule named w2, we put w2 in a TRANSLATE element, like this:
<TRANSLATE object='w2' t='0.2' position='3 0 1' />
This means that when the clock is at 0.2 of the period, the molecule w2 will be at (3,0,1). For the intermediate time instants, the w2's position is calculated by using interpolation. Using TRANSLATE again, w2's position can be specified at several time instants. The TRANSLATE object is generic, i.e. it can move not only molecules, but atoms, radicals and bonds as well.
Typically, bonds form between atoms when the distance between them is less than some particular value. We have used this concept so that authors don't have to explicitly write every bond they want in the molecular structure. The maximum inter-atomic distance between pairs of atoms can be recorded in the head of the document in a bond-table, and bonds will be put automatically between atoms where the distance is less than the specified value. In addition to this, authors can still explicitly put bonds between atoms where they want to.
Chemists typically want to see plots and graphs of various variables when the simulation is running. To facilitate this, MoDL has support for 2D and 3D plots. Three types of plot styles are supported - points, histogram and line plots. For every point on the curve, one can provide the time (as a fraction of the period) when it will be shown. In this way we can have animation in the plots as well.
Another useful thing is to be able to view the simulation from any point in the 3D space. Users viewing the simulation can navigate around in the 3D scene using the navigation controls present in VRML browsers. In addition, users can specify any of the atoms or molecules to be viewpoints in the MoDL file, jump to its position and view the simulation. Users can also sit on one of dynamic atoms and go for a ride, seeing the simulation as that particular atom would see it.
Given below is an example of a methane molecule in MoDL and a screen shot of it in VRML.
<mml>
<head>
<meta name='title' content='Example'/>
<DEFINE type='atom' name='C' color='1 1 0' radius='0.3'/>
<DEFINE type='atom' name='H' color='1 0 0' radius='0.2'/>
<DEFINE type='molecule' name='Methane' >
<atom type='C' id='c1' position='0 0 0'/>
<atom type='H' id='h1' position='1 0.7 0.3'/>
<atom type='H' id='h2' position='-1 0.7 0.3'/>
<atom type='H' id='h3' position='-1 -0.7 0.3'/>
<atom type='H' id='h4' position='1 -0.7 0.3'/>
<bond from='c1' to='h1'/>
<bond from='c1' to='h2'/>
<bond from='c1' to='h3'/>
<bond from='c1' to='h4'/>
</DEFINE>
</head>
<body>
<molecule type='Methane' position='0 0 0' viewpoint='true'/>
</body>
</mml>

Figure 1: A Methane Molecule in VRML
More examples are available at our homepage (http://violet.csa.iisc.ernet.in/~modl).
The Conversion To VRML From XML
The conversion from XML to VRML is done by a Perl script that uses the XML::Parser module. XML::Parser is the Perl interface to expat, a C library written by James Clark. Expat is an event-based non-validating XML parser. Ideally, this conversion should be done using style sheets. But the current state of XSL technology does not provide appropriate tools for this purpose.
The Interface To The User
A dashboard is added to the lower part of the browser window. It contains Start, Stop and Step buttons to control the clock running the simulation. The Reset can be used to restart the simulation from the beginning. The Flip button allows the user to go back and forth in the simulation. There is a Viewer button, which allows the user to select the atoms or molecules which have been specified as potential viewpoints and sit on them. On clicking the Original button, the user moves back to the original position from where they started viewing the scene. The Zoom button allows the user to focus on a particular dynamic atom or molecule and its neighbourhood, making the rest of the scene invisible. In case there are no dynamics, it is possible to view the static structure in 3 different models viz. Ball and Stick, Space-filling and Capped using the Model button.
Conclusions
The combination of XML and VRML can prove to be a very effective way of conveying chemical information over the Internet. Visualization of chemical simulations will get a boost once streaming is introduced in VRML. This will allow us to visualize a simulation when it is actually running in real-time. Other disciplines like Architecture and Planning can also benefit from the use of these technologies.
References
- 1
- Bray Tim et. al. XML 1.0 Specification http://www.w3.org/TR/REC-XML/19980210.html
- 2
- Ihlenfeldt Wolf-D. and Engel Klaus. Visualizing Chemical Data in the Internet -- Data Driven and Interactive Graphics. Computers and Graphics, 1998, Vol. 22, No. 6, pp. 703-714.
- 3
- International Standard ISO/IEC 14772-1:1997 Virtual Reality Modelling Language, http://www.vrml.org/Specifications/VRML97/index.html
- 4
- Peter Murray-Rust, Henry S. Rzepa, and Christopher Leach. Chemical Markup Language (CML), http://www.ch.ic.ac.uk/cml/
- 5
- Jon Bosak and Tim Bray. XML and the Second-Generation Web, Scientific American, May 1999, pp. 79-83.
Biography
Arun and Ashes are Graduate students working on XML and VRML in the Perceptual Computing Laboratory in the Department of Computer Science and Automation at the Indian Institute of Science. Common favourites include Ice-Creams, P.G. Wodehouse and Beatles. While Arun dreams of having a huge library all for himself, Ashes would like to have a huge Alsatian dog and own a nice big car.