Convert atom names/types into atomic symbols


# S3 method for default
atom2ele(x, elety.custom=NULL, rescue=TRUE, ...)

# S3 method for pdb
atom2ele(pdb, inds=NULL, ...)



a character vector containing atom names/types to be converted.


a customized data.frame containing atom names/types and corresponding atomic symbols.


logical, if TRUE the atomic symbols will be converted based on matching with bio3d::elements$symb.


an object of class ‘pdb’ for which elety will be converted.


an object of class ‘select’ indicating a subset of the pdb object to be used (see and trim.pdb).


further arguments passed to or from other methods.


The default method searchs for the atom names/types in the atom.index data set and returns their corresponding atomic symbols. If elety.custom is specified it is combined with atom.index (using rbind) before searching. Therefore, elety.custom must contains columns named name and symb.

The S3 method for object of class ‘pdb’, pass pdb$atom[,"elety"] to the default method.


Return a character vector of atomic symbols


Julien Ide, Lars Skjaerven

See also


atom.names <- c("CA", "O", "N", "OXT") atom2ele(atom.names)
#> [1] "C" "O" "N" "O"
# \donttest{ # 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=TRUE
lig <- trim(pdb, "ligand") ## maps PT1 to Pt, CL2 to Cl, C4A to C atom2ele(lig)
#> Warning: #> mapped element PT1 to Pt #> mapped element N1 to N #> mapped element N2 to N #> mapped element CL2 to Cl
#> [1] "Pt" "N" "N" "Cl" "Pt" "N" "N" "Cl"
## map atom name to element manually myelety <- data.frame(name = "CL2", symb = "Cl") atom2ele(lig, elety.custom = myelety)
#> Warning: #> mapped element PT1 to Pt #> mapped element N1 to N #> mapped element N2 to N
#> [1] "Pt" "N" "N" "Cl" "Pt" "N" "N" "Cl"
# }