WWW Site - Documentation - Tools

pdbfile tool


Read, write PDB files in combo with LAMMPS snapshots.


The pdbfile tool reads in PDB (Protein Data Bank) files of protein coordinates and uses them in conjunction with LAMMPS snapshots in various ways. The PDB format is commonly used by various vizualization and analysis programs.

The pdbfile constructor takes a string argument listing one or more PDB filenames and a data argument with LAMMPS atom information (data or dump object). The atom snapshots must have "id", "type", "x", "y", and "z" defined; see the map() methods of those tools.

Both arguments to the constructor are optional, as described below. If a single PDB file is given as a constructor argument, and it is 4 letters long, and it does not exist on your system, then it is treated as a PDB identifier and the matching PDB file is downloaded from a PDB repository on the WWW to your machine.

The one(), many(), and single() methods write out PDB files in various manners, depending on the 1 or 2 arguments used in the constructor. If only a string was specified (no data object), the specified PDB files are written out as-is. Thus the one() method concatenates the files together. If only a data object was specified (no string of PDB files), then PDB files in a generic format (Lennard-Jones atoms) are created. If both arguments are specified, then only a single PDB file can be listed. It is treated as a template file, and the atom coordinates in the data object replace the atom coordinates in the template PDB file to create a series of new PDB files. This replacement is only done for selected atoms (in the dump object) and for atom IDs that appear in the PDB file.

The iterator() method is called by the rasmol tool to create a series of PDB files for visualization purposes.


p = pdbfile("3CRO")         create pdb object from PDB file or WWW
p = pdbfile("pep1 pep2")    read in multiple PDB files
p = pdbfile("pep*")         can use wildcards
p = pdbfile(d)              read in snapshot data with no PDB file
p = pdbfile("3CRO",d)       read in single PDB file with snapshot data 
  string arg contains one or more PDB files
    don't need .pdb suffix except wildcard must expand to file.pdb
    if only one 4-char file specified and it is not found,
      it will be downloaded from as 3CRO.pdb
  d arg is object with atom coordinates (dump, data)                     write all output as one big PDB file to tmp.pdb"mine")               write to mine.pdb
p.many()                    write one PDB file per snapshot: tmp0000.pdb, ...
p.many("mine")              write as mine0000.pdb, mine0001.pdb, ...
p.single(N)                 write timestamp N as tmp.pdb
p.single(N,"new")           write as new.pdb 
  how new PDB files are created depends on constructor inputs:
    if no d: one new PDB file for each file in string arg (just a copy)
    if only d specified: one new PDB file per snapshot in generic format
    if one file in str arg and d: one new PDB file per snapshot
      using input PDB file as template
    multiple input PDB files with a d is not allowed 
index,time,flag = p.iterator(0)
index,time,flag = p.iterator(1) 
  iterator = loop over number of PDB files
    call first time with arg = 0, thereafter with arg = 1
    N = length = # of snapshots or # of input PDB files
    index = index of snapshot or input PDB file (0 to N-1)
    time = timestep value (time stamp for snapshot, index for multiple PDB)
    flag = -1 when iteration is done, 1 otherwise
  typically call p.single(time) in iterated loop to write out one PDB file 

Related tools:

data, dump, rasmol

Prerequisites: none