Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Last active August 29, 2015 14:27
Show Gist options
  • Save pepijn-devries/bf82ff25886ab9c800ce to your computer and use it in GitHub Desktop.
Save pepijn-devries/bf82ff25886ab9c800ce to your computer and use it in GitHub Desktop.
# create a data.frame with atom properties
atom.props <- data.frame(
symbol = c("O", "N", "C", "H"),
vanderwaals = c(1.52, 1.55, 1.7, 1.2), #Van der Waals radii of atoms
colour = c("red", "blue", grey(0.1), "white")
)
# get atoms from the molecule
atoms <- get.atoms(molfile)
# get 3D locations of atoms as read from the file
atom_dat <- data.frame(do.call('rbind', lapply(atoms, get.point3d)))
names(atom_dat) <- c("x", "y", "z")
# merge with atom info
atom_dat$symbol <- unlist(lapply(atoms, get.symbol))
atom_dat <- merge(atom_dat, atom.props, all.x = T, all.y = F)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment