- edited description
Help with calculating angles between atoms
I was wondering how I would go about calculating the angles for a list of pdbs? I am sure there is a way to do it using one line but I can't seem to figure it out.
############
library(bio3d)
ids<-list.files(path="pdbs/",pattern=".pdb$")
pdbfiles <-paste("pdbs/",ids, sep = "")
pdbs <- lapply(pdbfiles, function(i) read.pdb(i)$xyz)
pdb <- read.pdb("pdbs/output")
a.inds<-atom.select(pdb,resid = "TYR",resno=9,elety=c("OH","HH"))
b.inds<-atom.select(pdb,resid = "BCL",resno=362,elety=c("OBB"))
c.inds<-a.inds
c.inds$atom <- c(a.inds$atom,b.inds$atom)
c.inds$xyz <- c(a.inds$xyz,b.inds$xyz)
TYR15_BCL3 <- lapply(pdbs, function(i) angle.xyz((i)$xyz[c.inds$xyz]))
####################
Many thanks,
Alexander
Comments (7)
-
-
Hi Alexander,
Can you check what pdbs contains by typing e.g.
pdbs[[1]]
? By the last line of above commands, you probably expected it is a list of 'pdb' objects. Also, check the error message (if any) carefully to find out the possible reason (Paste it here if you have no idea what it means). Let me know what you get. -
If all your input PDB files have the same number of atoms in the same order you could combine them to a single multi-model PDB file from the command line and then use read.pdb() with the multi=TRUE option. Then angle.xyz() should work across all your coordinates by itself.
If you provide small same input files we could help further perhaps
-
reporter pdbs1
Total Frames#: 1 Total XYZs#: 64989, (Atoms#: 21663)
[1] 59.424 74.502 72.239 <...> 82.877 85.838 42.51 [64989]
I get the error message ( which I missed before);
Error in (i)$xyz : $ operator is invalid for atomic vectors
-
reporter Ah, needed to change
TYR15_BCL3 <- lapply(pdbs, function(i) angle.xyz((i)$xyz[c.inds$xyz]))
to
TYR15_BCL3 <- lapply(pdbs, function(i) angle.xyz((i)[c.inds$xyz]))
Thank you for your help,
Alexander
-
- changed status to resolved
-
- changed version to v2.2
- Log in to comment