Tag Archives: TwirlyMol

Using ChemSpider ID as Chemical Structure Identifier

ChemSpider IDs are definitely an important identifier to specify or name a chemical structure. Starting with the beta 4 version of the Chemical Identifier Resolver (CIR), ChemSpider IDs are now accepted both as input identifier as well as output representation. If it is used as input format, it has to be “classified” as ChemSpider ID (as we plan to enable the lookup of more database identifiers using the following format):

http://cactus.nci.nih.gov/chemical/structure/chemspider_id=1234567/smiles

The clue is, that for the conversion step “ChemSpider ID to structure” no local lookup in our databases is performed, but it is converted by connectiong to the ChemSpider’s InChI Resolver. If you want, you can combine this with other methods provided by CIR, for instance, the generation of all tautomers for a ChemSpider ID:

http://cactus.nci.nih.gov/chemical/structure/tautomers:chemspider_id=1234567/smiles
http://cactus.nci.nih.gov/chemical/structure/tautomers:chemspider_id=1234567/image

Or you can “twirl” a ChemSpider ID:

http://cactus.nci.nih.gov/chemical/structure/chemspider_id=1234567/twirl

Of course, it also works in the other direction: the following example starts from an IUPAC name, which internally is converted into a chemical structure by OPSIN, and then is resolved into a ChemSpider ID (which again uses ChemSpider’s InChI Resolver):

http://cactus.nci.nih.gov/chemical/structure/(3β)-cholest-5-en-3-ol/chemspider_id

And some final example: resolve a set of Warfarin tautomers into ChemSpider IDs (unfortunately the ChemSpider InChI Resolver returns also deprecated ChemSpider records):

http://cactus.nci.nih.gov/chemical/structure/tautomers:warfarin/chemspider_id

You can do the same thing by starting from a ChemSpider ID, generate the tautomers and resolve them into a set of ChemSpider IDs again:

http://cactus.nci.nih.gov/chemical/structure/tautomers:chemspider_id=52602/chemspider_id

Markus

Second Life, TwirlyMol and the Chemical Identifier Resolver

I just found this blog article – it mentions TwirlyMol and the Chemical Identifier Resolver:

http://blogs.nature.com/ub51cd45e/2010/04/15/shared-media-second-life-gets-serious-about-web-content

Interesting idea – it even includes a screenshot using TwirlyMolecules inside a metabolic browser:

http://blogs.nature.com/ub51cd45e/assets_c/2010/04/Snapshot_002-144.html

Markus

Standard InChIKey Lookup

In the previous version of the Chemical Identifier Resolver, only full length Standard InChIKeys were accepted as identifier part of the requested URL. Any successful request always returned the representation of a single structure record. However, the latter neglects some characteristics of Standard InChIKeys which specifically also were implemented for interlinking highly related (but not always exactly identical) chemical compounds.
For instance, the full-length Standard InChIKey ADVPTQAUNPRNPO-UHFFFAOYSA-N
represents 3-sulfino-alanine as well as its zwitterionic form (or in other words: both are regarded as the same chemical compound by Standard InChIKey):

Starting with the Beta 2 version of the Resolver we have changed the behavior of how a Standard InChIKey is looked up in the database. A request by Standard InChIKey returns now all structure records that have this key as their Standard InChIKey (previously only the first structure record for a Standard InChIKey was returned). For the request

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/smiles

the Resolver returns now the SMILES string for 3-sulfino-alanine and for its zwitterion:

NC(C[S](O)=O)C(O)=O
[NH3+]C(C[S]([O-])=O)C(O)=O

To access a specific structure record use the URL option structure_index:

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/smiles?structure_index=0

NC(C[S](O)=O)C(O)=O

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/smiles?structure_index=1

[NH3+]C(C[S]([O-])=O)C(O)=O
Likewise, this works for any other structure representation available from the Resolver, i.e. if the option structure_index is not being used

Note: be careful with the request for names. Both forms of 3-sulfino-alanine return more than one name and the request for names therefore returns a join list of both name lists:

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/names

If you want to separate both, please use the structure_index option again. For TwirlyMol always use the structure_index option (otherwise only the first structure is returned):

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/twirl?structure_index=0&div_id=NAME0

http://cactus.nci.nih.gov/chemical/structure/InChIKey=ADVPTQAUNPRNPO-UHFFFAOYSA-N/twirl?structure_index=1&div_id=NAME1

Twirl Your Molecule Nicer and Faster

