Posts Tagged ‘Software engineering’

Ten years on: Jmol and WordPress.

Wednesday, May 16th, 2018

Ten years are a long time when it comes to (recent) technologies. The first post on this blog was on the topic of how to present chemistry with three intact dimensions. I had in mind molecular models, molecular isosurfaces and molecular vibrations (arguably a further dimension). Here I reflect on how ten years of progress in technology has required changes and the challenge of how any necessary changes might be kept “under the hood” of this blog.

That first post described how the Java-based applet Jmol could be used to present 3D models and animations. Gradually over this decade, use of the Java technology has become more challenging, largely in an effort to make Web-page security higher. Java was implemented into web browsers via something called Netscape Plugin Application Programming Interface  or NPAPI, dating from around 1995. NPAPI has now been withdrawn from pretty much all modern browsers. Modern replacements are based on JavaScript, and the standard tool for presenting molecular models, Jmol has been totally refactored into JSmol. Now the challenge becomes how to replace Jmol by JSmol, whilst retaining the original Jmol Java-based syntax (as described in the original post). Modern JSmol uses its own improved syntax, but fortunately one can use a syntax converter script Jmol2.js which interprets the old syntax for you. Well, almost all syntax, but not in fact the variation I had used throughout this blog, which took the form:

<img onclick=”jmolApplet([450,450],’load a-data-file;spin 3;’);” src=”static-image-file” width=”450″ /> Click for 3D structure

This design was originally intended to allow browsers which did not have the Java plugin installed to default to a static image, but that clicking on the image would allow browsers that did support Java to replace (in a new window) the static image with a 3D model generated from the contents of a-data-file. The Jmol2.js converter script had not been coded to detect such invocations. Fortunately Angel came to my rescue and wrote a 39 line Javascript file that does just that (my Javascript coding skills do not extend that far!). Thanks Angel!!

In fact I did have to make one unavoidable change, to;

<img onclick=”jmolApplet([450,450],’load a-data-file;spin 3;’,’c1′);” src=”image-file” width=”450″ /> Click for 3D structure

to correct an error present in the original. It manifests when one has more than one such model present in the same document, and this necessitates that each instance has a unique name/identifier (e.g. c1). So now, in the WordPress header for the theme used here (in fact the default theme), the following script requests are added to the top of each page, the third of which is the new script.

<script type=”text/javascript” src=”JSmol.min.js”></script>
<script type=”text/javascript” src=”js/Jmol2.js”></script>
<script type=”text/javascript” src=”JmolAppletNew.js”></script>

The result is e.g.

Click for 3D

Click for 3D structure of GAVFIS

Click for 3D

Click for 3D interaction

This solution unfortunately is also likely to be unstable over the longer term. As standards (and security) evolve, so invocations such as onclick= have become considered “bad practice” (and may even become unsupported). Even more complex procedures will have to be devised to keep up with the changes in web browser behaviour and so I may have to again rescue the 3D models in this blog at some stage! Once upon a time, the expected usable lifetime of e.g. a Scientific Journal (print!) was a very long period (>300 years). Since ~1998 when most journals went online, that lifetime has considerably shortened (or at least requires periodic, very expensive, maintenance). For more ambitious types of content such as the 3D models discussed here, it might be judged to be <10 years, perhaps much less before the maintenance becomes again necessary. Sigh!


At the time of writing, WaterFox is one of the few browsers to still support it. An early issue with using Javascript instead of Java was performance. For some tasks, the former was often 10-50 times slower. Improvements in both hardware and software have now largely eliminated this issue. Thus using Jquery.

Ritonavir: a look at a famous example of conformational polymorphism.

Monday, January 2nd, 2017

Here is an inside peek at another one of Derek Lowe’s 250 milestones in chemistry, the polymorphism of Ritonavir.[1] The story in a nutshell concerns one of a pharma company’s worst nightmares; a drug which has been successfully brought to market unexpectedly “changes” after a few years on market to a less effective form (or to use the drug term, formulation). This can happen via a phenomenon known as polymorphism, where the crystalline structure of a molecule can have more than one form. In this case, form I was formulated into soluble tablets for oral intake. During later manufacturing, a new less-soluble form appeared and “within weeks this new polymorph began to appear throughout both the bulk drug and formulation areas[1]

