From k at dev.open-bio.org Wed Jan 9 12:18:21 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:18:21 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.88,1.89 Message-ID: <200801091718.m09HIKNg016110@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory dev.open-bio.org:/tmp/cvs-serv16099/lib Modified Files: bio.rb Log Message: * Bio::Hinv module for the H-invitational DB (http://h-invitational.jp/) web service is added Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** bio.rb 29 Dec 2007 19:19:07 -0000 1.88 --- bio.rb 9 Jan 2008 17:18:17 -0000 1.89 *************** *** 145,148 **** --- 145,149 ---- autoload :Ensembl, 'bio/io/ensembl' + autoload :Hinv, 'bio/io/hinv' ## below are described in bio/appl/blast.rb From k at dev.open-bio.org Wed Jan 9 12:18:21 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:18:21 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io hinv.rb,NONE,1.1 Message-ID: <200801091718.m09HIK3X016111@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv16099/lib/bio/io Added Files: hinv.rb Log Message: * Bio::Hinv module for the H-invitational DB (http://h-invitational.jp/) web service is added --- NEW FILE: hinv.rb --- # # = bio/io/hinv.rb - H-invDB web service (REST) client module # # Copyright:: Copyright (C) 2007 Toshiaki Katayama # License:: The Ruby License # # $Id: hinv.rb,v 1.1 2008/01/09 17:18:18 k Exp $ # 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?hit=" 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 From k at dev.open-bio.org Wed Jan 9 12:22:41 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:22:41 +0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.79,1.80 Message-ID: <200801091722.m09HMfk7016152@dev.open-bio.org> Update of /home/repository/bioruby/bioruby In directory dev.open-bio.org:/tmp/cvs-serv16148 Modified Files: ChangeLog Log Message: * Bio::Hinv is added Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** ChangeLog 29 Dec 2007 19:19:06 -0000 1.79 --- ChangeLog 9 Jan 2008 17:22:39 -0000 1.80 *************** *** 1,2 **** --- 1,9 ---- + 2008-01-10 Toshiaki Katayama + + * lib/bio/io/hinv.rb + + Bio::Hinv to access the H-invitational DB (http://h-invitational.jp/) + web service in REST mode is added. + 2007-12-30 Toshiaki Katayama From ngoto at dev.open-bio.org Wed Jan 9 22:51:12 2008 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 10 Jan 2008 03:51:12 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb,1.8,1.9 Message-ID: <200801100351.m0A3pCu9017201@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv17181/lib/bio/appl Modified Files: emboss.rb Log Message: Added a method Bio::EMBOSS.run(program, arguments...) and Bio::EMBOSS.new is obsoleted. Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** emboss.rb 5 Apr 2007 23:35:39 -0000 1.8 --- emboss.rb 10 Jan 2008 03:51:06 -0000 1.9 *************** *** 36,51 **** # # Suppose that you could get the sequence for XLRHODOP by running # # the EMBOSS command +seqret embl:xlrhodop+ on the command line. ! # # Then you can get the output of that command in a Bio::EMBOSS object ! # # by creating a new Bio::EMBOSS object and subsequently executing it. ! # xlrhodop = Bio::EMBOSS.new('seqret embl:xlrhodop') ! # puts xlrhodop.exec # # # Or all in one go: ! # puts Bio::EMBOSS.new('seqret embl:xlrhodop').exec # # # Similarly: ! # puts Bio::EMBOSS.new('transeq -sbegin 110 -send 1171 embl:xlrhodop') ! # puts Bio::EMBOSS.new('showfeat embl:xlrhodop').exec ! # puts Bio::EMBOSS.new('seqret embl:xlrhodop -osformat acedb').exec # # # A shortcut exists for this two-step process for +seqret+ and +entret+. --- 36,52 ---- # # Suppose that you could get the sequence for XLRHODOP by running # # the EMBOSS command +seqret embl:xlrhodop+ on the command line. ! # # Then you can get the output of that command in a String object ! # # by using Bio::EMBOSS.run method. ! # xlrhodop = Bio::EMBOSS.run('seqret', 'embl:xlrhodop') ! # puts xlrhodop # # # Or all in one go: ! # puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop') # # # Similarly: ! # puts Bio::EMBOSS.run('transeq', '-sbegin', '110','-send', '1171', ! # 'embl:xlrhodop') ! # puts Bio::EMBOSS.run('showfeat', 'embl:xlrhodop') ! # puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop', '-osformat', 'acedb') # # # A shortcut exists for this two-step process for +seqret+ and +entret+. *************** *** 53,56 **** --- 54,68 ---- # puts Bio::EMBOSS.entret('embl:xlrhodop') # + # # You can use %w() syntax. + # puts Bio::EMBOSS.run(*%w( transeq -sbegin 110 -send 1171 embl:xlrhodop )) + # + # # You can also use Shellwords.shellwords. + # require 'shellwords' + # str = 'transeq -sbegin 110 -send 1171 embl:xlrhodop' + # cmd = Shellwords.shellwords(str) + # puts Bio::EMBOSS.run(*cmd) + # + + # # == Pre-requisites # *************** *** 77,82 **** # --- # *Arguments*: ! # * (required) _command_: emboss command ! # *Returns*:: Bio::EMBOSS object def self.seqret(arg) str = self.retrieve('seqret', arg) --- 89,94 ---- # --- # *Arguments*: ! # * (required) _arg_: argument given to the emboss seqret command ! # *Returns*:: String def self.seqret(arg) str = self.retrieve('seqret', arg) *************** *** 93,102 **** # --- # *Arguments*: ! # * (required) _command_: emboss command ! # *Returns*:: Bio::EMBOSS object def self.entret(arg) str = self.retrieve('entret', arg) end # Initializes a new Bio::EMBOSS object. This provides a holder that can # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_ --- 105,118 ---- # --- # *Arguments*: ! # * (required) _arg_: argument given to the emboss entret command ! # *Returns*:: String def self.entret(arg) str = self.retrieve('entret', arg) end + # WARNING: Bio::EMBOSS.new will be changed in the future because + # Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole. + # Using Bio::EMBOSS.run(program, options...) is strongly recommended. + # # Initializes a new Bio::EMBOSS object. This provides a holder that can # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_ *************** *** 115,118 **** --- 131,135 ---- # *Returns*:: Bio::EMBOSS object def initialize(cmd_line) + warn 'Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole. Using Bio::EMBOSS.run(program, options...) is strongly recommended.' @cmd_line = cmd_line + ' -stdout -auto' end *************** *** 143,146 **** --- 160,195 ---- attr_reader :result + # Runs an emboss program and get the result as string. + # Note that "-auto -stdout" are automatically added to the options. + # + # Example 1: + # + # result = Bio::EMBOSS.run('seqret', 'embl:xlrhodop') + # + # Example 2: + # + # result = Bio::EMBOSS.run('water', + # '-asequence', 'swissprot:slpi_human', + # '-bsequence', 'swissprot:slpi_mouse') + # + # Example 3: + # options = %w( -asequence swissprot:slpi_human + # -bsequence swissprot:slpi_mouse ) + # result = Bio::EMBOSS.run('needle', *options) + # + # For an overview of commands that can be used with this method, see the + # emboss website. + # --- + # *Arguments*: + # * (required) _program_: command name, or filename of an emboss program + # * _options_: options given to the emboss program + # *Returns*:: String + def self.run(program, *options) + cmd = [ program, *options ] + cmd.push '-auto' + cmd.push '-stdout' + return Bio::Command.query_command(cmd) + end + private From nakao at dev.open-bio.org Wed Jan 30 12:43:36 2008 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 30 Jan 2008 17:43:36 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl test_blast.rb,1.5,1.6 Message-ID: <200801301743.m0UHhal7013528@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv13486/test/unit/bio/appl Modified Files: test_blast.rb Log Message: * Fixed the bug at building the blastall command line options ('-m 0'). Index: test_blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/test_blast.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_blast.rb 5 Apr 2007 23:35:43 -0000 1.5 --- test_blast.rb 30 Jan 2008 17:43:33 -0000 1.6 *************** *** 82,85 **** --- 82,91 ---- end + def test_option_set_m0 + @blast.option = '-m 0' + assert_equal('-m 0', @blast.option) + end + + def test_server assert_equal(@server, @blast.server) *************** *** 127,130 **** --- 133,147 ---- end end + + def test_make_command_line + @blast = Bio::Blast.new(@program, @db, '-m 7 -F F') + assert_equal(["blastall", "-p", "blastp", "-d", "test", "-m", "7", "-F", "F"], + @blast.instance_eval { make_command_line }) + end + def test_make_command_line_2 + @blast = Bio::Blast.new(@program, @db, '-m 0 -F F') + assert_equal(["blastall", "-p", "blastp", "-d", "test", "-m", "0", "-F", "F"], + @blast.instance_eval { make_command_line }) + end def test_parse_result From nakao at dev.open-bio.org Wed Jan 30 12:43:36 2008 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 30 Jan 2008 17:43:36 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.33,1.34 Message-ID: <200801301743.m0UHhafU013533@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv13486/lib/bio/appl Modified Files: blast.rb Log Message: * Fixed the bug at building the blastall command line options ('-m 0'). Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** blast.rb 5 Apr 2007 23:35:39 -0000 1.33 --- blast.rb 30 Jan 2008 17:43:34 -0000 1.34 *************** *** 2,6 **** # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001 Mitsuteru C. Nakao # Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama # Copyright:: Copyright (C) 2006 Jan Aerts --- 2,6 ---- # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001,2008 Mitsuteru C. Nakao # Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama # Copyright:: Copyright (C) 2006 Jan Aerts *************** *** 182,201 **** @output = '' @parser = nil - begin - a = opt.to_ary - rescue NameError #NoMethodError - # backward compatibility - a = Shellwords.shellwords(opt) - end - unless a.find { |x| /\A\-m/ =~ x.to_s } then - if defined?(XMLParser) or defined?(REXML) - @format = 7 - else - @format = 8 - end - end - @options = [ *a ] - end # This method submits a sequence to a BLAST factory, which performs the --- 182,190 ---- @output = '' @parser = nil + @format = 0 + + set_options(opt) + end # This method submits a sequence to a BLAST factory, which performs the *************** *** 225,231 **** end - private def parse_result(data) --- 214,239 ---- end private + def set_options(opt = nil) + opt = @options unless opt + begin + a = opt.to_ary + rescue NameError #NoMethodError + # backward compatibility + a = Shellwords.shellwords(opt) + end + unless a.find { |x| /\A\-m/ =~ x.to_s } then + if defined?(XMLParser) or defined?(REXML) + @format = 7 + else + @format = 8 + end + else + @format = a[a.index('-m') + 1].to_i + end + @options = [ *a ] + end + def parse_result(data) *************** *** 234,244 **** ! def exec_local(query) cmd = [ @blastall, '-p', @program, '-d', @db ] ! cmd.concat([ '-M', @matrix ]) if @matrix ! cmd.concat([ '-F', @filter ]) if @filter ! cmd.concat([ '-m', @format.to_s ]) if @format cmd.concat(@options) if @options report = nil --- 242,272 ---- ! def make_command_line ! set_options cmd = [ @blastall, '-p', @program, '-d', @db ] ! if @matrix ! cmd.concat([ '-M', @matrix ]) ! i = @options.index('-M') ! @options.delete_at(i) ! @options.delete_at(i) ! end ! if @filter ! cmd.concat([ '-F', @filter ]) ! i = @options.index('-F') ! @options.delete_at(i) ! @options.delete_at(i) ! end ! if @format ! cmd.concat([ '-m', @format.to_s ]) ! i = @options.index('-m') ! @options.delete_at(i) ! @options.delete_at(i) ! end cmd.concat(@options) if @options + end + + def exec_local(query) + cmd = make_command_line report = nil *************** *** 249,252 **** --- 277,281 ---- end + def exec_genomenet_tab(query) @format = 8 *************** *** 254,257 **** --- 283,287 ---- end + def exec_genomenet(query) host = "blast.genome.jp" From k at dev.open-bio.org Wed Jan 9 17:18:21 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:18:21 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.88,1.89 Message-ID: <200801091718.m09HIKNg016110@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory dev.open-bio.org:/tmp/cvs-serv16099/lib Modified Files: bio.rb Log Message: * Bio::Hinv module for the H-invitational DB (http://h-invitational.jp/) web service is added Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** bio.rb 29 Dec 2007 19:19:07 -0000 1.88 --- bio.rb 9 Jan 2008 17:18:17 -0000 1.89 *************** *** 145,148 **** --- 145,149 ---- autoload :Ensembl, 'bio/io/ensembl' + autoload :Hinv, 'bio/io/hinv' ## below are described in bio/appl/blast.rb From k at dev.open-bio.org Wed Jan 9 17:18:21 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:18:21 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io hinv.rb,NONE,1.1 Message-ID: <200801091718.m09HIK3X016111@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv16099/lib/bio/io Added Files: hinv.rb Log Message: * Bio::Hinv module for the H-invitational DB (http://h-invitational.jp/) web service is added --- NEW FILE: hinv.rb --- # # = bio/io/hinv.rb - H-invDB web service (REST) client module # # Copyright:: Copyright (C) 2007 Toshiaki Katayama # License:: The Ruby License # # $Id: hinv.rb,v 1.1 2008/01/09 17:18:18 k Exp $ # 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?hit=" 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 From k at dev.open-bio.org Wed Jan 9 17:22:41 2008 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Wed, 09 Jan 2008 17:22:41 +0000 Subject: [BioRuby-cvs] bioruby ChangeLog,1.79,1.80 Message-ID: <200801091722.m09HMfk7016152@dev.open-bio.org> Update of /home/repository/bioruby/bioruby In directory dev.open-bio.org:/tmp/cvs-serv16148 Modified Files: ChangeLog Log Message: * Bio::Hinv is added Index: ChangeLog =================================================================== RCS file: /home/repository/bioruby/bioruby/ChangeLog,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** ChangeLog 29 Dec 2007 19:19:06 -0000 1.79 --- ChangeLog 9 Jan 2008 17:22:39 -0000 1.80 *************** *** 1,2 **** --- 1,9 ---- + 2008-01-10 Toshiaki Katayama + + * lib/bio/io/hinv.rb + + Bio::Hinv to access the H-invitational DB (http://h-invitational.jp/) + web service in REST mode is added. + 2007-12-30 Toshiaki Katayama From ngoto at dev.open-bio.org Thu Jan 10 03:51:12 2008 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 10 Jan 2008 03:51:12 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb,1.8,1.9 Message-ID: <200801100351.m0A3pCu9017201@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv17181/lib/bio/appl Modified Files: emboss.rb Log Message: Added a method Bio::EMBOSS.run(program, arguments...) and Bio::EMBOSS.new is obsoleted. Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** emboss.rb 5 Apr 2007 23:35:39 -0000 1.8 --- emboss.rb 10 Jan 2008 03:51:06 -0000 1.9 *************** *** 36,51 **** # # Suppose that you could get the sequence for XLRHODOP by running # # the EMBOSS command +seqret embl:xlrhodop+ on the command line. ! # # Then you can get the output of that command in a Bio::EMBOSS object ! # # by creating a new Bio::EMBOSS object and subsequently executing it. ! # xlrhodop = Bio::EMBOSS.new('seqret embl:xlrhodop') ! # puts xlrhodop.exec # # # Or all in one go: ! # puts Bio::EMBOSS.new('seqret embl:xlrhodop').exec # # # Similarly: ! # puts Bio::EMBOSS.new('transeq -sbegin 110 -send 1171 embl:xlrhodop') ! # puts Bio::EMBOSS.new('showfeat embl:xlrhodop').exec ! # puts Bio::EMBOSS.new('seqret embl:xlrhodop -osformat acedb').exec # # # A shortcut exists for this two-step process for +seqret+ and +entret+. --- 36,52 ---- # # Suppose that you could get the sequence for XLRHODOP by running # # the EMBOSS command +seqret embl:xlrhodop+ on the command line. ! # # Then you can get the output of that command in a String object ! # # by using Bio::EMBOSS.run method. ! # xlrhodop = Bio::EMBOSS.run('seqret', 'embl:xlrhodop') ! # puts xlrhodop # # # Or all in one go: ! # puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop') # # # Similarly: ! # puts Bio::EMBOSS.run('transeq', '-sbegin', '110','-send', '1171', ! # 'embl:xlrhodop') ! # puts Bio::EMBOSS.run('showfeat', 'embl:xlrhodop') ! # puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop', '-osformat', 'acedb') # # # A shortcut exists for this two-step process for +seqret+ and +entret+. *************** *** 53,56 **** --- 54,68 ---- # puts Bio::EMBOSS.entret('embl:xlrhodop') # + # # You can use %w() syntax. + # puts Bio::EMBOSS.run(*%w( transeq -sbegin 110 -send 1171 embl:xlrhodop )) + # + # # You can also use Shellwords.shellwords. + # require 'shellwords' + # str = 'transeq -sbegin 110 -send 1171 embl:xlrhodop' + # cmd = Shellwords.shellwords(str) + # puts Bio::EMBOSS.run(*cmd) + # + + # # == Pre-requisites # *************** *** 77,82 **** # --- # *Arguments*: ! # * (required) _command_: emboss command ! # *Returns*:: Bio::EMBOSS object def self.seqret(arg) str = self.retrieve('seqret', arg) --- 89,94 ---- # --- # *Arguments*: ! # * (required) _arg_: argument given to the emboss seqret command ! # *Returns*:: String def self.seqret(arg) str = self.retrieve('seqret', arg) *************** *** 93,102 **** # --- # *Arguments*: ! # * (required) _command_: emboss command ! # *Returns*:: Bio::EMBOSS object def self.entret(arg) str = self.retrieve('entret', arg) end # Initializes a new Bio::EMBOSS object. This provides a holder that can # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_ --- 105,118 ---- # --- # *Arguments*: ! # * (required) _arg_: argument given to the emboss entret command ! # *Returns*:: String def self.entret(arg) str = self.retrieve('entret', arg) end + # WARNING: Bio::EMBOSS.new will be changed in the future because + # Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole. + # Using Bio::EMBOSS.run(program, options...) is strongly recommended. + # # Initializes a new Bio::EMBOSS object. This provides a holder that can # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_ *************** *** 115,118 **** --- 131,135 ---- # *Returns*:: Bio::EMBOSS object def initialize(cmd_line) + warn 'Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole. Using Bio::EMBOSS.run(program, options...) is strongly recommended.' @cmd_line = cmd_line + ' -stdout -auto' end *************** *** 143,146 **** --- 160,195 ---- attr_reader :result + # Runs an emboss program and get the result as string. + # Note that "-auto -stdout" are automatically added to the options. + # + # Example 1: + # + # result = Bio::EMBOSS.run('seqret', 'embl:xlrhodop') + # + # Example 2: + # + # result = Bio::EMBOSS.run('water', + # '-asequence', 'swissprot:slpi_human', + # '-bsequence', 'swissprot:slpi_mouse') + # + # Example 3: + # options = %w( -asequence swissprot:slpi_human + # -bsequence swissprot:slpi_mouse ) + # result = Bio::EMBOSS.run('needle', *options) + # + # For an overview of commands that can be used with this method, see the + # emboss website. + # --- + # *Arguments*: + # * (required) _program_: command name, or filename of an emboss program + # * _options_: options given to the emboss program + # *Returns*:: String + def self.run(program, *options) + cmd = [ program, *options ] + cmd.push '-auto' + cmd.push '-stdout' + return Bio::Command.query_command(cmd) + end + private From nakao at dev.open-bio.org Wed Jan 30 17:43:36 2008 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 30 Jan 2008 17:43:36 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/appl test_blast.rb,1.5,1.6 Message-ID: <200801301743.m0UHhal7013528@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv13486/test/unit/bio/appl Modified Files: test_blast.rb Log Message: * Fixed the bug at building the blastall command line options ('-m 0'). Index: test_blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/appl/test_blast.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_blast.rb 5 Apr 2007 23:35:43 -0000 1.5 --- test_blast.rb 30 Jan 2008 17:43:33 -0000 1.6 *************** *** 82,85 **** --- 82,91 ---- end + def test_option_set_m0 + @blast.option = '-m 0' + assert_equal('-m 0', @blast.option) + end + + def test_server assert_equal(@server, @blast.server) *************** *** 127,130 **** --- 133,147 ---- end end + + def test_make_command_line + @blast = Bio::Blast.new(@program, @db, '-m 7 -F F') + assert_equal(["blastall", "-p", "blastp", "-d", "test", "-m", "7", "-F", "F"], + @blast.instance_eval { make_command_line }) + end + def test_make_command_line_2 + @blast = Bio::Blast.new(@program, @db, '-m 0 -F F') + assert_equal(["blastall", "-p", "blastp", "-d", "test", "-m", "0", "-F", "F"], + @blast.instance_eval { make_command_line }) + end def test_parse_result From nakao at dev.open-bio.org Wed Jan 30 17:43:36 2008 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 30 Jan 2008 17:43:36 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.33,1.34 Message-ID: <200801301743.m0UHhafU013533@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv13486/lib/bio/appl Modified Files: blast.rb Log Message: * Fixed the bug at building the blastall command line options ('-m 0'). Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** blast.rb 5 Apr 2007 23:35:39 -0000 1.33 --- blast.rb 30 Jan 2008 17:43:34 -0000 1.34 *************** *** 2,6 **** # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001 Mitsuteru C. Nakao # Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama # Copyright:: Copyright (C) 2006 Jan Aerts --- 2,6 ---- # = bio/appl/blast.rb - BLAST wrapper # ! # Copyright:: Copyright (C) 2001,2008 Mitsuteru C. Nakao # Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama # Copyright:: Copyright (C) 2006 Jan Aerts *************** *** 182,201 **** @output = '' @parser = nil - begin - a = opt.to_ary - rescue NameError #NoMethodError - # backward compatibility - a = Shellwords.shellwords(opt) - end - unless a.find { |x| /\A\-m/ =~ x.to_s } then - if defined?(XMLParser) or defined?(REXML) - @format = 7 - else - @format = 8 - end - end - @options = [ *a ] - end # This method submits a sequence to a BLAST factory, which performs the --- 182,190 ---- @output = '' @parser = nil + @format = 0 + + set_options(opt) + end # This method submits a sequence to a BLAST factory, which performs the *************** *** 225,231 **** end - private def parse_result(data) --- 214,239 ---- end private + def set_options(opt = nil) + opt = @options unless opt + begin + a = opt.to_ary + rescue NameError #NoMethodError + # backward compatibility + a = Shellwords.shellwords(opt) + end + unless a.find { |x| /\A\-m/ =~ x.to_s } then + if defined?(XMLParser) or defined?(REXML) + @format = 7 + else + @format = 8 + end + else + @format = a[a.index('-m') + 1].to_i + end + @options = [ *a ] + end + def parse_result(data) *************** *** 234,244 **** ! def exec_local(query) cmd = [ @blastall, '-p', @program, '-d', @db ] ! cmd.concat([ '-M', @matrix ]) if @matrix ! cmd.concat([ '-F', @filter ]) if @filter ! cmd.concat([ '-m', @format.to_s ]) if @format cmd.concat(@options) if @options report = nil --- 242,272 ---- ! def make_command_line ! set_options cmd = [ @blastall, '-p', @program, '-d', @db ] ! if @matrix ! cmd.concat([ '-M', @matrix ]) ! i = @options.index('-M') ! @options.delete_at(i) ! @options.delete_at(i) ! end ! if @filter ! cmd.concat([ '-F', @filter ]) ! i = @options.index('-F') ! @options.delete_at(i) ! @options.delete_at(i) ! end ! if @format ! cmd.concat([ '-m', @format.to_s ]) ! i = @options.index('-m') ! @options.delete_at(i) ! @options.delete_at(i) ! end cmd.concat(@options) if @options + end + + def exec_local(query) + cmd = make_command_line report = nil *************** *** 249,252 **** --- 277,281 ---- end + def exec_genomenet_tab(query) @format = 8 *************** *** 254,257 **** --- 283,287 ---- end + def exec_genomenet(query) host = "blast.genome.jp"