[BioRuby-cvs] bioruby/lib/bio/appl blast.rb, 1.21, 1.22 clustalw.rb, 1.5, 1.6 emboss.rb, 1.1, 1.2 fasta.rb, 1.17, 1.18 mafft.rb, 1.4, 1.5 psort.rb, 1.4, 1.5

Katayama Toshiaki k at pub.open-bio.org
Wed Sep 7 21:22:10 EDT 2005


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

Modified Files:
	blast.rb clustalw.rb emboss.rb fasta.rb mafft.rb psort.rb 
Log Message:
* expanded tab at the line head


Index: emboss.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/emboss.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** emboss.rb	19 Aug 2002 02:49:29 -0000	1.1
--- emboss.rb	8 Sep 2005 01:22:08 -0000	1.2
***************
*** 31,39 ****
      def exec
        begin
! 	@io = IO.popen(@cmd_line, "w+")
! 	@result = @io.read
! 	return @result
        ensure
! 	@io.close
        end
      end
--- 31,39 ----
      def exec
        begin
!         @io = IO.popen(@cmd_line, "w+")
!         @result = @io.read
!         return @result
        ensure
!         @io.close
        end
      end

Index: blast.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast.rb,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** blast.rb	16 Aug 2005 09:38:34 -0000	1.21
--- blast.rb	8 Sep 2005 01:22:08 -0000	1.22
***************
*** 36,42 ****
      def initialize(program, db, opt = [], server = 'local')
        if defined?(XMLParser) or defined?(REXML)
! 	@format = 7
        else
! 	@format	= 8
        end
  
--- 36,42 ----
      def initialize(program, db, opt = [], server = 'local')
        if defined?(XMLParser) or defined?(REXML)
!         @format = 7
        else
!         @format	= 8
        end
  
***************
*** 118,130 ****
  
        form = {
! 	'style'		=> 'raw',
! 	'prog'		=> @program,
! 	'dbname'	=> @db,
! 	'sequence'	=> CGI.escape(query),
! 	'other_param'	=> CGI.escape(make_command_line_unix(@options)),
! 	'matrix'	=> matrix,
! 	'filter'	=> filter,
! 	'V_value'	=> 500,		# default value for GenomeNet
! 	'B_value'	=> 250,		# default value for GenomeNet
          'alignment_view' => 0,
        }
--- 118,130 ----
  
        form = {
!         'style'		=> 'raw',
!         'prog'		=> @program,
!         'dbname'	=> @db,
!         'sequence'	=> CGI.escape(query),
!         'other_param'	=> CGI.escape(make_command_line_unix(@options)),
!         'matrix'	=> matrix,
!         'filter'	=> filter,
!         'V_value'	=> 500,		# default value for GenomeNet
!         'B_value'	=> 250,		# default value for GenomeNet
          'alignment_view' => 0,
        }
***************
*** 133,137 ****
  
        form.each do |k, v|
! 	data.push("#{k}=#{v}") if v
        end
  
--- 133,137 ----
  
        form.each do |k, v|
!         data.push("#{k}=#{v}") if v
        end
  
***************
*** 142,146 ****
          http.open_timeout = 300
          http.read_timeout = 600
! 	result, = http.post(path, data.join('&'))
          @output = result.body
          # workaround 2005.08.12
--- 142,146 ----
          http.open_timeout = 300
          http.read_timeout = 600
!         result, = http.post(path, data.join('&'))
          @output = result.body
          # workaround 2005.08.12

Index: clustalw.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/clustalw.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** clustalw.rb	4 Mar 2005 04:48:41 -0000	1.5
--- clustalw.rb	8 Sep 2005 01:22:08 -0000	1.6
***************
*** 45,51 ****
      def query(seqs)
        if seqs then
! 	query_align(seqs)
        else
! 	exec_local(@option)
        end
      end
--- 45,51 ----
      def query(seqs)
        if seqs then
!         query_align(seqs)
        else
!         exec_local(@option)
        end
      end
***************
*** 55,67 ****
        seqtype = nil
        unless seqs.is_a?(Bio::Alignment)
! 	seqs = Bio::Alignment.new(seqs)
        end
        seqs.each do |s|
! 	if    s.is_a?(Bio::Sequence::AA) then
! 	  seqtype = 'PROTEIN'
! 	elsif s.is_a?(Bio::Sequence::NA) then
! 	  seqtype = 'DNA'
! 	end
! 	break if seqtype
        end
        query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype)
--- 55,67 ----
        seqtype = nil
        unless seqs.is_a?(Bio::Alignment)
!         seqs = Bio::Alignment.new(seqs)
        end
        seqs.each do |s|
!         if    s.is_a?(Bio::Sequence::AA) then
!           seqtype = 'PROTEIN'
!         elsif s.is_a?(Bio::Sequence::NA) then
!           seqtype = 'DNA'
!         end
!         break if seqtype
        end
        query_string(seqs.to_fasta(70, :avoid_same_name => true), seqtype)
***************
*** 70,77 ****
      def query_string(str, *arg)
        begin
! 	tf_in = Tempfile.open('align')
! 	tf_in.print str
        ensure
! 	tf_in.close(false)
        end
        r = query_by_filename(tf_in.path, *arg)
--- 70,77 ----
      def query_string(str, *arg)
        begin
!         tf_in = Tempfile.open('align')
!         tf_in.print str
        ensure
!         tf_in.close(false)
        end
        r = query_by_filename(tf_in.path, *arg)
***************
*** 89,96 ****
  
        opt = [ "-align",
! 	"-infile=#{path}",
! 	"-outfile=#{tf_out.path}",
! 	"-newtree=#{tf_dnd.path}",
! 	"-outorder=input"
        ]
        opt << "-type=#{seqtype}" if seqtype
--- 89,96 ----
  
        opt = [ "-align",
!         "-infile=#{path}",
!         "-outfile=#{tf_out.path}",
!         "-newtree=#{tf_dnd.path}",
!         "-outorder=input"
        ]
        opt << "-type=#{seqtype}" if seqtype
***************
*** 117,125 ****
        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(" ")
--- 117,125 ----
        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(" ")

Index: psort.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/psort.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** psort.rb	21 Jul 2004 03:12:02 -0000	1.4
--- psort.rb	8 Sep 2005 01:22:08 -0000	1.5
***************
*** 40,47 ****
        'Okazaki' => {'host' => 'psort.nibb.ac.jp', 
   	            'PSORT1' => '/cgi-bin/okumura.pl',
! 	            'PSORT2' => '/cgi-bin/runpsort.pl'},
        'Peking'  => {'host' => 'srs.pku.edu.en:8088', 
   	            'PSORT1' => '/cgi-bin/okumura.pl',
! 	            'PSORT2' => '/cgi-bin/runpsort.pl'}
      }
  
--- 40,47 ----
        'Okazaki' => {'host' => 'psort.nibb.ac.jp', 
   	            'PSORT1' => '/cgi-bin/okumura.pl',
!                     'PSORT2' => '/cgi-bin/runpsort.pl'},
        'Peking'  => {'host' => 'srs.pku.edu.en:8088', 
   	            'PSORT1' => '/cgi-bin/okumura.pl',
!                     'PSORT2' => '/cgi-bin/runpsort.pl'}
      }
  
***************
*** 53,60 ****
      class CGIDriver
        def initialize(host = '', path = '') 
! 	@host = host
! 	@path = path
! 	@args = {}
! 	@report
        end
        attr_accessor :args
--- 53,60 ----
      class CGIDriver
        def initialize(host = '', path = '') 
!         @host = host
!         @path = path
!         @args = {}
!         @report
        end
        attr_accessor :args
***************
*** 64,76 ****
        # CGIDriver#exec(query) -> aReport
        def exec(query)
! 	data = make_args(query)  
  
! 	begin
! 	  result, = Net::HTTP.new(@host).post(@path, data)
! 	  @report = result.body
! 	  output = parse_report(@report)
! 	end
  
! 	return output
        end
  
--- 64,76 ----
        # CGIDriver#exec(query) -> aReport
        def exec(query)
!         data = make_args(query)  
  
!         begin
!           result, = Net::HTTP.new(@host).post(@path, data)
!           @report = result.body
!           output = parse_report(@report)
!         end
  
!         return output
        end
  
***************
*** 79,87 ****
  
        def make_args(args_hash)
! 	# The routin should be provided in the inherited class
        end
  
        def parse_report(result_body)
! 	# The routin should be provided in the inherited class	
        end
  
--- 79,87 ----
  
        def make_args(args_hash)
!         # The routin should be provided in the inherited class
        end
  
        def parse_report(result_body)
!         # The routin should be provided in the inherited class	
        end
  
***************
*** 89,101 ****
  
        def erase_html_tags(str)
! 	return str.gsub(/<\S.*?>/,'')	
        end
  
        def args_join(hash, delim = '&')
! 	tmp = []
! 	hash.each do |key, val|
! 	  tmp << CGI.escape(key.to_s) + '=' + CGI.escape(val.to_s)
! 	end
! 	return tmp.join(delim)  # not ';' but '&' in psort's cgi
        end
  
--- 89,101 ----
  
        def erase_html_tags(str)
!         return str.gsub(/<\S.*?>/,'')	
        end
  
        def args_join(hash, delim = '&')
!         tmp = []
!         hash.each do |key, val|
!           tmp << CGI.escape(key.to_s) + '=' + CGI.escape(val.to_s)
!         end
!         return tmp.join(delim)  # not ';' but '&' in psort's cgi
        end
  
***************
*** 108,132 ****
  
        def self.imsut
! 	self.new(Remote.new(WWWServer['IMSUT']['host'],
! 			    WWWServer['IMSUT']['PSORT1']))
        end
  
        def self.okazaki
! 	self.new(Remote.new(WWWServer['Okazaki']['host'],
! 			    WWWServer['Okazaki']['PSORT1']))
        end
        
        def self.peking
! 	self.new(Remote.new(WWWServer['Peking']['host'],
! 			    WWWServer['Peking']['PSORT1']))
        end
  
        #
        def initialize(serv)
! 	@serv = serv
! 	@origin   = 'yeast' # Gram-positive bacterium, Gram-negative bacterium,
! 	                    # yeast, aminal, plant
! 	@title    = 'MYSEQ'
! 	@sequence = ''
        end
        attr_accessor :origin, :sequence, :title
--- 108,132 ----
  
        def self.imsut
!         self.new(Remote.new(WWWServer['IMSUT']['host'],
!                             WWWServer['IMSUT']['PSORT1']))
        end
  
        def self.okazaki
!         self.new(Remote.new(WWWServer['Okazaki']['host'],
!                             WWWServer['Okazaki']['PSORT1']))
        end
        
        def self.peking
!         self.new(Remote.new(WWWServer['Peking']['host'],
!                             WWWServer['Peking']['PSORT1']))
        end
  
        #
        def initialize(serv)
!         @serv = serv
!         @origin   = 'yeast' # Gram-positive bacterium, Gram-negative bacterium,
!                             # yeast, aminal, plant
!         @title    = 'MYSEQ'
!         @sequence = ''
        end
        attr_accessor :origin, :sequence, :title
***************
*** 134,146 ****
        # 
        def exec(faa, parsing = true)
! 	if faa.class == Bio::FastaFormat
! 	  @title        = faa.entry_id if @title == 'MYSEQ'
! 	  @sequence     = faa.seq
! 	  @serv.args    = {'title' => @title, 'origin' => @origin}
! 	  @serv.parsing = parsing
! 	  return @serv.exec(sequence)
! 	else
! 	  self.exec(Bio::FastaFormat.new(faa), parsing)
! 	end
        end
  
--- 134,146 ----
        # 
        def exec(faa, parsing = true)
!         if faa.class == Bio::FastaFormat
!           @title        = faa.entry_id if @title == 'MYSEQ'
!           @sequence     = faa.seq
!           @serv.args    = {'title' => @title, 'origin' => @origin}
!           @serv.parsing = parsing
!           return @serv.exec(sequence)
!         else
!           self.exec(Bio::FastaFormat.new(faa), parsing)
!         end
        end
  
***************
*** 149,175 ****
        class Remote < CGIDriver
  
! 	def initialize(host, path)
! 	  @origin  = 'yeast' # Gram-positive bacterium, 
    	                     # Gram-negative bacterium,
! 	                     # yeast, aminal, plant
! 	  @title   = 'MYSEQ'
! 	  @parsing = true
! 	  super(host, path)
! 	end
! 	attr_accessor :origin, :title, :parsing
  
  
! 	private
  
! 	def make_args(query)
! 	  @args.update({'sequence' => query})
! 	  return args_join(@args)
! 	end
  
! 	def parse_report(str)
! 	  str = erase_html_tags(str)
! 	  str = Bio::PSORT::PSORT1::Report.parser(str) if @parsing
! 	  return str
! 	end
  
        end # Class Remote
--- 149,175 ----
        class Remote < CGIDriver
  
!         def initialize(host, path)
!           @origin  = 'yeast' # Gram-positive bacterium, 
    	                     # Gram-negative bacterium,
!                              # yeast, aminal, plant
!           @title   = 'MYSEQ'
!           @parsing = true
!           super(host, path)
!         end
!         attr_accessor :origin, :title, :parsing
  
  
!         private
  
!         def make_args(query)
!           @args.update({'sequence' => query})
!           return args_join(@args)
!         end
  
!         def parse_report(str)
!           str = erase_html_tags(str)
!           str = Bio::PSORT::PSORT1::Report.parser(str) if @parsing
!           return str
!         end
  
        end # Class Remote
***************
*** 184,223 ****
        # remote
        def self.remote(host, path)
! 	self.new(Remote.new(host, path))
        end
  
        def self.imsut
! 	self.remote(WWWServer['IMSUT']['host'],
! 		    WWWServer['IMSUT']['PSORT2'])
        end
        
        def self.okazaki
! 	self.remote(WWWServer['Okazaki']['host'],
! 		    WWWServer['Okazaki']['PSORT2'])
        end
  
        def self.peking
! 	self.remote(WWWServer['Peking']['host'],
! 		    WWWServer['Peking']['PSORT2'])
        end
  
        # wrapper for ``psort'' command
        def initialize(serv, origin = 'yeast')
! 	@serv   = serv
! 	@origin = origin
! 	@title  = nil
        end
        attr_accessor :origin, :title
  
        def exec(faa, parsing = true)
! 	if faa.class == Bio::FastaFormat
! 	  @title        = faa.entry_id if @title == nil
! 	  @sequence     = faa.seq
! 	  @serv.args    = {'origin' => @origin, 'title' => @title}
! 	  @serv.parsing = parsing
! 	  return @serv.exec(@sequence)
! 	else
! 	  self.exec(Bio::FastaFormat.new(faa), parsing)
! 	end
        end
  
--- 184,223 ----
        # remote
        def self.remote(host, path)
!         self.new(Remote.new(host, path))
        end
  
        def self.imsut
!         self.remote(WWWServer['IMSUT']['host'],
!                     WWWServer['IMSUT']['PSORT2'])
        end
        
        def self.okazaki
!         self.remote(WWWServer['Okazaki']['host'],
!                     WWWServer['Okazaki']['PSORT2'])
        end
  
        def self.peking
!         self.remote(WWWServer['Peking']['host'],
!                     WWWServer['Peking']['PSORT2'])
        end
  
        # wrapper for ``psort'' command
        def initialize(serv, origin = 'yeast')
!         @serv   = serv
!         @origin = origin
!         @title  = nil
        end
        attr_accessor :origin, :title
  
        def exec(faa, parsing = true)
!         if faa.class == Bio::FastaFormat
!           @title        = faa.entry_id if @title == nil
!           @sequence     = faa.seq
!           @serv.args    = {'origin' => @origin, 'title' => @title}
!           @serv.parsing = parsing
!           return @serv.exec(@sequence)
!         else
!           self.exec(Bio::FastaFormat.new(faa), parsing)
!         end
        end
  
***************
*** 225,249 ****
        # PSORT2 specific CGIDriver
        class Remote < CGIDriver
! 	def initialize(host, path)
! 	  @origin = 'yeast'
! 	  super(host, path)
! 	  @parsing = true
! 	end
! 	attr_accessor :origin, :parsing
  
! 	
! 	private
! 	
! 	def make_args(query)
! 	  @args.update({'sequence' => query})
! 	  return args_join(@args)
! 	end
  
! 	def parse_report(str)
! 	  str = str.gsub(/\n<hr>/i, Report::BOUNDARY)
! 	  str = erase_html_tags(str)
! 	  str = Bio::PSORT::PSORT2::Report.parser(str, self.args['title']) if @parsing
! 	  return str
! 	end
  
        end # class Remote
--- 225,249 ----
        # PSORT2 specific CGIDriver
        class Remote < CGIDriver
!         def initialize(host, path)
!           @origin = 'yeast'
!           super(host, path)
!           @parsing = true
!         end
!         attr_accessor :origin, :parsing
  
!         
!         private
!         
!         def make_args(query)
!           @args.update({'sequence' => query})
!           return args_join(@args)
!         end
  
!         def parse_report(str)
!           str = str.gsub(/\n<hr>/i, Report::BOUNDARY)
!           str = erase_html_tags(str)
!           str = Bio::PSORT::PSORT2::Report.parser(str, self.args['title']) if @parsing
!           return str
!         end
  
        end # class Remote

Index: fasta.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/fasta.rb,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** fasta.rb	16 Aug 2005 09:38:34 -0000	1.17
--- fasta.rb	8 Sep 2005 01:22:08 -0000	1.18
***************
*** 98,104 ****
        case @format
        when 6
! 	require 'bio/appl/fasta/format6'
        when 10
! 	require 'bio/appl/fasta/format10'
        end
        Report.new(data)
--- 98,104 ----
        case @format
        when 6
!         require 'bio/appl/fasta/format6'
        when 10
!         require 'bio/appl/fasta/format10'
        end
        Report.new(data)
***************
*** 125,135 ****
  
        form = {
! 	'style'		=> 'raw',
! 	'prog'		=> @program,
! 	'dbname'	=> @db,
! 	'sequence'	=> CGI.escape(query),
! 	'other_param'	=> CGI.escape(make_command_line_unix(@options)),
! 	'ktup_value'	=> @ktup,
! 	'matrix'	=> @matrix,
        }
  
--- 125,135 ----
  
        form = {
!         'style'		=> 'raw',
!         'prog'		=> @program,
!         'dbname'	=> @db,
!         'sequence'	=> CGI.escape(query),
!         'other_param'	=> CGI.escape(make_command_line_unix(@options)),
!         'ktup_value'	=> @ktup,
!         'matrix'	=> @matrix,
        }
  
***************
*** 137,141 ****
  
        form.each do |k, v|
! 	data.push("#{k}=#{v}") if v
        end
  
--- 137,141 ----
  
        form.each do |k, v|
!         data.push("#{k}=#{v}") if v
        end
  
***************
*** 146,150 ****
          http.open_timeout = 300
          http.read_timeout = 600
! 	result, = http.post(path, data.join('&'))
          @output = result.body
          # workaround 2005.08.12
--- 146,150 ----
          http.open_timeout = 300
          http.read_timeout = 600
!         result, = http.post(path, data.join('&'))
          @output = result.body
          # workaround 2005.08.12

Index: mafft.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/mafft.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mafft.rb	4 Mar 2005 04:48:41 -0000	1.4
--- mafft.rb	8 Sep 2005 01:22:08 -0000	1.5
***************
*** 35,42 ****
        opt = []
        if n.to_s == 'i' then
! 	self.new2(nil, 'fftnsi', *opt)
        else
! 	opt << n.to_s if n
! 	self.new2(nil, 'fftns', *opt)
        end
      end
--- 35,42 ----
        opt = []
        if n.to_s == 'i' then
!         self.new2(nil, 'fftnsi', *opt)
        else
!         opt << n.to_s if n
!         self.new2(nil, 'fftns', *opt)
        end
      end
***************
*** 50,57 ****
        opt << '--all-positive' if ap
        if n.to_s == 'i' then
! 	self.new2(nil, 'nwnsi', *opt)
        else
! 	opt << n.to_s if n
! 	self.new2(nil, 'nwns', *opt)
        end
      end
--- 50,57 ----
        opt << '--all-positive' if ap
        if n.to_s == 'i' then
!         self.new2(nil, 'nwnsi', *opt)
        else
!         opt << n.to_s if n
!         self.new2(nil, 'nwns', *opt)
        end
      end
***************
*** 69,73 ****
      def self.new2(dir, prog, *opt)
        if dir then
! 	prog = File.join(dir, prog)
        end
        self.new(prog, opt)
--- 69,73 ----
      def self.new2(dir, prog, *opt)
        if dir then
!         prog = File.join(dir, prog)
        end
        self.new(prog, opt)
***************
*** 88,94 ****
      def query(seqs)
        if seqs then
! 	query_align(seqs)
        else
! 	exec_local(@option)
        end
      end
--- 88,94 ----
      def query(seqs)
        if seqs then
!         query_align(seqs)
        else
!         exec_local(@option)
        end
      end
***************
*** 97,101 ****
        # seqs should be Bio::Alignment or Array of sequences or nil
        unless seqs.is_a?(Bio::Alignment)
! 	seqs = Bio::Alignment.new(seqs, *arg)
        end
        query_string(seqs.to_fasta(70))
--- 97,101 ----
        # seqs should be Bio::Alignment or Array of sequences or nil
        unless seqs.is_a?(Bio::Alignment)
!         seqs = Bio::Alignment.new(seqs, *arg)
        end
        query_string(seqs.to_fasta(70))
***************
*** 104,111 ****
      def query_string(str, *arg)
        begin
! 	tf_in = Tempfile.open('align')
! 	tf_in.print str
        ensure
! 	tf_in.close(false)
        end
        r = query_by_filename(tf_in.path, *arg)
--- 104,111 ----
      def query_string(str, *arg)
        begin
!         tf_in = Tempfile.open('align')
!         tf_in.print str
        ensure
!         tf_in.close(false)
        end
        r = query_by_filename(tf_in.path, *arg)
***************
*** 128,139 ****
        @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
--- 128,139 ----
        @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



More information about the bioruby-cvs mailing list