[BioRuby-cvs] bioruby/lib/bio/appl clustalw.rb, 1.11, 1.12 mafft.rb, 1.11, 1.12 sim4.rb, 1.6, 1.7

Naohisa Goto ngoto at dev.open-bio.org
Thu Dec 14 14:54:53 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/appl
In directory dev.open-bio.org:/tmp/cvs-serv13473/lib/bio/appl

Modified Files:
	clustalw.rb mafft.rb sim4.rb 
Log Message:
Changed to use Bio::Command in bio/command.rb instead of Open3.popen3.
Bio::(ClustalW|MAFFT|Sim4)#option is changed to #options.
Bio::ClustalW::errorlog and Bio::(MAFFT|Sim4)#log are deprecated and
there are no replacements for the methods.


Index: sim4.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/sim4.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** sim4.rb	30 Apr 2006 05:50:19 -0000	1.6
--- sim4.rb	14 Dec 2006 14:54:50 -0000	1.7
***************
*** 16,21 ****
  #
  
- require 'open3'
  require 'tempfile'
  
  module Bio
--- 16,21 ----
  #
  
  require 'tempfile'
+ require 'bio/command'
  
  module Bio
***************
*** 30,41 ****
      # [+database+] Default file name of database('seq2').
      # [+option+]   Options (array of strings).
!     def initialize(program = 'sim4', database = nil, option = [])
        @program = program
!       @option = option
        @database = database #seq2
        @command = nil
        @output = nil
        @report = nil
-       @log = nil
      end
  
--- 30,40 ----
      # [+database+] Default file name of database('seq2').
      # [+option+]   Options (array of strings).
!     def initialize(program = 'sim4', database = nil, opt = [])
        @program = program
!       @options = opt
        @database = database #seq2
        @command = nil
        @output = nil
        @report = nil
      end
  
***************
*** 47,57 ****
  
      # options
!     attr_reader :option
  
      # last command-line strings executed by the object
      attr_reader :command
  
      # last messages of program reported to the STDERR
!     attr_reader :log
  
      # last result text (String)
--- 46,70 ----
  
      # options
!     attr_accessor :options
! 
!     # option is deprecated. Instead, please use options.
!     def option
!       warn "option is deprecated. Please use options."
!       options
!     end
  
      # last command-line strings executed by the object
      attr_reader :command
  
+     #---
      # last messages of program reported to the STDERR
!     #attr_reader :log
!     #+++
! 
!     #log is deprecated (no replacement) and returns empty string.
!     def log
!       warn "log is deprecated (no replacement) and returns empty string."
!       ''
!     end
  
      # last result text (String)
***************
*** 97,112 ****
        @command = [ @program, filename1, (filename2 or @database), *@option ]
        @output = nil
-       @log = nil
        @report = nil
!       Open3.popen3(*@command) do |din, dout, derr|
!         din.close
!         derr.sync = true
!         t = Thread.start { @log = derr.read }
!         begin
!           @output = dout.read
!           @report = Bio::Sim4::Report.new(@output)
!         ensure
!           t.join
!         end
        end
        @report
--- 110,118 ----
        @command = [ @program, filename1, (filename2 or @database), *@option ]
        @output = nil
        @report = nil
!       Bio::Command.call_command(*@command) do |io|
!         io.close_write
!         @output = io.read
!         @report = Bio::Sim4::Report.new(@output)
        end
        @report

Index: clustalw.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** clustalw.rb	30 Apr 2006 05:50:19 -0000	1.11
--- clustalw.rb	14 Dec 2006 14:54:50 -0000	1.12
***************
*** 24,29 ****
  
  require 'tempfile'
- require 'open3'
  
  require 'bio/sequence'
  require 'bio/alignment'
--- 24,29 ----
  
  require 'tempfile'
  
+ require 'bio/command'
  require 'bio/sequence'
  require 'bio/alignment'
***************
*** 39,45 ****
  
      # Creates a new CLUSTAL W execution wrapper object (alignment factory).
!     def initialize(program = 'clustalw', option = [])
        @program = program
!       @option = option
        @command = nil
        @output = nil
--- 39,45 ----
  
      # Creates a new CLUSTAL W execution wrapper object (alignment factory).
!     def initialize(program = 'clustalw', opt = [])
        @program = program
!       @options = opt
        @command = nil
        @output = nil
***************
*** 52,56 ****
  
      # options
