atom2mass(...) "atom2mass"(x, mass.custom=NULL, elety.custom=NULL, grpby=NULL, rescue=TRUE, ...) "atom2mass"(pdb, inds=NULL, mass.custom=NULL, elety.custom=NULL, grpby=NULL, rescue=TRUE, ...)
as.factor, used
to group the atoms.elety will
be converted.pdb object to be used (see atom.select and
trim.pdb).Convert atom names/types into atomic masses.
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.
atom.names <- c("CA", "O", "N", "OXT") atom2mass(atom.names)[1] 12.0107 15.9994 14.0067 15.9994# PDB server connection required - testing excluded ## Get atomic symbols from a PDB object with a customized data set pdb <- read.pdb("3RE0", verbose=FALSE)Note: Accessing on-line PDB file PDB has ALT records, taking A only, rm.alt=TRUEinds <- atom.select(pdb, resno=201, verbose=FALSE) ## selected atoms print(pdb$atom$elety[inds$atom])[1] "PT1" "N1" "N2" "CL2"## default will map CL2 to C atom2mass(pdb, inds)Warning message: unknown element: mapped PT1 to P unknown element: mapped N1 to N unknown element: mapped N2 to N unknown element: mapped CL2 to C[1] 30.97376 14.00670 14.00670 12.01070## 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)[1] 195.0780 14.0067 14.0067 35.4530## custom masses mymasses <- data.frame(symb = c("Cl","Pt"), mass = c(35.45, 195.08)) atom2mass(pdb, inds, elety.custom = myelety, mass.custom = mymasses)[1] 195.0800 14.0067 14.0067 35.4500