[BioRuby-cvs] bioruby/lib/bio/io fetch.rb,1.2,1.3
Katayama Toshiaki
k at pub.open-bio.org
Sun Nov 27 21:02:40 EST 2005
Update of /home/repository/bioruby/bioruby/lib/bio/io
In directory pub.open-bio.org:/tmp/cvs-serv8180/bio/io
Modified Files:
fetch.rb
Log Message:
* converted to RDoc format
* databases, formats, maxids methods are added
Index: fetch.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fetch.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** fetch.rb 21 Feb 2004 19:40:34 -0000 1.2
--- fetch.rb 28 Nov 2005 02:02:38 -0000 1.3
***************
*** 1,6 ****
#
! # bio/io/biofetch.rb - BioFetch access module
#
! # Copyright (C) 2002 KATAYAMA Toshiaki <k at bioruby.org>
#
# This library is free software; you can redistribute it and/or
--- 1,12 ----
#
! # = bio/io/biofetch.rb - BioFetch access module
#
! # Copyright:: Copyright (C) 2002, 2005
! # Toshiaki Katayama <k at bioruby.org>
! # Licence:: LGPL
! #
! # $Id$
! #
! #--
#
# This library is free software; you can redistribute it and/or
***************
*** 18,22 ****
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! # $Id$
#
--- 24,28 ----
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! #++
#
***************
*** 26,57 ****
module Bio
! class Fetch
! def initialize(url = 'http://bioruby.org/cgi-bin/biofetch.rb')
! schema, user, @host, @port, reg, @path, = URI.split(url)
! end
! attr_accessor :database
! def get_by_id(id)
! fetch(@database, id)
! end
! def fetch(db, id, style = 'raw', format = nil)
! data = [ "db=#{db}", "id=#{id}", "style=#{style}" ]
! data.push("format=#{format}") if format
! data = data.join('&')
! responce, result = Net::HTTP.new(@host, @port).post(@path, data)
! return result
! end
! def self.query(*args)
! self.new.fetch(*args)
end
end
end
--- 32,97 ----
module Bio
! class Fetch
! # Create a new Bio::Fetch server object.
! # Use Bio::Fetch.new('http://www.ebi.ac.uk/cgi-bin/dbfetch') to connect
! # to EBI BioFetch server.
! def initialize(url = 'http://bioruby.org/cgi-bin/biofetch.rb')
! schema, user, @host, @port, reg, @path, = URI.split(url)
! end
! # Set default database to dbname (prepare for get_by_id).
! attr_accessor :database
! # Get raw database entry by id (mainly used by Bio::Registry).
! def get_by_id(id)
! fetch(@database, id)
! end
! # Fetch a database entry as specified by database (db), entry id (id),
! # 'raw' text or 'html' (style), and format. When using BioRuby's
! # BioFetch server, value for the format should not be set.
! def fetch(db, id, style = 'raw', format = nil)
! data = [ "db=#{db}", "id=#{id}", "style=#{style}" ]
! data.push("format=#{format}") if format
! data = data.join('&')
! responce, result = Net::HTTP.new(@host, @port).post(@path, data)
! return result
! end
!
! # Short cut for using BioRuby's BioFetch server. You can fetch an entry
! # without creating instance of BioFetch server.
! def self.query(*args)
! self.new.fetch(*args)
! end
!
! # What databases are available?
! def databases
! query = "info=dbs"
! responce, result = Net::HTTP.new(@host, @port).post(@path, query)
! return result
! end
!
! # What formats does the database X have?
! def formats(database = @database)
! if database
! query = "info=formats;db=#{database}"
! responce, result = Net::HTTP.new(@host, @port).post(@path, query)
! return result
end
+ end
+ # How many entries can be retrieved simultaneously?
+ def maxids
+ query = "info=maxids"
+ responce, result = Net::HTTP.new(@host, @port).post(@path, query)
+ return result
end
end
+ end # module Bio
+
***************
*** 72,104 ****
end
-
- =begin
-
- = Bio::Fetch
-
- --- Bio::Fetch.new(url = 'http://bioruby.org/cgi-bin/biofetch.rb')
-
- Use Bio::Fetch.new('http://www.ebi.ac.uk/cgi-bin/dbfetch') to connect
- to EBI BioFetch server.
-
- --- Bio::Fetch#fetch(db, id, style = 'raw', format = nil)
-
- Fetch a database entry as specified by database (db), entry id (id),
- 'raw' text or 'html' (style), and format. When using BioRuby's
- BioFetch server, value for the format should not be set.
-
- --- Bio::Fetch#database=(dbname)
-
- Set default database to dbname (prepare for get_by_id).
-
- --- Bio::Fetch#get_by_id(id)
-
- Get raw database entry by id (mainly used by Bio::Registry).
-
- --- Bio::Fetch.query(db, id, style = 'raw', format = nil)
-
- Short cut for using BioRuby's BioFetch server. You can fetch an entry
- without creating instance of BioFetch server.
-
- =end
--- 112,114 ----
More information about the bioruby-cvs
mailing list