atom.select() residues that are inserts

Issue #373 resolved
Mark Sun created an issue

atom.select() does not appear to enable the selection of a single residue that is an insert.

So selecting just by the chain & resno ends up selecting more than one residue.

Comments (10)

  1. Lars Skjærven

    Hi Mark, Thanks for reporting. We've been discussing if we should include an insert argument in the atom.select function. What do you and others think about the following addition:

    > pdb = read.pdb("1fuj")
    > pdb = trim(pdb, chain="A")
    
    # inserts at resi 186 (default behavior)
    > sele = atom.select(pdb, resno=186, insert=NULL)
    > pdb$atom$insert[ sele$atom ]
     [1] NA  NA  NA  NA  NA  NA  NA  "A" "A" "A" "A" "A" "A" "A" "A" "A" "A" "A" "B"
    [20] "B" "B" "B" "B" "B" "B" "B" "B" "B" "B"
    
    # specify insert = NA
    > sele = atom.select(pdb, resno=186, insert=NA)
    > pdb$atom$insert[ sele$atom ]
    [1] NA NA NA NA NA NA NA
    
    # specify insert = "A"
    > sele = atom.select(pdb, resno=186, insert="A")
    > pdb$atom$insert[ sele$atom ]
     [1] "A" "A" "A" "A" "A" "A" "A" "A" "A" "A" "A"
    
  2. Lars Skjærven

    so that

    atom.select(pdb, resno=186, insert="")
    
    # equals to 
    atom.select(pdb, resno=186, insert=NA)
    

    ?

  3. Lars Skjærven

    Updated function in commit https://bitbucket.org/Grantlab/bio3d/commits/c14466a8c7a66adad689e39e26df2b9cfa7e5c4e (sorry I didn't see your comment before pushing the commit).

    Default value is insert = NULL which will select both inserts and non-insert residues.

    > pdb$atom[ atom.select(pdb, "calpha", resno=186, insert="")$atom, 1:8]
         type eleno elety  alt resid chain resno insert
    1260 ATOM  1260    CA <NA>   PRO     A   186   <NA>
    
    
    > pdb$atom[ atom.select(pdb, "calpha", resno=186, insert=NA)$atom, 1:8]
         type eleno elety  alt resid chain resno insert
    1260 ATOM  1260    CA <NA>   PRO     A   186   <NA>
    
    
    > pdb$atom[ atom.select(pdb, "calpha", resno=186, insert=NULL)$atom, 1:8]
         type eleno elety  alt resid chain resno insert
    1260 ATOM  1260    CA <NA>   PRO     A   186   <NA>
    1267 ATOM  1267    CA <NA>   ARG     A   186      A
    1278 ATOM  1278    CA <NA>   ARG     A   186      B
    
    # same as
    > pdb$atom[ atom.select(pdb, "calpha", resno=186, insert=c(NA, "A", "B"))$atom, 1:8]
         type eleno elety  alt resid chain resno insert
    1260 ATOM  1260    CA <NA>   PRO     A   186   <NA>
    1267 ATOM  1267    CA <NA>   ARG     A   186      A
    1278 ATOM  1278    CA <NA>   ARG     A   186      B
    
    > pdb$atom[ atom.select(pdb, "calpha", resno=186, insert=c("A", "B"))$atom, 1:8]
         type eleno elety  alt resid chain resno insert
    1267 ATOM  1267    CA <NA>   ARG     A   186      A
    1278 ATOM  1278    CA <NA>   ARG     A   186      B
    
  4. Mark Sun reporter

    I agree with setting insert = NULL as the default.

    Thanks for committing the fix. You guys are super fast at responding to requests / bugs, that it is impressive.

  5. Log in to comment