inprogress
[jalview.git] / forester / ruby / evoruby / lib / evo / io / web / uniprotkb.rb
1
2 require 'net/http'
3 require 'uri'
4
5 require 'lib/evo/io/parser/uniprot_parser'
6
7 module Evoruby
8
9
10   class UniprotKB
11
12     BASE_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch?db=uniprotkb;"
13
14
15     def UniprotKB::get_by_id( id, style = "raw", format = "uniprot" )
16       url_str = BASE_URL + "id=#{id};format=#{format};style=#{style}"
17       uri = URI.parse url_str
18       response = Net::HTTP.get_response uri
19       lines = []
20       response.body.each_line do |line|
21         lines << line
22         puts line
23       end
24       lines
25     end
26
27
28     def UniprotKB::get_entry_by_id( id  )
29       lines = get_by_id( id,  "raw", "uniprot" )
30       p = UniprotParser.new
31       return p.parse( lines )
32     end
33
34   end
35
36 end