Module: Bio::FANTOM

Defined in:
lib/bio/db/fantom.rb

Defined Under Namespace

Classes: MaXML

Class Method Summary collapse

Class Method Details

.get_by_id(idstr, http_proxy = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bio/db/fantom.rb', line 30

def get_by_id(idstr, http_proxy = nil)
  addr = 'fantom.gsc.riken.go.jp'
  port = 80
  path = "/db/maxml/maxmlseq.cgi?masterid=#{CGI.escape(idstr.to_s)}&style=xml"
  xml = ''
  if http_proxy then
    proxy = URI.parse(http_proxy.to_s)
    Net::HTTP.start(addr, port, proxy.host, proxy.port) do |http|
      response = http.get(path)
      xml = response.body
    end
  else
    Bio::Command.start_http(addr, port) do |http|
      response = http.get(path)
      xml = response.body
    end
  end
  xml
end

.query(idstr, http_proxy = nil) ⇒ Object



23
24
25
26
27
# File 'lib/bio/db/fantom.rb', line 23

def query(idstr, http_proxy = nil)
  xml = get_by_id(idstr, http_proxy)
  seqs = MaXML::Sequences.new(xml.to_s)
  seqs[0]
end