!     attr_accessor :option
  
      # Returns last command-line strings executed by this factory.
--- 52,62 ----
  
      # options
!     attr_accessor :options
! 
!     # option is deprecated. Instead, please use options.
!     def option
!       warn "option is deprecated. Please use options."
!       options
!     end
  
      # Returns last command-line strings executed by this factory.
***************
*** 144,149 ****
      attr_reader :output_dnd
  
      # Returns last error messages (to stderr) of CLUSTAL W execution.
!     attr_reader :errorlog
  
      private
--- 150,162 ----
      attr_reader :output_dnd
  
+     #---
      # Returns last error messages (to stderr) of CLUSTAL W execution.
!     #attr_reader :errorlog
!     #+++
!     #errorlog is deprecated (no replacement) and returns empty string.
!     def errorlog
!       warn "errorlog is deprecated (no replacement) and returns empty string."
!       ''
!     end
  
      private
***************
*** 154,170 ****
        @log = nil
  
!       Open3.popen3(*@command) do |din, dout, derr|
!         din.close
!         t = Thread.start do
!           @errorlog = derr.read
!         end
          @log = dout.read
          t.join
        end
- #      @command_string = @command.join(" ")
- #      IO.popen(@command, "r") do |io|
- #	io.sync = true
- #	@log = io.read
- #      end
        @log
      end
--- 167,175 ----
        @log = nil
  
!       Bio::Command.call_command(*@command) do |io|
!         io.close_write
          @log = dout.read
          t.join
        end
        @log
      end

Index: mafft.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** mafft.rb	25 Sep 2006 08:09:22 -0000	1.11
--- mafft.rb	14 Dec 2006 14:54:50 -0000	1.12
***************
*** 24,36 ****
  #
  
  require 'bio/db/fasta'
  require 'bio/io/flatfile'
  
- #--
- # We use Open3.popen3, because MAFFT on win32 requires Cygwin.
- #++
- require 'open3'
- require 'tempfile'
- 
  module Bio
  
--- 24,34 ----
  #
  
+ require 'tempfile'
+ 
+ require 'bio/command'
+ 
  require 'bio/db/fasta'
  require 'bio/io/flatfile'
  
  module Bio
  
***************
*** 108,118 ****
      # +program+ is the name of the program.
      # +opt+ is options of the program.
!     def initialize(program, option)
        @program = program
!       @option = option
        @command = nil
        @output = nil
        @report = nil
-       @log = nil
      end
  
--- 106,115 ----
      # +program+ is the name of the program.
      # +opt+ is options of the program.
!     def initialize(program, opt)
        @program = program
!       @options = opt
        @command = nil
        @output = nil
        @report = nil
      end
  
***************
*** 121,125 ****
  
      # options
!     attr_accessor :option
  
      # Shows last command-line string. Returns nil or an array of String.
--- 118,128 ----
  
      # options
!     attr_accessor :options
! 
!     # option is deprecated. Instead, please use options.
!     def option
!       warn "option is deprecated. Please use options."
!       options
!     end
  
      # Shows last command-line string. Returns nil or an array of String.
***************
*** 128,133 ****
      attr_reader :command
  
      # last message to STDERR when executing the program.
!     attr_reader :log
  
      # Shows latest raw alignment result.
--- 131,144 ----
      attr_reader :command
  
+     #---
      # last message to STDERR when executing the program.
!     #attr_reader :log
!     #+++
! 
!     #log is deprecated (no replacement) and returns empty string.
!     def log
!       warn "log is deprecated (no replacement) and returns empty string."
!       ''
!     end
  
      # Shows latest raw alignment result.
***************
*** 189,204 ****
        #STDERR.print "DEBUG: ", @command.join(" "), "\n"
        @output = nil
!       @log = nil
!       Open3.popen3(*@command) do |din, dout, derr|
!         din.close
!         derr.sync = true
!         t = Thread.start do
!           @log = derr.read
!         end
!         ff = Bio::FlatFile.new(Bio::FastaFormat, dout)
          @output = ff.to_a
-         t.join
        end
-       @log
      end
  
--- 200,208 ----
        #STDERR.print "DEBUG: ", @command.join(" "), "\n"
        @output = nil
!       Bio::Command.call_command(*@command) do |io|
!         io.close_write
!         ff = Bio::FlatFile.new(Bio::FastaFormat, io)
          @output = ff.to_a
        end
      end
  




More information about the bioruby-cvs mailing list