- marked as task
reading multiple PDB files with Bio3D
I would like to read the multiple PDB files from a folder and would like to calculate the radius of gyration of each PDB file.
I calculated the radius of of gyration for a single file using the following program.
data<- read.pdb("/home/sanvi/Desktop/4q21.pdb")
mass <- rep(12, length(data$xyz)/3)
rgyr(data, mass)
For multiple files, I used the following code.
list <- list.files(path="/home/sanvi/Desktop/pdbs", pattern=".pdb")
for(i in 1:length(list)){
d2 = read.pdb(list[i])
mass <- rep(12, length(d2$xyz)/3
rgyr(d2,mass)}
Error: unexpected symbol in:
"
rgyr"
How can I calculate the radius of gyration for multiple PDB files?
Comments (12)
-
reporter -
reporter - edited description
-
reporter - edited description
-
reporter - marked as critical
-
Hi,
Please check your codes carefully and make sure they are free of bugs. For example, you may need full.names=TRUE in list.files(). Also, you have missed a ")" in "mass <- ...".
Another (faster) way is using lapply to loop over all pdb files. For example,
files <- list.files('/home/sanvi/Desktop', '.*\\.pdb$', full.names=TRUE) rgs <- lapply(files, function(x) { data <- read.pdb(x) mass <- rep(12, length(data$xyz)/3) rgyr(data, mass) })
-
- changed status to resolved
See duplicated issue
#337 -
- changed status to open
Sorry Barry, I've closed issue
#337for the same reason and replied in this issue... -
reporter Thank you Xin-Qiu Yao for your help!
-
reporter Hi Xin-Qiu Yao,
Thank you very much for your help! When I tried your code, I get the following error.
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : scan() expected 'a real', got '3-0.52'
-
Hi,
Make sure the files contains the pdb files you want. The code I showed above was just an example and you need to check e.g. the path is exactly where you stored your pdb files!
-
- marked as trivial
-
- changed status to resolved
- Log in to comment