We developed an interactive web application to visualize and compare three-dimensional molecular structures, applied here to the conformers of lysine and their enantiomers. Its purpose is to make it easier to analyze the spatial arrangement of the atoms and the mirror relationship between structures, and to produce figures for theses, reports and scientific publications.
The program is contained in a single HTML file that brings together the interface, the presentation rules (CSS) and the algorithms (JavaScript), along with the libraries it needs, so all processing happens in the browser and offline. It accepts geometries in XYZ format (one or several structures per file), batches in Molden format, Gaussian outputs (.out/.log), ZIP files and whole folders. Optionally, it reads a DATA.dat table with the relative Gibbs free energies, point groups and Boltzmann populations of each structure.
Reading and preparing the structures. The elements and Cartesian coordinates of each geometry are read. Connectivity is estimated from distances: two atoms are considered bonded when their separation is smaller than the sum of their covalent radii plus a tolerance of 0.4 Å. This connectivity is used to draw the bonds, recognize hydrogens bonded to heteroatoms and locate the α carbon. That carbon is assigned its absolute configuration with the Cahn–Ingold–Prelog rules (N > COOH > side chain > H), and from it its L (S) or D (R) configuration.
Each structure is centered at its center of mass and oriented along the eigenvectors of its mass-weighted second-moment matrix. The axis of greatest spread is placed horizontally, the second vertically and the smallest toward the viewer; the sign of each axis is fixed with the third moment so that the orientation is reproducible.
Structures are grouped by file name, pairing each geometry of the lys series with its ent_lys counterpart. When both have the same number of atoms in the same order, the ent_lys geometry is reflected, superimposed on the lys geometry with the optimal rotation from Horn’s quaternion method and, when drawn, flipped back horizontally. The resulting transformation is a proper rotation, so the image of ent_lys is a true view of its own geometry that appears as the mirror image of its partner. In the set studied, the root-mean-square deviation of the superposition was at most 0.001 Å, confirming that each ent_lys structure is the exact enantiomer of its lys partner.