How to subset a PDB by range of residue

Issue #850 resolved
Edward Wijaya created an issue

I have the attached PDB file.

The PDB read out with this code:

library(bio3d)
pdb_file <- "test.pdb"
pdb <- read.pdb(pdb_file)
pdb

looks like this:

    Call:  read.pdb(file = pdb_file)

   Total Models#: 1
     Total Atoms#: 712,  XYZs#: 2136  Chains#: 1  (values: A)

     Protein Atoms#: 712  (residues/Calpha atoms#: 44)
     Nucleic acid Atoms#: 0  (residues/phosphate atoms#: 0)

     Non-protein/nucleic Atoms#: 0  (residues: 0)
     Non-protein/nucleic resid values: [ none ]

   Protein sequence:
      MGKGDPKKPRGKMSSYAFFVQTCREEHKKKHPDASVNFSEFSKK

+ attr: atom, xyz, calpha, call

What I want to do is to extract first 10 amino acid sequenceMGKGDPKKPR from MGKGDPKKPRGKMSSYAFFVQTCREEHKKKHPDASVNFSEFSKK (full) as PDB.
The final PDB is to include all atoms.

But with this code:

p1_sele <- atom.select(pdb, "protein", chain="A", resno = 1:10)
trim.pdb(pdb, p1_sele)

I only get MGK.

Call:  trim.pdb(pdb = pdb, p1_sele)

   Total Models#: 1
     Total Atoms#: 46,  XYZs#: 138  Chains#: 1  (values: A)

     Protein Atoms#: 46  (residues/Calpha atoms#: 3)
     Nucleic acid Atoms#: 0  (residues/phosphate atoms#: 0)

     Non-protein/nucleic Atoms#: 0  (residues: 0)
     Non-protein/nucleic resid values: [ none ]

   Protein sequence:
      MGK

+ attr: atom, helix, sheet, seqres, xyz,
        calpha, call

What’s the right way to do it?

Comments (9)

  1. Edward Wijaya reporter

    Thanks Xinqiu. I got it.
    By the way is there a way using Bio3D to renumber the residue number from 8 to 1
    on my test.pdb?

  2. Edward Wijaya reporter

    Xinqiu, I appreciate your prompt reply.

    What’s the difference of your suggestion with convert.pdb(pdb, type = "pdb", renumber = TRUE, first.resno = 1)?
    Which is safer?

  3. Xinqiu Yao

    They are the same effect. clean.pdb() does more checking and you may ignore some of the warnings (if there are any).

  4. Log in to comment