The structure of the original form I is shown below (3D DOI: 10.5517/CCRVC75). The compound has three HN-CO peptide linkages, all of which are in the stereoelectronically favoured s-cis form, with a dihedral angle of 180° across the H-N and C=O vectors.

Click for 3D

To show how favourable this s-cis form is, here is a search of the Cambridge structural database for acyclic HN-C=O bonds; of the ~8200 examples, only 5 have an s-trans torsion of ~180°. It is I feel statistically not entirely correct to convert this ratio of K=1640 to a free energy, but if one does, then at 298K, RTlnK works out to 4.4 kcal/mol. Note also that two compounds show an angle of ~90° (artefacts?).

The new type-II form that emerged has only two s-cis peptide linkages, and the third has isomerised to this higher energy s-trans form (3D DOI: 10.5517/CCRVC97)

Click for 3D

This has various knock-on effects on the conformation of the actual molecule itself.

  1. The cis-trans isomerisation of a peptide or amide bond is a relatively high energy process, since the C=N bond order is higher than 1. For example, in the 1H NMR spectrum of N,N-dimethyl formamide at room temperature, one can famously observe two methyl resonances and it is only at higher temperatures that the two signals coalesce due to more rapid rotation about the C=N bond.
  2. A pedant might query whether this isomerism is correctly termed a conformational or a configurational change? High-energy rotations that result in cis/trans isomerisms are normally referred to as a configurational changes, whereas low energy rotations about e.g. single bonds are known as conformational changes (thus the conformational changes in cyclohexane). There is a grey region such as this one, where the boundary between the two terms is encountered. 
  3. This isomerism has the knock-on effect of inducing a much lower energy rotation of a C-C single bond (on the left hand side of the representations above), rotating from a dihedral angle of +193 in form I to +51 in form II.
  4. More minor affects are seen in the conformation of the central benzyl group and the S/N heterocyclic ring on the right hand side.
  5. All these low energy conformational effects occur because a better hydrogen bonding network can then be set up in the crystal lattice, something not easily predictable  from the diagrams of the single molecules shown above.
  6. Overall, the free energy of the lattice is lower, despite the higher energy of the s-trans peptide bond. 
  7. Clearly, the dynamics of crystallisation initially favoured form I (despite the higher energy of the crystallised outcome), but if a tiny seed of form II is present (or perhaps other impurities) this can dramatically (but unpredictably) change these crystallisation dynamics.

I suspect that since 1998 when this story unfolded, all new drugs in which one or more s-cis peptide bonds are present have caused anxiety. In the system above for example, one might ask whether cis/trans isomerisation of instead either of the other two peptide bonds present might have similar results? Or hypothesize whether inhibiting the associated rotation of the C-C single bond noted above by appropriate “tethering” might prevent form I from converting to form II. Since 1998, I am sure trying to predict the solid form of an organic molecule from its isolated structure using computational methods has dramatically increased, although I have not found in SciFinder any reported instances of such modelling for Ritonavir itself.[2] Perhaps, if such a method were found, it might be too commercially valuable to share?

References

  1. J. Bauer, S. Spanton, R. Henry, J. Quick, W. Dziki, W. Porter, and J. Morris, "Ritonavir: An Extraordinary Example of Conformational Polymorphism", Pharmaceutical Research, vol. 18, pp. 859-866, 2001. https://doi.org/10.1023/a:1011052932607
  2. S.R. Chemburkar, J. Bauer, K. Deming, H. Spiwek, K. Patel, J. Morris, R. Henry, S. Spanton, W. Dziki, W. Porter, J. Quick, P. Bauer, J. Donaubauer, B.A. Narayanan, M. Soldani, D. Riley, and K. McFarland, "Dealing with the Impact of Ritonavir Polymorphs on the Late Stages of Bulk Drug Process Development", Organic Process Research & Development, vol. 4, pp. 413-417, 2000. https://doi.org/10.1021/op000023y