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,
  CONNECT = TRUE,
  TITLE = TRUE,
  REMARK = TRUE,
  MODEL = 1,
  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).

CONNECT

a logical value indicating whether to read the CONNECT 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).

resolution

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

verbose

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

Details

The read.pdb function reads the most important records from the PDB file, including TITLE, REMARK, ATOM, HETATM, Heterogen Names (HETNAM), CRYSTAL, CONNECT, HELIX and SHEET records.

Three different reading modes can be used depending on the value of MODEL:

  • When MODEL is a vector of integers, only the models which match these integers are read.

  • When MODEL == NULL, all models 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. Note: The handling of models may change in a future version of Rpdb.
If the resolution parameter is set, the function attempts to extract the resolution from the REMARKS field. Note: The resolution is only meaningful 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.

connect

a data.frame of class ‘connect’ containing the CONNECT records found in the PDB file.

Structure

a list with componentsHelix and Sheet

Resolution

a numeric value with the resolution.

When multiple MODEL sections are read, a list of object of class ‘pdb’ is returned. Note: this may change in the future.

References

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

See Also

write.pdb, pdb, crystal, atoms, connect

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 May 12, 2026, 5:06 p.m.