Well, Noel posted it already earlier on his blog: he has improved TwirlyMol quite a bit (the molecules look really awesome now), and I have worked on some improvements on how it is delivered by the Chemical Identifier Resolver.
If you have already embedded twirling molecules in your web page (as described here), Noel’s changes to TwirlyMol are visible immediately. Additionally, you can cache a once generated TwirlyMol on our web server. This reduces loading times quite a bit after the first request of the molecule. Here is, how it works :

1. create a div element, name it by the id attribute and set also the width and height attributes:

<div id="DIV_ID" height="height" width="width"></div>

2. load the TwirlyMol javascript with the following script:

<script src="http://cactus.nci.nih.gov/chemical/structure/IDENTIFIER/twirl_cached/DIV_ID"></script>

So, if you already use the “old” way in your web page for loading TiwrlyMol, you might change it to this for shorter loading times (however, we also will keep the previous method). The script created by the caching method will be available in our cache for 10 days since its last usage (after that it will be just re-cached after the next request).

Here it is how it works for NSC number 740 in the NCI database:

<div id="div_for_nsc740" height="400" width="600"></div>
<script src="http://cactus.nci.nih.gov/chemical/structure/NSC740/twirl_cached/div_for_nsc740"></script>

which creates the twirling molecule at the top of this post.

Twirl Your Identifier

twirl_very_smallA few month ago I stumbled over the fantastic TwirlyMol javascript posted by Noel O’Boyle on his blog. TwirlyMol creates a live 3D model of a chemical structure just in your webpage without the need of any plugins (the only thing that is required is a modern browser). Well, I thought it would be really cool to link TwirlyMol with the Resolver because this would offer a simple way to use it as a 3D molecule viewer, or, it would allow to embed 3D structure models into web pages, all by just crafting an URL – o.k., here it is.

As structure representation you can use any chemical structure identfier that is accepted by the Resolver including arbitrary SMILES and InChI strings.

Use it as a 3D structure viewer:

http://cactus.nci.nih.gov/chemical/structure/aspirin/twirl
http://cactus.nci.nih.gov/chemical/structure/CN(Cc1cnc2nc(N)nc(N)c2n1)c3ccc(cc3)C(=O)NC(CCC(O)=O)C(O)=O/twirl
http://cactus.nci.nih.gov/chemical/structure/InChI=1S/C6H12/c1-2-4-6-5-3-1/h1-6H2/twirl

You can resize it:

http://cactus.nci.nih.gov/chemical/structure/aspirin/twirl?height=200&width=200
http://cactus.nci.nih.gov/chemical/structure/aspirin/twirl?height=400&width=400
http://cactus.nci.nih.gov/chemical/structure/aspirin/twirl?height=800&width=800

Embed it into your own web page:

a. create div element in your page, tag it with an id (could be an arbitrary name), and set the height and width attribute of the div element:

<div id="twirler" height="300" width="300"></div>

b. load the twirl script from cactus.nci.nih.gov and add the URL option “div_id” which names the id of the div element:

<script src="http://cactus.nci.nih.gov/chemical/structure/aspirin/twirl?div_id=twirler" />

Thats it.  The rest is done by the javascript script coming from our webserver. Since TwirlyMol depends on the dojo and dojo.gfx javascript libraries these are loaded first from Google AJAX Libraries API into your web page. The 3D coordinates needed for the rendering of the structure are calculated by CORINA. You can use it also for more than one 3D model in the same web page, just use unique id names for the div element.

I tested on the following browsers how it works:

  • Firefox. It works well on Firefox<3.5, however is much slower compared to the Firefox>3.5. I used Firefox on Linux and Windows XP
  • Google Chrome. It works fine there and it is fast. OS was Windows XP
  • Safari. I tested it only quickly there and I don’t know any particular version numbers (neither of the OS nor the browser) but it seems to work fine there, too.
  • Internet Explorer. Well, well – it works, I tested it on IE7 and IE8 but it reminds more of a slide show than a molecule viewer.

If you experience any problems with TwirlyMol embedded by the Chemical Identifier Resolver, please report them to us. A thing I haven’t tested much is how it works with websites that uses the dojo and dojo.gfx libraries themselves. I also would be happy to hear about (present and absent) interferences with other javascript libraries like mootools, jquery, prototype.js etc. I used TwirlyMol with prototype.js myself and so far I didn’t run into any issues.

Read also Noel’s post about this on his blog, he has some nice live examples using this service (embarrassingly, I still have to figure out how I get TwirlyMol working in my WordPress blog here :-) )