Divide and Reassemble ‘pdb’ Objects
split
divides a ‘pdb’ object by groups of atoms defined by
f
. unsplit
reverses the effect of split
.
## S3 method for class 'pdb' split(x, f, drop = FALSE, ...) ## S3 method for class 'pdb' unsplit(value, f, drop = FALSE, ...)
x |
an object of class ‘pdb’ to be divided into groups. |
f |
a ‘factor’ in the sense that
|
drop |
logical indicating if levels that do not occur should be
dropped (if |
value |
a list of 'pdb' objects compatible with a splitting of
|
... |
further potential arguments passed to methods. |
split
produce a list of ‘pdb’ objects with the same
cryst1
, title
and remark
components as x
. Only
its atoms
component is splitted while its conect
component is
cleaned to keep only the meaningful connectivity for each ‘pdb’ object
of the list returned by the function. unlist
produce a ‘pdb’
object with the same cryst1
, title
and remark
components
as the first element of value
. The atoms
and conect
components of all the elements of value
are combined by row.
The value returned from split
is a list of ‘pdb’
objects containing the data for the groups of atoms. The components of the
list are named by the levels of f
(after converting to a factor, or if
already a factor and drop=TRUE
, dropping unused levels). unsplit
returns a ‘pdb’ object for which split(x, f)
equals value
.
## Not run: ## Split a pdb file by residue IDs and write them into separated files x <- read.pdb(system.file("examples/PCBM_ODCB.pdb",package="Rpdb")) file.names <- paste0(x$atoms$resname,"_",x$atoms$resid,".pdb") file.names <- unique(file.names) pdb.resid <- split(x, x$atoms$resid) useless <- mapply(write.pdb, pdb.resid, file.names) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.