When I tried to get 3D graphics for the molecule with CAS number 52364-73-5 using Mathematica 10, it produced the following result:

ChemicalData["CAS52364-73-5", "SpaceFillingMoleculePlot"]

but it makes a plot for caffeine:

ChemicalData["Caffeine", "SpaceFillingMoleculePlot"]

How can I get a structural diagram for my compound?

  • $\begingroup$ I can't reproduce this on v10 win7/64 bit. Try RebuildPacletData[] and then see if that changes things. $\endgroup$ Sep 6, 2014 at 21:43
  • $\begingroup$ I get the OP's result on OS X for in both V9 and V10. $\endgroup$
    – m_goldberg
    Sep 6, 2014 at 21:55
  • $\begingroup$ i also get op's result on Version Windows 8. $\endgroup$
    – kglr
    Sep 6, 2014 at 22:27

2 Answers 2


added 4/26/2020

Molecule[] + MoleculePlot3D[] can now do this directly in version 12.1:

MoleculePlot3D[Molecule["CAS52364-73-5"], PlotTheme -> "Spacefilling"]

Original answer

Since the compound of interest does not have the required 3D structure within ChemicalData[], we must look for other sources. One possibility is to use the CACTUS Chemical Identifier Resolver, which can take e.g. a SMILES string and output a *.mol file that can the be displayed in 3D.

Generate the SMILES string:

smiles = ChemicalData["CAS52364-73-5", "SMILES"]

Here is a little routine that retrieves (or tries to) the corresponding *.mol file from CACTUS:

CactusGet[arg_String, opts___] := Import[StringTemplate[
      "https://cactus.nci.nih.gov/chemical/structure/`spec`/file?format=sdf&get3d=true"] @
      <|"spec" -> StringReplace[If[StringMatchQ[arg, "InChI*"], arg, URLEncode[arg]],
                                "+" -> "%20"]|>, "MOL", opts]

Here goes:

CactusGet[smiles, "Rendering" -> "Spacefilling"]

space-filling model

Of course, not all known compounds are in CACTUS; one might then try to write routines for retrieving data from e.g. ChemSpider or PubChem.

Luckily, ServiceConnect[] and ServiceExecute[] allow one to access these sources directly from within Mathematica.

In the case of ChemSpider, you will need to register to obtain a security token, which Mathematica will prompt you for when you first use the service.

After doing that, you can then use this:

GetChemSpider[str_String, opts___] := Module[{res}, 
   res = ServiceExecute["ChemSpider", "Search", "Query" -> str] @ "ID"; 
   If[! FailureQ[res], 
      Import["http://www.chemspider.com/FilesHandler.ashx?type=str&3d=yes&id=" <> res,
             "MOL", opts], $Failed]]

I'll use some examples that are a bit more interesting than the one in the OP:

GetChemSpider[#, "Rendering" -> "Spacefilling"] & /@
{"4493-23-6", "4368-28-9", "1256580-46-7"} // GraphicsRow

some molecules

For PubChem, you can query with CAS numbers like so:

ServiceExecute["PubChem", "CompoundSDF", {"Name" -> "138261-41-3"}]["Graphics3D", 1]


but as you can see, the result returned is "fake 3D"; this is probably a problem on PubChem's end, tho.

Still another possibility presents itself if you happen to have OpenBabel also installed on your computer. Here's how to use OpenBabel's conversion capabilities from within Mathematica:

OpenBabelStructure[arg_String, opts___] := 
    ImportString[RunProcess[{"obabel", If[StringMatchQ[arg, "InChI*"], "-iinchi", ""], 
                             "-:" <> "\"" <> arg <> "\"", "-omol",
                             "--gen3d", "-c", "--minimize"}] @
                 "StandardOutput", "MOL", opts]

(See this for information on the command line options used.)

Using the same example as the CACTUS one:

smiles = ChemicalData["CAS52364-73-5", "SMILES"];
OpenBabelStructure[smiles, "Rendering" -> "Spacefilling"]

space-filling model


The information you ask for is simply not in Wolfram's curated database. The following works

ChemicalData["CAS52364-73-5", "CHBlackStructureDiagram"]


showing that queries on molecule CAS52364-73-5 are possible. My conclusion is that the 3D structure data needed to satisfy your query is not in the database.

I verified my conclusion by doing an Wolfram|Alpha query from Mathematica.


  • $\begingroup$ How can I get SpaceFillingMoleculePlot with custom .xyz file? I tried Import["custom.xyz","Rendering"->"Spacefilling"] which gives nice 3D plot with shining. How can I eliminate shining? $\endgroup$
    – user12609
    Sep 8, 2014 at 8:53
  • $\begingroup$ @user12609. I'm sorry but I don't have an answer to what you ask in the above comment. I recommend you post it as new question. More people will see it that way and you will have a better chance to get an answer. $\endgroup$
    – m_goldberg
    Sep 8, 2014 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.