Group Abstract Group Abstract

Message Boards Message Boards

The MoleculeViewer package

Posted 8 years ago

I have just released a package entitled "MoleculeViewer", whose functionality is exactly what it says on the tin.

This package was inspired in part by previous efforts by @BoB LeSuer and @Bianca Eifert. I took the best parts of their packages, along with some of the good parts of the built-in molecule renderer, and added a few of my own tweaks. One noticeable tweak would be the depiction of multiple bonds (just like what is done in some physical models), as in the following image:

MoleculeViewer["thiacloprid"]

thiacloprid

The package has a number of other nifty features and auxiliary functions, like highlighting:

MoleculeViewer["caffeine", Highlighted -> {"O", "N" -> Orange}]

caffeine

and legends:

MoleculeViewer[RunOpenBabel[GetChemSpider["calicheamicin", "InChI"]], PlotLegends -> True]

calicheamicin

Before using the package, you will need to install Open Babel for some of its conversion functionality. Additionally, to use the ChemSpider search functionality, you will need to register to obtain an API key.

Download the paclet from GitHub and install in the usual manner. Alternatively, using the technique featured here, evaluate

PacletInstall["MoleculeViewer", "Site" -> "http://raw.githubusercontent.com/tpfto/MoleculeViewer/master"]

Documentation and a gallery are given as separate notebooks.

POSTED BY: J. M.
19 Replies
Posted 6 years ago

Version 3.0 of MoleculeViewer has just been released. Altho version 12 now has MoleculePlot3D[], the method for depicting multiple bonds in MoleculeViewer[] is markedly different. (The package also remains useful for older versions without built-in Molecule[] objects.) Using one of the examples in the docs for MoleculePlot3D[]:

MoleculeViewer["Nc1nccc(n1)c1c(C)onc1c1ccccc1"]

ball-and-stick model displayed with MoleculeViewer

MoleculeViewer["Nc1nccc(n1)c1c(C)onc1c1ccccc1", PlotStyle -> "Tubes"]

stick model displayed with MoleculeViewer

Apart from the new multiple bond depiction style and the facility to change the depiction style for molecules (ball and stick, spacefilling, etc.), other features that have been added include

  • data access functions for PDB and ZINC
  • OCR for molecules using Imago OCR
  • support for chemical structure drawing with Accelrys JDraw and JChemPaint
  • ChEMBL Beaker support functions
  • additional molecule manipulation functions

and many more.

