Class: Bio::GGGenome
- Inherits:
-
Object
- Object
- Bio::GGGenome
- Defined in:
- lib/bio-gggenome/gggenome.rb
Overview
Bio::GGGenome
gggenome = Bio::GGGenome.new hits = gggenome.search(“hg19”, 1, “TTCATTGACAACATT”) hits = gggenome.search(“hg19”, “TTCATTGACAACATT”) hits = gggenome.search(“TTCATTGACAACATT”)
hits = Bio::GGGenome.search(“hg19”, “TTCATTGACAACATT”)
Constant Summary collapse
- BASE_URL =
"http://gggenome.dbcls.jp"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uri = BASE_URL) ⇒ GGGenome
constructor
A new instance of GGGenome.
-
#search(*args) ⇒ Object
Search, returns a result hash.
Constructor Details
#initialize(uri = BASE_URL) ⇒ GGGenome
Returns a new instance of GGGenome.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bio-gggenome/gggenome.rb', line 24 def initialize(uri = BASE_URL) uri = URI.parse(uri) unless uri.kind_of?(URI) @pathbase = uri.path @pathbase = '/' + @pathbase unless /\A\// =~ @pathbase @pathbase = @pathbase + '/' unless /\/\z/ =~ @pathbase @http = Bio::Command.new_http(uri.host, uri.port) @header = { 'User-Agent' => "BioRuby/#{Bio::BIORUBY_VERSION_ID}" } end |
Class Method Details
.search(*args) ⇒ Object
20 21 22 |
# File 'lib/bio-gggenome/gggenome.rb', line 20 def self.search(*args) new.search(args) end |
Instance Method Details
#search(*args) ⇒ Object
Search, returns a result hash. Bio::GGGenome#search(“hg19”, 1, “TTCATTGACAACATT”) Bio::GGGenome#search(“hg19”, “TTCATTGACAACATT”) Bio::GGGenome#search(1, “TTCATTGACAACATT”) Bio::GGGenome#search(“TTCATTGACAACATT”) Bio::GGGenome#search(“gggenome.dbcls.jp/hg19/TTCATTGACAACATTGCGT.json”)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bio-gggenome/gggenome.rb', line 41 def search(*args) db = nil missmatch = nil if args[0] =~ /^http/ args[0].sub!(BASE_URL, '') args[0].sub!(/^\//,'') args[0].sub!(".json", '') args = args[0].split("/") end case args.size when 1 seq = args.shift when 2 if args[0].to_s.strip =~ /^[0-9]+$/ missmatch,seq = args else db,seq = args end when 3 db,missmatch,seq = args else raise ArgumentError end query = ['', db, missmatch, seq].compact.join("/") path = query + ".json" begin response = @http.get(path, @header) rescue end case response.code when "200" JSON.parse(response.body) when "302" location = response.header['Location'] search(location) else nil end end |