Message Boards Message Boards

The MoleculeViewer package

Posted 7 years ago
POSTED BY: J. M.
19 Replies
Posted 6 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 BY: Murray Eisenberg
POSTED BY: Jason Biggs
Posted 7 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.
Posted 4 years ago
POSTED BY: J. M.
POSTED BY: Murray Eisenberg
Posted 7 years ago
POSTED BY: J. M.
POSTED BY: Murray Eisenberg
Posted 7 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.
POSTED BY: Murray Eisenberg

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 7 years ago
POSTED BY: J. M.
Posted 7 years ago

I agree with your assessment; I have been using it for a while (and its predecessor functions for a while more), so I do have blind spots with respect to usability. (Feedback like yours is a good thing!)

I believe I did something like that for $ChemSpiderAPIToken in one of the initialization cells for molviewer.nb, but did not add one for gallery.nb. I'll commit that, along with fixes for some bug reports that have been sent in, in my next point (i.e., 1.1) release.

POSTED BY: J. M.

Although the location of babel is on my system path — which is set in ~/.profile — still Mathematica is not recognizing that:

    Environment["PATH"]
/usr/bin:bin:/usr/sbin:/sbin

and hence your RunOpenBabel function fails with the same error I listed. This is even after a system reboot.

The link you provide for changing the value of PATH will probably lead to chaos on macOS, because if the file .bash_profile exists, then .profile will not even be read by the shell, and .profile is where MacPorts and other apps place additions to PATH (along with various command aliases).

What's even stranger is the following. In a new Mathematica session, before loading MoleculeViewer, I evaluate the commands

    SetEnvironment["PATH" -> StringJoin[Environment["PATH"], ":opt/local/bin"]]
    Environment["PATH"]

and get output:

/usr/bin:/bin:/usr/sbin:/sbin:opt/local/bin

The last location there, /opt/local/bin is definitely where the obabel executable resides, as I can check with the Mac's system command:

mdfind -name obabel

And indeed, in a Terminal session I can evaluate, e.g., either of:

obabel -H
/opt/local/bin/obabel -H

and get the expected output.

POSTED BY: Murray Eisenberg

But why is Mathematica not picking up the path from /etc/paths (really /private/etc/paths) and /etc/paths.d (really, /private/etc/paths.d) files?

As I indicated in a previous reply, one of the paths in /etc/paths is not being picked up by Mathematica as shown in the output from evaluating Environment["PATH"].

POSTED BY: Murray Eisenberg
Posted 7 years ago
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: Moderation Team
Anonymous User
Anonymous User
Posted 7 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 7 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.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract