Using the R package bio3d
I would like to draw bonds between two atoms on a protein and parse the structure to PyMOL using the pymol()
.
library(bio3d)
# Import PDB file
pdb <- read.pdb( system.file("examples/1hel.pdb", package="bio3d") )
# Atom 1
sele.1 <- atom.select(pdb, "calpha", resno=43, verbose=TRUE)
# Atom 2
sele.2 <- atom.select(pdb, "calpha", resno=54, verbose=TRUE)
In this example I would like to draw a bond/tangent/line between atoms sele.1
and sele.2
- a fairly trivial problem, is this possible?
It is possible to parse a PyMOL script from R:
# Return a string of commands to draw
pymol.bond.sele.command = function(atom1, atom2, nbond, chainID){
# return PyMOL command to draw a bond between atoms 1 and 2
return(paste(paste('distance ', paste('mydist', nbond, ', ', sep=''),
'chain ', pymolchain, ' and ', atom1, '/CA, ', 'chain ', pymolchain, ' and ', atom2, '/CA', sep='')))
}
> pymol.bond.sele.command(43, 54, 1, A)
[1] distance mydist1, chain A and 43/CA, chain A and 54/CA
Copy output of pymol.bond.sele.command()
into the PyMOL terminal.
To remove the distance label:
pymol.bond.lab.rm.command = function(nbond, chainID){
# return PyMOL command to remove the distance label drawn for distance element x
return(paste('hide labels, mydist', nbond, sep=''))
}
> pymol.bond.lab.rm.command(1, A)
[1] hide labels, mydist1
Copy output of pymol.bond.lab.rm.command()
into the PyMOL terminal.