Model selection (suggestion)

Issue #415 resolved
Former user created an issue

Hi! I am working with the read.pdb&read.cif functions of the package (v2.3) and different NMR structures (e.g.2mf1 and others). My interest is to load only the second/third... model (one at a time). I've seen the "multi" argument of these functions, but after reading the data into R, all the models are concatenated. The way I solved this is cutting the input PDB file to keep only the model I want, but it would be really nice if these functions could have an additional argument to select directly the model of interest (or maybe an additional column in the object$atom records with the model number to make it easier to subset). Thanks in advance and hope this suggestion is useful to other users also!

Comments (2)

  1. Lars Skjærven

    Hi, The coordinates of the different models are stored in a simple matrix where models are stored row-wise, i.e. you can obtain model 1 by accessing row 1. Quick example below:

    > library(bio3d)
    > pdb <- read.pdb("2mf1", multi=TRUE)
      Note: Accessing on-line PDB file
    
    # 20 frames or models in pdb object
    > dim(pdb$xyz)
    [1]    20 23556
    
    # coordinates for model 1
    > pdb$xyz[1, ]
    
    # store only model #1 in pdb object
    > xyz <- pdb$xyz
    > pdb$xyz <- trim(xyz, row.inds=1)
    
    # store only model 2 in pdb object
    > pdb$xyz <- trim(xyz, row.inds=2)
    

    Hope it helps. L

  2. Barry Grant

    As Lars states we store coordinates for all models so you just have to use the model number you want as the row.inds for trim.pdb(), or indeed directly on the $xyz component returned from read.pdb() etc., to get the coords you are after.

    marking as resolved - reopen if this is now what you intended.

  3. Log in to comment