| split.pdb | R Documentation |
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 |
... |
further potential arguments passed to methods. |
value |
a list of 'pdb' objects compatible with a splitting of
|
split produce a list of ‘pdb’ objects with the same
crystal, title and remark components as x. Only
its atoms component is split while its connect 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 crystal, title and remark components
as the first element of value. The atoms and connect
components of all the elements of value are combined by row.
split returns 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.
split, unsplit, pdb
### Split a pdb file by residue IDs and write them into separate 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)
length(pdb.resid)
useless <- mapply(write.pdb, pdb.resid, file.names)
# Cleanup
unlink(file.names)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.