Rpdb (version 2.2)

coords: The Atomic Coordinates of an Object

Description

Get or set the atomic coordinates (either Cartesian or fractional coordinates) of an object.

Usage

coords(...) coords(x) <- value is.coords(x)
"coords"(x1, x2, x3, basis = "xyz", ...)
"coords"(x, ...) "coords"(x) <- value
"coords"(x, ...) "coords"(x) <- value
"coords"(x, basis = NULL, ...)
"coords"(x, basis = NULL, ...)

Arguments

x1, x2, x3
numeric vectors containing the first, second and third coordinates.
basis
a single element character vector indicating the type of basis vector used to express the atomic coordinates.
x
an R object containing atomic coordinates.
value
an object of class ‘coords’ used for replacement
...
further arguments passed to or from other methods.

Value

The accessor function returns a data.frame of class ‘coords’ whose columns contain the three coordinates of the atoms of a molecular system. The coordinates can either be Cartesian (basis attribute equal to "xyz") or fractional coordinates (basis attribute equal to "abc").The replacement function returns an object of the same class as x with updated coordinates.is.coords returns TRUE if x is an object of class ‘coords’ and FALSE otherwise

Details

The purpose of the ‘coords’ class is to store the coordinates of a molecular system and facilitate their manipulation when passing from the Cartesian to fractional coordinates and vice versa. coords and coords<- are generic accessor and replacement functions. The default method of the coords function is actually a builder allowing to create a ‘coords’ object from its different components, i.e.: x1, x2, x3, and basis. All the arguments have to be specified except 'basis' which by default is set to "xyz" (Cartesian coordinates).

For an object of class ‘atoms’, the accessor function extracts its x1, x2 and x3 components as well as its basis attribute to create a ‘coords’ object. The replacement function set its x1, x2 and x3 components as well as its basis attribute.

For an object of class ‘pdb’, the accessor function extracts the x1, x2 and x3 components as well as the basis attribute of its atoms component to create a ‘coords’ object. The replacement function set the x1, x2 and x3 components as well as the basis attribute of its atoms component.

For ‘matrix’ and ‘data.frame’ objects, when basis==NULL this function search x, y, z or a, b, c columns in x. If x, y, z columns are found they are used to a set the first, second and third coordinates of the returned ‘coords’ object. In that case the basis set of x is set to "xyz". If a, b, c columns are found they are used to a set the first, second and third coordinates of the returned ‘coords’ object. In that case the basis set of x is set to "abc". If the function doesn't found neither the x, y, z nor the a, b, c columns an error is returned. When basis!=NULL it has to be equal to "xyz" or "abc" and x must have exactly 3 columns.

is.coords tests if x is an object of class ‘coords’, i.e. if x has a “class” attribute equal to coords.

See Also

basis

Examples

Run this code
x <- read.pdb(system.file("examples/PCBM_ODCB.pdb",package="Rpdb"))
is.coords(x)
is.coords(x$atoms)

## Replace the coordinates of x by translated coordinates
coords(x) <- coords(Tz(x, 10))
coords(x)

Run the code above in your browser using DataCamp Workspace