[BioRuby] bio.pdb doubt

Naohisa Goto ngoto at gen-info.osaka-u.ac.jp
Thu Feb 14 09:29:57 UTC 2008


Hi,

> I am currently looking for a simple way to extract pdb co-ordinates from a
> pdb file by using any inbuilt menthods available in bioruby.
> 
> For example, I need to extract a particular region of a PDB file with
> multiple  chains ; say A:22 to B:50 (22 and 50 are residue numbers). Is
> there any method in bio.pdb class to do this ?

You can use Bio::PDB#find_atom or Bio::PDB#find_residue methods.

  require 'bio'

  # reading PDB data
  pdb = Bio::FlatFile.open("pdb1a0d.ent") { |f| f.next_entry }

  # using Bio::PDB#find_atom
  atoms = pdb.find_atom do |atom|
    (atom.chainID == "A" and atom.resSeq >= 22) or
    (atom.chainID == "B" and atom.resSeq <= 50)
  end
  print atoms.to_s

  print "\n"

  # the same thing can be done by using Bio::PDB#find_residue
  residues = pdb.find_residue do |residue|
    (residue.chain.id == "A" and residue.resSeq >= 22) or
    (residue.chain.id == "B" and residue.resSeq <= 50)
  end
  print residues.to_s


-- 
Naohisa Goto 
ngoto at gen-info.osaka-u.ac.jp / ng at bioruby.org





More information about the BioRuby mailing list