From nakao at dev.open-bio.org Tue Jul 11 11:52:53 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 11 Jul 2006 15:52:53 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl sptr.rb,1.32,1.33 Message-ID: <200607111552.k6BFqrEP026141@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv25655/lib/bio/db/embl Modified Files: sptr.rb Log Message: * Added codes for "Changes concerning the copyright statement" (http://www.expasy.org/sprot/relnotes/sp_news.html#rel7). Index: sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/sptr.rb,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** sptr.rb 16 Jun 2006 17:01:01 -0000 1.32 --- sptr.rb 11 Jul 2006 15:52:51 -0000 1.33 *************** *** 354,362 **** ! @@cc_topics = ['ALTERNATIVE PRODUCTS','CATALYTIC ACTIVITY','CAUTION', ! 'COFACTOR','DATABASE','DEVELOPMENTAL STAGE','DISEASE','DOMAIN', ! 'ENZYME REGULATION','FUNCTION','INDUCTION','MASS SPECTROMETRY', ! 'MISCELLANEOUS','PATHWAY','PHARMACEUTICAL','POLYMORPHISM','PTM', ! 'SIMILARITY','SUBCELLULAR LOCATION','SUBUNIT','TISSUE SPECIFICITY'] # returns contents in the CC lines. # * Bio::SPTR#cc -> Hash --- 354,384 ---- ! @@cc_topics = ['PHARMACEUTICAL', ! 'BIOTECHNOLOGY', ! 'TOXIC DOSE', ! 'ALLERGEN', ! 'RNA EDITING', ! 'POLYMORPHISM', ! 'BIOPHYSICOCHEMICAL PROPERTIES', ! 'MASS SPECTROMETRY', ! 'WEB RESOURCE', ! 'ENZYME REGULATION', ! 'DISEASE', ! 'INTERACTION', ! 'DEVELOPMENTAL STAGE', ! 'INDUCTION', ! 'CAUTION', ! 'ALTERNATIVE PRODUCTS', ! 'DOMAIN', ! 'PTM', ! 'MISCELLANEOUS', ! 'TISSUE SPECIFICITY', ! 'COFACTOR', ! 'PATHWAY', ! 'SUBUNIT', ! 'CATALYTIC ACTIVITY', ! 'SUBCELLULAR LOCATION', ! 'FUNCTION', ! 'SIMILARITY'] # returns contents in the CC lines. # * Bio::SPTR#cc -> Hash *************** *** 398,401 **** --- 420,425 ---- # CC SECOND AND SUBSEQUENT LINES OF A COMMENT BLOCK. # + # See also http://www.expasy.org/sprot/userman.html#CC_line + # def cc(tag = nil) unless @data['CC'] *************** *** 404,411 **** dlm = /-!- / ! return cc if get('CC').size == 0 # 12KD_MYCSM has no CC lines. begin ! fetch('CC').split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 --- 428,443 ---- dlm = /-!- / ! # 12KD_MYCSM has no CC lines. ! return cc if get('CC').size == 0 ! ! cc_raw = fetch('CC') ! ! cc_raw.sub!(/ *---.+---/m, '') ! # Not any CC Lines without the copyright statement. ! return cc if cc_raw == '' ! begin ! cc_raw.split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 From ngoto at dev.open-bio.org Fri Jul 14 10:23:50 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:23:50 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_command.rb,1.1,1.2 Message-ID: <200607141423.k6EENoYN005258@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory dev.open-bio.org:/tmp/cvs-serv5233/test/unit/bio Modified Files: test_command.rb Log Message: * Bio::Command::Tools and Bio::Command::NetTools are combined and re-constructed into a new Bio::Command module. The method names and functions are also changed, and some new methods are added. * Now, you have no need to include Bio::Command. Index: test_command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_command.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_command.rb 27 Oct 2005 15:11:51 -0000 1.1 --- test_command.rb 14 Jul 2006 14:23:48 -0000 1.2 *************** *** 2,20 **** # test/unit/bio/test_command.rb - Unit test for external command execution methods # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. ! # ! # This library is distributed in the hope that it will be useful, ! # but WITHOUT ANY WARRANTY; without even the implied warranty of ! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! # Lesser General Public License for more details. ! # ! # You should have received a copy of the GNU Lesser General Public ! # License along with this library; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id$ --- 2,9 ---- # test/unit/bio/test_command.rb - Unit test for external command execution methods # ! # Copyright:: Copyright (C) 2005-2006 ! # Mitsuteru Nakao , ! # Naohisa Goto ! # License:: Ruby's # # $Id$ *************** *** 30,69 **** module Bio ! class TestCommandTools < Test::Unit::TestCase ! def test_command_tools_constants ! Bio::Command::Tools::UNSAFE_CHARS_UNIX ! Bio::Command::Tools::QUOTE_CHARS_WINDOWS ! Bio::Command::Tools::UNESCAPABLE_CHARS end def test_escape_shell_windows end def test_escape_shell_unix end def test_escape_shell end def test_make_command_line end def test_make_command_line_windows end def test_make_command_line_unix end ! def test_call_commandline_local end ! def test_call_commandline_local_popen end ! def test_call_commandline_local_open3 end ! def test_errorlog end --- 19,133 ---- module Bio ! class TestCommand < Test::Unit::TestCase ! def test_command_constants ! Bio::Command::UNSAFE_CHARS_UNIX ! Bio::Command::QUOTE_CHARS_WINDOWS ! Bio::Command::UNESCAPABLE_CHARS end def test_escape_shell_windows + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell_windows(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + assert_equal("\"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.escape_shell_windows(str)) end def test_escape_shell_unix + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell_unix(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.escape_shell_unix(str)) end def test_escape_shell + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + case RUBY_PLATFORM + when /mswin32|bccwin32/ + assert_equal("\"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.escape_shell(str)) + else + assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.escape_shell(str)) + end end def test_make_command_line + ary = [ "ruby", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + case RUBY_PLATFORM + when /mswin32|bccwin32/ + assert_equal("ruby" + + " test.rb atgcatgc" + + " \"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.make_command_line(ary)) + else + assert_equal("ruby" + + " test.rb atgcatgc" + + " bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.make_command_line(ary)) + end end def test_make_command_line_windows + ary = [ "C:\\Program Files\\Ruby\\bin\\ruby.exe", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + assert_equal("\"C:\\Program Files\\Ruby\\bin\\ruby.exe\"" + + " test.rb atgcatgc" + + " \"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.make_command_line_windows(ary)) end def test_make_command_line_unix + ary = [ "/usr/local/bin/ruby", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + assert_equal("/usr/local/bin/ruby" + + " test.rb atgcatgc" + + " bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.make_command_line_unix(ary)) end ! def test_call_command ! p $0 end ! def test_call_command_popen end ! def test_call_command_fork end ! def test_call_command_open3 ! end ! ! def test_query_command ! end ! ! def test_query_command_popen ! end ! ! def test_query_command_fork ! end ! ! def test_query_command_open3 ! end ! ! def test_read_uri ! end ! ! def test_start_http ! end ! ! def test_new_http ! end ! ! def test_post_form end From ngoto at dev.open-bio.org Fri Jul 14 10:23:50 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:23:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio command.rb,1.11,1.12 Message-ID: <200607141423.k6EENoB5005255@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv5233/lib/bio Modified Files: command.rb Log Message: * Bio::Command::Tools and Bio::Command::NetTools are combined and re-constructed into a new Bio::Command module. The method names and functions are also changed, and some new methods are added. * Now, you have no need to include Bio::Command. Index: command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/command.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** command.rb 30 May 2006 13:59:36 -0000 1.11 --- command.rb 14 Jul 2006 14:23:47 -0000 1.12 *************** *** 16,28 **** module Bio - module Command ! # = Bio::Command::Tools # ! # Bio::Command::Tools is a collection of useful methods for execution ! # of external commands or web applications. Any wrapper class for ! # applications shall include this class. Note that all methods below ! # are private except for some methods. ! module Tools UNSAFE_CHARS_UNIX = /[^A-Za-z0-9\_\-\.\:\,\/\@\x1b\x80-\xfe]/n --- 16,28 ---- module Bio ! # = Bio::Command # ! # Bio::Command is a collection of useful methods for execution ! # of external commands or web applications. ! # Any wrapper class for applications shall use this class. ! # ! # Library internal use only. Users should not directly use it. ! module Command UNSAFE_CHARS_UNIX = /[^A-Za-z0-9\_\-\.\:\,\/\@\x1b\x80-\xfe]/n *************** *** 83,135 **** # Executes the program. Automatically select popen for Windows ! # environment and open3 for the others. ! # ! # If block is given, yield the block with input and output IO objects. ! # Note that in some platform, inn and out are the same object. ! # Please be careful to do inn.close and out.close. ! def call_command_local(cmd, query = nil, &block) case RUBY_PLATFORM when /mswin32|bccwin32/ ! call_command_local_popen(cmd, query, &block) else ! call_command_local_fork(cmd, query, &block) end end # Executes the program via IO.popen for OS which doesn't support fork. ! # If block is given, yield the block with IO objects. ! # The two objects are the same because of limitation of IO.popen. ! def call_command_local_popen(cmd, query = nil) str = make_command_line(cmd) IO.popen(str, "w+") do |io| ! if block_given? then ! io.sync = true ! yield io, io ! else ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end end end # Executes the program via fork (by using IO.popen("-")) and exec. ! # If block is given, yield the block with input and output IO objects. # # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def call_command_local_fork(cmd, query = nil) IO.popen("-", "r+") do |io| if io then # parent ! if block_given? ! yield io, io ! else ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end else # child --- 83,117 ---- # Executes the program. Automatically select popen for Windows ! # environment and fork for the others. ! # A block must be given. An IO object is passed to the block. ! def call_command(cmd, &block) case RUBY_PLATFORM when /mswin32|bccwin32/ ! call_command_popen(cmd, &block) else ! call_command_fork(cmd, &block) end end # Executes the program via IO.popen for OS which doesn't support fork. ! # A block must be given. An IO object is passed to the block. ! def call_command_popen(cmd) str = make_command_line(cmd) IO.popen(str, "w+") do |io| ! io.sync = true ! yield io end end # Executes the program via fork (by using IO.popen("-")) and exec. ! # A block must be given. An IO object is passed to the block. # # From the view point of security, this method is recommended ! # rather than call_command_popen. ! def call_command_fork(cmd) IO.popen("-", "r+") do |io| if io then # parent ! yield io else # child *************** *** 140,184 **** # Executes the program via Open3.popen3 ! # If block is given, yield the block with input and output IO objects. # ! # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def call_command_local_open3(cmd, query = nil) cmd = cmd.collect { |x| x.to_s } Open3.popen3(*cmd) do |pin, pout, perr| ! perr.sync = true ! t = Thread.start { @errorlog = perr.read } ! if block_given? then ! yield pin, pout ! else ! begin ! pin.print query if query ! pin.close ! output = pout.read ! ensure ! t.join ! end ! output ! end end end ! # Shows the latest stderr of the program execution. ! # Note that this method may be thread unsafe. ! attr_reader :errorlog ! public :errorlog ! end # module Tools ! # = Bio::Command::NetTools ! # ! # Bio::Command::NetTools is a collection of miscellaneous methods ! # for data transport through network. ! # ! # Library internal use only. Users should not directly use it. ! # ! # Note that it is under construction. ! module NetTools # Same as OpenURI.open_uri(uri).read. --- 122,209 ---- # Executes the program via Open3.popen3 ! # A block must be given. IO objects are passed to the block. # ! # You would use this method only when you really need to get stderr. ! def call_command_open3(cmd) cmd = cmd.collect { |x| x.to_s } Open3.popen3(*cmd) do |pin, pout, perr| ! yield pin, pout, perr end end ! # Executes the program with the query (String) given to the standard input, ! # waits the program termination, and returns the output data printed to the ! # standard output as a string. ! # ! # Automatically select popen for Windows environment and fork for the others. ! def query_command(cmd, query = nil) ! case RUBY_PLATFORM ! when /mswin32|bccwin32/ ! query_command_popen(cmd, query) ! else ! query_command_fork(cmd, query) ! end ! end ! # Executes the program with the query (String) given to the standard input, ! # waits the program termination, and returns the output data printed to the ! # standard output as a string. ! # ! # IO.popen is used for OS which doesn't support fork. ! def query_command_popen(cmd, query = nil) ! str = make_command_line(cmd) ! IO.popen(str, "w+") do |io| ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end ! end + # Executes the program with the query (String) given to the standard input, + # waits the program termination, and returns the output data printed to the + # standard output as a string. + # + # Fork (by using IO.popen("-")) and exec is used to execute the program. + # + # From the view point of security, this method is recommended + # rather than query_popen. + def query_command_fork(cmd, query = nil) + IO.popen("-", "r+") do |io| + if io then + # parent + io.sync = true + io.print query if query + io.close_write + io.read + else + # child + Kernel.exec(*cmd) + end + end + end ! # Executes the program via Open3.popen3 with the query (String) given ! # to the stain, waits the program termination, and ! # returns the data from stdout and stderr as an array of the strings. ! # ! # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def query_command_open3(cmd, query = nil) ! errorlog = nil ! cmd = cmd.collect { |x| x.to_s } ! Open3.popen3(*cmd) do |pin, pout, perr| ! perr.sync = true ! t = Thread.start { errorlog = perr.read } ! begin ! pin.print query if query ! pin.close ! output = pout.read ! ensure ! t.join ! end ! [ output, errorlog ] ! end ! end # Same as OpenURI.open_uri(uri).read. *************** *** 186,190 **** OpenURI.open_uri(uri).read end - module_function :read_uri # Same as: --- 211,214 ---- *************** *** 194,198 **** # is set. # ! def net_http_start(address, port = 80, &block) uri = URI.parse("http://#{address}:#{port}") # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. --- 218,222 ---- # is set. # ! def start_http(address, port = 80, &block) uri = URI.parse("http://#{address}:#{port}") # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. *************** *** 206,210 **** http.start(address, port, &block) end ! module_function :net_http_start # Same as: --- 230,251 ---- http.start(address, port, &block) end ! ! # Same as: ! # Net::HTTP.new(address, port) ! # and ! # it uses proxy if an environment variable (same as OpenURI.open_uri) ! # is set. ! # ! def new_http(address, port = 80) ! uri = URI.parse("http://#{address}:#{port}") ! # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. ! # If the spec of open-uri.rb would be changed, we should change below. ! if proxyuri = uri.find_proxy then ! raise 'Non-HTTP proxy' if proxyuri.class != URI::HTTP ! Net::HTTP.new(address, port, proxyuri.host, proxyuri.port) ! else ! Net::HTTP.new(address, port) ! end ! end # Same as: *************** *** 228,238 **** } h.update(header) ! net_http_start(uri.host, uri.port) do |http| http.post(uri.path, data, h) end end - module_function :post_form - - end #module NetTools end # module Command --- 269,276 ---- } h.update(header) ! start_http(uri.host, uri.port) do |http| http.post(uri.path, data, h) end end end # module Command From ngoto at dev.open-bio.org Fri Jul 14 10:26:41 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:26:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb, 1.29, 1.30 fasta.rb, 1.20, 1.21 hmmer.rb, 1.5, 1.6 Message-ID: <200607141426.k6EEQfP4005309@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv5268/lib/bio/appl Modified Files: blast.rb fasta.rb hmmer.rb Log Message: * Changes due to the refactoring of Bio::Command. * Changed to use Bio::Command.new_http instead of Net::HTTP.new. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** blast.rb 16 May 2006 09:50:13 -0000 1.29 --- blast.rb 14 Jul 2006 14:26:39 -0000 1.30 *************** *** 83,88 **** autoload :Bl2seq, 'bio/appl/bl2seq/report' - include Bio::Command::Tools - # This is a shortcut for Bio::Blast.new: # Bio::Blast.local(program, database, options) --- 83,86 ---- *************** *** 227,231 **** def option # backward compatibility ! make_command_line(@options) end --- 225,229 ---- def option # backward compatibility ! Bio::Command.make_command_line(@options) end *************** *** 254,258 **** report = nil ! @output = call_command_local(cmd, query) report = parse_result(@output) --- 252,256 ---- report = nil ! @output = Bio::Command.query_command(cmd, query) report = parse_result(@output) *************** *** 278,282 **** 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(opt)), 'matrix' => matrix, 'filter' => filter, --- 276,280 ---- 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(Bio::Command.make_command_line_unix(opt)), 'matrix' => matrix, 'filter' => filter, *************** *** 295,299 **** begin ! http = Net::HTTP.new(host) http.open_timeout = 300 http.read_timeout = 600 --- 293,297 ---- begin ! http = Bio::Command.new_http(host) http.open_timeout = 300 http.read_timeout = 600 Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** fasta.rb 26 Sep 2005 13:00:04 -0000 1.20 --- fasta.rb 14 Jul 2006 14:26:39 -0000 1.21 *************** *** 33,38 **** #autoload :?????, 'bio/appl/fasta/format6' - include Bio::Command::Tools - def initialize(program, db, opt = [], server = 'local') @format = 10 --- 33,36 ---- *************** *** 60,64 **** def option # backward compatibility ! make_command_line(@options) end --- 58,62 ---- def option # backward compatibility ! Bio::Command.make_command_line(@options) end *************** *** 115,119 **** report = nil ! @output = call_command_local(cmd, query) report = parse_result(@output) --- 113,117 ---- report = nil ! @output = Bio::Command.query_command(cmd, query) report = parse_result(@output) *************** *** 132,136 **** 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), 'ktup_value' => @ktup, 'matrix' => @matrix, --- 130,134 ---- 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(Bio::Command.make_command_line_unix(@options)), 'ktup_value' => @ktup, 'matrix' => @matrix, *************** *** 146,150 **** begin ! http = Net::HTTP.new(host) http.open_timeout = 300 http.read_timeout = 600 --- 144,148 ---- begin ! http = Bio::Command.new_http(host) http.open_timeout = 300 http.read_timeout = 600 Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hmmer.rb 2 Feb 2006 17:08:36 -0000 1.5 --- hmmer.rb 14 Jul 2006 14:26:39 -0000 1.6 *************** *** 73,78 **** autoload :Report, 'bio/appl/hmmer/report' - include Bio::Command::Tools - # Prgrams name. (hmmsearch or hmmpfam). attr_accessor :program --- 73,76 ---- *************** *** 113,117 **** # backward compatibility. def option ! make_command_line(@options) end --- 111,115 ---- # backward compatibility. def option ! Bio::Command.make_command_line(@options) end *************** *** 132,136 **** report = nil ! @output = call_command_local(cmd, nil) report = parse_result(@output) --- 130,134 ---- report = nil ! @output = Bio::Command.query_command(cmd, nil) report = parse_result(@output) From ngoto at dev.open-bio.org Fri Jul 14 10:27:12 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:27:12 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.68,1.69 Message-ID: <200607141427.k6EERCDS005339@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory dev.open-bio.org:/tmp/cvs-serv5319/lib Modified Files: bio.rb Log Message: added autoload of Bio::Command. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** bio.rb 4 May 2006 13:12:57 -0000 1.68 --- bio.rb 14 Jul 2006 14:27:10 -0000 1.69 *************** *** 227,230 **** --- 227,233 ---- autoload :ColorScheme, 'bio/util/color_scheme' + ### Service libraries + autoload :Command, 'bio/command' + end From ngoto at dev.open-bio.org Fri Jul 14 10:28:46 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:28:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb, 1.5, 1.6 psort.rb, 1.9, 1.10 pts1.rb, 1.3, 1.4 Message-ID: <200607141428.k6EESkAT005369@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv5347/lib/bio/appl Modified Files: emboss.rb psort.rb pts1.rb Log Message: * Changes due to the refactoring of Bio::Command. Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** emboss.rb 17 May 2006 14:24:33 -0000 1.5 --- emboss.rb 14 Jul 2006 14:28:44 -0000 1.6 *************** *** 21,26 **** module Bio - autoload :Command, 'bio/command' - # = DESCRIPTION # --- 21,24 ---- *************** *** 76,81 **** class EMBOSS - extend Bio::Command::Tools - # Combines the initialization and execution for the emboss +seqret+ command. # --- 74,77 ---- *************** *** 158,167 **** def self.retrieve(cmd, arg) cmd = [ cmd, arg, '-auto', '-stdout' ] ! str = '' ! call_command_local(cmd) do |inn, out| ! inn.close_write ! str = out.read ! end ! return str end --- 154,158 ---- def self.retrieve(cmd, arg) cmd = [ cmd, arg, '-auto', '-stdout' ] ! return Bio::Command.query_command(cmd) end Index: pts1.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/pts1.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pts1.rb 5 Jun 2006 02:55:51 -0000 1.3 --- pts1.rb 14 Jul 2006 14:28:44 -0000 1.4 *************** *** 152,156 **** @uri = URI.parse(["http:/", @host, @cgi_path].join('/')) ! result, = Bio::Command::NetTools.post_form(@uri, @form_data) @output = Report.new(result.body) --- 152,156 ---- @uri = URI.parse(["http:/", @host, @cgi_path].join('/')) ! result, = Bio::Command.post_form(@uri, @form_data) @output = Report.new(result.body) Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** psort.rb 30 Apr 2006 07:13:39 -0000 1.9 --- psort.rb 14 Jul 2006 14:28:44 -0000 1.10 *************** *** 113,117 **** begin result = nil ! Bio::Command::NetTools.net_http_start(@uri.host) {|http| result, = http.post(@uri.path, data) } --- 113,117 ---- begin result = nil ! Bio::Command.start_http(@uri.host) {|http| result, = http.post(@uri.path, data) } From ngoto at dev.open-bio.org Fri Jul 14 10:28:46 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:28:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io ensembl.rb, 1.2, 1.3 fetch.rb, 1.8, 1.9 Message-ID: <200607141428.k6EESkUi005376@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5347/lib/bio/io Modified Files: ensembl.rb fetch.rb Log Message: * Changes due to the refactoring of Bio::Command. Index: ensembl.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/ensembl.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ensembl.rb 27 Apr 2006 05:38:50 -0000 1.2 --- ensembl.rb 14 Jul 2006 14:28:44 -0000 1.3 *************** *** 215,219 **** result = nil ! Bio::Command::NetTools.net_http_start(@uri.host, @uri.port) {|http| result, = http.post(@path, data) } --- 215,219 ---- result = nil ! Bio::Command.start_http(@uri.host, @uri.port) {|http| result, = http.post(@path, data) } Index: fetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fetch.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fetch.rb 8 May 2006 14:29:58 -0000 1.8 --- fetch.rb 14 Jul 2006 14:28:44 -0000 1.9 *************** *** 107,111 **** query = query.join('&') ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)) end --- 107,111 ---- query = query.join('&') ! Bio::Command.read_uri(@url + '?' + URI.escape(query)) end *************** *** 142,146 **** query = "info=dbs" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end --- 142,146 ---- query = "info=dbs" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end *************** *** 159,163 **** query = "info=formats;db=#{database}" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end end --- 159,163 ---- query = "info=formats;db=#{database}" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end end *************** *** 173,177 **** query = "info=maxids" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).to_i end --- 173,177 ---- query = "info=maxids" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).to_i end From ngoto at dev.open-bio.org Fri Jul 14 10:30:11 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:30:11 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io fastacmd.rb,1.11,1.12 Message-ID: <200607141430.k6EEUBjX005405@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5385/lib/bio/io Modified Files: fastacmd.rb Log Message: * Changes due to the reconstruction of Bio::Command. * Attrute 'errorlog' is removed. Index: fastacmd.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fastacmd.rb 21 Mar 2006 12:18:14 -0000 1.11 --- fastacmd.rb 14 Jul 2006 14:30:09 -0000 1.12 *************** *** 69,73 **** include Enumerable - include Bio::Command::Tools # Database file path. --- 69,72 ---- *************** *** 77,82 **** attr_accessor :fastacmd - attr_accessor :errorlog - # This method provides a handle to a BLASTable database, which you can then # use to retrieve sequences. --- 76,79 ---- *************** *** 136,142 **** cmd = [ @fastacmd, '-d', @database, '-s', entry_id ] ! call_command_local(cmd) do |inn, out| ! inn.close_write ! Bio::FlatFile.new(Bio::FastaFormat, out).to_a end end --- 133,139 ---- cmd = [ @fastacmd, '-d', @database, '-s', entry_id ] ! Bio::Command.call_command(cmd) do |io| ! io.close_write ! Bio::FlatFile.new(Bio::FastaFormat, io).to_a end end *************** *** 151,157 **** def each_entry cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] ! call_command_local(cmd) do |inn, out| ! inn.close_write ! Bio::FlatFile.open(Bio::FastaFormat, out) do |f| f.each_entry do |entry| yield entry --- 148,154 ---- def each_entry cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] ! Bio::Command.call_command(cmd) do |io| ! io.close_write ! Bio::FlatFile.open(Bio::FastaFormat, io) do |f| f.each_entry do |entry| yield entry From ngoto at dev.open-bio.org Fri Jul 14 10:48:58 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:48:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io keggapi.rb, 1.11, 1.12 pubmed.rb, 1.13, 1.14 registry.rb, 1.17, 1.18 Message-ID: <200607141448.k6EEmwAC005544@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5517/lib/bio/io Modified Files: keggapi.rb pubmed.rb registry.rb Log Message: * Changed to use Bio::Command.new_http instead of Net::HTTP.new. * Changed to use Bio::Command.start_http instead of Net::HTTP.start. Index: pubmed.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/pubmed.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pubmed.rb 16 Mar 2006 17:29:05 -0000 1.13 --- pubmed.rb 14 Jul 2006 14:48:56 -0000 1.14 *************** *** 24,27 **** --- 24,28 ---- require 'net/http' require 'cgi' unless defined?(CGI) + require 'bio/command' module Bio *************** *** 86,90 **** path = "/entrez/query.fcgi?tool=bioruby&cmd=Search&doptcmdl=MEDLINE&db=PubMed&term=" ! http = Net::HTTP.new(host) response, = http.get(path + CGI.escape(str)) result = response.body --- 87,91 ---- path = "/entrez/query.fcgi?tool=bioruby&cmd=Search&doptcmdl=MEDLINE&db=PubMed&term=" ! http = Bio::Command.new_http(host) response, = http.get(path + CGI.escape(str)) result = response.body *************** *** 123,127 **** path = "/entrez/eutils/esearch.fcgi?tool=bioruby&db=pubmed&#{opts.join('&')}&term=" ! http = Net::HTTP.new(host) response, = http.get(path + CGI.escape(str)) result = response.body --- 124,128 ---- path = "/entrez/eutils/esearch.fcgi?tool=bioruby&db=pubmed&#{opts.join('&')}&term=" ! http = Bio::Command.new_http(host) response, = http.get(path + CGI.escape(str)) result = response.body *************** *** 140,144 **** path = "/entrez/query.fcgi?tool=bioruby&cmd=Text&dopt=MEDLINE&db=PubMed&uid=" ! http = Net::HTTP.new(host) response, = http.get(path + id.to_s) result = response.body --- 141,145 ---- path = "/entrez/query.fcgi?tool=bioruby&cmd=Text&dopt=MEDLINE&db=PubMed&uid=" ! http = Bio::Command.new_http(host) response, = http.get(path + id.to_s) result = response.body *************** *** 161,165 **** path = "/entrez/utils/pmfetch.fcgi?tool=bioruby&mode=text&report=medline&db=PubMed&id=" ! http = Net::HTTP.new(host) response, = http.get(path + id.to_s) result = response.body --- 162,166 ---- path = "/entrez/utils/pmfetch.fcgi?tool=bioruby&mode=text&report=medline&db=PubMed&id=" ! http = Bio::Command.new_http(host) response, = http.get(path + id.to_s) result = response.body *************** *** 189,193 **** ids = ids.join(",") ! http = Net::HTTP.new(host) response, = http.get(path + ids) result = response.body --- 190,194 ---- ids = ids.join(",") ! http = Bio::Command.new_http(host) response, = http.get(path + ids) result = response.body Index: registry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/registry.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** registry.rb 8 May 2006 14:29:58 -0000 1.17 --- registry.rb 14 Jul 2006 14:48:56 -0000 1.18 *************** *** 85,88 **** --- 85,89 ---- require 'uri' require 'net/http' + require 'bio/command' *************** *** 171,175 **** def read_remote(url) schema, user, host, port, reg, path, = URI.split(url) ! Net::HTTP.start(host, port) do |http| response, = http.get(path) parse_stanza(response.body) --- 172,176 ---- def read_remote(url) schema, user, host, port, reg, path, = URI.split(url) ! Bio::Command.start_http(host, port) do |http| response, = http.get(path) parse_stanza(response.body) Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/keggapi.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** keggapi.rb 18 Dec 2005 19:10:55 -0000 1.11 --- keggapi.rb 14 Jul 2006 14:48:56 -0000 1.12 *************** *** 24,27 **** --- 24,28 ---- require 'uri' require 'net/http' + require 'bio/command' module Bio *************** *** 96,100 **** filename ||= File.basename(path) ! http = Net::HTTP.new(host, port) response, = http.get(path) File.open(filename, "w+") do |f| --- 97,101 ---- filename ||= File.basename(path) ! http = Bio::Command.new_http(host, port) response, = http.get(path) File.open(filename, "w+") do |f| From ngoto at dev.open-bio.org Fri Jul 14 10:48:58 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:48:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fantom.rb,1.12,1.13 Message-ID: <200607141448.k6EEmwXK005539@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory dev.open-bio.org:/tmp/cvs-serv5517/lib/bio/db Modified Files: fantom.rb Log Message: * Changed to use Bio::Command.new_http instead of Net::HTTP.new. * Changed to use Bio::Command.start_http instead of Net::HTTP.start. Index: fantom.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fantom.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fantom.rb 30 Apr 2006 05:57:40 -0000 1.12 --- fantom.rb 14 Jul 2006 14:48:55 -0000 1.13 *************** *** 16,19 **** --- 16,20 ---- require 'bio/db' + require 'bio/command' #require 'bio/sequence' *************** *** 33,41 **** port = 80 path = "/db/maxml/maxmlseq.cgi?masterid=#{URI.escape(idstr.to_s)}&style=xml" - proxy = URI.parse(http_proxy.to_s) xml = '' ! Net::HTTP.start(addr, port, proxy.host, proxy.port) do |http| ! response, = http.get(path) ! xml = response.body end xml --- 34,49 ---- port = 80 path = "/db/maxml/maxmlseq.cgi?masterid=#{URI.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 From nakao at dev.open-bio.org Sat Jul 15 11:29:28 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 15 Jul 2006 15:29:28 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db/embl test_sptr.rb,1.3,1.4 Message-ID: <200607151529.k6FFTSAn008912@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv8890/test/unit/bio/db/embl Modified Files: test_sptr.rb Log Message: * Refactered code for parsing CC lines. * Added Bio::SPTR#ref method. * Added comprehensive tests for the recent updates of UniProt. * Added OH line parser (Bio::SPTR#oh). * Added HI line parser (Bio::SPTR#hi). Index: test_sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/embl/test_sptr.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_sptr.rb 16 Jun 2006 16:51:05 -0000 1.3 --- test_sptr.rb 15 Jul 2006 15:29:26 -0000 1.4 *************** *** 2,20 **** # test/unit/bio/db/embl/test_sptr.rb - Unit test for Bio::SPTR # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. ! # ! # This library is distributed in the hope that it will be useful, [...1716 lines suppressed...] ! {'NCBI_TaxID' => '35938', 'HostName' => 'Robinia pseudoacacia (Black locust)'}, ! {'NCBI_TaxID' => '23216', 'HostName' => 'Rubus (bramble)'}, ! {'NCBI_TaxID' => '4113', 'HostName' => 'Solanum tuberosum (Potato)'}, ! {'NCBI_TaxID' => '13305', 'HostName' => 'Tulipa'}, ! {'NCBI_TaxID' => '3603', 'HostName' => 'Vitis'}] ! sp = SPTR.new(data) ! assert_equal(res, sp.oh) ! end ! ! def test_OH_line_exception ! data = "ID TEST_ENTRY STANDARD; PRT; 393 AA. ! OH NCBI_TaxID=23216x: Rubus (bramble)." ! sp = SPTR.new(data) ! assert_raise(ArgumentError) { sp.oh } ! end ! ! end ! ! end # module Bio ! From nakao at dev.open-bio.org Sat Jul 15 11:29:28 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 15 Jul 2006 15:29:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl sptr.rb,1.33,1.34 Message-ID: <200607151529.k6FFTSQ4008917@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv8890/lib/bio/db/embl Modified Files: sptr.rb Log Message: * Refactered code for parsing CC lines. * Added Bio::SPTR#ref method. * Added comprehensive tests for the recent updates of UniProt. * Added OH line parser (Bio::SPTR#oh). * Added HI line parser (Bio::SPTR#hi). Index: sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/sptr.rb,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** sptr.rb 11 Jul 2006 15:52:51 -0000 1.33 --- sptr.rb 15 Jul 2006 15:29:26 -0000 1.34 *************** *** 187,200 **** # === GN Line: Gene name(s) (>=0, optional) def gn ! return @data['GN'] if @data['GN'] ! ! case fetch('GN') ! when /Name=/ then ! return gn_uniprot_parser ! else ! return gn_old_parser end end # returns contents in the old style GN line. # === GN Line: Gene name(s) (>=0, optional) --- 187,202 ---- # === GN Line: Gene name(s) (>=0, optional) def gn ! unless @data['GN'] ! case fetch('GN') ! when /Name=/,/ORFNames=/ ! @data['GN'] = gn_uniprot_parser ! else ! @data['GN'] = gn_old_parser ! end end + @data['GN'] end + # returns contents in the old style GN line. # === GN Line: Gene name(s) (>=0, optional) *************** *** 218,222 **** } end ! return @data['GN'] = names end private :gn_old_parser --- 220,224 ---- } end ! @data['GN'] = names end private :gn_old_parser *************** *** 348,351 **** --- 350,380 ---- end + # === The OH Line; + # + # OH NCBI_TaxID=TaxID; HostName. + # http://br.expasy.org/sprot/userman.html#OH_line + def oh + unless @data['OH'] + @data['OH'] = fetch('OH').split("\. ").map {|x| + if x =~ /NCBI_TaxID=(\d+);/ + taxid = $1 + else + raise ArgumentError, ["Error: Invalid OH line format (#{self.entry_id}):", + $!, "\n", get('OH'), "\n"].join + + end + if x =~ /NCBI_TaxID=\d+; (.+)/ + host_name = $1 + host_name.sub!(/\.$/, '') + else + host_name = nil + end + {'NCBI_TaxID' => taxid, 'HostName' => host_name} + } + end + @data['OH'] + end + + # Bio::EMBLDB::Common#ref -> Array *************** *** 353,356 **** --- 382,543 ---- # RN RC RP RX RA RT RL + # returns contents in the R lines. + # * Bio::EMBLDB::Common#ref -> [ * ] + # where is: + # {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '', + # 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''} + # + # R Lines + # * RN RC RP RX RA RT RL RG + def ref + unless @data['R'] + @data['R'] = [get('R').split(/\nRN /)].flatten.map { |str| + hash = {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '', + 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''} + str = 'RN ' + str unless /^RN / =~ str + + str.split("\n").each do |line| + if /^(R[NPXARLCTG]) (.+)/ =~ line + hash[$1] += $2 + ' ' + else + raise "Invalid format in R lines, \n[#{line}]\n" + end + end + + hash['RN'] = set_RN(hash['RN']) + hash['RC'] = set_RC(hash['RC']) + hash['RP'] = set_RP(hash['RP']) + hash['RX'] = set_RX(hash['RX']) + hash['RA'] = set_RA(hash['RA']) + hash['RT'] = set_RT(hash['RT']) + hash['RL'] = set_RL(hash['RL']) + hash['RG'] = set_RG(hash['RG']) + + hash + } + + end + @data['R'] + end + + def set_RN(data) + data.strip + end + + def set_RC(data) + data.scan(/([STP]\w+)=(.+);/).map { |comment| + [comment[1].split(/, and |, /)].flatten.map { |text| + {'Token' => comment[0], 'Text' => text} + } + }.flatten + end + private :set_RC + + def set_RP(data) + data = data.strip + data = data.sub(/\.$/, '') + data.split(/, AND |, /i).map {|x| + x = x.strip + x = x.gsub(' ', ' ') + } + end + private :set_RP + + def set_RX(data) + rx = {'MEDLINE' => nil, 'PubMed' => nil, 'DOI' => nil} + if data =~ /MEDLINE=(.+?);/ + rx['MEDLINE'] = $1 + end + if data =~ /PubMed=(.+?);/ + rx['PubMed'] = $1 + end + if data =~ /DOI=(.+?);/ + rx['DOI'] = $1 + end + rx + end + private :set_RX + + def set_RA(data) + data = data.sub(/; *$/, '') + end + private :set_RA + + def set_RT(data) + data = data.sub(/; *$/, '') + data = data.gsub(/(^"|"$)/, '') + end + private :set_RT + + def set_RL(data) + data = data.strip + end + private :set_RL + + def set_RG(data) + data = data.split('; ') + end + private :set_RG + + + + # returns Bio::Reference object from Bio::EMBLDB::Common#ref. + # * Bio::EMBLDB::Common#ref -> Bio::References + def references + unless @data['references'] + ary = self.ref.map {|ent| + hash = Hash.new('') + ent.each {|key, value| + case key + when 'RA' + hash['authors'] = value.split(/, /) + when 'RT' + hash['title'] = value + when 'RL' + if value =~ /(.*) (\d+) \((\d+)\), (\d+-\d+) \((\d+)\)$/ + hash['journal'] = $1 + hash['volume'] = $2 + hash['issue'] = $3 + hash['pages'] = $4 + hash['year'] = $5 + else + hash['journal'] = value + end + when 'RX' # PUBMED, MEDLINE + value.split('.').each {|item| + tag, xref = item.split(/; /).map {|i| i.strip } + hash[ tag.downcase ] = xref + } + end + } + Reference.new(hash) + } + @data['references'] = References.new(ary) + end + @data['references'] + end + + + + + + + # === The HI line + # Bio::SPTR#hi #=> hash + def hi + unless @data['HI'] + @data['HI'] = [] + fetch('HI').split(/\. /).each do |hlist| + hash = {'Category' => '', 'Keywords' => [], 'Keyword' => ''} + hash['Category'], hash['Keywords'] = hlist.split(': ') + hash['Keywords'] = hash['Keywords'].split('; ') + hash['Keyword'] = hash['Keywords'].pop + hash['Keyword'].sub!(/\.$/, '') + @data['HI'] << hash + end + end + @data['HI'] + end + @@cc_topics = ['PHARMACEUTICAL', *************** *** 422,429 **** # See also http://www.expasy.org/sprot/userman.html#CC_line # ! def cc(tag = nil) unless @data['CC'] cc = Hash.new ! cmt = '-' * (77 - 4 + 1) dlm = /-!- / --- 609,616 ---- # See also http://www.expasy.org/sprot/userman.html#CC_line # ! def cc(topic = nil) unless @data['CC'] cc = Hash.new ! comment_border= '-' * (77 - 4 + 1) dlm = /-!- / *************** *** 433,446 **** cc_raw = fetch('CC') cc_raw.sub!(/ *---.+---/m, '') # Not any CC Lines without the copyright statement. return cc if cc_raw == '' - begin ! cc_raw.split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 ! body = $2.gsub(/- (?!AND)/,'-') unless cc[key] cc[key] = [body] --- 620,640 ---- cc_raw = fetch('CC') + # Removing the copyright statement. cc_raw.sub!(/ *---.+---/m, '') + # Not any CC Lines without the copyright statement. return cc if cc_raw == '' begin ! cc_raw, copyright = cc_raw.split(/#{comment_border}/)[0] ! cc_raw = cc_raw.sub(dlm,'') ! cc_raw.split(dlm).each do |tmp| ! tmp = tmp.strip ! if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 ! body = $2 ! body.gsub!(/- (?!AND)/,'-') ! body.strip! unless cc[key] cc[key] = [body] *************** *** 449,454 **** end else ! raise ["Error: [#{entry_id}]: CC Lines", '', ! tmp, '', '', fetch('CC'),''].join("\n") end end --- 643,648 ---- end else ! raise ["Error: [#{entry_id}]: CC Lines", '"', tmp, '"', ! '', get('CC'),''].join("\n") end end *************** *** 466,493 **** end - case tag - when 'ALTERNATIVE PRODUCTS' - ap = @data['CC']['ALTERNATIVE PRODUCTS'].to_s - return ap unless ap - - # Event, Named isoforms, Comment, [Name, Synonyms, IsoId, Sequnce]+ - tmp = {'Event' => nil, 'Named isoforms' => nil, 'Comment' => nil, - 'Variants' => []} - - if /Event=(.+?);/ =~ ap - tmp['Event'] = $1 - end - if /Named isoforms=(\S+?);/ =~ ap - tmp['Named isoforms'] = $1 - end - if /Comment=(.+?);/m =~ ap - tmp['Comment'] = $1 - end - ap.scan(/Name=.+?Sequence=.+?;/).each do |ent| - tmp['Variants'] << cc_ap_variants_parse(ent) - end - return tmp - when 'DATABASE' # DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"]. --- 660,719 ---- end + case topic + when 'ALLERGEN' + return @data['CC'][topic] + when 'ALTERNATIVE PRODUCTS' + return cc_alternative_products(@data['CC'][topic]) + when 'BIOPHYSICOCHEMICAL PROPERTIES' + return cc_biophysiochemical_properties(@data['CC'][topic]) + when 'BIOTECHNOLOGY' + return @data['CC'][topic] + when 'CATALITIC ACTIVITY' + return cc_catalytic_activity(@data['CC'][topic]) + when 'CAUTION' + return cc_caution(@data['CC'][topic]) + when 'COFACTOR' + return @data['CC'][topic] + when 'DEVELOPMENTAL STAGE' + return @data['CC'][topic].to_s + when 'DISEASE' + return @data['CC'][topic].to_s + when 'DOMAIN' + return @data['CC'][topic] + when 'ENZYME REGULATION' + return @data['CC'][topic].to_s + when 'FUNCTION' + return @data['CC'][topic].to_s + when 'INDUCTION' + return @data['CC'][topic].to_s + when 'INTERACTION' + return cc_interaction(@data['CC'][topic]) + when 'MASS SPECTROMETRY' + return cc_mass_spectrometry(@data['CC'][topic]) + when 'MISCELLANEOUS' + return @data['CC'][topic] + when 'PATHWAY' + return cc_pathway(@data['CC'][topic]) + when 'PHARMACEUTICAL' + return @data['CC'][topic] + when 'POLYMORPHISM' + return @data['CC'][topic] + when 'PTM' + return @data['CC'][topic] + when 'RNA EDITING' + return cc_rna_editing(@data['CC'][topic]) + when 'SIMILARITY' + return @data['CC'][topic] + when 'SUBCELLULAR LOCATION' + return cc_subcellular_location(@data['CC'][topic]) + when 'SUBUNIT' + return @data['CC'][topic] + when 'TISSUE SPECIFICITY' + return @data['CC'][topic] + when 'TOXIC DOSE' + return @data['CC'][topic] + when 'WEB RESOURCE' + return cc_web_resource(@data['CC'][topic]) when 'DATABASE' # DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"]. *************** *** 513,566 **** end return tmp - - when 'MASS SPECTOROMETRY' - # MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX]. - tmp = Array.new - ms = @data['CC']['MASS SPECTOROMETRY'] - return ms unless ms - - ms.each do |m| - mass = {'MW' => nil,'MW_ERR' => nil,'METHOD' => nil,'RANGE' => nil} - m.sub(/.$/,'').split(/;/).each do |line| - case line - when /MW=(.+)/ - mass['MW'] = $1.to_f - when /MW_ERR=(.+)/ - mass['MW_ERR'] = $1.to_f - when /METHOD="(.+)"/ - mass['METHOD'] = $1.to_s - when /RANGE="(\d+-\d+)"/ - mass['RANGE'] = $1 # RANGE class ? - end - end - tmp.push(mass) - end - return tmp - - when 'INTERACTION' - return cc_interaction_parse(@data['CC']['INTERACTION'].to_s) - when nil return @data['CC'] - else ! return @data['CC'][tag] end end ! def cc_ap_variants_parse(ent) ! hsh = {} ! ent.split(/; /).map {|e| e.split(/=/) }.each do |e| case e[0] ! when 'Sequence' e[1] = e[1].sub(/;/,'').split(/, /) end ! hsh[e[0]] = e[1] end ! return hsh end ! private :cc_ap_variants_parse --- 739,827 ---- end return tmp when nil return @data['CC'] else ! return @data['CC'][topic] end end + def cc_alternative_products(data) + ap = data.to_s + return ap unless ap ! # Event, Named isoforms, Comment, [Name, Synonyms, IsoId, Sequnce]+ ! tmp = {'Event' => "", 'Named isoforms' => "", 'Comment' => "", ! 'Variants' => []} ! if /Event=(.+?);/ =~ ap ! tmp['Event'] = $1 ! tmp['Event'] = tmp['Event'].sub(/;/,'').split(/, /) ! end ! if /Named isoforms=(\S+?);/ =~ ap ! tmp['Named isoforms'] = $1 ! end ! if /Comment=(.+?);/m =~ ap ! tmp['Comment'] = $1 ! end ! ap.scan(/Name=.+?Sequence=.+?;/).each do |ent| ! tmp['Variants'] << cc_alternative_products_variants(ent) ! end ! return tmp ! end ! private :cc_alternative_products ! ! def cc_alternative_products_variants(data) ! variant = {'Name' => '', 'Synonyms' => [], 'IsoId' => [], 'Sequence' => []} ! data.split(/; /).map {|x| x.split(/=/) }.each do |e| case e[0] ! when 'Sequence', 'Synonyms', 'IsoId' e[1] = e[1].sub(/;/,'').split(/, /) end ! variant[e[0]] = e[1] end ! variant end ! private :cc_alternative_products_variants ! ! ! def cc_biophysiochemical_properties(data) ! data = data[0] ! ! hash = {'Absorption' => {}, ! 'Kinetic parameters' => {}, ! 'pH dependence' => "", ! 'Redox potential' => "", ! 'Temperature dependence' => ""} ! if data =~ /Absorption: Abs\(max\)=(.+?);/ ! hash['Absorption']['Abs(max)'] = $1 ! end ! if data =~ /Absorption: Abs\(max\)=.+; Note=(.+?);/ ! hash['Absorption']['Note'] = $1 ! end ! if data =~ /Kinetic parameters: KM=(.+?); Vmax=(.+?);/ ! hash['Kinetic parameters']['KM'] = $1 ! hash['Kinetic parameters']['Vmax'] = $2 ! end ! if data =~ /Kinetic parameters: KM=.+; Vmax=.+; Note=(.+?);/ ! hash['Kinetic parameters']['Note'] = $1 ! end ! if data =~ /pH dependence: (.+?);/ ! hash['pH dependence'] = $1 ! end ! if data =~ /Redox potential: (.+?);/ ! hash['Redox potential'] = $1 ! end ! if data =~ /Temperature dependence: (.+?);/ ! hash['Temperature dependence'] = $1 ! end ! hash ! end ! private :cc_biophysiochemical_properties ! ! ! def cc_caution(data) ! data.to_s ! end ! private :cc_caution *************** *** 568,583 **** # # CC P46527:CDKN1B; NbExp=1; IntAct=EBI-359815, EBI-519280; ! def cc_interaction_parse(str) it = str.scan(/(.+?); NbExp=(.+?); IntAct=(.+?);/) it.map {|ent| ! {:partner_id => ent[0].strip, ! :nbexp => ent[1].strip, ! :intact_acc => ent[2].split(', ') } } end ! private :cc_interaction_parse # returns databases cross-references in the DR lines. ! # * Bio::EMBLDB#dr -> Hash w/in Array # # === DR Line; defabases cross-reference (>=0) --- 829,944 ---- # # CC P46527:CDKN1B; NbExp=1; IntAct=EBI-359815, EBI-519280; ! def cc_interaction(data) ! str = data.to_s it = str.scan(/(.+?); NbExp=(.+?); IntAct=(.+?);/) it.map {|ent| ! ent.map! {|x| x.strip } ! if ent[0] =~ /^(.+):(.+)/ ! spac = $1 ! spid = $2.split(' ')[0] ! optid = nil ! elsif ent[0] =~ /Self/ ! spac = self.entry_id ! spid = self.entry_id ! optid = nil ! end ! if ent[0] =~ /^.+:.+ (.+)/ ! optid = $1 ! end ! ! {'SP_Ac' => spac, ! 'identifier' => spid, ! 'NbExp' => ent[1], ! 'IntAct' => ent[2].split(', '), ! 'optional_identifier' => optid} } end ! private :cc_interaction ! ! ! def cc_mass_spectrometry(data) ! # MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX]. ! return data unless data ! ! data.map { |m| ! mass = {'MW' => nil, 'MW_ERR' => nil, 'METHOD' => nil, 'RANGE' => nil, ! 'NOTE' => nil} ! m.sub(/.$/,'').split(/;/).each do |line| ! case line ! when /MW=(.+)/ ! mass['MW'] = $1 ! when /MW_ERR=(.+)/ ! mass['MW_ERR'] = $1 ! when /METHOD=(.+)/ ! mass['METHOD'] = $1 ! when /RANGE=(\d+-\d+)/ ! mass['RANGE'] = $1 # RANGE class ? ! when /NOTE=(.+)/ ! mass['NOTE'] = $1 ! end ! end ! mass ! } ! end ! private :cc_mass_spectrometry ! ! ! def cc_pathway(data) ! data.map {|x| x.sub(/\.$/, '') }.map {|x| ! x.split(/; | and |: /) ! }[0] ! end ! private :cc_pathway ! ! ! def cc_rna_editing(data) ! data = data.to_s ! entry = {'Modified_positions' => [], 'Note' => ""} ! if data =~ /Modified_positions=(.+?)(\.|;)/ ! entry['Modified_positions'] = $1.sub(/\.$/, '').split(', ') ! else ! raise ArgumentError, "Invarid CC RNA Editing lines (#{self.entry_id}):#{$!}\n#{get('CC')}" ! end ! if data =~ /Note=(.+)/ ! entry['Note'] = $1 ! end ! entry ! end ! private :cc_rna_editing ! ! ! def cc_subcellular_location(data) ! data.map {|x| ! x.split('. ').map {|y| ! y.split('; ').map {|z| ! z.sub(/\.$/, '') ! } ! } ! }[0] ! end ! private :cc_subcellular_location ! ! ! # CC -!- WEB RESOURCE: NAME=ResourceName[; NOTE=FreeText][; URL=WWWAddress]. ! def cc_web_resource(data) ! data.map {|x| ! entry = {'NAME' => nil, 'NOTE' => nil, 'URL' => nil} ! x.split(';').each do |y| ! case y ! when /NAME=(.+)/ ! entry['NAME'] = $1.strip ! when /NOTE=(.+)/ ! entry['NOTE'] = $1.strip ! when /URL="(.+)"/ ! entry['URL'] = $1.strip ! end ! end ! entry ! } ! end ! # returns databases cross-references in the DR lines. ! # * Bio::SPTR#dr -> Hash w/in Array # # === DR Line; defabases cross-reference (>=0) *************** *** 591,594 **** --- 952,973 ---- 'SWISS-2DPAGE','TIGR','TRANSFAC','TUBERCULIST','WORMPEP','YEPD','ZFIN'] + # Backup Bio::EMBLDB#dr as embl_dr + alias :embl_dr :dr + + # Bio::SPTR#dr + def dr(key = nil) + unless key + embl_dr + else + embl_dr[key].map {|x| + {'Accession' => x[0], + 'Version' => x[1], + ' ' => x[2], + 'Molecular Type' => x[3]} + } + end + end + + # Bio::EMBLDB::Common#kw - Array # #keywords -> Array *************** *** 598,602 **** ! # returns conteins in the feature table. # # == Examples --- 977,981 ---- ! # returns contents in the feature table. # # == Examples *************** *** 612,621 **** # feature['FTId'] #=> '' # feature['diff'] #=> [] # end # end # # * Bio::SPTR#ft -> Hash ! # {FEATURE_KEY => [{'From' => int, 'To' => int, 'diff' => [], ! # 'Description' => aStr, 'FTId' => aStr}],...} # # returns an Array of the information about the feature_name in the feature table. --- 991,1003 ---- # feature['FTId'] #=> '' # feature['diff'] #=> [] + # feature['original'] #=> [feature_key, '1', '21', '', ''] # end # end # # * Bio::SPTR#ft -> Hash ! # {FEATURE_KEY => [{'From' => int, 'To' => int, ! # 'Description' => aStr, 'FTId' => aStr, ! # 'diff' => [original_residues, changed_residues], ! # 'original' => aAry }],...} # # returns an Array of the information about the feature_name in the feature table. *************** *** 634,637 **** --- 1016,1024 ---- # ----- ----------------- # + # Note: 'FROM' and 'TO' endopoints are allowed to use non-numerial charactors + # including '<', '>' or '?'. (c.f. '<1', '?42') + # + # See also http://www.expasy.org/sprot/userman.html#FT_line + # def ft(feature_key = nil) return ft[feature_key] if feature_key *************** *** 640,693 **** table = [] begin ! get('FT').split("\n").each do |line| ! if line =~ /^FT \w/ ! feature = line.chomp.ljust(74) ! table << [feature[ 5..12].strip, # Feature Name ! feature[14..19].strip, # From ! feature[21..26].strip, # To ! feature[34..74].strip ] # Description ! else ! table.last << line.chomp.sub!(/^FT +/, '') ! end ! end ! ! # Join Desctiption lines ! table = table.map { |feature| ! ftid = feature.pop if feature.last =~ /FTId=/ ! if feature.size > 4 ! feature = [feature[0], feature[1], feature[2], ! feature[3, feature.size - 3].join(" ")] end - feature << ftid - } ! hash = {} ! table.each do |feature| ! hash[feature[0]] = [] unless hash[feature[0]] ! ! hash[feature[0]] << { ! 'From' => feature[1].to_i, ! 'To' => feature[2].to_i, ! 'Description' => feature[3], ! 'FTId' => feature[4].to_s.sub(/\/FTId=/, '').sub(/\.$/, ''), ! 'diff' => [] } ! case feature[0] ! when 'VARSPLIC', 'VARIANT', 'VAR_SEQ', 'CONFLICT' ! case hash[feature[0]].last['Description'] ! when /(\w[\w ]*\w*) - ?> (\w[\w ]*\w*)/ ! original_res = $1 ! changed_res = $2 ! original_res = original_res.gsub(/ /,'').strip ! chenged_res = changed_res.gsub(/ /,'').strip ! when /Missing/i ! original_res = seq.subseq(hash[feature[0]].last['From'], ! hash[feature[0]].last['To']) ! changed_res = '' end - hash[feature[0]].last['diff'] = [original_res, chenged_res] end - end rescue raise "Invalid FT Lines(#{$!}) in #{entry_id}:, \n'#{self.get('FT')}'\n" --- 1027,1083 ---- table = [] begin ! get('FT').split("\n").each do |line| ! if line =~ /^FT \w/ ! feature = line.chomp.ljust(74) ! table << [feature[ 5..12].strip, # Feature Name ! feature[14..19].strip, # From ! feature[21..26].strip, # To ! feature[34..74].strip ] # Description ! else ! table.last << line.chomp.sub!(/^FT +/, '') ! end end ! # Joining Description lines ! table = table.map { |feature| ! ftid = feature.pop if feature.last =~ /FTId=/ ! if feature.size > 4 ! feature = [feature[0], ! feature[1], ! feature[2], ! feature[3, feature.size - 3].join(" ")] ! end ! feature << if ftid then ftid else '' end } ! hash = {} ! table.each do |feature| ! hash[feature[0]] = [] unless hash[feature[0]] ! hash[feature[0]] << { ! # Removing '<', '>' or '?' in FROM/TO endopoint. ! 'From' => feature[1].sub(/\D/, '').to_i, ! 'To' => feature[2].sub(/\D/, '').to_i, ! 'Description' => feature[3], ! 'FTId' => feature[4].to_s.sub(/\/FTId=/, '').sub(/\.$/, ''), ! 'diff' => [], ! 'original' => feature ! } ! ! case feature[0] ! when 'VARSPLIC', 'VARIANT', 'VAR_SEQ', 'CONFLICT' ! case hash[feature[0]].last['Description'] ! when /(\w[\w ]*\w*) - ?> (\w[\w ]*\w*)/ ! original_res = $1 ! changed_res = $2 ! original_res = original_res.gsub(/ /,'').strip ! chenged_res = changed_res.gsub(/ /,'').strip ! when /Missing/i ! original_res = seq.subseq(hash[feature[0]].last['From'], ! hash[feature[0]].last['To']) ! changed_res = '' ! end ! hash[feature[0]].last['diff'] = [original_res, chenged_res] end end rescue raise "Invalid FT Lines(#{$!}) in #{entry_id}:, \n'#{self.get('FT')}'\n" *************** *** 872,875 **** --- 1262,1266 ---- # OC - organism classification (>=1 per entry) # OX - organism taxonomy x-ref (>=1 per entry) + # OH - Organism Host # RN - reference number (>=1 per entry) # RP - reference positions (>=1 per entry) *************** *** 879,882 **** --- 1270,1274 ---- # RT - reference title (>=0 per entry; optional) # RL - reference location (>=1 per entry) + # RG - reference group(s) # CC - comments or notes (>=0 per entry; optional) # DR - database cross-references (>=0 per entry; optional) From ngoto at dev.open-bio.org Wed Jul 19 23:45:24 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 20 Jul 2006 03:45:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence na.rb,1.4,1.5 Message-ID: <200607200345.k6K3jOVA012571@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory dev.open-bio.org:/tmp/cvs-serv12551/lib/bio/sequence Modified Files: na.rb Log Message: In gc_content, at_content, gc_skew, at_skew methods, changed to use Numeric#quo instead of Float#/. Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/na.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** na.rb 27 Jun 2006 05:44:57 -0000 1.4 --- na.rb 20 Jul 2006 03:45:22 -0000 1.5 *************** *** 308,312 **** gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return (gc.to_f / (at + gc).to_f) end --- 308,312 ---- gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return gc.quo(at + gc) end *************** *** 322,326 **** gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return (at.to_f / (at + gc).to_f) end --- 322,326 ---- gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return at.quo(at + gc) end *************** *** 336,340 **** c = count['c'] return 0.0 if g + c == 0 ! return ((g - c).to_f / (g + c).to_f) end --- 336,340 ---- c = count['c'] return 0.0 if g + c == 0 ! return (g - c).quo(g + c) end *************** *** 350,354 **** t = count['t'] + count['u'] return 0.0 if a + t == 0 ! return ((a - t).to_f / (a + t).to_f) end --- 350,354 ---- t = count['t'] + count['u'] return 0.0 if a + t == 0 ! return (a - t).quo(a + t) end From k at dev.open-bio.org Tue Jul 25 14:16:31 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:16:31 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.15,1.16 Message-ID: <200607251816.k6PIGVw6027202@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory dev.open-bio.org:/tmp/cvs-serv27198/bin Modified Files: bioruby Log Message: * changed to show working directory when exit Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** bioruby 27 Feb 2006 09:41:54 -0000 1.15 --- bioruby 25 Jul 2006 18:16:28 -0000 1.16 *************** *** 24,40 **** # command line argument (working directory or bioruby shell script file) script = nil if arg = ARGV.shift if File.directory?(arg) # directory or symlink to directory ! Dir.chdir(arg) elsif File.exists?(arg) # BioRuby shell script (load script after the previous session is restored) ! dir = File.dirname(arg) script = File.basename(arg) ! Dir.chdir(dir) ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) end else --- 24,43 ---- # command line argument (working directory or bioruby shell script file) + workdir = nil script = nil if arg = ARGV.shift if File.directory?(arg) # directory or symlink to directory ! workdir = arg ! Dir.chdir(workdir) elsif File.exists?(arg) # BioRuby shell script (load script after the previous session is restored) ! workdir = File.dirname(arg) script = File.basename(arg) ! Dir.chdir(workdir) ! else ! workdir = arg ! Dir.mkdir(workdir) ! Dir.chdir(workdir) end else *************** *** 150,151 **** --- 153,160 ---- Bio::Shell.save_session + if workdir + puts "Leaving directory '#{workdir}'." + puts "History is saved in '#{workdir}/#{Bio::Shell.history}'." + end + + From k at dev.open-bio.org Tue Jul 25 14:18:23 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:18:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io fastacmd.rb,1.12,1.13 Message-ID: <200607251818.k6PIINNt027229@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv27223/lib/bio/io Modified Files: fastacmd.rb Log Message: * fixed to work with newer version of fastacmd (suggested by the author of this module, Shuji Shigenbu) Index: fastacmd.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fastacmd.rb 14 Jul 2006 14:30:09 -0000 1.12 --- fastacmd.rb 25 Jul 2006 18:18:21 -0000 1.13 *************** *** 147,151 **** # *Returns*:: a Bio::FastaFormat object for each iteration def each_entry ! cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] Bio::Command.call_command(cmd) do |io| io.close_write --- 147,151 ---- # *Returns*:: a Bio::FastaFormat object for each iteration def each_entry ! cmd = [ @fastacmd, '-d', @database, '-D', '1' ] Bio::Command.call_command(cmd) do |io| io.close_write From k at dev.open-bio.org Tue Jul 25 14:21:28 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:21:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio pathway.rb,1.34,1.35 Message-ID: <200607251821.k6PILShI027308@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv27304/lib/bio Modified Files: pathway.rb Log Message: * changed to RDoc format * changed to Ruby's license Index: pathway.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/pathway.rb,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** pathway.rb 18 Dec 2005 16:50:56 -0000 1.34 --- pathway.rb 25 Jul 2006 18:21:26 -0000 1.35 *************** *** 1,21 **** # ! # bio/pathway.rb - Binary relations and Graph algorithms ! # ! # Copyright (C) 2001 KATAYAMA Toshiaki ! # KAWASHIMA Shuichi ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. [...1476 lines suppressed...] - --- Bio::Relation#eql?(rel) - --- Bio::Relation#hash - - Method eql? is an alias of the === method and is used with hash method - to make uniq arry of the Bio::Relation objects. - - a1 = Bio::Relation.new('a', 'b', 1) - a2 = Bio::Relation.new('b', 'a', 1) - a3 = Bio::Relation.new('b', 'c', 1) - p [ a1, a2, a3 ].uniq - - --- Bio::Relation#<=>(rel) - - Used by the each method to compare with another Bio::Relation object. - This method is only usable when the edge objects have the property of - the module Comparable. - - =end - --- 853,854 ---- From k at dev.open-bio.org Tue Jul 25 14:41:25 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:41:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl psort.rb,1.10,1.11 Message-ID: <200607251841.k6PIfPZu027478@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27438/lib/bio/appl Modified Files: psort.rb Log Message: * changed to use autoload * changed to require 'psort/report' from psort.rb to make PSORT::PSORT2::SclNames available whenever psort.rb is loaded. Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** psort.rb 14 Jul 2006 14:28:44 -0000 1.10 --- psort.rb 25 Jul 2006 18:41:23 -0000 1.11 *************** *** 28,34 **** # ! require 'bio/sequence' ! require 'bio/command' ! require 'bio/db/fasta' require 'cgi' --- 28,34 ---- # ! require 'bio/appl/psort/report' ! autoload :FastaFormat, 'bio/db/fasta' ! autoload :Command, 'bio/command' require 'cgi' From k at dev.open-bio.org Tue Jul 25 14:41:25 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:41:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/psort report.rb,1.13,1.14 Message-ID: <200607251841.k6PIfPjh027483@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/psort In directory dev.open-bio.org:/tmp/cvs-serv27438/lib/bio/appl/psort Modified Files: report.rb Log Message: * changed to use autoload * changed to require 'psort/report' from psort.rb to make PSORT::PSORT2::SclNames available whenever psort.rb is loaded. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort/report.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** report.rb 30 Apr 2006 07:11:28 -0000 1.13 --- report.rb 25 Jul 2006 18:41:23 -0000 1.14 *************** *** 11,15 **** # - require 'bio/sequence' require 'bio/appl/psort' --- 11,14 ---- *************** *** 17,20 **** --- 16,21 ---- module Bio + autoload :Sequence, 'bio/sequence' + class PSORT From k at dev.open-bio.org Tue Jul 25 14:42:11 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:42:11 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin psort.rb,NONE,1.1 Message-ID: <200607251842.k6PIgBSu027526@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory dev.open-bio.org:/tmp/cvs-serv27522/lib/bio/shell/plugin Added Files: psort.rb Log Message: * newly added shell plugin for psort --- NEW FILE: psort.rb --- # # = bio/shell/plugin/psort.rb - plugin for PSORT # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: psort.rb,v 1.1 2006/07/25 18:42:09 k Exp $ # module Bio::Shell private def psort1(str) seq = seq(str) if seq.is_a?(Bio::Sequence::NA) seq = seq.translate end psort = Bio::PSORT::PSORT1.imsut fasta = seq.to_fasta results = psort.exec(fasta).final_result results.each do |result| puts "#{result["certainty"].to_f*100.0}\t#{result["prediction"]}" end return results.first["prediction"] end def psort2(str) seq = seq(str) if seq.is_a?(Bio::Sequence::NA) seq = seq.translate end psort = Bio::PSORT::PSORT2.imsut fasta = seq.to_fasta results = psort.exec(fasta).prob.sort_by{|x, y| y}.reverse results.each do |loc, prob| next if prob <= 0.0 puts "#{prob}\t#{Bio::PSORT::PSORT2::SclNames[loc]}" end return results.first.first end def psort2locations names = Bio::PSORT::PSORT2::SclNames names.sort.each do |loc, desc| puts "#{loc}\t#{desc}" end return names end end From k at dev.open-bio.org Tue Jul 25 14:43:19 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:43:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin blast.rb,NONE,1.1 Message-ID: <200607251843.k6PIhJWi027569@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory dev.open-bio.org:/tmp/cvs-serv27565/lib/bio/shell/plugin Added Files: blast.rb Log Message: * newly added shell plugin for blast (currently only supports blast against KEGG GENES peptides) --- NEW FILE: blast.rb --- # # = bio/shell/plugin/blast.rb - plugin for BLAST services # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: blast.rb,v 1.1 2006/07/25 18:43:17 k Exp $ # module Bio::Shell private # GenomeNet def keggblast(query) server = Bio::Blast.remote("blastp", "genes", "", "genomenet_tab") if query[/^>/] data = Bio::FastaFormat.new(query) desc = data.definition tmp = seq(data.seq) else desc = "query" tmp = seq(query) end if tmp.respond_to?(:translate) aaseq = tmp.translate else aaseq = tmp end fasta = aaseq.to_fasta(desc, 60) result = server.query(fasta) puts server.output return result end end From k at dev.open-bio.org Tue Jul 25 14:45:29 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:45:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.15,1.16 Message-ID: <200607251845.k6PIjTgL027632@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv27628/lib/bio Modified Files: shell.rb Log Message: * added blast and psort plugins Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** shell.rb 27 Feb 2006 09:34:23 -0000 1.15 --- shell.rb 25 Jul 2006 18:45:27 -0000 1.16 *************** *** 29,32 **** --- 29,34 ---- require 'bio/shell/plugin/keggapi' require 'bio/shell/plugin/emboss' + require 'bio/shell/plugin/blast' + require 'bio/shell/plugin/psort' extend Ghost From k at dev.open-bio.org Tue Jul 25 14:47:15 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:47:15 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.30,1.31 Message-ID: <200607251847.k6PIlFWo027706@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27702/lib/bio/appl Modified Files: blast.rb Log Message: * added exec_genomenet_tab method used by shell plugin Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** blast.rb 14 Jul 2006 14:26:39 -0000 1.30 --- blast.rb 25 Jul 2006 18:47:13 -0000 1.31 *************** *** 258,261 **** --- 258,265 ---- end + def exec_genomenet_tab(query) + @format = 8 + exec_genomenet(query) + end def exec_genomenet(query) From k at dev.open-bio.org Tue Jul 25 14:48:43 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:48:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl fasta.rb,1.21,1.22 Message-ID: <200607251848.k6PImh2c027731@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27727/lib/bio/appl Modified Files: fasta.rb Log Message: * remote fasta is currently broken (need to be fixed), added a comment for now. Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** fasta.rb 14 Jul 2006 14:26:39 -0000 1.21 --- fasta.rb 25 Jul 2006 18:48:41 -0000 1.22 *************** *** 149,153 **** result, = http.post(path, data.join('&')) @output = result.body ! # workaround 2005.08.12 if /\Show all result\<\/A\>/i =~ @output.to_s then result, = http.get($2) --- 149,153 ---- result, = http.post(path, data.join('&')) @output = result.body ! # workaround 2005.08.12 - realized that this is bloken again (by new batch queuing system) 2006.06.08 if /\Show all result\<\/A\>/i =~ @output.to_s then result, = http.get($2) From k at dev.open-bio.org Tue Jul 25 14:50:03 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:50:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/data aa.rb,0.17,0.18 Message-ID: <200607251850.k6PIo3pm027792@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/data In directory dev.open-bio.org:/tmp/cvs-serv27788/lib/bio/data Modified Files: aa.rb Log Message: * added J, O, and X amino acids Index: aa.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/aa.rb,v retrieving revision 0.17 retrieving revision 0.18 diff -C2 -d -r0.17 -r0.18 *** aa.rb 8 May 2006 14:19:51 -0000 0.17 --- aa.rb 25 Jul 2006 18:50:01 -0000 0.18 *************** *** 18,21 **** --- 18,22 ---- # * http://www.iupac.org/ # * http://www.chem.qmw.ac.uk/iubmb/newsletter/1999/item3.html + # * http://www.ebi.ac.uk/RESID/faq.html NAMES = { *************** *** 43,48 **** 'B' => 'Asx', # D/N 'Z' => 'Glx', # E/Q 'U' => 'Sec', # 'uga' (stop) ! '?' => 'Pyl', # 'uag' (stop) 'Ala' => 'alanine', --- 44,51 ---- 'B' => 'Asx', # D/N 'Z' => 'Glx', # E/Q + 'J' => 'Xle', # I/L 'U' => 'Sec', # 'uga' (stop) ! 'O' => 'Pyl', # 'uag' (stop) ! 'X' => 'Xaa', # (unknown) 'Ala' => 'alanine', *************** *** 68,73 **** --- 71,78 ---- 'Asx' => 'asparagine/aspartic acid', 'Glx' => 'glutamine/glutamic acid', + 'Xle' => 'isoleucine/leucine', 'Sec' => 'selenocysteine', 'Pyl' => 'pyrrolysine', + 'Xaa' => 'unknown', } From k at dev.open-bio.org Tue Jul 25 14:53:58 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:53:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db prosite.rb,0.14,0.15 Message-ID: <200607251853.k6PIrwDV027835@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory dev.open-bio.org:/tmp/cvs-serv27831/lib/bio/db Modified Files: prosite.rb Log Message: * added 're' instance method in addition to 'pa2re' class method to return Regexp of the PATTERN entry instantly Index: prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/prosite.rb,v retrieving revision 0.14 retrieving revision 0.15 diff -C2 -d -r0.14 -r0.15 *** prosite.rb 8 May 2006 14:23:07 -0000 0.14 --- prosite.rb 25 Jul 2006 18:53:56 -0000 0.15 *************** *** 478,482 **** pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' pattern.tr!('-', '') # (6) each element is separated by a '-' ! Regexp.new(pattern) end --- 478,482 ---- pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' pattern.tr!('-', '') # (6) each element is separated by a '-' ! Regexp.new(pattern, Regexp::IGNORECASE) end *************** *** 485,488 **** --- 485,492 ---- end + def re + self.class.pa2re(self.pa) + end + ### prosite profile to regular expression From k at dev.open-bio.org Tue Jul 25 15:12:34 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:12:34 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg genes.rb,0.22,0.23 Message-ID: <200607251912.k6PJCYhr028011@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory dev.open-bio.org:/tmp/cvs-serv27986/lib/bio/db/kegg Modified Files: genes.rb Log Message: * changed to RDoc * changed to use autoload * 'keggclass' method is changed to the 'pathway' method (this field is renamed in the original database) * removed splinks method (this field is obsoleted in the original database) * chromosome method is slightly improved * locations method is added to return Bio::Locations object when possible * motifs method is added (this field is added in the original database) * codon_usage method is renamed to cu_list method (and disabled the codon argument - use hash for this purpose) which returns an Array of codon usages * cu method is renamed to codon_usage which returns a Hash of codon usage * aalen and ntlen method is changed to return the numbers written in the entry (not the number calculated by the sequence length - use seq.length for this purpose) Index: genes.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genes.rb,v retrieving revision 0.22 retrieving revision 0.23 diff -C2 -d -r0.22 -r0.23 *** genes.rb 9 Nov 2005 12:30:07 -0000 0.22 --- genes.rb 25 Jul 2006 19:12:32 -0000 0.23 *************** *** 1,293 **** # ! # bio/db/kegg/genes.rb - KEGG/GENES database class # ! # Copyright (C) 2001, 2002 KATAYAMA Toshiaki # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. # - # This library is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # Lesser General Public License for more details. # ! # You should have received a copy of the GNU Lesser General Public ! # License along with this library; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # ! ! require 'bio/db' module Bio ! class KEGG ! ! class GENES < KEGGDB ! DELIMITER = RS = "\n///\n" ! TAGSIZE = 12 ! def initialize(entry) ! super(entry, TAGSIZE) ! end ! def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip ! end ! @data['ENTRY'] = hash ! end ! @data['ENTRY'] ! end - def entry_id - entry['id'] - end ! def division ! entry['division'] # CDS, tRNA etc. end ! def organism ! entry['organism'] # H.sapiens etc. ! end ! def name ! field_fetch('NAME') ! end ! def genes ! name.split(', ') ! end ! def gene ! genes.first ! end ! def definition ! field_fetch('DEFINITION') ! end ! def eclinks ! # definition.slice(/\[EC:(.*?)\]/, 1) # ruby >= 1.7 ! # definition.scan(/\[EC:(.*?)\]/).flatten ! if /\[EC:(.*?)\]/.match(definition) ! $1.split(/\s+/) ! else ! [] ! end ! end ! def splinks ! # definition.slice(/\[SP:(.*?)\]/, 1) # ruby >= 1.7 ! # definition.scan(/\[SP:(.*?)\]/).flatten ! if /\[SP:(.*?)\]/.match(definition) ! $1.split(/\s+/) ! else ! [] ! end ! end ! def keggclass ! field_fetch('CLASS') ! end ! def pathways ! keggclass.scan(/\[PATH:(.*?)\]/).flatten ! end ! def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] ! end ! def gbposition ! position.sub(/.*?:/, '') ! end ! def chromosome ! if position =~ /:/ ! position.sub(/:.*/, '') ! else ! nil ! end ! end ! def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n?/).each do |db, str| ! id_array = str.strip.split(/\s+/) ! hash[db] = id_array ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of Array of DB IDs in DBLINKS ! end ! def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) ! end ! end ! @data['CODON_USAGE'] = ary ! end ! if codon ! h = { 't' => 0, 'c' => 1, 'a' => 2, 'g' => 3 } ! x, y, z = codon.downcase.scan(/\w/) ! codon_num = h[x] * 16 + h[y] * 4 + h[z] ! @data['CODON_USAGE'][codon_num] # CODON_USAGE of the codon else ! return @data['CODON_USAGE'] # Array of CODON_USAGE (default) ! end ! end ! ! def cu ! hash = Hash.new ! list = codon_usage ! base = %w(t c a g) ! base.each_with_index do |x, i| ! base.each_with_index do |y, j| ! base.each_with_index do |z, k| ! hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k] ! end ! end ! end ! return hash ! end ! ! def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Sequence::AA.new(fetch('AASEQ').gsub(/[\s\d\/]+/, '')) end ! @data['AASEQ'] end ! def aalen ! @data['AALEN'] = aaseq.length end ! def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Sequence::NA.new(fetch('NTSEQ').gsub(/[\s\d\/]+/, '')) end - @data['NTSEQ'] end ! alias naseq ntseq ! def ntlen ! @data['NTLEN'] = ntseq.length end - alias nalen ntlen - end ! end ! end ! ! ! ! if __FILE__ == $0 ! require 'bio/io/fetch' ! e = Bio::Fetch.query('genes', 'b0002') ! g = Bio::KEGG::GENES.new(e) ! p g.entry ! p g.entry_id ! p g.division ! p g.name ! p g.gene ! p g.definition ! p g.keggclass ! p g.position ! p g.dblinks ! p g.codon_usage ! p g.cu ! p g.aaseq ! p g.aalen ! p g.naseq ! p g.nalen ! p g.eclinks ! p g.splinks ! p g.pathways end - =begin - - = Bio::KEGG::GENES - - === Initialize - - --- Bio::KEGG::GENES.new - - === ENTRY - - --- Bio::KEGG::GENES#entry -> Hash - --- Bio::KEGG::GENES#entry_id -> String - --- Bio::KEGG::GENES#division -> String - --- Bio::KEGG::GENES#organism -> String - - === NAME - - --- Bio::KEGG::GENES#name -> String - --- Bio::KEGG::GENES#genes -> Array - --- Bio::KEGG::GENES#gene -> String - - === DEFINITION - - --- Bio::KEGG::GENES#definition -> String - --- Bio::KEGG::GENES#eclinks -> Array - --- Bio::KEGG::GENES#splinks -> Array - - === CLASS - - --- Bio::KEGG::GENES#keggclass -> String - --- Bio::KEGG::GENES#pathways -> Array - - === POSITION - - --- Bio::KEGG::GENES#position -> String - - === DBLINKS - - --- Bio::KEGG::GENES#dblinks -> Hash - - === CODON_USAGE - - --- Bio::KEGG::GENES#codon_usage(codon = nil) -> Array or Fixnum - --- Bio::KEGG::GENES#cu -> Hash - - === AASEQ - --- Bio::KEGG::GENES#aaseq -> Bio::Sequence::AA - --- Bio::KEGG::GENES#aalen -> Fixnum - - === NTSEQ - --- Bio::KEGG::GENES#ntseq -> Bio::Sequence::NA - --- Bio::KEGG::GENES#naseq -> Bio::Sequence::NA - --- Bio::KEGG::GENES#ntlen -> Fixnum - --- Bio::KEGG::GENES#nalen -> Fixnum - - =end --- 1,259 ---- # ! # = bio/db/kegg/genes.rb - KEGG/GENES database class # ! # Copyright:: Copyright (C) 2001, 2002, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # # ! # == KEGG GENES parser # ! # See http://www.genome.jp/kegg/genes.html # ! # ! # === Examples ! # ! # require 'bio/io/fetch' ! # entry_string = Bio::Fetch.query('genes', 'b0002') ! # ! # entry = Bio::KEGG::GENES.new(entry_string) ! # ! # # ENTRY ! # p entry.entry # => Hash ! # ! # p entry.entry_id # => String ! # p entry.division # => String ! # p entry.organism # => String ! # ! # # NAME ! # p entry.name # => String ! # p entry.genes # => Array ! # p entry.gene # => String ! # ! # # DEFINITION ! # p entry.definition # => String ! # p entry.eclinks # => Array ! # ! # # PATHWAY ! # p entry.pathway # => String ! # p entry.pathways # => Array ! # ! # # POSITION ! # p entry.position # => String ! # p entry.chromosome # => String ! # p entry.gbposition # => String ! # p entry.locations # => Bio::Locations ! # ! # # MOTIF ! # p entry.motif # => Hash of Array ! # ! # # DBLINKS ! # p entry.dblinks # => Hash of Array ! # ! # # CODON_USAGE ! # p entry.codon_usage # => Hash ! # p entry.cu_list # => Array ! # ! # # AASEQ ! # p entry.aaseq # => Bio::Sequence::AA ! # p entry.aalen # => Fixnum ! # ! # # NTSEQ ! # p entry.ntseq # => Bio::Sequence::NA ! # p entry.naseq # => Bio::Sequence::NA ! # p entry.ntlen # => Fixnum ! # p entry.nalen # => Fixnum ! # module Bio ! autoload :KEGGDB, 'bio/db' ! autoload :Locations, 'bio/location' ! autoload :Sequence, 'bio/sequence' ! class KEGG ! class GENES < KEGGDB + DELIMITER = RS = "\n///\n" + TAGSIZE = 12 ! def initialize(entry) ! super(entry, TAGSIZE) ! end ! def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip end + @data['ENTRY'] = hash + end + @data['ENTRY'] + end ! def entry_id ! entry['id'] ! end ! def division ! entry['division'] # CDS, tRNA etc. ! end ! def organism ! entry['organism'] # H.sapiens etc. ! end ! def name ! field_fetch('NAME') ! end ! def genes ! name.split(', ') ! end ! def gene ! genes.first ! end ! def definition ! field_fetch('DEFINITION') ! end ! def eclinks ! ec_list = definition.slice(/\[EC:(.*?)\]/, 1) ! if ec_list ! ec_list.strip.split(/\s+/) ! else ! [] ! end ! end ! def pathway ! field_fetch('PATHWAY') ! end ! def pathways ! pathway.scan(/\[PATH:(.*?)\]/).flatten ! end ! def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] ! end ! def chromosome ! if position[/:/] ! position.sub(/:.*/, '') ! elsif ! position[/\.\./] ! position ! else ! nil ! end ! end ! def gbposition ! position.sub(/.*?:/, '') ! end ! def locations ! Bio::Locations.new(gbposition) ! end ! def motif ! unless @data['MOTIF'] ! hash = {} ! db = nil ! lines_fetch('MOTIF').each do |line| ! if line[/^\S+:/] ! db, str = line.split(/:/) else ! str = line end ! hash[db] ||= [] ! hash[db] += str.strip.split(/\s+/) end + @data['MOTIF'] = hash + end + @data['MOTIF'] # Hash of Array of IDs in MOTIF + end ! def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n?/).each do |db, str| ! id_array = str.strip.split(/\s+/) ! hash[db] = id_array end + @data['DBLINKS'] = hash + end + @data['DBLINKS'] # Hash of Array of IDs in DBLINKS + end ! def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! hash = Hash.new ! list = cu_list ! base = %w(t c a g) ! base.each_with_index do |x, i| ! base.each_with_index do |y, j| ! base.each_with_index do |z, k| ! hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k] ! end end end ! @data['CODON_USAGE'] = hash ! end ! @data['CODON_USAGE'] ! end ! def cu_list ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) end end ! return ary end ! def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Bio::Sequence::AA.new(fetch('AASEQ').gsub(/\d+/, '')) ! end ! @data['AASEQ'] ! end ! def aalen ! fetch('AASEQ')[/\d+/].to_i ! end ! def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Bio::Sequence::NA.new(fetch('NTSEQ').gsub(/\d+/, '')) ! end ! @data['NTSEQ'] ! end ! alias naseq ntseq ! def ntlen ! fetch('NTSEQ')[/\d+/].to_i ! end ! alias nalen ntlen end + end # KEGG + end # Bio From k at dev.open-bio.org Tue Jul 25 15:17:41 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:17:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg kgml.rb,1.3,1.4 Message-ID: <200607251917.k6PJHfOP028056@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory dev.open-bio.org:/tmp/cvs-serv28050/lib/bio/db/kegg Modified Files: kgml.rb Log Message: * please note that the method names of some accessors are changed! * bug fixed * @dom is obsoleted Note: # === Incompatible attribute names with KGML tags # # # :id -> :entry_id # :type -> :entry_type # names() # # :name -> :label # :type -> :shape # # :entry1 -> :node1 # :entry2 -> :node2 # :type -> :rel # # edge() # # :name -> :entry_id # :type -> :direction Index: kgml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/kgml.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** kgml.rb 8 May 2006 14:25:25 -0000 1.3 --- kgml.rb 25 Jul 2006 19:17:39 -0000 1.4 *************** *** 12,18 **** # See http://www.genome.jp/kegg/xml/ for more details on KGML. # # === Examples # ! # file = ARGF.read # kgml = Bio::KEGG::KGML.new(file) # --- 12,37 ---- # See http://www.genome.jp/kegg/xml/ for more details on KGML. # + # === Incompatible attribute names with KGML tags + # + # + # :id -> :entry_id + # :type -> :entry_type + # names() + # + # :name -> :label + # :type -> :shape + # + # :entry1 -> :node1 + # :entry2 -> :node2 + # :type -> :rel + # + # edge() + # + # :name -> :entry_id + # :type -> :direction + # # === Examples # ! # file = ARGF.read("kgml/hsa/hsa00010.xml") # kgml = Bio::KEGG::KGML.new(file) # *************** *** 27,82 **** # kgml.entries.each do |entry| # # attributes ! # puts entry.id # puts entry.name ! # puts entry.names ! # puts entry.type # puts entry.link # puts entry.reaction # puts entry.map # # attributes ! # puts entry.label # This is an accessor for # puts entry.x # puts entry.y - # puts entry.type # puts entry.width # puts entry.height # puts entry.fgcolor # puts entry.bgcolor # end # # kgml.relations.each do |relation| # # attributes ! # puts relation.entry1 ! # puts relation.entry2 ! # puts relation.type # # attributes # puts relation.name # puts relation.value - # # or - # relation.subtype.each do |value, name| - # puts value, name - # end # end # # kgml.reactions.each do |reaction| # # attributes ! # puts reaction.name ! # puts reaction.type # # attributes ! # reaction.substrates.each do |name| ! # puts name # # attributes ! # altnames = reaction.alt[name] ! # altnames.each do |altname| ! # puts altname # end # end # # attributes ! # reaction.products.each do |name| ! # puts name # # attributes ! # altnames = reaction.alt[name] ! # altnames.each do |altname| ! # puts altname # end # end --- 46,100 ---- # kgml.entries.each do |entry| # # attributes ! # puts entry.entry_id # puts entry.name ! # puts entry.entry_type # puts entry.link # puts entry.reaction # puts entry.map # # attributes ! # puts entry.label # name ! # puts entry.shape # type # puts entry.x # puts entry.y # puts entry.width # puts entry.height # puts entry.fgcolor # puts entry.bgcolor + # # methood + # puts entry.names # end # # kgml.relations.each do |relation| # # attributes ! # puts relation.node1 # entry1 ! # puts relation.node2 # entry2 ! # puts relation.rel # type ! # # method ! # puts relation.edge # # attributes # puts relation.name # puts relation.value # end # # kgml.reactions.each do |reaction| # # attributes ! # puts reaction.entry_id # name ! # puts reaction.direction # type # # attributes ! # reaction.substrates.each do |entry_id| ! # puts entry_id # # attributes ! # altnames = reaction.alt[entry_id] ! # altnames.each do |name| ! # puts name # end # end # # attributes ! # reaction.products.each do |entry_id| ! # puts entry_id # # attributes ! # altnames = reaction.alt[entry_id] ! # altnames.each do |name| ! # puts name # end # end *************** *** 84,88 **** # ! require 'rexml/document' module Bio --- 102,106 ---- # ! autoload :REXML, 'rexml/document' module Bio *************** *** 92,123 **** def initialize(xml) ! @dom = REXML::Document.new(xml) ! parse_root ! parse_entry ! parse_relation ! parse_reaction end attr_reader :name, :org, :number, :title, :image, :link ! attr_reader :entries, :relations, :reactions # Array class Entry ! attr_accessor :id, :name, :names, :type, :link, :reaction, :map ! attr_accessor :label, :x, :y, :type, :width, :height, :fgcolor, :bgcolor end class Relation ! attr_accessor :entry1, :entry2, :type attr_accessor :name, :value ! attr_accessor :subtype # Hash end class Reaction ! attr_accessor :name, :type ! attr_accessor :substrates, :products # Array ! attr_accessor :alt # Hash end ! def parse_root ! root = @dom.root.attributes @name = root["name"] @org = root["org"] --- 110,148 ---- def initialize(xml) ! dom = REXML::Document.new(xml) ! parse_root(dom) ! parse_entry(dom) ! parse_relation(dom) ! parse_reaction(dom) end attr_reader :name, :org, :number, :title, :image, :link ! attr_accessor :entries, :relations, :reactions class Entry ! attr_accessor :entry_id, :name, :entry_type, :link, :reaction, :map ! attr_accessor :label, :shape, :x, :y, :width, :height, :fgcolor, :bgcolor ! def names ! @name.split(/\s+/) ! end end class Relation ! attr_accessor :node1, :node2, :rel attr_accessor :name, :value ! def edge ! @value.to_i ! end end class Reaction ! attr_accessor :entry_id, :direction ! attr_accessor :substrates, :products # Array ! attr_accessor :alt # Hash end ! private ! ! def parse_root(dom) ! root = dom.root.attributes @name = root["name"] @org = root["org"] *************** *** 128,155 **** end ! def parse_entry @entries = Array.new ! @dom.elements.each("/pathway/entry") { |node| attr = node.attributes entry = Entry.new ! entry.id = attr["id"].to_i ! entry.map = attr["map"] ! entry.name = attr["name"] ! entry.names = entry.name.split(/\s+/) ! entry.type = attr["type"] ! entry.link = attr["link"] ! entry.reaction = attr["reaction"] node.elements.each("graphics") { |graphics| attr = graphics.attributes ! entry.x = attr["x"].to_i ! entry.y = attr["y"].to_i ! entry.type = attr["type"] ! entry.label = attr["label"] # name ! entry.width = attr["width"].to_i ! entry.height = attr["height"].to_i ! entry.fgcolor = attr["fgcolor"] ! entry.bgcolor = attr["bgcolor"] } @entries << entry --- 153,180 ---- end ! def parse_entry(dom) @entries = Array.new ! dom.elements.each("/pathway/entry") { |node| attr = node.attributes entry = Entry.new ! entry.entry_id = attr["id"].to_i ! entry.name = attr["name"] ! entry.entry_type = attr["type"] ! # implied ! entry.link = attr["link"] ! entry.reaction = attr["reaction"] ! entry.map = attr["map"] node.elements.each("graphics") { |graphics| attr = graphics.attributes ! entry.x = attr["x"].to_i ! entry.y = attr["y"].to_i ! entry.shape = attr["type"] ! entry.label = attr["name"] ! entry.width = attr["width"].to_i ! entry.height = attr["height"].to_i ! entry.fgcolor = attr["fgcolor"] ! entry.bgcolor = attr["bgcolor"] } @entries << entry *************** *** 157,194 **** end ! def parse_relation @relations = Array.new ! @dom.elements.each("/pathway/relation") { |node| attr = node.attributes relation = Relation.new ! relation.entry1 = attr["entry1"].to_i ! relation.entry2 = attr["entry2"].to_i ! relation.type = attr["type"] - hash = Hash.new node.elements.each("subtype") { |subtype| attr = subtype.attributes ! relation.name = name = attr["name"] ! relation.value = value = attr["value"].to_i ! hash[value] = name } - relation.subtype = hash @relations << relation } end ! def parse_reaction @reactions = Array.new ! @dom.elements.each("/pathway/reaction") { |node| attr = node.attributes reaction = Reaction.new ! reaction.name = attr["name"] ! reaction.type = attr["type"] substrates = Array.new products = Array.new ! hash = Hash.new node.elements.each("substrate") { |substrate| --- 182,216 ---- end ! def parse_relation(dom) @relations = Array.new ! dom.elements.each("/pathway/relation") { |node| attr = node.attributes relation = Relation.new ! relation.node1 = attr["entry1"].to_i ! relation.node2 = attr["entry2"].to_i ! relation.rel = attr["type"] node.elements.each("subtype") { |subtype| attr = subtype.attributes ! relation.name = attr["name"] ! relation.value = attr["value"] } @relations << relation } end ! def parse_reaction(dom) @reactions = Array.new ! dom.elements.each("/pathway/reaction") { |node| attr = node.attributes reaction = Reaction.new ! reaction.entry_id = attr["name"] ! reaction.direction = attr["type"] substrates = Array.new products = Array.new ! hash = Hash.new node.elements.each("substrate") { |substrate| *************** *** 208,215 **** } } - reaction.substrates = substrates ! reaction.products = products ! reaction.alt = hash @reactions << reaction --- 230,236 ---- } } reaction.substrates = substrates ! reaction.products = products ! reaction.alt = hash @reactions << reaction *************** *** 218,281 **** end # KGML end # KEGG end # Bio - if __FILE__ == $0 - require 'pp' - xml = ARGF.read - pp Bio::KEGG::KGML.new(xml) - end - - - =begin - - # This is a test implementation which reflects original KGML data structure. - - class KGML - - class Pathway - attr_accessor :name, :org, :number, :title, :image, :link - attr_accessor :entries, :relations, :reactions - - class Entry - attr_accessor :id, :name, :type, :link, :reaction, :map - attr_accessor :components, :graphics - - class Component - attr_accessor :id - end - - class Graphics - attr_accessor :name, :x, :y, :type, :width, :height, :fgcolor, :bgcolor - end - end - - class Relation - attr_accessor :entry1, :entry2, :type - attr_accessor : - - class Subtype - attr_accessor :name, :value - end - end - - class Reaction - attr_accessor :name, :type - - class Substrate - attr_accessor :name - end - - class Product - attr_accessor :name - end - - class Alt - attr_accessor :name - end - end - end - - end - =end --- 239,245 ---- end # KGML + end # KEGG end # Bio From k at dev.open-bio.org Tue Jul 25 15:46:45 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io das.rb,1.12,1.13 Message-ID: <200607251946.k6PJkjKY028173@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv28169/lib/bio/io Modified Files: das.rb Log Message: * bug fixed that segment.stop was overwritten by segment.orientation Index: das.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/das.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** das.rb 8 May 2006 14:31:58 -0000 1.12 --- das.rb 25 Jul 2006 19:46:43 -0000 1.13 *************** *** 64,71 **** # Returns Bio::DAS::ENTRY_POINT. # The 'dsn' can be a String or a Bio::DAS::DSN object. ! def get_entry_point(dsn) entry_point = ENTRY_POINT.new ! dsn = dsn.source if dsn.instance_of?(Bio::DAS::DSN) ! result, = @server.get(@prefix + '/das/' + dsn + '/entry_points') doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| --- 64,75 ---- # Returns Bio::DAS::ENTRY_POINT. # The 'dsn' can be a String or a Bio::DAS::DSN object. ! def get_entry_points(dsn) entry_point = ENTRY_POINT.new ! if dsn.instance_of?(Bio::DAS::DSN) ! src = dsn.source ! else ! src = dsn ! end ! result, = @server.get(@prefix + '/das/' + src + '/entry_points') doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| *************** *** 77,81 **** segment.start = e.attributes['start'] segment.stop = e.attributes['stop'] ! segment.stop = e.attributes['orientation'] segment.subparts = e.attributes['subparts'] segment.description = e.text --- 81,85 ---- segment.start = e.attributes['start'] segment.stop = e.attributes['stop'] ! segment.orientation = e.attributes['orientation'] segment.subparts = e.attributes['subparts'] segment.description = e.text From nakao at dev.open-bio.org Wed Jul 26 04:15:30 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 26 Jul 2006 08:15:30 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_prosite.rb,1.3,1.4 Message-ID: <200607260815.k6Q8FUSd030540@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory dev.open-bio.org:/tmp/cvs-serv30520/test/unit/bio/db Modified Files: test_prosite.rb Log Message: * Fixed the regular expressions for test_pa2re methods. Index: test_prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_prosite.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_prosite.rb 18 Dec 2005 18:21:58 -0000 1.3 --- test_prosite.rb 26 Jul 2006 08:15:28 -0000 1.4 *************** *** 1439,1448 **** def test_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/, @obj.pa2re(pa)) end def test_self_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/, Bio::PROSITE.pa2re(pa)) end --- 1439,1448 ---- def test_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/i, @obj.pa2re(pa)) end def test_self_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/i, Bio::PROSITE.pa2re(pa)) end From ngoto at dev.open-bio.org Wed Jul 26 23:50:38 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 27 Jul 2006 03:50:38 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_command.rb,1.2,1.3 Message-ID: <200607270350.k6R3ocGL000508@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory dev.open-bio.org:/tmp/cvs-serv488/test/unit/bio Modified Files: test_command.rb Log Message: removed forgotten debug code Index: test_command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_command.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_command.rb 14 Jul 2006 14:23:48 -0000 1.2 --- test_command.rb 27 Jul 2006 03:50:36 -0000 1.3 *************** *** 96,100 **** def test_call_command - p $0 end --- 96,99 ---- From nakao at dev.open-bio.org Tue Jul 11 15:52:53 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Tue, 11 Jul 2006 15:52:53 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl sptr.rb,1.32,1.33 Message-ID: <200607111552.k6BFqrEP026141@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv25655/lib/bio/db/embl Modified Files: sptr.rb Log Message: * Added codes for "Changes concerning the copyright statement" (http://www.expasy.org/sprot/relnotes/sp_news.html#rel7). Index: sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/sptr.rb,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** sptr.rb 16 Jun 2006 17:01:01 -0000 1.32 --- sptr.rb 11 Jul 2006 15:52:51 -0000 1.33 *************** *** 354,362 **** ! @@cc_topics = ['ALTERNATIVE PRODUCTS','CATALYTIC ACTIVITY','CAUTION', ! 'COFACTOR','DATABASE','DEVELOPMENTAL STAGE','DISEASE','DOMAIN', ! 'ENZYME REGULATION','FUNCTION','INDUCTION','MASS SPECTROMETRY', ! 'MISCELLANEOUS','PATHWAY','PHARMACEUTICAL','POLYMORPHISM','PTM', ! 'SIMILARITY','SUBCELLULAR LOCATION','SUBUNIT','TISSUE SPECIFICITY'] # returns contents in the CC lines. # * Bio::SPTR#cc -> Hash --- 354,384 ---- ! @@cc_topics = ['PHARMACEUTICAL', ! 'BIOTECHNOLOGY', ! 'TOXIC DOSE', ! 'ALLERGEN', ! 'RNA EDITING', ! 'POLYMORPHISM', ! 'BIOPHYSICOCHEMICAL PROPERTIES', ! 'MASS SPECTROMETRY', ! 'WEB RESOURCE', ! 'ENZYME REGULATION', ! 'DISEASE', ! 'INTERACTION', ! 'DEVELOPMENTAL STAGE', ! 'INDUCTION', ! 'CAUTION', ! 'ALTERNATIVE PRODUCTS', ! 'DOMAIN', ! 'PTM', ! 'MISCELLANEOUS', ! 'TISSUE SPECIFICITY', ! 'COFACTOR', ! 'PATHWAY', ! 'SUBUNIT', ! 'CATALYTIC ACTIVITY', ! 'SUBCELLULAR LOCATION', ! 'FUNCTION', ! 'SIMILARITY'] # returns contents in the CC lines. # * Bio::SPTR#cc -> Hash *************** *** 398,401 **** --- 420,425 ---- # CC SECOND AND SUBSEQUENT LINES OF A COMMENT BLOCK. # + # See also http://www.expasy.org/sprot/userman.html#CC_line + # def cc(tag = nil) unless @data['CC'] *************** *** 404,411 **** dlm = /-!- / ! return cc if get('CC').size == 0 # 12KD_MYCSM has no CC lines. begin ! fetch('CC').split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 --- 428,443 ---- dlm = /-!- / ! # 12KD_MYCSM has no CC lines. ! return cc if get('CC').size == 0 ! ! cc_raw = fetch('CC') ! ! cc_raw.sub!(/ *---.+---/m, '') ! # Not any CC Lines without the copyright statement. ! return cc if cc_raw == '' ! begin ! cc_raw.split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 From ngoto at dev.open-bio.org Fri Jul 14 14:23:50 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:23:50 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_command.rb,1.1,1.2 Message-ID: <200607141423.k6EENoYN005258@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory dev.open-bio.org:/tmp/cvs-serv5233/test/unit/bio Modified Files: test_command.rb Log Message: * Bio::Command::Tools and Bio::Command::NetTools are combined and re-constructed into a new Bio::Command module. The method names and functions are also changed, and some new methods are added. * Now, you have no need to include Bio::Command. Index: test_command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_command.rb,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_command.rb 27 Oct 2005 15:11:51 -0000 1.1 --- test_command.rb 14 Jul 2006 14:23:48 -0000 1.2 *************** *** 2,20 **** # test/unit/bio/test_command.rb - Unit test for external command execution methods # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. ! # ! # This library is distributed in the hope that it will be useful, ! # but WITHOUT ANY WARRANTY; without even the implied warranty of ! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! # Lesser General Public License for more details. ! # ! # You should have received a copy of the GNU Lesser General Public ! # License along with this library; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id$ --- 2,9 ---- # test/unit/bio/test_command.rb - Unit test for external command execution methods # ! # Copyright:: Copyright (C) 2005-2006 ! # Mitsuteru Nakao , ! # Naohisa Goto ! # License:: Ruby's # # $Id$ *************** *** 30,69 **** module Bio ! class TestCommandTools < Test::Unit::TestCase ! def test_command_tools_constants ! Bio::Command::Tools::UNSAFE_CHARS_UNIX ! Bio::Command::Tools::QUOTE_CHARS_WINDOWS ! Bio::Command::Tools::UNESCAPABLE_CHARS end def test_escape_shell_windows end def test_escape_shell_unix end def test_escape_shell end def test_make_command_line end def test_make_command_line_windows end def test_make_command_line_unix end ! def test_call_commandline_local end ! def test_call_commandline_local_popen end ! def test_call_commandline_local_open3 end ! def test_errorlog end --- 19,133 ---- module Bio ! class TestCommand < Test::Unit::TestCase ! def test_command_constants ! Bio::Command::UNSAFE_CHARS_UNIX ! Bio::Command::QUOTE_CHARS_WINDOWS ! Bio::Command::UNESCAPABLE_CHARS end def test_escape_shell_windows + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell_windows(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + assert_equal("\"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.escape_shell_windows(str)) end def test_escape_shell_unix + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell_unix(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.escape_shell_unix(str)) end def test_escape_shell + str = "bio_ruby.123 at 456:789" + assert_equal("bio_ruby.123 at 456:789", + Bio::Command.escape_shell(str)) + str = "bio\'\"r u\"b\\y123 at 456:789" + case RUBY_PLATFORM + when /mswin32|bccwin32/ + assert_equal("\"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.escape_shell(str)) + else + assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.escape_shell(str)) + end end def test_make_command_line + ary = [ "ruby", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + case RUBY_PLATFORM + when /mswin32|bccwin32/ + assert_equal("ruby" + + " test.rb atgcatgc" + + " \"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.make_command_line(ary)) + else + assert_equal("ruby" + + " test.rb atgcatgc" + + " bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.make_command_line(ary)) + end end def test_make_command_line_windows + ary = [ "C:\\Program Files\\Ruby\\bin\\ruby.exe", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + assert_equal("\"C:\\Program Files\\Ruby\\bin\\ruby.exe\"" + + " test.rb atgcatgc" + + " \"bio'\"\"r u\"\"b\\y123 at 456:789\"", + Bio::Command.make_command_line_windows(ary)) end def test_make_command_line_unix + ary = [ "/usr/local/bin/ruby", + "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123 at 456:789" ] + assert_equal("/usr/local/bin/ruby" + + " test.rb atgcatgc" + + " bio\\'\\\"r\\ u\\\"b\\\\y123 at 456:789", + Bio::Command.make_command_line_unix(ary)) end ! def test_call_command ! p $0 end ! def test_call_command_popen end ! def test_call_command_fork end ! def test_call_command_open3 ! end ! ! def test_query_command ! end ! ! def test_query_command_popen ! end ! ! def test_query_command_fork ! end ! ! def test_query_command_open3 ! end ! ! def test_read_uri ! end ! ! def test_start_http ! end ! ! def test_new_http ! end ! ! def test_post_form end From ngoto at dev.open-bio.org Fri Jul 14 14:23:50 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:23:50 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio command.rb,1.11,1.12 Message-ID: <200607141423.k6EENoB5005255@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv5233/lib/bio Modified Files: command.rb Log Message: * Bio::Command::Tools and Bio::Command::NetTools are combined and re-constructed into a new Bio::Command module. The method names and functions are also changed, and some new methods are added. * Now, you have no need to include Bio::Command. Index: command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/command.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** command.rb 30 May 2006 13:59:36 -0000 1.11 --- command.rb 14 Jul 2006 14:23:47 -0000 1.12 *************** *** 16,28 **** module Bio - module Command ! # = Bio::Command::Tools # ! # Bio::Command::Tools is a collection of useful methods for execution ! # of external commands or web applications. Any wrapper class for ! # applications shall include this class. Note that all methods below ! # are private except for some methods. ! module Tools UNSAFE_CHARS_UNIX = /[^A-Za-z0-9\_\-\.\:\,\/\@\x1b\x80-\xfe]/n --- 16,28 ---- module Bio ! # = Bio::Command # ! # Bio::Command is a collection of useful methods for execution ! # of external commands or web applications. ! # Any wrapper class for applications shall use this class. ! # ! # Library internal use only. Users should not directly use it. ! module Command UNSAFE_CHARS_UNIX = /[^A-Za-z0-9\_\-\.\:\,\/\@\x1b\x80-\xfe]/n *************** *** 83,135 **** # Executes the program. Automatically select popen for Windows ! # environment and open3 for the others. ! # ! # If block is given, yield the block with input and output IO objects. ! # Note that in some platform, inn and out are the same object. ! # Please be careful to do inn.close and out.close. ! def call_command_local(cmd, query = nil, &block) case RUBY_PLATFORM when /mswin32|bccwin32/ ! call_command_local_popen(cmd, query, &block) else ! call_command_local_fork(cmd, query, &block) end end # Executes the program via IO.popen for OS which doesn't support fork. ! # If block is given, yield the block with IO objects. ! # The two objects are the same because of limitation of IO.popen. ! def call_command_local_popen(cmd, query = nil) str = make_command_line(cmd) IO.popen(str, "w+") do |io| ! if block_given? then ! io.sync = true ! yield io, io ! else ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end end end # Executes the program via fork (by using IO.popen("-")) and exec. ! # If block is given, yield the block with input and output IO objects. # # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def call_command_local_fork(cmd, query = nil) IO.popen("-", "r+") do |io| if io then # parent ! if block_given? ! yield io, io ! else ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end else # child --- 83,117 ---- # Executes the program. Automatically select popen for Windows ! # environment and fork for the others. ! # A block must be given. An IO object is passed to the block. ! def call_command(cmd, &block) case RUBY_PLATFORM when /mswin32|bccwin32/ ! call_command_popen(cmd, &block) else ! call_command_fork(cmd, &block) end end # Executes the program via IO.popen for OS which doesn't support fork. ! # A block must be given. An IO object is passed to the block. ! def call_command_popen(cmd) str = make_command_line(cmd) IO.popen(str, "w+") do |io| ! io.sync = true ! yield io end end # Executes the program via fork (by using IO.popen("-")) and exec. ! # A block must be given. An IO object is passed to the block. # # From the view point of security, this method is recommended ! # rather than call_command_popen. ! def call_command_fork(cmd) IO.popen("-", "r+") do |io| if io then # parent ! yield io else # child *************** *** 140,184 **** # Executes the program via Open3.popen3 ! # If block is given, yield the block with input and output IO objects. # ! # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def call_command_local_open3(cmd, query = nil) cmd = cmd.collect { |x| x.to_s } Open3.popen3(*cmd) do |pin, pout, perr| ! perr.sync = true ! t = Thread.start { @errorlog = perr.read } ! if block_given? then ! yield pin, pout ! else ! begin ! pin.print query if query ! pin.close ! output = pout.read ! ensure ! t.join ! end ! output ! end end end ! # Shows the latest stderr of the program execution. ! # Note that this method may be thread unsafe. ! attr_reader :errorlog ! public :errorlog ! end # module Tools ! # = Bio::Command::NetTools ! # ! # Bio::Command::NetTools is a collection of miscellaneous methods ! # for data transport through network. ! # ! # Library internal use only. Users should not directly use it. ! # ! # Note that it is under construction. ! module NetTools # Same as OpenURI.open_uri(uri).read. --- 122,209 ---- # Executes the program via Open3.popen3 ! # A block must be given. IO objects are passed to the block. # ! # You would use this method only when you really need to get stderr. ! def call_command_open3(cmd) cmd = cmd.collect { |x| x.to_s } Open3.popen3(*cmd) do |pin, pout, perr| ! yield pin, pout, perr end end ! # Executes the program with the query (String) given to the standard input, ! # waits the program termination, and returns the output data printed to the ! # standard output as a string. ! # ! # Automatically select popen for Windows environment and fork for the others. ! def query_command(cmd, query = nil) ! case RUBY_PLATFORM ! when /mswin32|bccwin32/ ! query_command_popen(cmd, query) ! else ! query_command_fork(cmd, query) ! end ! end ! # Executes the program with the query (String) given to the standard input, ! # waits the program termination, and returns the output data printed to the ! # standard output as a string. ! # ! # IO.popen is used for OS which doesn't support fork. ! def query_command_popen(cmd, query = nil) ! str = make_command_line(cmd) ! IO.popen(str, "w+") do |io| ! io.sync = true ! io.print query if query ! io.close_write ! io.read ! end ! end + # Executes the program with the query (String) given to the standard input, + # waits the program termination, and returns the output data printed to the + # standard output as a string. + # + # Fork (by using IO.popen("-")) and exec is used to execute the program. + # + # From the view point of security, this method is recommended + # rather than query_popen. + def query_command_fork(cmd, query = nil) + IO.popen("-", "r+") do |io| + if io then + # parent + io.sync = true + io.print query if query + io.close_write + io.read + else + # child + Kernel.exec(*cmd) + end + end + end ! # Executes the program via Open3.popen3 with the query (String) given ! # to the stain, waits the program termination, and ! # returns the data from stdout and stderr as an array of the strings. ! # ! # From the view point of security, this method is recommended ! # rather than exec_local_popen. ! def query_command_open3(cmd, query = nil) ! errorlog = nil ! cmd = cmd.collect { |x| x.to_s } ! Open3.popen3(*cmd) do |pin, pout, perr| ! perr.sync = true ! t = Thread.start { errorlog = perr.read } ! begin ! pin.print query if query ! pin.close ! output = pout.read ! ensure ! t.join ! end ! [ output, errorlog ] ! end ! end # Same as OpenURI.open_uri(uri).read. *************** *** 186,190 **** OpenURI.open_uri(uri).read end - module_function :read_uri # Same as: --- 211,214 ---- *************** *** 194,198 **** # is set. # ! def net_http_start(address, port = 80, &block) uri = URI.parse("http://#{address}:#{port}") # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. --- 218,222 ---- # is set. # ! def start_http(address, port = 80, &block) uri = URI.parse("http://#{address}:#{port}") # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. *************** *** 206,210 **** http.start(address, port, &block) end ! module_function :net_http_start # Same as: --- 230,251 ---- http.start(address, port, &block) end ! ! # Same as: ! # Net::HTTP.new(address, port) ! # and ! # it uses proxy if an environment variable (same as OpenURI.open_uri) ! # is set. ! # ! def new_http(address, port = 80) ! uri = URI.parse("http://#{address}:#{port}") ! # Note: URI#find_proxy is an unofficial method defined in open-uri.rb. ! # If the spec of open-uri.rb would be changed, we should change below. ! if proxyuri = uri.find_proxy then ! raise 'Non-HTTP proxy' if proxyuri.class != URI::HTTP ! Net::HTTP.new(address, port, proxyuri.host, proxyuri.port) ! else ! Net::HTTP.new(address, port) ! end ! end # Same as: *************** *** 228,238 **** } h.update(header) ! net_http_start(uri.host, uri.port) do |http| http.post(uri.path, data, h) end end - module_function :post_form - - end #module NetTools end # module Command --- 269,276 ---- } h.update(header) ! start_http(uri.host, uri.port) do |http| http.post(uri.path, data, h) end end end # module Command From ngoto at dev.open-bio.org Fri Jul 14 14:26:41 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:26:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb, 1.29, 1.30 fasta.rb, 1.20, 1.21 hmmer.rb, 1.5, 1.6 Message-ID: <200607141426.k6EEQfP4005309@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv5268/lib/bio/appl Modified Files: blast.rb fasta.rb hmmer.rb Log Message: * Changes due to the refactoring of Bio::Command. * Changed to use Bio::Command.new_http instead of Net::HTTP.new. Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** blast.rb 16 May 2006 09:50:13 -0000 1.29 --- blast.rb 14 Jul 2006 14:26:39 -0000 1.30 *************** *** 83,88 **** autoload :Bl2seq, 'bio/appl/bl2seq/report' - include Bio::Command::Tools - # This is a shortcut for Bio::Blast.new: # Bio::Blast.local(program, database, options) --- 83,86 ---- *************** *** 227,231 **** def option # backward compatibility ! make_command_line(@options) end --- 225,229 ---- def option # backward compatibility ! Bio::Command.make_command_line(@options) end *************** *** 254,258 **** report = nil ! @output = call_command_local(cmd, query) report = parse_result(@output) --- 252,256 ---- report = nil ! @output = Bio::Command.query_command(cmd, query) report = parse_result(@output) *************** *** 278,282 **** 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(opt)), 'matrix' => matrix, 'filter' => filter, --- 276,280 ---- 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(Bio::Command.make_command_line_unix(opt)), 'matrix' => matrix, 'filter' => filter, *************** *** 295,299 **** begin ! http = Net::HTTP.new(host) http.open_timeout = 300 http.read_timeout = 600 --- 293,297 ---- begin ! http = Bio::Command.new_http(host) http.open_timeout = 300 http.read_timeout = 600 Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** fasta.rb 26 Sep 2005 13:00:04 -0000 1.20 --- fasta.rb 14 Jul 2006 14:26:39 -0000 1.21 *************** *** 33,38 **** #autoload :?????, 'bio/appl/fasta/format6' - include Bio::Command::Tools - def initialize(program, db, opt = [], server = 'local') @format = 10 --- 33,36 ---- *************** *** 60,64 **** def option # backward compatibility ! make_command_line(@options) end --- 58,62 ---- def option # backward compatibility ! Bio::Command.make_command_line(@options) end *************** *** 115,119 **** report = nil ! @output = call_command_local(cmd, query) report = parse_result(@output) --- 113,117 ---- report = nil ! @output = Bio::Command.query_command(cmd, query) report = parse_result(@output) *************** *** 132,136 **** 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(make_command_line_unix(@options)), 'ktup_value' => @ktup, 'matrix' => @matrix, --- 130,134 ---- 'dbname' => @db, 'sequence' => CGI.escape(query), ! 'other_param' => CGI.escape(Bio::Command.make_command_line_unix(@options)), 'ktup_value' => @ktup, 'matrix' => @matrix, *************** *** 146,150 **** begin ! http = Net::HTTP.new(host) http.open_timeout = 300 http.read_timeout = 600 --- 144,148 ---- begin ! http = Bio::Command.new_http(host) http.open_timeout = 300 http.read_timeout = 600 Index: hmmer.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/hmmer.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hmmer.rb 2 Feb 2006 17:08:36 -0000 1.5 --- hmmer.rb 14 Jul 2006 14:26:39 -0000 1.6 *************** *** 73,78 **** autoload :Report, 'bio/appl/hmmer/report' - include Bio::Command::Tools - # Prgrams name. (hmmsearch or hmmpfam). attr_accessor :program --- 73,76 ---- *************** *** 113,117 **** # backward compatibility. def option ! make_command_line(@options) end --- 111,115 ---- # backward compatibility. def option ! Bio::Command.make_command_line(@options) end *************** *** 132,136 **** report = nil ! @output = call_command_local(cmd, nil) report = parse_result(@output) --- 130,134 ---- report = nil ! @output = Bio::Command.query_command(cmd, nil) report = parse_result(@output) From ngoto at dev.open-bio.org Fri Jul 14 14:27:12 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:27:12 +0000 Subject: [BioRuby-cvs] bioruby/lib bio.rb,1.68,1.69 Message-ID: <200607141427.k6EERCDS005339@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib In directory dev.open-bio.org:/tmp/cvs-serv5319/lib Modified Files: bio.rb Log Message: added autoload of Bio::Command. Index: bio.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio.rb,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** bio.rb 4 May 2006 13:12:57 -0000 1.68 --- bio.rb 14 Jul 2006 14:27:10 -0000 1.69 *************** *** 227,230 **** --- 227,233 ---- autoload :ColorScheme, 'bio/util/color_scheme' + ### Service libraries + autoload :Command, 'bio/command' + end From ngoto at dev.open-bio.org Fri Jul 14 14:28:46 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:28:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl emboss.rb, 1.5, 1.6 psort.rb, 1.9, 1.10 pts1.rb, 1.3, 1.4 Message-ID: <200607141428.k6EESkAT005369@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv5347/lib/bio/appl Modified Files: emboss.rb psort.rb pts1.rb Log Message: * Changes due to the refactoring of Bio::Command. Index: emboss.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** emboss.rb 17 May 2006 14:24:33 -0000 1.5 --- emboss.rb 14 Jul 2006 14:28:44 -0000 1.6 *************** *** 21,26 **** module Bio - autoload :Command, 'bio/command' - # = DESCRIPTION # --- 21,24 ---- *************** *** 76,81 **** class EMBOSS - extend Bio::Command::Tools - # Combines the initialization and execution for the emboss +seqret+ command. # --- 74,77 ---- *************** *** 158,167 **** def self.retrieve(cmd, arg) cmd = [ cmd, arg, '-auto', '-stdout' ] ! str = '' ! call_command_local(cmd) do |inn, out| ! inn.close_write ! str = out.read ! end ! return str end --- 154,158 ---- def self.retrieve(cmd, arg) cmd = [ cmd, arg, '-auto', '-stdout' ] ! return Bio::Command.query_command(cmd) end Index: pts1.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/pts1.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pts1.rb 5 Jun 2006 02:55:51 -0000 1.3 --- pts1.rb 14 Jul 2006 14:28:44 -0000 1.4 *************** *** 152,156 **** @uri = URI.parse(["http:/", @host, @cgi_path].join('/')) ! result, = Bio::Command::NetTools.post_form(@uri, @form_data) @output = Report.new(result.body) --- 152,156 ---- @uri = URI.parse(["http:/", @host, @cgi_path].join('/')) ! result, = Bio::Command.post_form(@uri, @form_data) @output = Report.new(result.body) Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** psort.rb 30 Apr 2006 07:13:39 -0000 1.9 --- psort.rb 14 Jul 2006 14:28:44 -0000 1.10 *************** *** 113,117 **** begin result = nil ! Bio::Command::NetTools.net_http_start(@uri.host) {|http| result, = http.post(@uri.path, data) } --- 113,117 ---- begin result = nil ! Bio::Command.start_http(@uri.host) {|http| result, = http.post(@uri.path, data) } From ngoto at dev.open-bio.org Fri Jul 14 14:28:46 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:28:46 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io ensembl.rb, 1.2, 1.3 fetch.rb, 1.8, 1.9 Message-ID: <200607141428.k6EESkUi005376@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5347/lib/bio/io Modified Files: ensembl.rb fetch.rb Log Message: * Changes due to the refactoring of Bio::Command. Index: ensembl.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/ensembl.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ensembl.rb 27 Apr 2006 05:38:50 -0000 1.2 --- ensembl.rb 14 Jul 2006 14:28:44 -0000 1.3 *************** *** 215,219 **** result = nil ! Bio::Command::NetTools.net_http_start(@uri.host, @uri.port) {|http| result, = http.post(@path, data) } --- 215,219 ---- result = nil ! Bio::Command.start_http(@uri.host, @uri.port) {|http| result, = http.post(@path, data) } Index: fetch.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fetch.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fetch.rb 8 May 2006 14:29:58 -0000 1.8 --- fetch.rb 14 Jul 2006 14:28:44 -0000 1.9 *************** *** 107,111 **** query = query.join('&') ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)) end --- 107,111 ---- query = query.join('&') ! Bio::Command.read_uri(@url + '?' + URI.escape(query)) end *************** *** 142,146 **** query = "info=dbs" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end --- 142,146 ---- query = "info=dbs" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end *************** *** 159,163 **** query = "info=formats;db=#{database}" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end end --- 159,163 ---- query = "info=formats;db=#{database}" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).strip.split(/\s+/) end end *************** *** 173,177 **** query = "info=maxids" ! Bio::Command::NetTools.read_uri(@url + '?' + URI.escape(query)).to_i end --- 173,177 ---- query = "info=maxids" ! Bio::Command.read_uri(@url + '?' + URI.escape(query)).to_i end From ngoto at dev.open-bio.org Fri Jul 14 14:30:11 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:30:11 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io fastacmd.rb,1.11,1.12 Message-ID: <200607141430.k6EEUBjX005405@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5385/lib/bio/io Modified Files: fastacmd.rb Log Message: * Changes due to the reconstruction of Bio::Command. * Attrute 'errorlog' is removed. Index: fastacmd.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fastacmd.rb 21 Mar 2006 12:18:14 -0000 1.11 --- fastacmd.rb 14 Jul 2006 14:30:09 -0000 1.12 *************** *** 69,73 **** include Enumerable - include Bio::Command::Tools # Database file path. --- 69,72 ---- *************** *** 77,82 **** attr_accessor :fastacmd - attr_accessor :errorlog - # This method provides a handle to a BLASTable database, which you can then # use to retrieve sequences. --- 76,79 ---- *************** *** 136,142 **** cmd = [ @fastacmd, '-d', @database, '-s', entry_id ] ! call_command_local(cmd) do |inn, out| ! inn.close_write ! Bio::FlatFile.new(Bio::FastaFormat, out).to_a end end --- 133,139 ---- cmd = [ @fastacmd, '-d', @database, '-s', entry_id ] ! Bio::Command.call_command(cmd) do |io| ! io.close_write ! Bio::FlatFile.new(Bio::FastaFormat, io).to_a end end *************** *** 151,157 **** def each_entry cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] ! call_command_local(cmd) do |inn, out| ! inn.close_write ! Bio::FlatFile.open(Bio::FastaFormat, out) do |f| f.each_entry do |entry| yield entry --- 148,154 ---- def each_entry cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] ! Bio::Command.call_command(cmd) do |io| ! io.close_write ! Bio::FlatFile.open(Bio::FastaFormat, io) do |f| f.each_entry do |entry| yield entry From ngoto at dev.open-bio.org Fri Jul 14 14:48:58 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:48:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io keggapi.rb, 1.11, 1.12 pubmed.rb, 1.13, 1.14 registry.rb, 1.17, 1.18 Message-ID: <200607141448.k6EEmwAC005544@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv5517/lib/bio/io Modified Files: keggapi.rb pubmed.rb registry.rb Log Message: * Changed to use Bio::Command.new_http instead of Net::HTTP.new. * Changed to use Bio::Command.start_http instead of Net::HTTP.start. Index: pubmed.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/pubmed.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pubmed.rb 16 Mar 2006 17:29:05 -0000 1.13 --- pubmed.rb 14 Jul 2006 14:48:56 -0000 1.14 *************** *** 24,27 **** --- 24,28 ---- require 'net/http' require 'cgi' unless defined?(CGI) + require 'bio/command' module Bio *************** *** 86,90 **** path = "/entrez/query.fcgi?tool=bioruby&cmd=Search&doptcmdl=MEDLINE&db=PubMed&term=" ! http = Net::HTTP.new(host) response, = http.get(path + CGI.escape(str)) result = response.body --- 87,91 ---- path = "/entrez/query.fcgi?tool=bioruby&cmd=Search&doptcmdl=MEDLINE&db=PubMed&term=" ! http = Bio::Command.new_http(host) response, = http.get(path + CGI.escape(str)) result = response.body *************** *** 123,127 **** path = "/entrez/eutils/esearch.fcgi?tool=bioruby&db=pubmed&#{opts.join('&')}&term=" ! http = Net::HTTP.new(host) response, = http.get(path + CGI.escape(str)) result = response.body --- 124,128 ---- path = "/entrez/eutils/esearch.fcgi?tool=bioruby&db=pubmed&#{opts.join('&')}&term=" ! http = Bio::Command.new_http(host) response, = http.get(path + CGI.escape(str)) result = response.body *************** *** 140,144 **** path = "/entrez/query.fcgi?tool=bioruby&cmd=Text&dopt=MEDLINE&db=PubMed&uid=" ! http = Net::HTTP.new(host) response, = http.get(path + id.to_s) result = response.body --- 141,145 ---- path = "/entrez/query.fcgi?tool=bioruby&cmd=Text&dopt=MEDLINE&db=PubMed&uid=" ! http = Bio::Command.new_http(host) response, = http.get(path + id.to_s) result = response.body *************** *** 161,165 **** path = "/entrez/utils/pmfetch.fcgi?tool=bioruby&mode=text&report=medline&db=PubMed&id=" ! http = Net::HTTP.new(host) response, = http.get(path + id.to_s) result = response.body --- 162,166 ---- path = "/entrez/utils/pmfetch.fcgi?tool=bioruby&mode=text&report=medline&db=PubMed&id=" ! http = Bio::Command.new_http(host) response, = http.get(path + id.to_s) result = response.body *************** *** 189,193 **** ids = ids.join(",") ! http = Net::HTTP.new(host) response, = http.get(path + ids) result = response.body --- 190,194 ---- ids = ids.join(",") ! http = Bio::Command.new_http(host) response, = http.get(path + ids) result = response.body Index: registry.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/registry.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** registry.rb 8 May 2006 14:29:58 -0000 1.17 --- registry.rb 14 Jul 2006 14:48:56 -0000 1.18 *************** *** 85,88 **** --- 85,89 ---- require 'uri' require 'net/http' + require 'bio/command' *************** *** 171,175 **** def read_remote(url) schema, user, host, port, reg, path, = URI.split(url) ! Net::HTTP.start(host, port) do |http| response, = http.get(path) parse_stanza(response.body) --- 172,176 ---- def read_remote(url) schema, user, host, port, reg, path, = URI.split(url) ! Bio::Command.start_http(host, port) do |http| response, = http.get(path) parse_stanza(response.body) Index: keggapi.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/keggapi.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** keggapi.rb 18 Dec 2005 19:10:55 -0000 1.11 --- keggapi.rb 14 Jul 2006 14:48:56 -0000 1.12 *************** *** 24,27 **** --- 24,28 ---- require 'uri' require 'net/http' + require 'bio/command' module Bio *************** *** 96,100 **** filename ||= File.basename(path) ! http = Net::HTTP.new(host, port) response, = http.get(path) File.open(filename, "w+") do |f| --- 97,101 ---- filename ||= File.basename(path) ! http = Bio::Command.new_http(host, port) response, = http.get(path) File.open(filename, "w+") do |f| From ngoto at dev.open-bio.org Fri Jul 14 14:48:58 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Fri, 14 Jul 2006 14:48:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db fantom.rb,1.12,1.13 Message-ID: <200607141448.k6EEmwXK005539@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory dev.open-bio.org:/tmp/cvs-serv5517/lib/bio/db Modified Files: fantom.rb Log Message: * Changed to use Bio::Command.new_http instead of Net::HTTP.new. * Changed to use Bio::Command.start_http instead of Net::HTTP.start. Index: fantom.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/fantom.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fantom.rb 30 Apr 2006 05:57:40 -0000 1.12 --- fantom.rb 14 Jul 2006 14:48:55 -0000 1.13 *************** *** 16,19 **** --- 16,20 ---- require 'bio/db' + require 'bio/command' #require 'bio/sequence' *************** *** 33,41 **** port = 80 path = "/db/maxml/maxmlseq.cgi?masterid=#{URI.escape(idstr.to_s)}&style=xml" - proxy = URI.parse(http_proxy.to_s) xml = '' ! Net::HTTP.start(addr, port, proxy.host, proxy.port) do |http| ! response, = http.get(path) ! xml = response.body end xml --- 34,49 ---- port = 80 path = "/db/maxml/maxmlseq.cgi?masterid=#{URI.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 From nakao at dev.open-bio.org Sat Jul 15 15:29:28 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 15 Jul 2006 15:29:28 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db/embl test_sptr.rb,1.3,1.4 Message-ID: <200607151529.k6FFTSAn008912@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv8890/test/unit/bio/db/embl Modified Files: test_sptr.rb Log Message: * Refactered code for parsing CC lines. * Added Bio::SPTR#ref method. * Added comprehensive tests for the recent updates of UniProt. * Added OH line parser (Bio::SPTR#oh). * Added HI line parser (Bio::SPTR#hi). Index: test_sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/embl/test_sptr.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_sptr.rb 16 Jun 2006 16:51:05 -0000 1.3 --- test_sptr.rb 15 Jul 2006 15:29:26 -0000 1.4 *************** *** 2,20 **** # test/unit/bio/db/embl/test_sptr.rb - Unit test for Bio::SPTR # ! # Copyright (C) 2005 Mitsuteru Nakao ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. ! # ! # This library is distributed in the hope that it will be useful, [...1716 lines suppressed...] ! {'NCBI_TaxID' => '35938', 'HostName' => 'Robinia pseudoacacia (Black locust)'}, ! {'NCBI_TaxID' => '23216', 'HostName' => 'Rubus (bramble)'}, ! {'NCBI_TaxID' => '4113', 'HostName' => 'Solanum tuberosum (Potato)'}, ! {'NCBI_TaxID' => '13305', 'HostName' => 'Tulipa'}, ! {'NCBI_TaxID' => '3603', 'HostName' => 'Vitis'}] ! sp = SPTR.new(data) ! assert_equal(res, sp.oh) ! end ! ! def test_OH_line_exception ! data = "ID TEST_ENTRY STANDARD; PRT; 393 AA. ! OH NCBI_TaxID=23216x: Rubus (bramble)." ! sp = SPTR.new(data) ! assert_raise(ArgumentError) { sp.oh } ! end ! ! end ! ! end # module Bio ! From nakao at dev.open-bio.org Sat Jul 15 15:29:28 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Sat, 15 Jul 2006 15:29:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/embl sptr.rb,1.33,1.34 Message-ID: <200607151529.k6FFTSQ4008917@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/embl In directory dev.open-bio.org:/tmp/cvs-serv8890/lib/bio/db/embl Modified Files: sptr.rb Log Message: * Refactered code for parsing CC lines. * Added Bio::SPTR#ref method. * Added comprehensive tests for the recent updates of UniProt. * Added OH line parser (Bio::SPTR#oh). * Added HI line parser (Bio::SPTR#hi). Index: sptr.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/sptr.rb,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** sptr.rb 11 Jul 2006 15:52:51 -0000 1.33 --- sptr.rb 15 Jul 2006 15:29:26 -0000 1.34 *************** *** 187,200 **** # === GN Line: Gene name(s) (>=0, optional) def gn ! return @data['GN'] if @data['GN'] ! ! case fetch('GN') ! when /Name=/ then ! return gn_uniprot_parser ! else ! return gn_old_parser end end # returns contents in the old style GN line. # === GN Line: Gene name(s) (>=0, optional) --- 187,202 ---- # === GN Line: Gene name(s) (>=0, optional) def gn ! unless @data['GN'] ! case fetch('GN') ! when /Name=/,/ORFNames=/ ! @data['GN'] = gn_uniprot_parser ! else ! @data['GN'] = gn_old_parser ! end end + @data['GN'] end + # returns contents in the old style GN line. # === GN Line: Gene name(s) (>=0, optional) *************** *** 218,222 **** } end ! return @data['GN'] = names end private :gn_old_parser --- 220,224 ---- } end ! @data['GN'] = names end private :gn_old_parser *************** *** 348,351 **** --- 350,380 ---- end + # === The OH Line; + # + # OH NCBI_TaxID=TaxID; HostName. + # http://br.expasy.org/sprot/userman.html#OH_line + def oh + unless @data['OH'] + @data['OH'] = fetch('OH').split("\. ").map {|x| + if x =~ /NCBI_TaxID=(\d+);/ + taxid = $1 + else + raise ArgumentError, ["Error: Invalid OH line format (#{self.entry_id}):", + $!, "\n", get('OH'), "\n"].join + + end + if x =~ /NCBI_TaxID=\d+; (.+)/ + host_name = $1 + host_name.sub!(/\.$/, '') + else + host_name = nil + end + {'NCBI_TaxID' => taxid, 'HostName' => host_name} + } + end + @data['OH'] + end + + # Bio::EMBLDB::Common#ref -> Array *************** *** 353,356 **** --- 382,543 ---- # RN RC RP RX RA RT RL + # returns contents in the R lines. + # * Bio::EMBLDB::Common#ref -> [ * ] + # where is: + # {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '', + # 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''} + # + # R Lines + # * RN RC RP RX RA RT RL RG + def ref + unless @data['R'] + @data['R'] = [get('R').split(/\nRN /)].flatten.map { |str| + hash = {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '', + 'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''} + str = 'RN ' + str unless /^RN / =~ str + + str.split("\n").each do |line| + if /^(R[NPXARLCTG]) (.+)/ =~ line + hash[$1] += $2 + ' ' + else + raise "Invalid format in R lines, \n[#{line}]\n" + end + end + + hash['RN'] = set_RN(hash['RN']) + hash['RC'] = set_RC(hash['RC']) + hash['RP'] = set_RP(hash['RP']) + hash['RX'] = set_RX(hash['RX']) + hash['RA'] = set_RA(hash['RA']) + hash['RT'] = set_RT(hash['RT']) + hash['RL'] = set_RL(hash['RL']) + hash['RG'] = set_RG(hash['RG']) + + hash + } + + end + @data['R'] + end + + def set_RN(data) + data.strip + end + + def set_RC(data) + data.scan(/([STP]\w+)=(.+);/).map { |comment| + [comment[1].split(/, and |, /)].flatten.map { |text| + {'Token' => comment[0], 'Text' => text} + } + }.flatten + end + private :set_RC + + def set_RP(data) + data = data.strip + data = data.sub(/\.$/, '') + data.split(/, AND |, /i).map {|x| + x = x.strip + x = x.gsub(' ', ' ') + } + end + private :set_RP + + def set_RX(data) + rx = {'MEDLINE' => nil, 'PubMed' => nil, 'DOI' => nil} + if data =~ /MEDLINE=(.+?);/ + rx['MEDLINE'] = $1 + end + if data =~ /PubMed=(.+?);/ + rx['PubMed'] = $1 + end + if data =~ /DOI=(.+?);/ + rx['DOI'] = $1 + end + rx + end + private :set_RX + + def set_RA(data) + data = data.sub(/; *$/, '') + end + private :set_RA + + def set_RT(data) + data = data.sub(/; *$/, '') + data = data.gsub(/(^"|"$)/, '') + end + private :set_RT + + def set_RL(data) + data = data.strip + end + private :set_RL + + def set_RG(data) + data = data.split('; ') + end + private :set_RG + + + + # returns Bio::Reference object from Bio::EMBLDB::Common#ref. + # * Bio::EMBLDB::Common#ref -> Bio::References + def references + unless @data['references'] + ary = self.ref.map {|ent| + hash = Hash.new('') + ent.each {|key, value| + case key + when 'RA' + hash['authors'] = value.split(/, /) + when 'RT' + hash['title'] = value + when 'RL' + if value =~ /(.*) (\d+) \((\d+)\), (\d+-\d+) \((\d+)\)$/ + hash['journal'] = $1 + hash['volume'] = $2 + hash['issue'] = $3 + hash['pages'] = $4 + hash['year'] = $5 + else + hash['journal'] = value + end + when 'RX' # PUBMED, MEDLINE + value.split('.').each {|item| + tag, xref = item.split(/; /).map {|i| i.strip } + hash[ tag.downcase ] = xref + } + end + } + Reference.new(hash) + } + @data['references'] = References.new(ary) + end + @data['references'] + end + + + + + + + # === The HI line + # Bio::SPTR#hi #=> hash + def hi + unless @data['HI'] + @data['HI'] = [] + fetch('HI').split(/\. /).each do |hlist| + hash = {'Category' => '', 'Keywords' => [], 'Keyword' => ''} + hash['Category'], hash['Keywords'] = hlist.split(': ') + hash['Keywords'] = hash['Keywords'].split('; ') + hash['Keyword'] = hash['Keywords'].pop + hash['Keyword'].sub!(/\.$/, '') + @data['HI'] << hash + end + end + @data['HI'] + end + @@cc_topics = ['PHARMACEUTICAL', *************** *** 422,429 **** # See also http://www.expasy.org/sprot/userman.html#CC_line # ! def cc(tag = nil) unless @data['CC'] cc = Hash.new ! cmt = '-' * (77 - 4 + 1) dlm = /-!- / --- 609,616 ---- # See also http://www.expasy.org/sprot/userman.html#CC_line # ! def cc(topic = nil) unless @data['CC'] cc = Hash.new ! comment_border= '-' * (77 - 4 + 1) dlm = /-!- / *************** *** 433,446 **** cc_raw = fetch('CC') cc_raw.sub!(/ *---.+---/m, '') # Not any CC Lines without the copyright statement. return cc if cc_raw == '' - begin ! cc_raw.split(/#{cmt}/)[0].sub(dlm,'').split(dlm).each do |tmp| if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 ! body = $2.gsub(/- (?!AND)/,'-') unless cc[key] cc[key] = [body] --- 620,640 ---- cc_raw = fetch('CC') + # Removing the copyright statement. cc_raw.sub!(/ *---.+---/m, '') + # Not any CC Lines without the copyright statement. return cc if cc_raw == '' begin ! cc_raw, copyright = cc_raw.split(/#{comment_border}/)[0] ! cc_raw = cc_raw.sub(dlm,'') ! cc_raw.split(dlm).each do |tmp| ! tmp = tmp.strip ! if /(^[A-Z ]+[A-Z]): (.+)/ =~ tmp key = $1 ! body = $2 ! body.gsub!(/- (?!AND)/,'-') ! body.strip! unless cc[key] cc[key] = [body] *************** *** 449,454 **** end else ! raise ["Error: [#{entry_id}]: CC Lines", '', ! tmp, '', '', fetch('CC'),''].join("\n") end end --- 643,648 ---- end else ! raise ["Error: [#{entry_id}]: CC Lines", '"', tmp, '"', ! '', get('CC'),''].join("\n") end end *************** *** 466,493 **** end - case tag - when 'ALTERNATIVE PRODUCTS' - ap = @data['CC']['ALTERNATIVE PRODUCTS'].to_s - return ap unless ap - - # Event, Named isoforms, Comment, [Name, Synonyms, IsoId, Sequnce]+ - tmp = {'Event' => nil, 'Named isoforms' => nil, 'Comment' => nil, - 'Variants' => []} - - if /Event=(.+?);/ =~ ap - tmp['Event'] = $1 - end - if /Named isoforms=(\S+?);/ =~ ap - tmp['Named isoforms'] = $1 - end - if /Comment=(.+?);/m =~ ap - tmp['Comment'] = $1 - end - ap.scan(/Name=.+?Sequence=.+?;/).each do |ent| - tmp['Variants'] << cc_ap_variants_parse(ent) - end - return tmp - when 'DATABASE' # DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"]. --- 660,719 ---- end + case topic + when 'ALLERGEN' + return @data['CC'][topic] + when 'ALTERNATIVE PRODUCTS' + return cc_alternative_products(@data['CC'][topic]) + when 'BIOPHYSICOCHEMICAL PROPERTIES' + return cc_biophysiochemical_properties(@data['CC'][topic]) + when 'BIOTECHNOLOGY' + return @data['CC'][topic] + when 'CATALITIC ACTIVITY' + return cc_catalytic_activity(@data['CC'][topic]) + when 'CAUTION' + return cc_caution(@data['CC'][topic]) + when 'COFACTOR' + return @data['CC'][topic] + when 'DEVELOPMENTAL STAGE' + return @data['CC'][topic].to_s + when 'DISEASE' + return @data['CC'][topic].to_s + when 'DOMAIN' + return @data['CC'][topic] + when 'ENZYME REGULATION' + return @data['CC'][topic].to_s + when 'FUNCTION' + return @data['CC'][topic].to_s + when 'INDUCTION' + return @data['CC'][topic].to_s + when 'INTERACTION' + return cc_interaction(@data['CC'][topic]) + when 'MASS SPECTROMETRY' + return cc_mass_spectrometry(@data['CC'][topic]) + when 'MISCELLANEOUS' + return @data['CC'][topic] + when 'PATHWAY' + return cc_pathway(@data['CC'][topic]) + when 'PHARMACEUTICAL' + return @data['CC'][topic] + when 'POLYMORPHISM' + return @data['CC'][topic] + when 'PTM' + return @data['CC'][topic] + when 'RNA EDITING' + return cc_rna_editing(@data['CC'][topic]) + when 'SIMILARITY' + return @data['CC'][topic] + when 'SUBCELLULAR LOCATION' + return cc_subcellular_location(@data['CC'][topic]) + when 'SUBUNIT' + return @data['CC'][topic] + when 'TISSUE SPECIFICITY' + return @data['CC'][topic] + when 'TOXIC DOSE' + return @data['CC'][topic] + when 'WEB RESOURCE' + return cc_web_resource(@data['CC'][topic]) when 'DATABASE' # DATABASE: NAME=Text[; NOTE=Text][; WWW="Address"][; FTP="Address"]. *************** *** 513,566 **** end return tmp - - when 'MASS SPECTOROMETRY' - # MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX]. - tmp = Array.new - ms = @data['CC']['MASS SPECTOROMETRY'] - return ms unless ms - - ms.each do |m| - mass = {'MW' => nil,'MW_ERR' => nil,'METHOD' => nil,'RANGE' => nil} - m.sub(/.$/,'').split(/;/).each do |line| - case line - when /MW=(.+)/ - mass['MW'] = $1.to_f - when /MW_ERR=(.+)/ - mass['MW_ERR'] = $1.to_f - when /METHOD="(.+)"/ - mass['METHOD'] = $1.to_s - when /RANGE="(\d+-\d+)"/ - mass['RANGE'] = $1 # RANGE class ? - end - end - tmp.push(mass) - end - return tmp - - when 'INTERACTION' - return cc_interaction_parse(@data['CC']['INTERACTION'].to_s) - when nil return @data['CC'] - else ! return @data['CC'][tag] end end ! def cc_ap_variants_parse(ent) ! hsh = {} ! ent.split(/; /).map {|e| e.split(/=/) }.each do |e| case e[0] ! when 'Sequence' e[1] = e[1].sub(/;/,'').split(/, /) end ! hsh[e[0]] = e[1] end ! return hsh end ! private :cc_ap_variants_parse --- 739,827 ---- end return tmp when nil return @data['CC'] else ! return @data['CC'][topic] end end + def cc_alternative_products(data) + ap = data.to_s + return ap unless ap ! # Event, Named isoforms, Comment, [Name, Synonyms, IsoId, Sequnce]+ ! tmp = {'Event' => "", 'Named isoforms' => "", 'Comment' => "", ! 'Variants' => []} ! if /Event=(.+?);/ =~ ap ! tmp['Event'] = $1 ! tmp['Event'] = tmp['Event'].sub(/;/,'').split(/, /) ! end ! if /Named isoforms=(\S+?);/ =~ ap ! tmp['Named isoforms'] = $1 ! end ! if /Comment=(.+?);/m =~ ap ! tmp['Comment'] = $1 ! end ! ap.scan(/Name=.+?Sequence=.+?;/).each do |ent| ! tmp['Variants'] << cc_alternative_products_variants(ent) ! end ! return tmp ! end ! private :cc_alternative_products ! ! def cc_alternative_products_variants(data) ! variant = {'Name' => '', 'Synonyms' => [], 'IsoId' => [], 'Sequence' => []} ! data.split(/; /).map {|x| x.split(/=/) }.each do |e| case e[0] ! when 'Sequence', 'Synonyms', 'IsoId' e[1] = e[1].sub(/;/,'').split(/, /) end ! variant[e[0]] = e[1] end ! variant end ! private :cc_alternative_products_variants ! ! ! def cc_biophysiochemical_properties(data) ! data = data[0] ! ! hash = {'Absorption' => {}, ! 'Kinetic parameters' => {}, ! 'pH dependence' => "", ! 'Redox potential' => "", ! 'Temperature dependence' => ""} ! if data =~ /Absorption: Abs\(max\)=(.+?);/ ! hash['Absorption']['Abs(max)'] = $1 ! end ! if data =~ /Absorption: Abs\(max\)=.+; Note=(.+?);/ ! hash['Absorption']['Note'] = $1 ! end ! if data =~ /Kinetic parameters: KM=(.+?); Vmax=(.+?);/ ! hash['Kinetic parameters']['KM'] = $1 ! hash['Kinetic parameters']['Vmax'] = $2 ! end ! if data =~ /Kinetic parameters: KM=.+; Vmax=.+; Note=(.+?);/ ! hash['Kinetic parameters']['Note'] = $1 ! end ! if data =~ /pH dependence: (.+?);/ ! hash['pH dependence'] = $1 ! end ! if data =~ /Redox potential: (.+?);/ ! hash['Redox potential'] = $1 ! end ! if data =~ /Temperature dependence: (.+?);/ ! hash['Temperature dependence'] = $1 ! end ! hash ! end ! private :cc_biophysiochemical_properties ! ! ! def cc_caution(data) ! data.to_s ! end ! private :cc_caution *************** *** 568,583 **** # # CC P46527:CDKN1B; NbExp=1; IntAct=EBI-359815, EBI-519280; ! def cc_interaction_parse(str) it = str.scan(/(.+?); NbExp=(.+?); IntAct=(.+?);/) it.map {|ent| ! {:partner_id => ent[0].strip, ! :nbexp => ent[1].strip, ! :intact_acc => ent[2].split(', ') } } end ! private :cc_interaction_parse # returns databases cross-references in the DR lines. ! # * Bio::EMBLDB#dr -> Hash w/in Array # # === DR Line; defabases cross-reference (>=0) --- 829,944 ---- # # CC P46527:CDKN1B; NbExp=1; IntAct=EBI-359815, EBI-519280; ! def cc_interaction(data) ! str = data.to_s it = str.scan(/(.+?); NbExp=(.+?); IntAct=(.+?);/) it.map {|ent| ! ent.map! {|x| x.strip } ! if ent[0] =~ /^(.+):(.+)/ ! spac = $1 ! spid = $2.split(' ')[0] ! optid = nil ! elsif ent[0] =~ /Self/ ! spac = self.entry_id ! spid = self.entry_id ! optid = nil ! end ! if ent[0] =~ /^.+:.+ (.+)/ ! optid = $1 ! end ! ! {'SP_Ac' => spac, ! 'identifier' => spid, ! 'NbExp' => ent[1], ! 'IntAct' => ent[2].split(', '), ! 'optional_identifier' => optid} } end ! private :cc_interaction ! ! ! def cc_mass_spectrometry(data) ! # MASS SPECTROMETRY: MW=XXX[; MW_ERR=XX][; METHOD=XX][;RANGE=XX-XX]. ! return data unless data ! ! data.map { |m| ! mass = {'MW' => nil, 'MW_ERR' => nil, 'METHOD' => nil, 'RANGE' => nil, ! 'NOTE' => nil} ! m.sub(/.$/,'').split(/;/).each do |line| ! case line ! when /MW=(.+)/ ! mass['MW'] = $1 ! when /MW_ERR=(.+)/ ! mass['MW_ERR'] = $1 ! when /METHOD=(.+)/ ! mass['METHOD'] = $1 ! when /RANGE=(\d+-\d+)/ ! mass['RANGE'] = $1 # RANGE class ? ! when /NOTE=(.+)/ ! mass['NOTE'] = $1 ! end ! end ! mass ! } ! end ! private :cc_mass_spectrometry ! ! ! def cc_pathway(data) ! data.map {|x| x.sub(/\.$/, '') }.map {|x| ! x.split(/; | and |: /) ! }[0] ! end ! private :cc_pathway ! ! ! def cc_rna_editing(data) ! data = data.to_s ! entry = {'Modified_positions' => [], 'Note' => ""} ! if data =~ /Modified_positions=(.+?)(\.|;)/ ! entry['Modified_positions'] = $1.sub(/\.$/, '').split(', ') ! else ! raise ArgumentError, "Invarid CC RNA Editing lines (#{self.entry_id}):#{$!}\n#{get('CC')}" ! end ! if data =~ /Note=(.+)/ ! entry['Note'] = $1 ! end ! entry ! end ! private :cc_rna_editing ! ! ! def cc_subcellular_location(data) ! data.map {|x| ! x.split('. ').map {|y| ! y.split('; ').map {|z| ! z.sub(/\.$/, '') ! } ! } ! }[0] ! end ! private :cc_subcellular_location ! ! ! # CC -!- WEB RESOURCE: NAME=ResourceName[; NOTE=FreeText][; URL=WWWAddress]. ! def cc_web_resource(data) ! data.map {|x| ! entry = {'NAME' => nil, 'NOTE' => nil, 'URL' => nil} ! x.split(';').each do |y| ! case y ! when /NAME=(.+)/ ! entry['NAME'] = $1.strip ! when /NOTE=(.+)/ ! entry['NOTE'] = $1.strip ! when /URL="(.+)"/ ! entry['URL'] = $1.strip ! end ! end ! entry ! } ! end ! # returns databases cross-references in the DR lines. ! # * Bio::SPTR#dr -> Hash w/in Array # # === DR Line; defabases cross-reference (>=0) *************** *** 591,594 **** --- 952,973 ---- 'SWISS-2DPAGE','TIGR','TRANSFAC','TUBERCULIST','WORMPEP','YEPD','ZFIN'] + # Backup Bio::EMBLDB#dr as embl_dr + alias :embl_dr :dr + + # Bio::SPTR#dr + def dr(key = nil) + unless key + embl_dr + else + embl_dr[key].map {|x| + {'Accession' => x[0], + 'Version' => x[1], + ' ' => x[2], + 'Molecular Type' => x[3]} + } + end + end + + # Bio::EMBLDB::Common#kw - Array # #keywords -> Array *************** *** 598,602 **** ! # returns conteins in the feature table. # # == Examples --- 977,981 ---- ! # returns contents in the feature table. # # == Examples *************** *** 612,621 **** # feature['FTId'] #=> '' # feature['diff'] #=> [] # end # end # # * Bio::SPTR#ft -> Hash ! # {FEATURE_KEY => [{'From' => int, 'To' => int, 'diff' => [], ! # 'Description' => aStr, 'FTId' => aStr}],...} # # returns an Array of the information about the feature_name in the feature table. --- 991,1003 ---- # feature['FTId'] #=> '' # feature['diff'] #=> [] + # feature['original'] #=> [feature_key, '1', '21', '', ''] # end # end # # * Bio::SPTR#ft -> Hash ! # {FEATURE_KEY => [{'From' => int, 'To' => int, ! # 'Description' => aStr, 'FTId' => aStr, ! # 'diff' => [original_residues, changed_residues], ! # 'original' => aAry }],...} # # returns an Array of the information about the feature_name in the feature table. *************** *** 634,637 **** --- 1016,1024 ---- # ----- ----------------- # + # Note: 'FROM' and 'TO' endopoints are allowed to use non-numerial charactors + # including '<', '>' or '?'. (c.f. '<1', '?42') + # + # See also http://www.expasy.org/sprot/userman.html#FT_line + # def ft(feature_key = nil) return ft[feature_key] if feature_key *************** *** 640,693 **** table = [] begin ! get('FT').split("\n").each do |line| ! if line =~ /^FT \w/ ! feature = line.chomp.ljust(74) ! table << [feature[ 5..12].strip, # Feature Name ! feature[14..19].strip, # From ! feature[21..26].strip, # To ! feature[34..74].strip ] # Description ! else ! table.last << line.chomp.sub!(/^FT +/, '') ! end ! end ! ! # Join Desctiption lines ! table = table.map { |feature| ! ftid = feature.pop if feature.last =~ /FTId=/ ! if feature.size > 4 ! feature = [feature[0], feature[1], feature[2], ! feature[3, feature.size - 3].join(" ")] end - feature << ftid - } ! hash = {} ! table.each do |feature| ! hash[feature[0]] = [] unless hash[feature[0]] ! ! hash[feature[0]] << { ! 'From' => feature[1].to_i, ! 'To' => feature[2].to_i, ! 'Description' => feature[3], ! 'FTId' => feature[4].to_s.sub(/\/FTId=/, '').sub(/\.$/, ''), ! 'diff' => [] } ! case feature[0] ! when 'VARSPLIC', 'VARIANT', 'VAR_SEQ', 'CONFLICT' ! case hash[feature[0]].last['Description'] ! when /(\w[\w ]*\w*) - ?> (\w[\w ]*\w*)/ ! original_res = $1 ! changed_res = $2 ! original_res = original_res.gsub(/ /,'').strip ! chenged_res = changed_res.gsub(/ /,'').strip ! when /Missing/i ! original_res = seq.subseq(hash[feature[0]].last['From'], ! hash[feature[0]].last['To']) ! changed_res = '' end - hash[feature[0]].last['diff'] = [original_res, chenged_res] end - end rescue raise "Invalid FT Lines(#{$!}) in #{entry_id}:, \n'#{self.get('FT')}'\n" --- 1027,1083 ---- table = [] begin ! get('FT').split("\n").each do |line| ! if line =~ /^FT \w/ ! feature = line.chomp.ljust(74) ! table << [feature[ 5..12].strip, # Feature Name ! feature[14..19].strip, # From ! feature[21..26].strip, # To ! feature[34..74].strip ] # Description ! else ! table.last << line.chomp.sub!(/^FT +/, '') ! end end ! # Joining Description lines ! table = table.map { |feature| ! ftid = feature.pop if feature.last =~ /FTId=/ ! if feature.size > 4 ! feature = [feature[0], ! feature[1], ! feature[2], ! feature[3, feature.size - 3].join(" ")] ! end ! feature << if ftid then ftid else '' end } ! hash = {} ! table.each do |feature| ! hash[feature[0]] = [] unless hash[feature[0]] ! hash[feature[0]] << { ! # Removing '<', '>' or '?' in FROM/TO endopoint. ! 'From' => feature[1].sub(/\D/, '').to_i, ! 'To' => feature[2].sub(/\D/, '').to_i, ! 'Description' => feature[3], ! 'FTId' => feature[4].to_s.sub(/\/FTId=/, '').sub(/\.$/, ''), ! 'diff' => [], ! 'original' => feature ! } ! ! case feature[0] ! when 'VARSPLIC', 'VARIANT', 'VAR_SEQ', 'CONFLICT' ! case hash[feature[0]].last['Description'] ! when /(\w[\w ]*\w*) - ?> (\w[\w ]*\w*)/ ! original_res = $1 ! changed_res = $2 ! original_res = original_res.gsub(/ /,'').strip ! chenged_res = changed_res.gsub(/ /,'').strip ! when /Missing/i ! original_res = seq.subseq(hash[feature[0]].last['From'], ! hash[feature[0]].last['To']) ! changed_res = '' ! end ! hash[feature[0]].last['diff'] = [original_res, chenged_res] end end rescue raise "Invalid FT Lines(#{$!}) in #{entry_id}:, \n'#{self.get('FT')}'\n" *************** *** 872,875 **** --- 1262,1266 ---- # OC - organism classification (>=1 per entry) # OX - organism taxonomy x-ref (>=1 per entry) + # OH - Organism Host # RN - reference number (>=1 per entry) # RP - reference positions (>=1 per entry) *************** *** 879,882 **** --- 1270,1274 ---- # RT - reference title (>=0 per entry; optional) # RL - reference location (>=1 per entry) + # RG - reference group(s) # CC - comments or notes (>=0 per entry; optional) # DR - database cross-references (>=0 per entry; optional) From ngoto at dev.open-bio.org Thu Jul 20 03:45:24 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 20 Jul 2006 03:45:24 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/sequence na.rb,1.4,1.5 Message-ID: <200607200345.k6K3jOVA012571@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/sequence In directory dev.open-bio.org:/tmp/cvs-serv12551/lib/bio/sequence Modified Files: na.rb Log Message: In gc_content, at_content, gc_skew, at_skew methods, changed to use Numeric#quo instead of Float#/. Index: na.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence/na.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** na.rb 27 Jun 2006 05:44:57 -0000 1.4 --- na.rb 20 Jul 2006 03:45:22 -0000 1.5 *************** *** 308,312 **** gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return (gc.to_f / (at + gc).to_f) end --- 308,312 ---- gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return gc.quo(at + gc) end *************** *** 322,326 **** gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return (at.to_f / (at + gc).to_f) end --- 322,326 ---- gc = count['g'] + count['c'] return 0.0 if at + gc == 0 ! return at.quo(at + gc) end *************** *** 336,340 **** c = count['c'] return 0.0 if g + c == 0 ! return ((g - c).to_f / (g + c).to_f) end --- 336,340 ---- c = count['c'] return 0.0 if g + c == 0 ! return (g - c).quo(g + c) end *************** *** 350,354 **** t = count['t'] + count['u'] return 0.0 if a + t == 0 ! return ((a - t).to_f / (a + t).to_f) end --- 350,354 ---- t = count['t'] + count['u'] return 0.0 if a + t == 0 ! return (a - t).quo(a + t) end From k at dev.open-bio.org Tue Jul 25 18:16:31 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:16:31 +0000 Subject: [BioRuby-cvs] bioruby/bin bioruby,1.15,1.16 Message-ID: <200607251816.k6PIGVw6027202@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/bin In directory dev.open-bio.org:/tmp/cvs-serv27198/bin Modified Files: bioruby Log Message: * changed to show working directory when exit Index: bioruby =================================================================== RCS file: /home/repository/bioruby/bioruby/bin/bioruby,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** bioruby 27 Feb 2006 09:41:54 -0000 1.15 --- bioruby 25 Jul 2006 18:16:28 -0000 1.16 *************** *** 24,40 **** # command line argument (working directory or bioruby shell script file) script = nil if arg = ARGV.shift if File.directory?(arg) # directory or symlink to directory ! Dir.chdir(arg) elsif File.exists?(arg) # BioRuby shell script (load script after the previous session is restored) ! dir = File.dirname(arg) script = File.basename(arg) ! Dir.chdir(dir) ! elsif arg ! Dir.mkdir(arg) ! Dir.chdir(arg) end else --- 24,43 ---- # command line argument (working directory or bioruby shell script file) + workdir = nil script = nil if arg = ARGV.shift if File.directory?(arg) # directory or symlink to directory ! workdir = arg ! Dir.chdir(workdir) elsif File.exists?(arg) # BioRuby shell script (load script after the previous session is restored) ! workdir = File.dirname(arg) script = File.basename(arg) ! Dir.chdir(workdir) ! else ! workdir = arg ! Dir.mkdir(workdir) ! Dir.chdir(workdir) end else *************** *** 150,151 **** --- 153,160 ---- Bio::Shell.save_session + if workdir + puts "Leaving directory '#{workdir}'." + puts "History is saved in '#{workdir}/#{Bio::Shell.history}'." + end + + From k at dev.open-bio.org Tue Jul 25 18:18:23 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:18:23 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io fastacmd.rb,1.12,1.13 Message-ID: <200607251818.k6PIINNt027229@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv27223/lib/bio/io Modified Files: fastacmd.rb Log Message: * fixed to work with newer version of fastacmd (suggested by the author of this module, Shuji Shigenbu) Index: fastacmd.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/fastacmd.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fastacmd.rb 14 Jul 2006 14:30:09 -0000 1.12 --- fastacmd.rb 25 Jul 2006 18:18:21 -0000 1.13 *************** *** 147,151 **** # *Returns*:: a Bio::FastaFormat object for each iteration def each_entry ! cmd = [ @fastacmd, '-d', @database, '-D', 'T' ] Bio::Command.call_command(cmd) do |io| io.close_write --- 147,151 ---- # *Returns*:: a Bio::FastaFormat object for each iteration def each_entry ! cmd = [ @fastacmd, '-d', @database, '-D', '1' ] Bio::Command.call_command(cmd) do |io| io.close_write From k at dev.open-bio.org Tue Jul 25 18:21:28 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:21:28 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio pathway.rb,1.34,1.35 Message-ID: <200607251821.k6PILShI027308@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv27304/lib/bio Modified Files: pathway.rb Log Message: * changed to RDoc format * changed to Ruby's license Index: pathway.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/pathway.rb,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** pathway.rb 18 Dec 2005 16:50:56 -0000 1.34 --- pathway.rb 25 Jul 2006 18:21:26 -0000 1.35 *************** *** 1,21 **** # ! # bio/pathway.rb - Binary relations and Graph algorithms ! # ! # Copyright (C) 2001 KATAYAMA Toshiaki ! # KAWASHIMA Shuichi ! # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. [...1476 lines suppressed...] - --- Bio::Relation#eql?(rel) - --- Bio::Relation#hash - - Method eql? is an alias of the === method and is used with hash method - to make uniq arry of the Bio::Relation objects. - - a1 = Bio::Relation.new('a', 'b', 1) - a2 = Bio::Relation.new('b', 'a', 1) - a3 = Bio::Relation.new('b', 'c', 1) - p [ a1, a2, a3 ].uniq - - --- Bio::Relation#<=>(rel) - - Used by the each method to compare with another Bio::Relation object. - This method is only usable when the edge objects have the property of - the module Comparable. - - =end - --- 853,854 ---- From k at dev.open-bio.org Tue Jul 25 18:41:25 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:41:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl psort.rb,1.10,1.11 Message-ID: <200607251841.k6PIfPZu027478@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27438/lib/bio/appl Modified Files: psort.rb Log Message: * changed to use autoload * changed to require 'psort/report' from psort.rb to make PSORT::PSORT2::SclNames available whenever psort.rb is loaded. Index: psort.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** psort.rb 14 Jul 2006 14:28:44 -0000 1.10 --- psort.rb 25 Jul 2006 18:41:23 -0000 1.11 *************** *** 28,34 **** # ! require 'bio/sequence' ! require 'bio/command' ! require 'bio/db/fasta' require 'cgi' --- 28,34 ---- # ! require 'bio/appl/psort/report' ! autoload :FastaFormat, 'bio/db/fasta' ! autoload :Command, 'bio/command' require 'cgi' From k at dev.open-bio.org Tue Jul 25 18:41:25 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:41:25 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl/psort report.rb,1.13,1.14 Message-ID: <200607251841.k6PIfPjh027483@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl/psort In directory dev.open-bio.org:/tmp/cvs-serv27438/lib/bio/appl/psort Modified Files: report.rb Log Message: * changed to use autoload * changed to require 'psort/report' from psort.rb to make PSORT::PSORT2::SclNames available whenever psort.rb is loaded. Index: report.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort/report.rb,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** report.rb 30 Apr 2006 07:11:28 -0000 1.13 --- report.rb 25 Jul 2006 18:41:23 -0000 1.14 *************** *** 11,15 **** # - require 'bio/sequence' require 'bio/appl/psort' --- 11,14 ---- *************** *** 17,20 **** --- 16,21 ---- module Bio + autoload :Sequence, 'bio/sequence' + class PSORT From k at dev.open-bio.org Tue Jul 25 18:42:11 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:42:11 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin psort.rb,NONE,1.1 Message-ID: <200607251842.k6PIgBSu027526@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory dev.open-bio.org:/tmp/cvs-serv27522/lib/bio/shell/plugin Added Files: psort.rb Log Message: * newly added shell plugin for psort --- NEW FILE: psort.rb --- # # = bio/shell/plugin/psort.rb - plugin for PSORT # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: psort.rb,v 1.1 2006/07/25 18:42:09 k Exp $ # module Bio::Shell private def psort1(str) seq = seq(str) if seq.is_a?(Bio::Sequence::NA) seq = seq.translate end psort = Bio::PSORT::PSORT1.imsut fasta = seq.to_fasta results = psort.exec(fasta).final_result results.each do |result| puts "#{result["certainty"].to_f*100.0}\t#{result["prediction"]}" end return results.first["prediction"] end def psort2(str) seq = seq(str) if seq.is_a?(Bio::Sequence::NA) seq = seq.translate end psort = Bio::PSORT::PSORT2.imsut fasta = seq.to_fasta results = psort.exec(fasta).prob.sort_by{|x, y| y}.reverse results.each do |loc, prob| next if prob <= 0.0 puts "#{prob}\t#{Bio::PSORT::PSORT2::SclNames[loc]}" end return results.first.first end def psort2locations names = Bio::PSORT::PSORT2::SclNames names.sort.each do |loc, desc| puts "#{loc}\t#{desc}" end return names end end From k at dev.open-bio.org Tue Jul 25 18:43:19 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:43:19 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/shell/plugin blast.rb,NONE,1.1 Message-ID: <200607251843.k6PIhJWi027569@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/shell/plugin In directory dev.open-bio.org:/tmp/cvs-serv27565/lib/bio/shell/plugin Added Files: blast.rb Log Message: * newly added shell plugin for blast (currently only supports blast against KEGG GENES peptides) --- NEW FILE: blast.rb --- # # = bio/shell/plugin/blast.rb - plugin for BLAST services # # Copyright:: Copyright (C) 2006 # Toshiaki Katayama # License:: Ruby's # # $Id: blast.rb,v 1.1 2006/07/25 18:43:17 k Exp $ # module Bio::Shell private # GenomeNet def keggblast(query) server = Bio::Blast.remote("blastp", "genes", "", "genomenet_tab") if query[/^>/] data = Bio::FastaFormat.new(query) desc = data.definition tmp = seq(data.seq) else desc = "query" tmp = seq(query) end if tmp.respond_to?(:translate) aaseq = tmp.translate else aaseq = tmp end fasta = aaseq.to_fasta(desc, 60) result = server.query(fasta) puts server.output return result end end From k at dev.open-bio.org Tue Jul 25 18:45:29 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:45:29 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio shell.rb,1.15,1.16 Message-ID: <200607251845.k6PIjTgL027632@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio In directory dev.open-bio.org:/tmp/cvs-serv27628/lib/bio Modified Files: shell.rb Log Message: * added blast and psort plugins Index: shell.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/shell.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** shell.rb 27 Feb 2006 09:34:23 -0000 1.15 --- shell.rb 25 Jul 2006 18:45:27 -0000 1.16 *************** *** 29,32 **** --- 29,34 ---- require 'bio/shell/plugin/keggapi' require 'bio/shell/plugin/emboss' + require 'bio/shell/plugin/blast' + require 'bio/shell/plugin/psort' extend Ghost From k at dev.open-bio.org Tue Jul 25 18:47:15 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:47:15 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl blast.rb,1.30,1.31 Message-ID: <200607251847.k6PIlFWo027706@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27702/lib/bio/appl Modified Files: blast.rb Log Message: * added exec_genomenet_tab method used by shell plugin Index: blast.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** blast.rb 14 Jul 2006 14:26:39 -0000 1.30 --- blast.rb 25 Jul 2006 18:47:13 -0000 1.31 *************** *** 258,261 **** --- 258,265 ---- end + def exec_genomenet_tab(query) + @format = 8 + exec_genomenet(query) + end def exec_genomenet(query) From k at dev.open-bio.org Tue Jul 25 18:48:43 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:48:43 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/appl fasta.rb,1.21,1.22 Message-ID: <200607251848.k6PImh2c027731@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/appl In directory dev.open-bio.org:/tmp/cvs-serv27727/lib/bio/appl Modified Files: fasta.rb Log Message: * remote fasta is currently broken (need to be fixed), added a comment for now. Index: fasta.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** fasta.rb 14 Jul 2006 14:26:39 -0000 1.21 --- fasta.rb 25 Jul 2006 18:48:41 -0000 1.22 *************** *** 149,153 **** result, = http.post(path, data.join('&')) @output = result.body ! # workaround 2005.08.12 if /\Show all result\<\/A\>/i =~ @output.to_s then result, = http.get($2) --- 149,153 ---- result, = http.post(path, data.join('&')) @output = result.body ! # workaround 2005.08.12 - realized that this is bloken again (by new batch queuing system) 2006.06.08 if /\Show all result\<\/A\>/i =~ @output.to_s then result, = http.get($2) From k at dev.open-bio.org Tue Jul 25 18:50:03 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:50:03 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/data aa.rb,0.17,0.18 Message-ID: <200607251850.k6PIo3pm027792@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/data In directory dev.open-bio.org:/tmp/cvs-serv27788/lib/bio/data Modified Files: aa.rb Log Message: * added J, O, and X amino acids Index: aa.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/data/aa.rb,v retrieving revision 0.17 retrieving revision 0.18 diff -C2 -d -r0.17 -r0.18 *** aa.rb 8 May 2006 14:19:51 -0000 0.17 --- aa.rb 25 Jul 2006 18:50:01 -0000 0.18 *************** *** 18,21 **** --- 18,22 ---- # * http://www.iupac.org/ # * http://www.chem.qmw.ac.uk/iubmb/newsletter/1999/item3.html + # * http://www.ebi.ac.uk/RESID/faq.html NAMES = { *************** *** 43,48 **** 'B' => 'Asx', # D/N 'Z' => 'Glx', # E/Q 'U' => 'Sec', # 'uga' (stop) ! '?' => 'Pyl', # 'uag' (stop) 'Ala' => 'alanine', --- 44,51 ---- 'B' => 'Asx', # D/N 'Z' => 'Glx', # E/Q + 'J' => 'Xle', # I/L 'U' => 'Sec', # 'uga' (stop) ! 'O' => 'Pyl', # 'uag' (stop) ! 'X' => 'Xaa', # (unknown) 'Ala' => 'alanine', *************** *** 68,73 **** --- 71,78 ---- 'Asx' => 'asparagine/aspartic acid', 'Glx' => 'glutamine/glutamic acid', + 'Xle' => 'isoleucine/leucine', 'Sec' => 'selenocysteine', 'Pyl' => 'pyrrolysine', + 'Xaa' => 'unknown', } From k at dev.open-bio.org Tue Jul 25 18:53:58 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 18:53:58 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db prosite.rb,0.14,0.15 Message-ID: <200607251853.k6PIrwDV027835@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db In directory dev.open-bio.org:/tmp/cvs-serv27831/lib/bio/db Modified Files: prosite.rb Log Message: * added 're' instance method in addition to 'pa2re' class method to return Regexp of the PATTERN entry instantly Index: prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/prosite.rb,v retrieving revision 0.14 retrieving revision 0.15 diff -C2 -d -r0.14 -r0.15 *** prosite.rb 8 May 2006 14:23:07 -0000 0.14 --- prosite.rb 25 Jul 2006 18:53:56 -0000 0.15 *************** *** 478,482 **** pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' pattern.tr!('-', '') # (6) each element is separated by a '-' ! Regexp.new(pattern) end --- 478,482 ---- pattern.tr!('x', '.') # (5) any amino acid is accepted : 'x' pattern.tr!('-', '') # (6) each element is separated by a '-' ! Regexp.new(pattern, Regexp::IGNORECASE) end *************** *** 485,488 **** --- 485,492 ---- end + def re + self.class.pa2re(self.pa) + end + ### prosite profile to regular expression From k at dev.open-bio.org Tue Jul 25 19:12:34 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:12:34 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg genes.rb,0.22,0.23 Message-ID: <200607251912.k6PJCYhr028011@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory dev.open-bio.org:/tmp/cvs-serv27986/lib/bio/db/kegg Modified Files: genes.rb Log Message: * changed to RDoc * changed to use autoload * 'keggclass' method is changed to the 'pathway' method (this field is renamed in the original database) * removed splinks method (this field is obsoleted in the original database) * chromosome method is slightly improved * locations method is added to return Bio::Locations object when possible * motifs method is added (this field is added in the original database) * codon_usage method is renamed to cu_list method (and disabled the codon argument - use hash for this purpose) which returns an Array of codon usages * cu method is renamed to codon_usage which returns a Hash of codon usage * aalen and ntlen method is changed to return the numbers written in the entry (not the number calculated by the sequence length - use seq.length for this purpose) Index: genes.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/genes.rb,v retrieving revision 0.22 retrieving revision 0.23 diff -C2 -d -r0.22 -r0.23 *** genes.rb 9 Nov 2005 12:30:07 -0000 0.22 --- genes.rb 25 Jul 2006 19:12:32 -0000 0.23 *************** *** 1,293 **** # ! # bio/db/kegg/genes.rb - KEGG/GENES database class # ! # Copyright (C) 2001, 2002 KATAYAMA Toshiaki # ! # This library is free software; you can redistribute it and/or ! # modify it under the terms of the GNU Lesser General Public ! # License as published by the Free Software Foundation; either ! # version 2 of the License, or (at your option) any later version. # - # This library is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # Lesser General Public License for more details. # ! # You should have received a copy of the GNU Lesser General Public ! # License along with this library; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ! # $Id$ # ! ! require 'bio/db' module Bio ! class KEGG ! ! class GENES < KEGGDB ! DELIMITER = RS = "\n///\n" ! TAGSIZE = 12 ! def initialize(entry) ! super(entry, TAGSIZE) ! end ! def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip ! end ! @data['ENTRY'] = hash ! end ! @data['ENTRY'] ! end - def entry_id - entry['id'] - end ! def division ! entry['division'] # CDS, tRNA etc. end ! def organism ! entry['organism'] # H.sapiens etc. ! end ! def name ! field_fetch('NAME') ! end ! def genes ! name.split(', ') ! end ! def gene ! genes.first ! end ! def definition ! field_fetch('DEFINITION') ! end ! def eclinks ! # definition.slice(/\[EC:(.*?)\]/, 1) # ruby >= 1.7 ! # definition.scan(/\[EC:(.*?)\]/).flatten ! if /\[EC:(.*?)\]/.match(definition) ! $1.split(/\s+/) ! else ! [] ! end ! end ! def splinks ! # definition.slice(/\[SP:(.*?)\]/, 1) # ruby >= 1.7 ! # definition.scan(/\[SP:(.*?)\]/).flatten ! if /\[SP:(.*?)\]/.match(definition) ! $1.split(/\s+/) ! else ! [] ! end ! end ! def keggclass ! field_fetch('CLASS') ! end ! def pathways ! keggclass.scan(/\[PATH:(.*?)\]/).flatten ! end ! def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] ! end ! def gbposition ! position.sub(/.*?:/, '') ! end ! def chromosome ! if position =~ /:/ ! position.sub(/:.*/, '') ! else ! nil ! end ! end ! def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n?/).each do |db, str| ! id_array = str.strip.split(/\s+/) ! hash[db] = id_array ! end ! @data['DBLINKS'] = hash ! end ! @data['DBLINKS'] # Hash of Array of DB IDs in DBLINKS ! end ! def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) ! end ! end ! @data['CODON_USAGE'] = ary ! end ! if codon ! h = { 't' => 0, 'c' => 1, 'a' => 2, 'g' => 3 } ! x, y, z = codon.downcase.scan(/\w/) ! codon_num = h[x] * 16 + h[y] * 4 + h[z] ! @data['CODON_USAGE'][codon_num] # CODON_USAGE of the codon else ! return @data['CODON_USAGE'] # Array of CODON_USAGE (default) ! end ! end ! ! def cu ! hash = Hash.new ! list = codon_usage ! base = %w(t c a g) ! base.each_with_index do |x, i| ! base.each_with_index do |y, j| ! base.each_with_index do |z, k| ! hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k] ! end ! end ! end ! return hash ! end ! ! def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Sequence::AA.new(fetch('AASEQ').gsub(/[\s\d\/]+/, '')) end ! @data['AASEQ'] end ! def aalen ! @data['AALEN'] = aaseq.length end ! def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Sequence::NA.new(fetch('NTSEQ').gsub(/[\s\d\/]+/, '')) end - @data['NTSEQ'] end ! alias naseq ntseq ! def ntlen ! @data['NTLEN'] = ntseq.length end - alias nalen ntlen - end ! end ! end ! ! ! ! if __FILE__ == $0 ! require 'bio/io/fetch' ! e = Bio::Fetch.query('genes', 'b0002') ! g = Bio::KEGG::GENES.new(e) ! p g.entry ! p g.entry_id ! p g.division ! p g.name ! p g.gene ! p g.definition ! p g.keggclass ! p g.position ! p g.dblinks ! p g.codon_usage ! p g.cu ! p g.aaseq ! p g.aalen ! p g.naseq ! p g.nalen ! p g.eclinks ! p g.splinks ! p g.pathways end - =begin - - = Bio::KEGG::GENES - - === Initialize - - --- Bio::KEGG::GENES.new - - === ENTRY - - --- Bio::KEGG::GENES#entry -> Hash - --- Bio::KEGG::GENES#entry_id -> String - --- Bio::KEGG::GENES#division -> String - --- Bio::KEGG::GENES#organism -> String - - === NAME - - --- Bio::KEGG::GENES#name -> String - --- Bio::KEGG::GENES#genes -> Array - --- Bio::KEGG::GENES#gene -> String - - === DEFINITION - - --- Bio::KEGG::GENES#definition -> String - --- Bio::KEGG::GENES#eclinks -> Array - --- Bio::KEGG::GENES#splinks -> Array - - === CLASS - - --- Bio::KEGG::GENES#keggclass -> String - --- Bio::KEGG::GENES#pathways -> Array - - === POSITION - - --- Bio::KEGG::GENES#position -> String - - === DBLINKS - - --- Bio::KEGG::GENES#dblinks -> Hash - - === CODON_USAGE - - --- Bio::KEGG::GENES#codon_usage(codon = nil) -> Array or Fixnum - --- Bio::KEGG::GENES#cu -> Hash - - === AASEQ - --- Bio::KEGG::GENES#aaseq -> Bio::Sequence::AA - --- Bio::KEGG::GENES#aalen -> Fixnum - - === NTSEQ - --- Bio::KEGG::GENES#ntseq -> Bio::Sequence::NA - --- Bio::KEGG::GENES#naseq -> Bio::Sequence::NA - --- Bio::KEGG::GENES#ntlen -> Fixnum - --- Bio::KEGG::GENES#nalen -> Fixnum - - =end --- 1,259 ---- # ! # = bio/db/kegg/genes.rb - KEGG/GENES database class # ! # Copyright:: Copyright (C) 2001, 2002, 2006 ! # Toshiaki Katayama ! # License:: Ruby's # ! # $Id$ # # ! # == KEGG GENES parser # ! # See http://www.genome.jp/kegg/genes.html # ! # ! # === Examples ! # ! # require 'bio/io/fetch' ! # entry_string = Bio::Fetch.query('genes', 'b0002') ! # ! # entry = Bio::KEGG::GENES.new(entry_string) ! # ! # # ENTRY ! # p entry.entry # => Hash ! # ! # p entry.entry_id # => String ! # p entry.division # => String ! # p entry.organism # => String ! # ! # # NAME ! # p entry.name # => String ! # p entry.genes # => Array ! # p entry.gene # => String ! # ! # # DEFINITION ! # p entry.definition # => String ! # p entry.eclinks # => Array ! # ! # # PATHWAY ! # p entry.pathway # => String ! # p entry.pathways # => Array ! # ! # # POSITION ! # p entry.position # => String ! # p entry.chromosome # => String ! # p entry.gbposition # => String ! # p entry.locations # => Bio::Locations ! # ! # # MOTIF ! # p entry.motif # => Hash of Array ! # ! # # DBLINKS ! # p entry.dblinks # => Hash of Array ! # ! # # CODON_USAGE ! # p entry.codon_usage # => Hash ! # p entry.cu_list # => Array ! # ! # # AASEQ ! # p entry.aaseq # => Bio::Sequence::AA ! # p entry.aalen # => Fixnum ! # ! # # NTSEQ ! # p entry.ntseq # => Bio::Sequence::NA ! # p entry.naseq # => Bio::Sequence::NA ! # p entry.ntlen # => Fixnum ! # p entry.nalen # => Fixnum ! # module Bio ! autoload :KEGGDB, 'bio/db' ! autoload :Locations, 'bio/location' ! autoload :Sequence, 'bio/sequence' ! class KEGG ! class GENES < KEGGDB + DELIMITER = RS = "\n///\n" + TAGSIZE = 12 ! def initialize(entry) ! super(entry, TAGSIZE) ! end ! def entry ! unless @data['ENTRY'] ! hash = Hash.new('') ! if get('ENTRY').length > 30 ! e = get('ENTRY') ! hash['id'] = e[12..29].strip ! hash['division'] = e[30..39].strip ! hash['organism'] = e[40..80].strip end + @data['ENTRY'] = hash + end + @data['ENTRY'] + end ! def entry_id ! entry['id'] ! end ! def division ! entry['division'] # CDS, tRNA etc. ! end ! def organism ! entry['organism'] # H.sapiens etc. ! end ! def name ! field_fetch('NAME') ! end ! def genes ! name.split(', ') ! end ! def gene ! genes.first ! end ! def definition ! field_fetch('DEFINITION') ! end ! def eclinks ! ec_list = definition.slice(/\[EC:(.*?)\]/, 1) ! if ec_list ! ec_list.strip.split(/\s+/) ! else ! [] ! end ! end ! def pathway ! field_fetch('PATHWAY') ! end ! def pathways ! pathway.scan(/\[PATH:(.*?)\]/).flatten ! end ! def position ! unless @data['POSITION'] ! @data['POSITION'] = fetch('POSITION').gsub(/\s/, '') ! end ! @data['POSITION'] ! end ! def chromosome ! if position[/:/] ! position.sub(/:.*/, '') ! elsif ! position[/\.\./] ! position ! else ! nil ! end ! end ! def gbposition ! position.sub(/.*?:/, '') ! end ! def locations ! Bio::Locations.new(gbposition) ! end ! def motif ! unless @data['MOTIF'] ! hash = {} ! db = nil ! lines_fetch('MOTIF').each do |line| ! if line[/^\S+:/] ! db, str = line.split(/:/) else ! str = line end ! hash[db] ||= [] ! hash[db] += str.strip.split(/\s+/) end + @data['MOTIF'] = hash + end + @data['MOTIF'] # Hash of Array of IDs in MOTIF + end ! def dblinks ! unless @data['DBLINKS'] ! hash = {} ! get('DBLINKS').scan(/(\S+):\s*(.*)\n?/).each do |db, str| ! id_array = str.strip.split(/\s+/) ! hash[db] = id_array end + @data['DBLINKS'] = hash + end + @data['DBLINKS'] # Hash of Array of IDs in DBLINKS + end ! def codon_usage(codon = nil) ! unless @data['CODON_USAGE'] ! hash = Hash.new ! list = cu_list ! base = %w(t c a g) ! base.each_with_index do |x, i| ! base.each_with_index do |y, j| ! base.each_with_index do |z, k| ! hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k] ! end end end ! @data['CODON_USAGE'] = hash ! end ! @data['CODON_USAGE'] ! end ! def cu_list ! ary = [] ! get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line ! line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu| ! ary.push(cu.to_i) end end ! return ary end ! def aaseq ! unless @data['AASEQ'] ! @data['AASEQ'] = Bio::Sequence::AA.new(fetch('AASEQ').gsub(/\d+/, '')) ! end ! @data['AASEQ'] ! end ! def aalen ! fetch('AASEQ')[/\d+/].to_i ! end ! def ntseq ! unless @data['NTSEQ'] ! @data['NTSEQ'] = Bio::Sequence::NA.new(fetch('NTSEQ').gsub(/\d+/, '')) ! end ! @data['NTSEQ'] ! end ! alias naseq ntseq ! def ntlen ! fetch('NTSEQ')[/\d+/].to_i ! end ! alias nalen ntlen end + end # KEGG + end # Bio From k at dev.open-bio.org Tue Jul 25 19:17:41 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:17:41 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/db/kegg kgml.rb,1.3,1.4 Message-ID: <200607251917.k6PJHfOP028056@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg In directory dev.open-bio.org:/tmp/cvs-serv28050/lib/bio/db/kegg Modified Files: kgml.rb Log Message: * please note that the method names of some accessors are changed! * bug fixed * @dom is obsoleted Note: # === Incompatible attribute names with KGML tags # # # :id -> :entry_id # :type -> :entry_type # names() # # :name -> :label # :type -> :shape # # :entry1 -> :node1 # :entry2 -> :node2 # :type -> :rel # # edge() # # :name -> :entry_id # :type -> :direction Index: kgml.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/kgml.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** kgml.rb 8 May 2006 14:25:25 -0000 1.3 --- kgml.rb 25 Jul 2006 19:17:39 -0000 1.4 *************** *** 12,18 **** # See http://www.genome.jp/kegg/xml/ for more details on KGML. # # === Examples # ! # file = ARGF.read # kgml = Bio::KEGG::KGML.new(file) # --- 12,37 ---- # See http://www.genome.jp/kegg/xml/ for more details on KGML. # + # === Incompatible attribute names with KGML tags + # + # + # :id -> :entry_id + # :type -> :entry_type + # names() + # + # :name -> :label + # :type -> :shape + # + # :entry1 -> :node1 + # :entry2 -> :node2 + # :type -> :rel + # + # edge() + # + # :name -> :entry_id + # :type -> :direction + # # === Examples # ! # file = ARGF.read("kgml/hsa/hsa00010.xml") # kgml = Bio::KEGG::KGML.new(file) # *************** *** 27,82 **** # kgml.entries.each do |entry| # # attributes ! # puts entry.id # puts entry.name ! # puts entry.names ! # puts entry.type # puts entry.link # puts entry.reaction # puts entry.map # # attributes ! # puts entry.label # This is an accessor for # puts entry.x # puts entry.y - # puts entry.type # puts entry.width # puts entry.height # puts entry.fgcolor # puts entry.bgcolor # end # # kgml.relations.each do |relation| # # attributes ! # puts relation.entry1 ! # puts relation.entry2 ! # puts relation.type # # attributes # puts relation.name # puts relation.value - # # or - # relation.subtype.each do |value, name| - # puts value, name - # end # end # # kgml.reactions.each do |reaction| # # attributes ! # puts reaction.name ! # puts reaction.type # # attributes ! # reaction.substrates.each do |name| ! # puts name # # attributes ! # altnames = reaction.alt[name] ! # altnames.each do |altname| ! # puts altname # end # end # # attributes ! # reaction.products.each do |name| ! # puts name # # attributes ! # altnames = reaction.alt[name] ! # altnames.each do |altname| ! # puts altname # end # end --- 46,100 ---- # kgml.entries.each do |entry| # # attributes ! # puts entry.entry_id # puts entry.name ! # puts entry.entry_type # puts entry.link # puts entry.reaction # puts entry.map # # attributes ! # puts entry.label # name ! # puts entry.shape # type # puts entry.x # puts entry.y # puts entry.width # puts entry.height # puts entry.fgcolor # puts entry.bgcolor + # # methood + # puts entry.names # end # # kgml.relations.each do |relation| # # attributes ! # puts relation.node1 # entry1 ! # puts relation.node2 # entry2 ! # puts relation.rel # type ! # # method ! # puts relation.edge # # attributes # puts relation.name # puts relation.value # end # # kgml.reactions.each do |reaction| # # attributes ! # puts reaction.entry_id # name ! # puts reaction.direction # type # # attributes ! # reaction.substrates.each do |entry_id| ! # puts entry_id # # attributes ! # altnames = reaction.alt[entry_id] ! # altnames.each do |name| ! # puts name # end # end # # attributes ! # reaction.products.each do |entry_id| ! # puts entry_id # # attributes ! # altnames = reaction.alt[entry_id] ! # altnames.each do |name| ! # puts name # end # end *************** *** 84,88 **** # ! require 'rexml/document' module Bio --- 102,106 ---- # ! autoload :REXML, 'rexml/document' module Bio *************** *** 92,123 **** def initialize(xml) ! @dom = REXML::Document.new(xml) ! parse_root ! parse_entry ! parse_relation ! parse_reaction end attr_reader :name, :org, :number, :title, :image, :link ! attr_reader :entries, :relations, :reactions # Array class Entry ! attr_accessor :id, :name, :names, :type, :link, :reaction, :map ! attr_accessor :label, :x, :y, :type, :width, :height, :fgcolor, :bgcolor end class Relation ! attr_accessor :entry1, :entry2, :type attr_accessor :name, :value ! attr_accessor :subtype # Hash end class Reaction ! attr_accessor :name, :type ! attr_accessor :substrates, :products # Array ! attr_accessor :alt # Hash end ! def parse_root ! root = @dom.root.attributes @name = root["name"] @org = root["org"] --- 110,148 ---- def initialize(xml) ! dom = REXML::Document.new(xml) ! parse_root(dom) ! parse_entry(dom) ! parse_relation(dom) ! parse_reaction(dom) end attr_reader :name, :org, :number, :title, :image, :link ! attr_accessor :entries, :relations, :reactions class Entry ! attr_accessor :entry_id, :name, :entry_type, :link, :reaction, :map ! attr_accessor :label, :shape, :x, :y, :width, :height, :fgcolor, :bgcolor ! def names ! @name.split(/\s+/) ! end end class Relation ! attr_accessor :node1, :node2, :rel attr_accessor :name, :value ! def edge ! @value.to_i ! end end class Reaction ! attr_accessor :entry_id, :direction ! attr_accessor :substrates, :products # Array ! attr_accessor :alt # Hash end ! private ! ! def parse_root(dom) ! root = dom.root.attributes @name = root["name"] @org = root["org"] *************** *** 128,155 **** end ! def parse_entry @entries = Array.new ! @dom.elements.each("/pathway/entry") { |node| attr = node.attributes entry = Entry.new ! entry.id = attr["id"].to_i ! entry.map = attr["map"] ! entry.name = attr["name"] ! entry.names = entry.name.split(/\s+/) ! entry.type = attr["type"] ! entry.link = attr["link"] ! entry.reaction = attr["reaction"] node.elements.each("graphics") { |graphics| attr = graphics.attributes ! entry.x = attr["x"].to_i ! entry.y = attr["y"].to_i ! entry.type = attr["type"] ! entry.label = attr["label"] # name ! entry.width = attr["width"].to_i ! entry.height = attr["height"].to_i ! entry.fgcolor = attr["fgcolor"] ! entry.bgcolor = attr["bgcolor"] } @entries << entry --- 153,180 ---- end ! def parse_entry(dom) @entries = Array.new ! dom.elements.each("/pathway/entry") { |node| attr = node.attributes entry = Entry.new ! entry.entry_id = attr["id"].to_i ! entry.name = attr["name"] ! entry.entry_type = attr["type"] ! # implied ! entry.link = attr["link"] ! entry.reaction = attr["reaction"] ! entry.map = attr["map"] node.elements.each("graphics") { |graphics| attr = graphics.attributes ! entry.x = attr["x"].to_i ! entry.y = attr["y"].to_i ! entry.shape = attr["type"] ! entry.label = attr["name"] ! entry.width = attr["width"].to_i ! entry.height = attr["height"].to_i ! entry.fgcolor = attr["fgcolor"] ! entry.bgcolor = attr["bgcolor"] } @entries << entry *************** *** 157,194 **** end ! def parse_relation @relations = Array.new ! @dom.elements.each("/pathway/relation") { |node| attr = node.attributes relation = Relation.new ! relation.entry1 = attr["entry1"].to_i ! relation.entry2 = attr["entry2"].to_i ! relation.type = attr["type"] - hash = Hash.new node.elements.each("subtype") { |subtype| attr = subtype.attributes ! relation.name = name = attr["name"] ! relation.value = value = attr["value"].to_i ! hash[value] = name } - relation.subtype = hash @relations << relation } end ! def parse_reaction @reactions = Array.new ! @dom.elements.each("/pathway/reaction") { |node| attr = node.attributes reaction = Reaction.new ! reaction.name = attr["name"] ! reaction.type = attr["type"] substrates = Array.new products = Array.new ! hash = Hash.new node.elements.each("substrate") { |substrate| --- 182,216 ---- end ! def parse_relation(dom) @relations = Array.new ! dom.elements.each("/pathway/relation") { |node| attr = node.attributes relation = Relation.new ! relation.node1 = attr["entry1"].to_i ! relation.node2 = attr["entry2"].to_i ! relation.rel = attr["type"] node.elements.each("subtype") { |subtype| attr = subtype.attributes ! relation.name = attr["name"] ! relation.value = attr["value"] } @relations << relation } end ! def parse_reaction(dom) @reactions = Array.new ! dom.elements.each("/pathway/reaction") { |node| attr = node.attributes reaction = Reaction.new ! reaction.entry_id = attr["name"] ! reaction.direction = attr["type"] substrates = Array.new products = Array.new ! hash = Hash.new node.elements.each("substrate") { |substrate| *************** *** 208,215 **** } } - reaction.substrates = substrates ! reaction.products = products ! reaction.alt = hash @reactions << reaction --- 230,236 ---- } } reaction.substrates = substrates ! reaction.products = products ! reaction.alt = hash @reactions << reaction *************** *** 218,281 **** end # KGML end # KEGG end # Bio - if __FILE__ == $0 - require 'pp' - xml = ARGF.read - pp Bio::KEGG::KGML.new(xml) - end - - - =begin - - # This is a test implementation which reflects original KGML data structure. - - class KGML - - class Pathway - attr_accessor :name, :org, :number, :title, :image, :link - attr_accessor :entries, :relations, :reactions - - class Entry - attr_accessor :id, :name, :type, :link, :reaction, :map - attr_accessor :components, :graphics - - class Component - attr_accessor :id - end - - class Graphics - attr_accessor :name, :x, :y, :type, :width, :height, :fgcolor, :bgcolor - end - end - - class Relation - attr_accessor :entry1, :entry2, :type - attr_accessor : - - class Subtype - attr_accessor :name, :value - end - end - - class Reaction - attr_accessor :name, :type - - class Substrate - attr_accessor :name - end - - class Product - attr_accessor :name - end - - class Alt - attr_accessor :name - end - end - end - - end - =end --- 239,245 ---- end # KGML + end # KEGG end # Bio From k at dev.open-bio.org Tue Jul 25 19:46:45 2006 From: k at dev.open-bio.org (Katayama Toshiaki) Date: Tue, 25 Jul 2006 19:46:45 +0000 Subject: [BioRuby-cvs] bioruby/lib/bio/io das.rb,1.12,1.13 Message-ID: <200607251946.k6PJkjKY028173@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/lib/bio/io In directory dev.open-bio.org:/tmp/cvs-serv28169/lib/bio/io Modified Files: das.rb Log Message: * bug fixed that segment.stop was overwritten by segment.orientation Index: das.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/lib/bio/io/das.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** das.rb 8 May 2006 14:31:58 -0000 1.12 --- das.rb 25 Jul 2006 19:46:43 -0000 1.13 *************** *** 64,71 **** # Returns Bio::DAS::ENTRY_POINT. # The 'dsn' can be a String or a Bio::DAS::DSN object. ! def get_entry_point(dsn) entry_point = ENTRY_POINT.new ! dsn = dsn.source if dsn.instance_of?(Bio::DAS::DSN) ! result, = @server.get(@prefix + '/das/' + dsn + '/entry_points') doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| --- 64,75 ---- # Returns Bio::DAS::ENTRY_POINT. # The 'dsn' can be a String or a Bio::DAS::DSN object. ! def get_entry_points(dsn) entry_point = ENTRY_POINT.new ! if dsn.instance_of?(Bio::DAS::DSN) ! src = dsn.source ! else ! src = dsn ! end ! result, = @server.get(@prefix + '/das/' + src + '/entry_points') doc = REXML::Document.new(result.body) doc.elements.each('/descendant::ENTRY_POINTS') do |e| *************** *** 77,81 **** segment.start = e.attributes['start'] segment.stop = e.attributes['stop'] ! segment.stop = e.attributes['orientation'] segment.subparts = e.attributes['subparts'] segment.description = e.text --- 81,85 ---- segment.start = e.attributes['start'] segment.stop = e.attributes['stop'] ! segment.orientation = e.attributes['orientation'] segment.subparts = e.attributes['subparts'] segment.description = e.text From nakao at dev.open-bio.org Wed Jul 26 08:15:30 2006 From: nakao at dev.open-bio.org (Mitsuteru C. Nakao) Date: Wed, 26 Jul 2006 08:15:30 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio/db test_prosite.rb,1.3,1.4 Message-ID: <200607260815.k6Q8FUSd030540@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio/db In directory dev.open-bio.org:/tmp/cvs-serv30520/test/unit/bio/db Modified Files: test_prosite.rb Log Message: * Fixed the regular expressions for test_pa2re methods. Index: test_prosite.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/db/test_prosite.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_prosite.rb 18 Dec 2005 18:21:58 -0000 1.3 --- test_prosite.rb 26 Jul 2006 08:15:28 -0000 1.4 *************** *** 1439,1448 **** def test_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/, @obj.pa2re(pa)) end def test_self_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/, Bio::PROSITE.pa2re(pa)) end --- 1439,1448 ---- def test_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/i, @obj.pa2re(pa)) end def test_self_pa2re pa = '[AC]-x-V-x(4)-{ED}.' ! assert_equal(/[AC].V.{4}[^ED]/i, Bio::PROSITE.pa2re(pa)) end From ngoto at dev.open-bio.org Thu Jul 27 03:50:38 2006 From: ngoto at dev.open-bio.org (Naohisa Goto) Date: Thu, 27 Jul 2006 03:50:38 +0000 Subject: [BioRuby-cvs] bioruby/test/unit/bio test_command.rb,1.2,1.3 Message-ID: <200607270350.k6R3ocGL000508@dev.open-bio.org> Update of /home/repository/bioruby/bioruby/test/unit/bio In directory dev.open-bio.org:/tmp/cvs-serv488/test/unit/bio Modified Files: test_command.rb Log Message: removed forgotten debug code Index: test_command.rb =================================================================== RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_command.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_command.rb 14 Jul 2006 14:23:48 -0000 1.2 --- test_command.rb 27 Jul 2006 03:50:36 -0000 1.3 *************** *** 96,100 **** def test_call_command - p $0 end --- 96,99 ----