atom2mass | R Documentation |
Convert atom names/types into atomic masses.
atom2mass(...)
## Default S3 method:
atom2mass(x, mass.custom=NULL, elety.custom=NULL,
grpby=NULL, rescue=TRUE, ...)
## S3 method for class 'pdb'
atom2mass(pdb, inds=NULL, mass.custom=NULL,
elety.custom=NULL, grpby=NULL, rescue=TRUE, ...)
x |
a character vector containing atom names/types to be converted. |
mass.custom |
a customized data.frame containing atomic symbols and corresponding masses. |
elety.custom |
a customized data.frame containing atom names/types and corresponding atomic symbols. |
grpby |
a ‘factor’, as returned by |
rescue |
logical, if TRUE the atomic symbols will be mapped to the first character of the atom names/types. |
pdb |
an object of class ‘pdb’ for which |
inds |
an object of class ‘select’ indicating a subset of
the |
... |
. |
The default method first convert atom names/types into atomic symbols
using the atom2ele
function. Then, atomic symbols are
searched in the elements
data set and their corresponding masses
are returned. If mass.custom
is specified it is combined with
elements
(using rbind
) before searching. Therefore,
mass.custom
must have columns named symb
and mass
(see examples). If grpby
is specified masses are splitted (using
split
) to compute the mass of groups of atoms defined by
grpby
.
The S3 method for object of class ‘pdb’, pass
pdb$atom$elety
to the default method.
Return a numeric vector of masses.
Julien Ide, Lars Skjaerven
elements
, atom.index
,
atom2ele
, read.pdb
atom.names <- c("CA", "O", "N", "OXT")
atom2mass(atom.names)
# PDB server connection required - testing excluded
try({
## Get atomic symbols from a PDB object with a customized data set
pdb <- read.pdb("3RE0", verbose=FALSE)
inds <- atom.select(pdb, resno=201, verbose=FALSE)
## selected atoms
print(pdb$atom$elety[inds$atom])
## default will map CL2 to C
atom2mass(pdb, inds)
## map element CL2 correctly to Cl
myelety <- data.frame(name = c("CL2","PT1","N1","N2"), symb = c("Cl","Pt","N","N"))
atom2mass(pdb, inds, elety.custom = myelety)
## custom masses
mymasses <- data.frame(symb = c("Cl","Pt"), mass = c(35.45, 195.08))
atom2mass(pdb, inds, elety.custom = myelety, mass.custom = mymasses)
}, silent=TRUE)
if(inherits(.Last.value, "try-error")) {
message("Need internet to run the example")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.