# Proteins, ProteinData, WolframAlpha

Apologies in advance, this is the first I've messed with ProteinData and access through WolframAlpha, so clearly I may not know how Mathematica and Alpha decide on what is the 'right way' to ask for things of this ilk.

I'd like to grab ProteinData[], specifically a 3D model of the "RibbonStructure", of rhodopsin.

I can easily get a low-resolution, static image from Alpha, directly in Mathematica:

but I'd prefer the manipulatable 3D sort one gets from ProteinData[], since this is much better for classroom demos, interactive explanation, etc.

So, I try to look up rhodopsin via ProteinData in a wide variety of ways, by name, by PDB name, nada-

Let's try an alias ---

Success! But, there is no MoleculePlot

It knows a few things about "RHO", but not the things I need; and, more importantly, what Alpha is able to return.

So I'm at a loss here. I've tried other aliases ("OPN2", "visual purple") to no avail. I'm curious about ---

• Is there any way to figure out what WolframAlpha is doing with my request, since it can clearly interpret rhodopsin or rhodopsin protein?

• Is there a better way to use ProteinData than just randomly trying things? Is there a mapping somewhere of PDB <-> aliases, etc?

• Is there a way to as Alpha to return a higher resolution image than the sort-of-lame 320× I get? I know how to ask for just that pod, but it's unclear if there are any ways of asking for better / different pod content.

• When you click the subpod containing the low-res image and then right click to paste the computable WolframAlpha call you see that even this doesn't work. Feb 1, 2017 at 16:23
• The typical way to find entities is to use inline free-form input. For example "AAMP protein" gives you an entity for that protein if you search for it in this way. Free-form search for "rhodopsin protein" does not give you an entity, which suggests to me that it doesn't exist. Feb 1, 2017 at 16:29
• yet, "RHO" exists, which is rhodopsin... so lord knows what it's thinking.
– flip
Feb 1, 2017 at 17:20
• @halirutan - yeah- I forgot to mention that too. Intuition = fails. I now have a notebook called Finding Rhodopsin full of frustration :)
– flip
Feb 1, 2017 at 17:26
• Looking at the paclet, it seems you are only going to get a "MoleculePlot" if the entity has a "PrimaryPDBID" property. For instance, ProteinData["RHOA", "MoleculePlot"] works because ProteinData["RHOA", "PrimaryPDBID"]. For now you'll have to use halirutan's workaround, but I would like to fix this soon. Feb 1, 2017 at 17:41

Here's a workaround that directly queries the PDB search API and returns the first num search results as a Dataset[]. The routine is more complicated than I'd like, due to the finicky nature of the API (it only takes queries in XML format), as well as the somewhat clunky way XML is represented in Mathematica:

pdbFindMoleculeName[name_String, num : (_Integer?Positive) : 10] :=
Module[{query, res},
query = XMLObject["Document"][{
XMLObject["Declaration"]["Version" -> "1.0", "Encoding" -> "UTF-8"]},
XMLElement["orgPdbQuery", {},
{XMLElement["queryType", {}, {"org.pdb.query.simple.StructTitleQuery"}],
XMLElement["struct.title.comparator", {}, {"contains"}],
XMLElement["struct.title.value", {}, {name}]}], {}];

<|"ContentType" -> "application/x-www-form-urlencoded",
"Body" -> ExportString[query, "XML"], "Method" -> "POST"|>]];

If[! FailureQ[res], res = Import[res];
If[res =!= "null", res = DeleteDuplicates[Flatten[res]];
res = Dataset[AssociationThread[{"PDB ID", "Title", "Structure"},
{#, Cases[Import["http://www.rcsb.org/pdb/rest/describePDB?structureId=" <>
#, "XML"], ("title" -> t_) :> t, ∞][[1]],

Take[res, UpTo[num]]],
res = Failure["NoResults",
<|"MessageTemplate" :> "No results found for name",
"MessageParameters" -> <|"name" -> name|>|>]]];
res]


As a demo:

rhod = pdbFindMoleculeName["bovine rhodopsin"]


Of course, the Dataset[] format allows for convenient querying; e.g., if you want to see the structure of 1HZX:

First[rhod[Select[#"PDB ID" === "1HZX" &], "Structure"]]


• I, for one, applaud our API using overlords. Feb 1, 2017 at 21:22

Try this here

Import["http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1U19", "PDB"]


• Cheating :) ! But seriously, this is the way I've done it up until now, I was sort of hoping to use more of the nice builtin stuff, but I see it's rather incomplete.
– flip
Feb 1, 2017 at 17:22

A quick and dirty is to download the PDB file from the main PDB database (eg Bovine rhodopsin), use the Download button/dropdown on the top right and select Text format then

rhodopsin= Import["DownloadedFileAndPath","Rendering"->"Structure"]