# # = bio/io/hinv.rb - H-invDB web service (REST) client module # # Copyright:: Copyright (C) 2008 Toshiaki Katayama # License:: The Ruby License # # $Id:$ # require 'bio/command' require 'rexml/document' module Bio # = Bio::Hinv # # Accessing the H-invDB web services. # # * http://www.h-invitational.jp/ # * http://www.jbirc.aist.go.jp/hinv/hws/doc/index.html # class Hinv BASE_URI = "http://www.jbirc.aist.go.jp/hinv/hws/" module Common def query(options = nil) response = Bio::Command.post_form(@url, options) @result = response.body @xml = REXML::Document.new(@result) end end # Bio::Hinv.acc2hit("BC053657") # => "HIT000053961" def self.acc2hit(acc) serv = Acc2hit.new serv.query("acc" => acc) serv.result end # Bio::Hinv.hit2acc("HIT000022181") # => "AK097327" def self.hit2acc(hit) serv = Hit2acc.new serv.query("hit" => hit) serv.result end # Bio::Hinv.hit_cnt # => 187156 def self.hit_cnt serv = HitCnt.new serv.query serv.result end # Bio::Hinv.hit_definition("HIT000000001") # => "Rho guanine ..." def self.hit_definition(hit) serv = HitDefinition.new serv.query("hit" => hit) serv.result end # Bio::Hinv.hit_pubmedid("HIT000053961") # => [7624364, 11279095, ... ] def self.hit_pubmedid(hit) serv = HitPubmedId.new serv.query("hit" => hit) serv.result end # Bio::Hinv.hit_xml("HIT000000001") # => " hit) puts serv.result end # Bio::Hinv.hix2hit("HIX0000004") # => ["HIT000012846", ... ] def self.hix2hit(hix) serv = Bio::Hinv::Hix2hit.new serv.query("hix" => hix) serv.result end # Bio::Hinv.hix_cnt # => 36073 def self.hix_cnt serv = HixCnt.new serv.query serv.result end # Bio::Hinv.hix_represent("HIX0000001") # => "HIT000022181" def self.hix_represent(hix) serv = HixRepresent.new serv.query("hix" => hix) serv.result end # Bio::Hinv.id_search("HIT00002218*") # => ["HIT000022181", ... ] def self.id_search(query) serv = IdSearch.new serv.query("query" => query) serv.result end # Bio::Hinv.keyword_search("HIT00002218*") # => ["HIT000022181", ... ] def self.keyword_search(query) serv = KeywordSearch.new serv.query("query" => query) serv.result end # serv = Bio::Hinv::Acc2hit.new # serv.query("acc" => "BC053657") # puts serv.result class Acc2hit include Common def initialize @url = BASE_URI + "acc2hit.php" end # # # HIT000053961 # def result @xml.elements['//H-INVITATIONAL-ID'].text end end # serv = Bio::Hinv::Hit2acc.new # serv.query("hit" => "HIT000022181") # puts serv.result class Hit2acc include Common def initialize @url = BASE_URI + "hit2acc.php" end # # # AK097327 # def result @xml.elements['//ACCESSION-NO'].text end end # serv = Bio::Hinv::HitCnt.new # serv.query # puts serv.result class HitCnt include Common def initialize @url = BASE_URI + "hit_cnt.php" end # # # 187156 # def result @xml.elements['//TRANSCRIPT_CNT'].text.to_i end end # serv = Bio::Hinv::HitDefinition.new # serv.query("hit" => "HIT000000001") # puts serv.result # puts serv.data_source_definition # puts serv.cdna_rep_h_invitational # puts serv.cdna_splicing_isoform_curation # puts serv.data_source_db_reference_protein_motif_id # puts serv.data_source_identity # puts serv.data_source_coverage # puts serv.data_source_homologous_species # puts serv.data_source_similarity_category class HitDefinition include Common def initialize @url = BASE_URI + "hit_definition.php" end # # # # HIT000000001 # Rho guanine nucleotide exchange factor 10. # Representative transcript # # NP_055444 # 100.0 # 100.0 # Homo sapiens # Identical to known human protein(Category I). # # def result @xml.elements['//DATA-SOURCE_DEFINITION'].text end alias :data_source_definition :result def cdna_rep_h_invitational @xml.elements['//CDNA_REP-H-INVITATIONAL'].text end def cdna_splicing_isoform_curation @xml.elements['//CDNA_SPLICING-ISOFORM_CURATION'].text end def data_source_db_reference_protein_motif_id @xml.elements['//DATA-SOURCE_DB-REFERENCE_PROTEIN-MOTIF-ID'].text end def data_source_identity @xml.elements['//DATA-SOURCE_IDENTITY'].text.to_f end def data_source_coverage @xml.elements['//DATA-SOURCE_COVERAGE'].text.to_f end def data_source_homologous_species @xml.elements['//DATA-SOURCE_HOMOLOGOUS_SPECIES'].text end def data_source_similarity_category @xml.elements['//DATA-SOURCE_SIMILARITY-CATEGORY'].text end end # serv = Bio::Hinv::HitPubmedId.new # serv.query("hit" => "HIT000053961") # puts serv.result class HitPubmedId include Common def initialize @url = BASE_URI + "hit_pubmedid.php" end # # # 7624364 # 11279095 # 15489334 # def result list = [] @xml.elements.each('//CDNA_DB-REFERENCE_PUBMED') do |e| list << e.text.to_i end return list end end # serv = Bio::Hinv::HitXML.new # serv.query("hit" => "HIT000000001") # puts serv.result class HitXML include Common def initialize @url = BASE_URI + "hit_xml.php" end # # # # HIX0021591 # HIX0021591.11 # HIT000000001 # : # # # # def result @result end end # serv = Bio::Hinv::Hix2hit.new # serv.query("hix" => "HIX0000004") # puts serv.result class Hix2hit include Common def initialize @url = BASE_URI + "hix2hit.php" end # # # HIT000012846 # HIT000022124 # HIT000007722 # : # HIT000262478 # def result list = [] @xml.elements.each('//H-INVITATIONAL-ID') do |e| list << e.text end return list end end # serv = Bio::Hinv::HixCnt.new # serv.query # puts serv.result class HixCnt include Common def initialize @url = BASE_URI + "hix_cnt.php" end # # # 36073 # def result @xml.elements['//LOCUS_CNT'].text.to_i end end # serv = Bio::Hinv::HixRepresent.new # serv.query("hix" => "HIX0000001") # puts serv.result # puts serv.rep_h_invitational_id # puts serv.rep_accession_no class HixRepresent include Common def initialize @url = BASE_URI + "hix_represent.php" end # # # # HIX0000001 # HIT000022181 # AK097327 # # def result @xml.elements['//REP-H-INVITATIONAL-ID'].text end alias :rep_h_invitational_id :result def rep_accession_no @xml.elements['//REP-ACCESSION-NO'].text end end # example at "http://www.jbirc.aist.go.jp/hinv/hws/doc/index_jp.html" # is for hit_xml.php (not for hix_xml.php) class HixXML end # serv = Bio::Hinv::KeywordSearch.new # serv.query("query" => "HIT00002218*", "start" => 1, "end" => 100) # puts serv.result # puts serv.size # puts serv.start # puts serv.end class KeywordSearch include Common def initialize @url = BASE_URI + "keyword_search.php" end def query(hash = {}) default = { "start" => 1, "end" => 100 } options = default.update(hash) super(options) end # # # HIT00002218* # 8 # 1 # 8 # HIT000022180 # HIT000022181 # HIT000022183 # HIT000022184 # HIT000022185 # HIT000022186 # HIT000022188 # HIT000022189 # def result list = [] @xml.elements.each('//H-INVITATIONAL-ID') do |e| list << e.text end return list end def size @xml.elements['//SIZE'].text.to_i end def start @xml.elements['//START'].text.to_i end def end @xml.elements['//END'].text.to_i end end # serv = Bio::Hinv::IdSearch.new # serv.query("query" => "HIT00002218*", "id_type" => "H-INVITATIONAL-ID", "start" => 1, "end" => 100) # puts serv.result # puts serv.size # puts serv.start # puts serv.end class IdSearch < KeywordSearch def initialize @url = BASE_URI + "id_search.php" end def query(hash = {}) default = { "id_type" => "H-INVITATIONAL-ID", "start" => 1, "end" => 100 } options = default.update(hash) super(options) end end end end