reading multiple PDB files with Bio3D

Issue #337 resolved
sanvi created an issue

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(d2, mass)

How can I calculate the radius of gyration for multiple PDB files?

Comments (2)

  1. Xinqiu Yao

    Hi,

    The simplest 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)
    })
    
  2. Log in to comment