# NOT RUN {
## Calculate torsions for cis & trans conformers
xyz <- rbind(c(0,-0.5,0,1,0,0,1,1,0,0,1.5,0),
c(0,-0.5,0,1,0,0,1,1,0,2,1.5,0)-3)
cis.tor <- torsion.xyz( xyz[1,] )
trans.tor <- torsion.xyz( xyz[2,] )
apply(xyz, 1, torsion.xyz)
plot(range(xyz), range(xyz), xlab="", ylab="", typ="n", axes=FALSE)
apply(xyz, 1, function(x){
lines(matrix(x, ncol=3, byrow=TRUE), lwd=4)
points(matrix(x, ncol=3, byrow=TRUE), cex=2.5,
bg="white", col="black", pch=21) } )
text( t(apply(xyz, 1, function(x){
apply(matrix(x, ncol=3, byrow=TRUE)[c(2,3),], 2, mean) })),
labels=c(0,180), adj=-0.5, col="red")
# }
# NOT RUN {
# PDB server connection required - testing excluded
##-- PDB torsion analysis
pdb <- read.pdb("1bg2")
tor <- torsion.pdb(pdb)
## basic Ramachandran plot
plot(tor$phi, tor$psi)
## torsion analysis of a single coordinate vector
inds <- atom.select(pdb,"calpha")
tor.ca <- torsion.xyz(pdb$xyz[inds$xyz], atm.inc=3)
##-- Compare two PDBs to highlight interesting residues
aln <- read.fasta(system.file("examples/kif1a.fa",package="bio3d"))
m <- read.fasta.pdb(aln)
a <- torsion.xyz(m$xyz[1,],1)
b <- torsion.xyz(m$xyz[2,],1)
## Note the periodicity of torsion angles
d <- wrap.tor(a-b)
plot(m$resno[1,],d, typ="h")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab