Skip to content

Instantly share code, notes, and snippets.

@garyo
Last active May 20, 2020 14:15
Show Gist options
  • Save garyo/492548aee1ceb2b0be38faad785e123e to your computer and use it in GitHub Desktop.
Save garyo/492548aee1ceb2b0be38faad785e123e to your computer and use it in GitHub Desktop.

Query by text "covid-19" -- returns PDB IDs, one per line

Just fill in the keywords section, the rest is constant. Keywords are comma-separated and get "AND"ed together.

% curl --data-binary '<orgPdbQuery>
<queryType>org.pdb.query.simple.AdvancedKeywordQuery</queryType>
<keywords>covid-19</keywords>
</orgPdbQuery>' https://www.rcsb.org/pdb/rest/search

Query by text "1d3"

This shows how searching for "1d3" returns "1d3s" as well as some other PDBs. But weirdly it doesn't return "1d3e". I guess it's not perfect. But better for full-text search like "coronavirus"

% curl --data-raw '<orgPdbQuery>
<queryType>org.pdb.query.simple.AdvancedKeywordQuery</queryType>
<keywords>1d3</keywords>
</orgPdbQuery>' https://www.rcsb.org/pdb/rest/search
1D3S
4Z8G
4Z94

Get a list of all PDB IDs

This takes a few sec; returns XML. We could use this to do real-time search by PDB ID rather than the full-text search above. % curl https://www.rcsb.org/pdb/rest/getCurrent

<?xml version='1.0' standalone='no' ?>
<current>
  <PDB structureId="100D" />
  <PDB structureId="101D" />
  <PDB structureId="101M" />
  ...
  <PDB structureId="9RUB" />
  <PDB structureId="9WGA" />
  <PDB structureId="9XIA" />
  <PDB structureId="9XIM" />
</current>

Query for info about one or more PDB IDs (comma-separated) -- returns XML.

We would show the structureId and title, and possibly structure_authors. Ignore the relatedPDB fields.

% curl 'https://www.rcsb.org/pdb/rest/describePDB?structureId=4hhb,2d3e'

<?xml version='1.0' standalone='no' ?>
<PDBdescription>
  <PDB structureId="4HHB" title="THE CRYSTAL STRUCTURE OF HUMAN DEOXYHAEMOGLOBIN AT 1.74 ANGSTROMS RESOLUTION" pubmedId="6726807" expMethod="X-RAY DIFFRACTION" resolution="1.74" replaces="1HHB" keywords="OXYGEN TRANSPORT" nr_entities="2" nr_residues="574" nr_atoms="4558" deposition_date="1984-03-07" release_date="1984-07-17" last_modification_date="2011-07-13" structure_authors="Fermi, G., Perutz, M.F." citation_authors="Fermi, G., Perutz, M.F., Shaanan, B., Fourme, R." status="CURRENT">
    <relatedPDB pdbId="1GLI" details="" />
    <relatedPDB pdbId="2HHB" details="REFINED BY THE METHOD OF JACK AND LEVITT.  THIS         ENTRY PRESENTS THE BEST ESTIMATE OF THE         COORDINATES." />
    <relatedPDB pdbId="3HHB" details="SYMMETRY AVERAGED ABOUT THE (NON-CRYSTALLOGRAPHIC)         MOLECULAR AXIS AND THEN RE-REGULARIZED BY THE         ENERGY REFINEMENT METHOD OF LEVITT.  THIS ENTRY         PRESENTS COORDINATES THAT ARE ADEQUATE FOR MOST         PURPOSES, SUCH AS COMPARISON WITH OTHER STRUCTURES." />
  </PDB>
  <PDB structureId="1D3E" title="CRYO-EM STRUCTURE OF HUMAN RHINOVIRUS 16 (HRV16) COMPLEXED WITH A TWO-DOMAIN FRAGMENT OF ITS CELLULAR RECEPTOR, INTERCELLULAR ADHESION MOLECULE-1 (D1D2-ICAM-1). IMPLICATIONS FOR VIRUS-RECEPTOR INTERACTIONS. ALPHA CARBONS ONLY" pubmedId="10562537" pubmedCentralId="PMC1171688" expMethod="ELECTRON MICROSCOPY" resolution="28.00" keywords="Virus/Receptor" nr_entities="5" nr_residues="1028" nr_atoms="989" deposition_date="1999-09-29" release_date="2000-01-19" last_modification_date="2019-12-18" structure_authors="Bella, J., Rossmann, M.G." citation_authors="Kolatkar, P.R., Bella, J., Olson, N.H., Bator, C.M., Baker, T.S., Rossmann, M.G." status="CURRENT" />
</PDBdescription>

Query for details of the structure of a molecule, by PDB ID

This could be used to show what structures are in a PDB. This is great info to show in a popup somewhere once the structure is loaded. A possible display for this (plus the previous one) would be:

  • 4HBB: The crystal structure of human deoxyhaemoglobin at 1.74 angstroms resolution
    • Hemoglobin subunit alpha: chains A, C
      • Description: HEMOGLOBIN (DEOXY) (ALPHA CHAIN)
    • Hemoglobin subunit beta: chains B, D
      • Description: HEMOGLOBIN (DEOXY) (BETA CHAIN)

curl https://www.rcsb.org/pdb/rest/describeMol?structureId=4hhb

<?xml version='1.0' standalone='no' ?>
<molDescription>
  <structureId id="4HHB">
    <polymer entityNr="1" length="141" type="protein" weight="15150.4">
      <chain id="A" />
      <chain id="C" />
      <Taxonomy name="Homo sapiens" id="9606" />
      <macroMolecule name="Hemoglobin subunit alpha">
        <accession id="P69905" />
      </macroMolecule>
      <polymerDescription description="HEMOGLOBIN (DEOXY) (ALPHA CHAIN)" />
    </polymer>
    <polymer entityNr="2" length="146" type="protein" weight="15890.2">
      <chain id="B" />
      <chain id="D" />
      <Taxonomy name="Homo sapiens" id="9606" />
      <macroMolecule name="Hemoglobin subunit beta">
        <accession id="P68871" />
      </macroMolecule>
      <polymerDescription description="HEMOGLOBIN (DEOXY) (BETA CHAIN)" />
    </polymer>
  </structureId>
</molDescription>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment