[BioRuby-cvs] bioruby/lib/bio/appl emboss.rb,1.8,1.9

Naohisa Goto ngoto at dev.open-bio.org
Thu Jan 10 03:51:12 UTC 2008


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

Modified Files:
	emboss.rb 
Log Message:
Added a method Bio::EMBOSS.run(program, arguments...)
and Bio::EMBOSS.new is obsoleted.


Index: emboss.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** emboss.rb	5 Apr 2007 23:35:39 -0000	1.8
--- emboss.rb	10 Jan 2008 03:51:06 -0000	1.9
***************
*** 36,51 ****
  #  # Suppose that you could get the sequence for XLRHODOP by running
  #  # the EMBOSS command +seqret embl:xlrhodop+ on the command line.
! #  # Then you can get the output of that command in a Bio::EMBOSS object
! #  # by creating a new Bio::EMBOSS object and subsequently executing it.
! #  xlrhodop = Bio::EMBOSS.new('seqret embl:xlrhodop')
! #  puts xlrhodop.exec
  #
  #  # Or all in one go:
! #  puts Bio::EMBOSS.new('seqret embl:xlrhodop').exec
  #
  #  # Similarly:
! #  puts Bio::EMBOSS.new('transeq -sbegin 110 -send 1171 embl:xlrhodop')
! #  puts Bio::EMBOSS.new('showfeat embl:xlrhodop').exec
! #  puts Bio::EMBOSS.new('seqret embl:xlrhodop -osformat acedb').exec
  #
  #  # A shortcut exists for this two-step process for +seqret+ and +entret+.
--- 36,52 ----
  #  # Suppose that you could get the sequence for XLRHODOP by running
  #  # the EMBOSS command +seqret embl:xlrhodop+ on the command line.
! #  # Then you can get the output of that command in a String object
! #  # by using  Bio::EMBOSS.run method.
! #  xlrhodop = Bio::EMBOSS.run('seqret', 'embl:xlrhodop')
! #  puts xlrhodop
  #
  #  # Or all in one go:
! #  puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop')
  #
  #  # Similarly:
! #  puts Bio::EMBOSS.run('transeq', '-sbegin', '110','-send', '1171',
! #                       'embl:xlrhodop')
! #  puts Bio::EMBOSS.run('showfeat', 'embl:xlrhodop')
! #  puts Bio::EMBOSS.run('seqret', 'embl:xlrhodop', '-osformat', 'acedb')
  #
  #  # A shortcut exists for this two-step process for +seqret+ and +entret+.
***************
*** 53,56 ****
--- 54,68 ----
  #  puts Bio::EMBOSS.entret('embl:xlrhodop')
  #
+ #  # You can use %w() syntax.
+ #  puts Bio::EMBOSS.run(*%w( transeq -sbegin 110 -send 1171 embl:xlrhodop ))
+ #
+ #  # You can also use Shellwords.shellwords.
+ #  require 'shellwords'
+ #  str = 'transeq -sbegin 110 -send 1171 embl:xlrhodop'
+ #  cmd = Shellwords.shellwords(str)
+ #  puts Bio::EMBOSS.run(*cmd)
+ #
+ 
+ #
  # == Pre-requisites
  #
***************
*** 77,82 ****
    # ---
    # *Arguments*:
!   # * (required) _command_: emboss command
!   # *Returns*:: Bio::EMBOSS object
    def self.seqret(arg)
      str = self.retrieve('seqret', arg)
--- 89,94 ----
    # ---
    # *Arguments*:
!   # * (required) _arg_: argument given to the emboss seqret command
!   # *Returns*:: String
    def self.seqret(arg)
      str = self.retrieve('seqret', arg)
***************
*** 93,102 ****
    # ---
    # *Arguments*:
!   # * (required) _command_: emboss command
!   # *Returns*:: Bio::EMBOSS object
    def self.entret(arg)
      str = self.retrieve('entret', arg)
    end
  
    # Initializes a new Bio::EMBOSS object. This provides a holder that can
    # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_
--- 105,118 ----
    # ---
    # *Arguments*:
!   # * (required) _arg_: argument given to the emboss entret command
!   # *Returns*:: String
    def self.entret(arg)
      str = self.retrieve('entret', arg)
    end
  
+   # WARNING: Bio::EMBOSS.new will be changed in the future because
+   # Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole.
+   # Using Bio::EMBOSS.run(program, options...) is strongly recommended.
+   #
    # Initializes a new Bio::EMBOSS object. This provides a holder that can
    # subsequently be executed (see Bio::EMBOSS.exec). The object does _not_
***************
*** 115,118 ****
--- 131,135 ----
    # *Returns*:: Bio::EMBOSS object
    def initialize(cmd_line)
+     warn 'Bio::EMBOSS.new(cmd_line) is inconvenient and potential security hole. Using Bio::EMBOSS.run(program, options...) is strongly recommended.'
      @cmd_line = cmd_line + ' -stdout -auto'
    end
***************
*** 143,146 ****
--- 160,195 ----
    attr_reader :result
  
+   # Runs an emboss program and get the result as string.
+   # Note that "-auto -stdout" are automatically added to the options.
+   #
+   # Example 1:
+   #
+   #   result = Bio::EMBOSS.run('seqret', 'embl:xlrhodop')
+   #
+   # Example 2:
+   #
+   #   result = Bio::EMBOSS.run('water',
+   #                             '-asequence', 'swissprot:slpi_human',
+   #                             '-bsequence', 'swissprot:slpi_mouse')
+   #
+   # Example 3:
+   #   options = %w( -asequence swissprot:slpi_human
+   #                 -bsequence swissprot:slpi_mouse )
+   #   result = Bio::EMBOSS.run('needle', *options)
+   #
+   # For an overview of commands that can be used with this method, see the
+   # emboss website.
+   # ---
+   # *Arguments*:
+   # * (required) _program_: command name, or filename of an emboss program
+   # * _options_: options given to the emboss program
+   # *Returns*:: String
+   def self.run(program, *options)
+     cmd = [ program, *options ]
+     cmd.push '-auto'
+     cmd.push '-stdout'
+     return Bio::Command.query_command(cmd)
+   end
+ 
    private
  




More information about the bioruby-cvs mailing list