SpaceFillingMolecularPlot using CAS number of a compound

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"]
   "CCCCCCCCOC1=CC=C(C=C1)C2=CC=C(C=C2)C#N"

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]

imidacloprid

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"]

CAS52364-73-5

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.

query