Quickstart

This is a five-minute tour. For the full treatment of each topic, see the User Guide.

Install pidibble (see Installation) and parse an entry. We’ll use 4ZMJ, a trimeric ectodomain construct of the HIV-1 envelope glycoprotein:

>>> from pidibble.pdbparse import PDBParser
>>> p = PDBParser(source_db='rcsb', source_id='4zmj').parse()

Constructing the PDBParser and calling parse() downloads 4zmj.pdb from the RCSB (only if it is not already in the working directory) and parses it into the dictionary parsed.

Every parsed record type is a key of p.parsed:

>>> keys = sorted(p.parsed.keys())
>>> len(keys)
60
>>> keys[:8]
['ANISOU', 'ATOM', 'AUTHOR', 'CISPEP', 'COMPND', 'CONECT', 'CRYST1', 'DBREF']

Each value is either a single PDBRecord (for records that occur once, like HEADER) or a PDBRecordList of them (for records that recur, like ATOM). Use pstr() to see what any record holds:

>>> print(p.parsed['HEADER'].pstr())
HEADER
      classification: VIRAL PROTEIN
             depDate: 04-MAY-15
              idCode: 4ZMJ

Fields are plain instance attributes:

>>> p.parsed['HEADER'].classification
'VIRAL PROTEIN'
>>> atoms = p.parsed['ATOM']
>>> len(atoms)
4518
>>> print(atoms[0].pstr())
ATOM
              serial: 1
                name: N
              altLoc:
             residue: resName: LEU; chainID: G; seqNum: 34; iCode:
                   x: -0.092
                   y: 99.33
                   z: 57.967
           occupancy: 1.0
          tempFactor: 137.71
             element: N
              charge:

Notice that structured sub-fields — like the residue of an atom — are themselves small record objects with their own attributes:

>>> atoms[0].residue.resName
'LEU'
>>> atoms[0].residue.chainID
'G'
>>> atoms[0].residue.seqNum
34

Reading an mmCIF/PDBx file instead of a legacy PDB file is a one-word change:

>>> c = PDBParser(source_db='rcsb', source_id='4zmj', input_format='mmCIF').parse()

pidibble parses the mmCIF entry into the same record objects, using author (auth) numbering so the result is a drop-in equivalent of the PDB parse. See PDBx/mmCIF parsing for the details and the small, deliberate differences.

Where to go next