Naohisa Goto edited this page Jun 14, 2016 · 1 revision

PDB is Protein Data Bank, which stores many atomic coordinates of biological molecules. http://www.pdb.org/

Fetching PDB using ruby

Following program can be used to obtain and save a pdb entry.

module Bio
  class PDB
    def PDB.fetch(id)
      serv = Bio::Fetch.new("http://www.ebi.ac.uk/cgi-bin/dbfetch")
      entry = serv.fetch('pdb', id)
      return nil if entry[0,5].downcase == 'error'
      return nil if entry[0,10].downcase == 'no entries'
      # get header
      pdb = Bio::PDB.new(entry)
      return pdb
    end

    def save(filename)
      fp = File.open(filename, "w")
      fp << self.to_s
      fp.close
    end
  end
end


pdb = Bio::PDB.fetch(ARGV[0])
pdb.save(ARGV[0] + ".pdb")
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.