Proteins, ProteinData, WolframAlpha
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}]}], {}];
res = URLRead[HTTPRequest["http://www.rcsb.org/pdb/rest/search/",
<|"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]],
Import["https://files.rcsb.org/download/" <> # <> ".pdb", "PDB"]}] & /@
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"]]
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"]
Naturally, you could get Mathematica to do the download too.
Options for alternate renderings can be found in the documentation for PDB format
Try this here
Import["http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1U19", "PDB"]