read.pdb: PDB File Reader

View source: R/read.pdb.R

read.pdbR Documentation

PDB File Reader

Description

Reads a Protein Data Bank (PDB) coordinates file.

Usage

read.pdb(
  file,
  ATOM = TRUE,
  HETATM = TRUE,
  CRYSTAL = TRUE,
  CONECT = TRUE,
  TITLE = TRUE,
  REMARK = TRUE,
  MODEL = 1,
  CRYST1 = NULL,
  resolution = TRUE,
  verbose = TRUE
)

Arguments

file

a single element character vector containing the name of the PDB file to be read.

ATOM

a logical value indicating whether to read the ATOM records.

HETATM

a logical value indicating whether to read the HETATM records.

CRYSTAL

a logical value indicating whether to read the crystal cell parameters (from the CRYST1 pdb record).

CONECT

a logical value indicating whether to read the CONECT records.

TITLE

a logical value indicating whether to read the TITLE records.

REMARK

a logical value indicating whether to read the REMARK records.

MODEL

an integer vector containing the serial number of the MODEL sections to be read. Can also be equal to NULL to read all the MODEL sections or to NA to ignore MODEL records (see details).

CRYST1

will be replaced by the CRYSTAL argument; existing code should be migrated to use the CRYSTAL argument.

resolution

logical value indicating wheter to extract the resolution (see details).

verbose

logical value indicating wheter to print additional information, e.g. number of models.

Details

The read.pdb function reads the TITLE, REMARK, ATOM, HETATM, CRYST1 and CONECT records from a PDB file. Three different reading modes can be used depending on the value of MODEL:

  • When MODEL is a vector of integers, MODEL sections whose serial numbers match these integers are read.

  • When MODEL == NULL, all MODEL sections are read.

  • When MODEL == NA, MODEL records are ignored and all ATOM and/or HETATM records are merged together to return a single object.

When multiple models are specified, each of the models is actually stored as a separate pdb molecule in a list of pdb molecules. If the resolution parameter is set, the function attempts to extract the resolution from the REMARKS field. Note: The resolution is only meaningfull for X-ray crystallography.

Value

When a single MODEL section is read, this function returns an object of class ‘pdb’ (a list with a class attribute equal to pdb) with the following components:

title

a character vector containing the TITLE records found in the PDB file.

remark

a character vector containing the REMARK records found in the PDB file.

crystal

a list of class ‘crystal’ containing the first CRYSTAL record found in the PDB file. All others are ignored.

atoms

a data.frame of class ‘atoms’ containing the ATOM and HETATM records found in the PDB file.

conect

a data.frame of class ‘conect’ containing the CONECT records found in the PDB file.

When multiple MODEL sections are read, a list of object of class ‘pdb’ is returned.

References

PDB format has been taken from: http://www.wwpdb.org/documentation/format33/v3.3.html

See Also

write.pdb, pdb, crystal, atoms, conect

Examples

# Read a PDB file included with the package
x <- read.pdb(system.file("examples/PCBM_ODCB.pdb", package="Rpdb"))

# Visualize the PDB file
visualize(x, mode = NULL)

# Write the 'pdb' object 'x' in file "Rpdb.pdb" into the current directory
write.pdb(x, file = "Rpdb.pdb")

# Cleanup
unlink("Rpdb.pdb")


Rpdb documentation built on March 16, 2026, 5:07 p.m.