m1 = ChEMBLSMILESTo3D["Nc1nccc(n1)c1c(C)onc1c1ccccc1", Method -> "ETKDG"];
bond = Reverse[Extract[Pick[##, "Single"] & @@ ArrayPad[m1, -1], 4]];
Animate[MoleculeViewer[BondRotate[m1, bond, ?],
                       PlotRange -> 600, ViewPoint -> {-0.832, 0.453, 3.265}],
        {?, 0, 2 ?, ?/12}]

bond rotation of a random molecule

Download the paclet from GitHub.

POSTED BY: J. M.
Posted 7 years ago

Version 2.0 of MoleculeViewer has been released. The package now uses the new API system for ChemSpider, so users of previous versions will need to register for a new API key on the RSC page.

Additionally, the PubChem API is now also used to obtain structural information. For example:

MoleculeViewer[GetPubChem["fexofenadine"]]

fexofenadine

Support for files and URLs has also been implemented:

MoleculeViewer["http://exampledata.wolfram.com/aspirin.mol"]

aspirin

as well as chemical Entity[] objects:

efavirenz

Download the paclet from GitHub.

POSTED BY: J. M.
Posted 8 years ago

MoleculeViewer has been updated to version 1.1. Some updates include

  • user is now explicitly prompted for a ChemSpider API key
  • implemented detailed option settings for RunOpenBabel
  • some minor tweaks and bug fixes

Please obtain the updated paclet from the GitHub releases page.

POSTED BY: J. M.
Anonymous User
Anonymous User
Posted 8 years ago

As a passer by to this article I have to ask: why is a chemical "stick modeler" needed - albeit free?

Why I ask: Mathematica has chemical modeling built-in and also downloadable data (ie, molecules), including new extension to show electron affinity of bonds in a cloud/bond manner (and i think even keeping bond angles right). And I imagine Mathematica store has one or a few extenders of that. (i know only a little about Organic and Inorganic chemistry IUPAC naming and other things - i'm no chemistry professor though)

POSTED BY: Anonymous User
Posted 8 years ago

Why I ask: Mathematica has chemical modeling built-in and also downloadable data (ie, molecules)

  • Right, this augments the built-in functionality. I've already noted the bit about depicting multiple bonds (which the default renderer does not do) in the very first post. Additionally, I do use ChemicalData[] as one possible source of info, but it does not have everything. (Try looking up the first and last examples in ChemicalData[] yourself and report back.)

And I imagine Mathematica store has one or a few extenders of that.

  • If indeed there are, they did not show up in my searching efforts. Feel free to post links to anything you've seen. ;)

P. S. I am a chemist, FWIW.

POSTED BY: J. M.

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming! The post was also added to our curated Mathematica Add-Ons group.

POSTED BY: EDITORIAL BOARD

@Murray Eisenberg, try opening Mathematica from the command line to have access to your usual $PATH. For me, I enter in the terminal

/Applications/Mathematica-11.2.app/Contents/MacOS/Mathematica &

and in the front end that pops up, you should see a different return for Environment["PATH"].

@J. M. - very cool visualizations!

POSTED BY: Jason Biggs
POSTED BY: Murray Eisenberg
Posted 8 years ago
POSTED BY: J. M.

Next issue: how to tell RunOpenBabel the path on which to find the openbabel binary obabel. The program is in my macOS system path (at /opt/local/bin/obabel).

I ask because I tried in your notebook molviewer.nb to execute the code:

MoleculeViewer[RunOpenBabel[GetChemSpider["ixabepilone", "InChI"]], 
 PlotLegends -> True]

But that gave an error:

RunProcess: Program babel not found. Check Environment'"PATH"]
POSTED BY: Murray Eisenberg
Posted 8 years ago
POSTED BY: J. M.
POSTED BY: Murray Eisenberg
POSTED BY: Murray Eisenberg
Posted 8 years ago
POSTED BY: J. M.

I installed the MoleculeViewer paclet in the usual way, as well as openbabel (Macports version). And I registered with ChemSpider (which was a confusing procedure, as it involves first getting a Royal Society of Chemistry login and then linking tht with ChemSpider).

But how do I actually get that ChemSpider API key? And how do I tell MoleculeViewer about it?

I ask because when I tried to reevaluate a cell in the notebook gallery.nb, I got error message:

GetChemSpider: ChemSpider API key in $ChemSpiderAPIToken not detected or invalid
POSTED BY: Murray Eisenberg
Posted 8 years ago

When you have a ChemSpider (actually, RSC) account, go to your ChemSpider profile page. The API key is listed under the "Security Token" field. Copy that, and assign the string to $ChemSpiderAPIToken, which should look like this:

$ChemSpiderAPIToken = "ef739634-61c8-3c6c-6ff5-6d3a8a12f5d1"

(not my actual API key!)

You might wish to edit the notebook or the package itself so that $ChemSpiderAPIToken is permanently assigned to your API key.

I'll need to think of an easier way to let people enter their API keys.

POSTED BY: J. M.

In order to use MoleculeViewer using Mathematica on macOS: which installation procedure will work with it for Open Babel?

  • Macports?
  • Conda (conda install open babel)?
  • compile the source code (which is always a hassle).?
POSTED BY: Murray Eisenberg
Posted 8 years ago
POSTED BY: J. M.

I'll try the MacPorts version of MoleculeViewer, as it seems to be the current version, as contrasted with the installer to which you supplied a link.

Homebrew is not a viable option on a Mac where one is already using MacPorts: using both can cause considerable confusion and clashes between different versions of libraries.

POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard