how to load a local pdb files

Issue #288 resolved
rene created an issue

I'm trying make a dendrogram with pdb files, but i cant load my local edited pdb files, how can i do this? thanks

Comments (13)

  1. Barry Grant

    Basically, just use their file names as input to the read.pdb() or pdbaln() functions. The first will read individual files (so you could apply it in a loop for example) the second will read all your files and then align them (useful if there sequences are different or they are of different length etc.). Here is an example of a few ways to do this:

    library(bio3d)
    # make a vector of *.pdb file names from the contents of the current directory
    myFileNames = list.files(path=".", pattern=".pdb")
    
    # option 1. read each file individually (not tractable if you have lots of files obviously)
    pdb.1 <- read.pdb(myFileNames[1])
    pdb.2 <- read.pdb(myFileNames[1]) ## etc... see option 3 for example of putting this in a loop
    
    # option 2. read and align all structures
    pdbs = pdbaln(myFileNames)
    
    # option 3. if they are of identical composition and you only want xyz coordinates
    xyz <- NULL
    for(i in myFileNames) {
       xyz = rbind(xyz, read.pdb(myFileNames)$xyz)
    }
    
    # you can also use the apply function if you are familiar with that instead of the 'for loop' above
    

    Also note that if your structure composition is identical in each file it is often easier to concatenate into one multi-model file and read in one go with a single call to read.pdb() whilst using the multi=TURE option.

    This tutorial will be helpful in this regard: http://thegrantlab.org/bio3d/tutorials/structure-analysis

  2. rene reporter

    Hi Barry, Thank you for the answer. I could able to load the pdb files locally.

    myfiles <- list.files(path="C:/Users/rsepulveda/Desktop/structuras_para_dendograma/pdbcortados", pattern=".pdb") pdbs = pdbaln(myfiles, exefile="C:/Users/rsepulveda/Downloads/muscle3.8.31_i86win32.exe") Reading PDB files:

    Error in if (substr(file, 1, 4) == "http") { : missing value where TRUE/FALSE needed

  3. rene reporter
    > myfiles <- list.files(path="C:/Users/rsepulveda/Desktop/structuras_para_dendograma/pdbcortados", pattern=".pdb")
    
    > pdbs = pdbaln(myfiles, exefile="C:/Users/rsepulveda/Downloads/muscle3.8.31_i86win32.exe")
    
    Reading PDB files:
    
    Error in if (substr(file, 1, 4) == "http") { : 
    missing value where TRUE/FALSE needed
    
  4. Lars Skjærven

    Can you output the content of myfiles here? e.g. the first few elements of the vector?

    Can you also report the output of

    head(readLines(myfiles[1]))
    

    you can also try

    read.pdb(myfiles[1])
    
  5. rene reporter

    ok, it was a R problem running in win7, you must run R like administrator, that is all, I hate win in all her versions. thank to all

  6. rene reporter
    4QJY.pdb
    > myfiles <- list.files(path="C:/structurasparadendograma/cortados", pattern=".pdb")
    > pdbs = pdbaln(myfiles, exefile="C:/Users/rsepulveda/Downloads/muscle3.8.31_i86win32.exe")
      Note: Accessing online PDB files using 4 letter PDBID
    Error in pdbaln(myfiles, exefile = "C:/Users/rsepulveda/Downloads/muscle3.8.31_i86win32.exe") : 
       ** Missing files: check filenames
    2GSA.pdb
    2VPW.pdb
    2YEA.pdb
    2YED.pdb
    3AYA.pdb
    3DTA.pdb
    3MKA.p
    
  7. Xinqiu Yao

    Hi,

    Can you print out the content of 'myfiles'? Just make sure the variable has desired values. Also note that by default list.files() returns just file names without path prefix (see help(list.files)). A proper way could be

    myfiles <- list.files(path="C:/structurasparadendograma/cortados", pattern=".pdb", full.names=TRUE)
    
  8. Log in to comment