[BioRuby-cvs] bioruby/lib/bio/appl/blast format0.rb, 1.9, 1.10 format8.rb, 1.4, 1.5 report.rb, 1.6, 1.7 rexml.rb, 1.9, 1.10 wublast.rb, 1.1, 1.2 xmlparser.rb, 1.12, 1.13

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


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

Modified Files:
	format0.rb format8.rb report.rb rexml.rb wublast.rb 
	xmlparser.rb 
Log Message:
* expanded tab at the line head


Index: xmlparser.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/xmlparser.rb,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** xmlparser.rb	29 Sep 2003 10:00:41 -0000	1.12
--- xmlparser.rb	8 Sep 2005 01:22:08 -0000	1.13
***************
*** 34,214 ****
  
        def xmlparser_parse(xml)
! 	parser = XMLParser.new
! 	def parser.default; end
! 	
! 	begin
! 	  tag_stack = Array.new
! 	  hash = Hash.new
  
! 	  parser.parse(xml) do |type, name, data|
! 	    #print "type=#{type.inspect} name=#{name.inspect} data=#{data.inspect}\n" # for DEBUG
! 	    case type
! 	    when XMLParser::START_ELEM
! 	      tag_stack.push(name)
! 	      hash.update(data)
! 	      case name
! 	      when 'Iteration'
! 		iteration = Iteration.new
! 		@iterations.push(iteration)
! 	      when 'Hit'
! 		hit = Hit.new
! 		hit.query_id = @query_id
! 		hit.query_def = @query_def
! 		hit.query_len = @query_len
! 		@iterations.last.hits.push(hit)
! 	      when 'Hsp'
! 		hsp = Hsp.new
! 		@iterations.last.hits.last.hsps.push(hsp)
! 	      end
! 	    when XMLParser::END_ELEM
! 	      case name
! 	      when /^BlastOutput/
! 		xmlparser_parse_program(name,hash)
! 		hash = Hash.new
! 	      when /^Parameters$/
! 		xmlparser_parse_parameters(hash)
! 		hash = Hash.new
! 	      when /^Iteration/
! 		xmlparser_parse_iteration(name, hash)
! 		hash = Hash.new
! 	      when /^Hit/
! 		xmlparser_parse_hit(name, hash)
! 		hash = Hash.new
! 	      when /^Hsp$/
! 		xmlparser_parse_hsp(hash)
! 		hash = Hash.new
! 	      when /^Statistics$/
! 		xmlparser_parse_statistics(hash)
! 		hash = Hash.new
! 	      end
! 	      tag_stack.pop
! 	    when XMLParser::CDATA
! 	      if hash[tag_stack.last].nil?
! 		hash[tag_stack.last] = data unless data.strip.empty?
! 	      else
! 		hash[tag_stack.last].concat(data) if data
! 	      end
! 	    when XMLParser::PI
! 	    end
! 	  end
! 	rescue XMLParserError
! 	  line = parser.line
! 	  column = parser.column
! 	  print "Parse error at #{line}(#{column}) : #{$!}\n"
! 	end
        end
  
  
        def xmlparser_parse_program(tag, hash)
! 	case tag
! 	when 'BlastOutput_program'
! 	  @program = hash[tag]
! 	when 'BlastOutput_version'
! 	  @version = hash[tag]
! 	when 'BlastOutput_reference'
! 	  @reference = hash[tag]
! 	when 'BlastOutput_db'
! 	  @db = hash[tag].strip
! 	when 'BlastOutput_query-ID'
! 	  @query_id = hash[tag]
! 	when 'BlastOutput_query-def'
! 	  @query_def = hash[tag]
! 	when 'BlastOutput_query-len'
! 	  @query_len = hash[tag].to_i
! 	end
        end
  
        def xmlparser_parse_parameters(hash)
! 	labels = { 
! 	  'matrix'	=> 'Parameters_matrix',
! 	  'expect'	=> 'Parameters_expect',
! 	  'include'	=> 'Parameters_include',
! 	  'sc-match'	=> 'Parameters_sc-match',
! 	  'sc-mismatch'	=> 'Parameters_sc-mismatch',
! 	  'gap-open'	=> 'Parameters_gap-open',
! 	  'gap-extend'	=> 'Parameters_gap-extend',
! 	  'filter'	=> 'Parameters_filter',
! 	  'pattern'	=> 'Parameters_pattern',
! 	  'entrez-query'=> 'Parameters_entrez-query',
! 	}
! 	labels.each do |k,v|
! 	  case k
! 	  when 'filter', 'matrix'
! 	    @parameters[k] = hash[v].to_s
! 	  else
! 	    @parameters[k] = hash[v].to_i
! 	  end
! 	end
        end
  
        def xmlparser_parse_iteration(tag, hash)
! 	case tag
! 	when 'Iteration_iter-num'
! 	  @iterations.last.num = hash[tag].to_i
! 	when 'Iteration_message'
! 	  @iterations.last.message = hash[tag].to_s
! 	end
        end
  
        def xmlparser_parse_hit(tag, hash)
! 	hit = @iterations.last.hits.last
! 	case tag
! 	when 'Hit_num'
! 	  hit.num = hash[tag].to_i
! 	when 'Hit_id'
! 	  hit.hit_id = hash[tag].clone
! 	when 'Hit_def'
! 	  hit.definition = hash[tag].clone
! 	when 'Hit_accession'
! 	  hit.accession = hash[tag].clone
! 	when 'Hit_len'
! 	  hit.len = hash[tag].clone.to_i
! 	end
        end
  
        def xmlparser_parse_hsp(hash)
! 	hsp = @iterations.last.hits.last.hsps.last
! 	hsp.num			= hash['Hsp_num'].to_i
! 	hsp.bit_score		= hash['Hsp_bit-score'].to_f
! 	hsp.score		= hash['Hsp_score'].to_i
! 	hsp.evalue		= hash['Hsp_evalue'].to_f
! 	hsp.query_from		= hash['Hsp_query-from'].to_i
! 	hsp.query_to		= hash['Hsp_query-to'].to_i
! 	hsp.hit_from		= hash['Hsp_hit-from'].to_i
! 	hsp.hit_to		= hash['Hsp_hit-to'].to_i
! 	hsp.pattern_from	= hash['Hsp_pattern-from'].to_i
! 	hsp.pattern_to		= hash['Hsp_pattern-to'].to_i
     	hsp.query_frame		= hash['Hsp_query-frame'].to_i
! 	hsp.hit_frame		= hash['Hsp_hit-frame'].to_i
! 	hsp.identity		= hash['Hsp_identity'].to_i
! 	hsp.positive		= hash['Hsp_positive'].to_i
! 	hsp.gaps		= hash['Hsp_gaps'].to_i
! 	hsp.align_len		= hash['Hsp_align-len'].to_i
! 	hsp.density		= hash['Hsp_density'].to_i
! 	hsp.qseq		= hash['Hsp_qseq']
! 	hsp.hseq		= hash['Hsp_hseq']
! 	hsp.midline		= hash['Hsp_midline']
        end
  
        def xmlparser_parse_statistics(hash)
! 	labels = {
! 	  'db-num'	=> 'Statistics_db-num',
! 	  'db-len'	=> 'Statistics_db-len',
! 	  'hsp-len'	=> 'Statistics_hsp-len',
! 	  'eff-space'	=> 'Statistics_eff-space',
! 	  'kappa'	=> 'Statistics_kappa',
! 	  'lambda'	=> 'Statistics_lambda',
! 	  'entropy'	=> 'Statistics_entropy'
! 	}
! 	labels.each do |k,v|
! 	  case k
! 	  when 'db-num', 'db-len', 'hsp-len'
! 	    @iterations.last.statistics[k] = hash[v].to_i
! 	  else
! 	    @iterations.last.statistics[k] = hash[v].to_f
! 	  end
! 	end
        end
! 	
      end
    end
--- 34,214 ----
  
        def xmlparser_parse(xml)
!         parser = XMLParser.new
!         def parser.default; end
!         
!         begin
!           tag_stack = Array.new
!           hash = Hash.new
  
!           parser.parse(xml) do |type, name, data|
!             #print "type=#{type.inspect} name=#{name.inspect} data=#{data.inspect}\n" # for DEBUG
!             case type
!             when XMLParser::START_ELEM
!               tag_stack.push(name)
!               hash.update(data)
!               case name
!               when 'Iteration'
!                 iteration = Iteration.new
!                 @iterations.push(iteration)
!               when 'Hit'
!                 hit = Hit.new
!                 hit.query_id = @query_id
!                 hit.query_def = @query_def
!                 hit.query_len = @query_len
!                 @iterations.last.hits.push(hit)
!               when 'Hsp'
!                 hsp = Hsp.new
!                 @iterations.last.hits.last.hsps.push(hsp)
!               end
!             when XMLParser::END_ELEM
!               case name
!               when /^BlastOutput/
!                 xmlparser_parse_program(name,hash)
!                 hash = Hash.new
!               when /^Parameters$/
!                 xmlparser_parse_parameters(hash)
!                 hash = Hash.new
!               when /^Iteration/
!                 xmlparser_parse_iteration(name, hash)
!                 hash = Hash.new
!               when /^Hit/
!                 xmlparser_parse_hit(name, hash)
!                 hash = Hash.new
!               when /^Hsp$/
!                 xmlparser_parse_hsp(hash)
!                 hash = Hash.new
!               when /^Statistics$/
!                 xmlparser_parse_statistics(hash)
!                 hash = Hash.new
!               end
!               tag_stack.pop
!             when XMLParser::CDATA
!               if hash[tag_stack.last].nil?
!                 hash[tag_stack.last] = data unless data.strip.empty?
!               else
!                 hash[tag_stack.last].concat(data) if data
!               end
!             when XMLParser::PI
!             end
!           end
!         rescue XMLParserError
!           line = parser.line
!           column = parser.column
!           print "Parse error at #{line}(#{column}) : #{$!}\n"
!         end
        end
  
  
        def xmlparser_parse_program(tag, hash)
!         case tag
!         when 'BlastOutput_program'
!           @program = hash[tag]
!         when 'BlastOutput_version'
!           @version = hash[tag]
!         when 'BlastOutput_reference'
!           @reference = hash[tag]
!         when 'BlastOutput_db'
!           @db = hash[tag].strip
!         when 'BlastOutput_query-ID'
!           @query_id = hash[tag]
!         when 'BlastOutput_query-def'
!           @query_def = hash[tag]
!         when 'BlastOutput_query-len'
!           @query_len = hash[tag].to_i
!         end
        end
  
        def xmlparser_parse_parameters(hash)
!         labels = { 
!           'matrix'	=> 'Parameters_matrix',
!           'expect'	=> 'Parameters_expect',
!           'include'	=> 'Parameters_include',
!           'sc-match'	=> 'Parameters_sc-match',
!           'sc-mismatch'	=> 'Parameters_sc-mismatch',
!           'gap-open'	=> 'Parameters_gap-open',
!           'gap-extend'	=> 'Parameters_gap-extend',
!           'filter'	=> 'Parameters_filter',
!           'pattern'	=> 'Parameters_pattern',
!           'entrez-query'=> 'Parameters_entrez-query',
!         }
!         labels.each do |k,v|
!           case k
!           when 'filter', 'matrix'
!             @parameters[k] = hash[v].to_s
!           else
!             @parameters[k] = hash[v].to_i
!           end
!         end
        end
  
        def xmlparser_parse_iteration(tag, hash)
!         case tag
!         when 'Iteration_iter-num'
!           @iterations.last.num = hash[tag].to_i
!         when 'Iteration_message'
!           @iterations.last.message = hash[tag].to_s
!         end
        end
  
        def xmlparser_parse_hit(tag, hash)
!         hit = @iterations.last.hits.last
!         case tag
!         when 'Hit_num'
!           hit.num = hash[tag].to_i
!         when 'Hit_id'
!           hit.hit_id = hash[tag].clone
!         when 'Hit_def'
!           hit.definition = hash[tag].clone
!         when 'Hit_accession'
!           hit.accession = hash[tag].clone
!         when 'Hit_len'
!           hit.len = hash[tag].clone.to_i
!         end
        end
  
        def xmlparser_parse_hsp(hash)
!         hsp = @iterations.last.hits.last.hsps.last
!         hsp.num			= hash['Hsp_num'].to_i
!         hsp.bit_score		= hash['Hsp_bit-score'].to_f
!         hsp.score		= hash['Hsp_score'].to_i
!         hsp.evalue		= hash['Hsp_evalue'].to_f
!         hsp.query_from		= hash['Hsp_query-from'].to_i
!         hsp.query_to		= hash['Hsp_query-to'].to_i
!         hsp.hit_from		= hash['Hsp_hit-from'].to_i
!         hsp.hit_to		= hash['Hsp_hit-to'].to_i
!         hsp.pattern_from	= hash['Hsp_pattern-from'].to_i
!         hsp.pattern_to		= hash['Hsp_pattern-to'].to_i
     	hsp.query_frame		= hash['Hsp_query-frame'].to_i
!         hsp.hit_frame		= hash['Hsp_hit-frame'].to_i
!         hsp.identity		= hash['Hsp_identity'].to_i
!         hsp.positive		= hash['Hsp_positive'].to_i
!         hsp.gaps		= hash['Hsp_gaps'].to_i
!         hsp.align_len		= hash['Hsp_align-len'].to_i
!         hsp.density		= hash['Hsp_density'].to_i
!         hsp.qseq		= hash['Hsp_qseq']
!         hsp.hseq		= hash['Hsp_hseq']
!         hsp.midline		= hash['Hsp_midline']
        end
  
        def xmlparser_parse_statistics(hash)
!         labels = {
!           'db-num'	=> 'Statistics_db-num',
!           'db-len'	=> 'Statistics_db-len',
!           'hsp-len'	=> 'Statistics_hsp-len',
!           'eff-space'	=> 'Statistics_eff-space',
!           'kappa'	=> 'Statistics_kappa',
!           'lambda'	=> 'Statistics_lambda',
!           'entropy'	=> 'Statistics_entropy'
!         }
!         labels.each do |k,v|
!           case k
!           when 'db-num', 'db-len', 'hsp-len'
!             @iterations.last.statistics[k] = hash[v].to_i
!           else
!             @iterations.last.statistics[k] = hash[v].to_f
!           end
!         end
        end
!         
      end
    end

Index: report.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/report.rb,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** report.rb	21 Jun 2005 07:03:28 -0000	1.6
--- report.rb	8 Sep 2005 01:22:08 -0000	1.7
***************
*** 31,41 ****
        ary = []
        input.each("</BlastOutput>\n") do |xml|
! 	xml.sub!(/[^<]*(<?)/, '\1')		# skip before <?xml> tag
! 	next if xml.empty?			# skip trailing no hits
! 	if block_given?
! 	  yield Report.new(xml, parser)
! 	else
! 	  ary << Report.new(xml, parser)
! 	end
        end
        return ary
--- 31,41 ----
        ary = []
        input.each("</BlastOutput>\n") do |xml|
!         xml.sub!(/[^<]*(<?)/, '\1')		# skip before <?xml> tag
!         next if xml.empty?			# skip trailing no hits
!         if block_given?
!           yield Report.new(xml, parser)
!         else
!           ary << Report.new(xml, parser)
!         end
        end
        return ary
***************
*** 49,90 ****
  
        def self.xmlparser(data)
! 	self.new(data, :xmlparser)
        end
        def self.rexml(data)
! 	self.new(data, :rexml)
        end
        def self.tab(data)
! 	self.new(data, :tab)
        end
  
        def auto_parse(data)
! 	if /<?xml/.match(data[/.*/])
! 	  if defined?(XMLParser)
! 	    xmlparser_parse(data)
! 	  else
! 	    rexml_parse(data)
! 	  end
! 	else
! 	  tab_parse(data)
! 	end
        end
        private :auto_parse
  
        def initialize(data, parser = nil)
! 	@iterations = []
! 	@parameters = {}
! 	case parser
! 	when :xmlparser		# format 7
! 	  xmlparser_parse(data)
! 	when :rexml		# format 7
! 	  rexml_parse(data)
! 	when :tab		# format 8
! 	  tab_parse(data)
! 	else
! 	  auto_parse(data)
! 	end
        end
        attr_reader :iterations, :parameters,
! 	:program, :version, :reference,	:db, :query_id, :query_def, :query_len
  
        # shortcut for @parameters
--- 49,90 ----
  
        def self.xmlparser(data)
!         self.new(data, :xmlparser)
        end
        def self.rexml(data)
!         self.new(data, :rexml)
        end
        def self.tab(data)
!         self.new(data, :tab)
        end
  
        def auto_parse(data)
!         if /<?xml/.match(data[/.*/])
!           if defined?(XMLParser)
!             xmlparser_parse(data)
!           else
!             rexml_parse(data)
!           end
!         else
!           tab_parse(data)
!         end
        end
        private :auto_parse
  
        def initialize(data, parser = nil)
!         @iterations = []
!         @parameters = {}
!         case parser
!         when :xmlparser		# format 7
!           xmlparser_parse(data)
!         when :rexml		# format 7
!           rexml_parse(data)
!         when :tab		# format 8
!           tab_parse(data)
!         else
!           auto_parse(data)
!         end
        end
        attr_reader :iterations, :parameters,
!         :program, :version, :reference,	:db, :query_id, :query_def, :query_len
  
        # shortcut for @parameters
***************
*** 102,115 ****
        # <for blastpgp>
        def each_iteration
! 	@iterations.each do |x|
! 	  yield x
! 	end
        end
  
        # <for blastall> shortcut for the last iteration's hits
        def each_hit
! 	@iterations.last.each do |x|
! 	  yield x
! 	end
        end
        alias :each :each_hit
--- 102,115 ----
        # <for blastpgp>
        def each_iteration
!         @iterations.each do |x|
!           yield x
!         end
        end
  
        # <for blastall> shortcut for the last iteration's hits
        def each_hit
!         @iterations.last.each do |x|
!           yield x
!         end
        end
        alias :each :each_hit
***************
*** 117,126 ****
        # shortcut for the last iteration's hits
        def hits
! 	@iterations.last.hits
        end
  
        # shortcut for the last iteration's statistics
        def statistics
! 	@iterations.last.statistics
        end
        def db_num;	statistics['db-num'];			end
--- 117,126 ----
        # shortcut for the last iteration's hits
        def hits
!         @iterations.last.hits
        end
  
        # shortcut for the last iteration's statistics
        def statistics
!         @iterations.last.statistics
        end
        def db_num;	statistics['db-num'];			end
***************
*** 134,138 ****
        # shortcut for the last iteration's message (for checking 'CONVERGED')
        def message
! 	@iterations.last.message
        end
  
--- 134,138 ----
        # shortcut for the last iteration's message (for checking 'CONVERGED')
        def message
!         @iterations.last.message
        end
  
***************
*** 140,157 ****
        # Bio::Blast::Report::Iteration
        class Iteration
! 	def initialize
! 	  @message = nil
! 	  @statistics = {}
! 	  @num = 1
! 	  @hits = []
! 	end
! 	attr_reader :hits, :statistics
! 	attr_accessor :num, :message
  
! 	def each
! 	  @hits.each do |x|
! 	    yield x
! 	  end
! 	end
        end
  
--- 140,157 ----
        # Bio::Blast::Report::Iteration
        class Iteration
!         def initialize
!           @message = nil
!           @statistics = {}
!           @num = 1
!           @hits = []
!         end
!         attr_reader :hits, :statistics
!         attr_accessor :num, :message
  
!         def each
!           @hits.each do |x|
!             yield x
!           end
!         end
        end
  
***************
*** 159,200 ****
        # Bio::Blast::Report::Hit
        class Hit
! 	def initialize
! 	  @hsps = []
! 	end
! 	attr_reader :hsps
! 	attr_accessor :query_id, :query_def, :query_len,
! 	  :num, :hit_id, :len, :definition, :accession
  
! 	def each
! 	  @hsps.each do |x|
! 	    yield x
! 	  end
! 	end
  
! 	# Compatible with Bio::Fasta::Report::Hit
  
! 	alias :target_id :accession
! 	alias :target_def :definition
! 	alias :target_len :len
  
! 	# Shortcut methods for the best Hsp
  
! 	def evalue;		@hsps.first.evalue;		end
! 	def bit_score;		@hsps.first.bit_score;		end
! 	def identity;		@hsps.first.identity;		end
! 	def percent_identity;	@hsps.first.percent_identity;	end
! 	def overlap;		@hsps.first.align_len;		end
  
! 	def query_seq;		@hsps.first.qseq;		end
! 	def target_seq;		@hsps.first.hseq;		end
! 	def midline;		@hsps.first.midline;		end
  
! 	def query_start;	@hsps.first.query_from;		end
! 	def query_end;		@hsps.first.query_to;		end
! 	def target_start;	@hsps.first.hit_from;		end
! 	def target_end;		@hsps.first.hit_to;		end
! 	def lap_at
! 	  [ query_start, query_end, target_start, target_end ]
! 	end
        end
  
--- 159,200 ----
        # Bio::Blast::Report::Hit
        class Hit
!         def initialize
!           @hsps = []
!         end
!         attr_reader :hsps
!         attr_accessor :query_id, :query_def, :query_len,
!           :num, :hit_id, :len, :definition, :accession
  
!         def each
!           @hsps.each do |x|
!             yield x
!           end
!         end
  
!         # Compatible with Bio::Fasta::Report::Hit
  
!         alias :target_id :accession
!         alias :target_def :definition
!         alias :target_len :len
  
!         # Shortcut methods for the best Hsp
  
!         def evalue;		@hsps.first.evalue;		end
!         def bit_score;		@hsps.first.bit_score;		end
!         def identity;		@hsps.first.identity;		end
!         def percent_identity;	@hsps.first.percent_identity;	end
!         def overlap;		@hsps.first.align_len;		end
  
!         def query_seq;		@hsps.first.qseq;		end
!         def target_seq;		@hsps.first.hseq;		end
!         def midline;		@hsps.first.midline;		end
  
!         def query_start;	@hsps.first.query_from;		end
!         def query_end;		@hsps.first.query_to;		end
!         def target_start;	@hsps.first.hit_from;		end
!         def target_end;		@hsps.first.hit_to;		end
!         def lap_at
!           [ query_start, query_end, target_start, target_end ]
!         end
        end
  
***************
*** 202,215 ****
        # Bio::Blast::Report::Hsp
        class Hsp
! 	def initialize
! 	  @hsp = {}
! 	end
! 	attr_reader :hsp
! 	attr_accessor :num, :bit_score, :score, :evalue,
! 	  :query_from, :query_to, :hit_from, :hit_to,
! 	  :pattern_from, :pattern_to, :query_frame, :hit_frame,
! 	  :identity, :positive, :gaps, :align_len, :density,
! 	  :qseq, :hseq, :midline,
! 	  :percent_identity, :mismatch_count	 # only for '-m 8'
        end
  
--- 202,215 ----
        # Bio::Blast::Report::Hsp
        class Hsp
!         def initialize
!           @hsp = {}
!         end
!         attr_reader :hsp
!         attr_accessor :num, :bit_score, :score, :evalue,
!           :query_from, :query_to, :hit_from, :hit_to,
!           :pattern_from, :pattern_to, :query_frame, :hit_frame,
!           :identity, :positive, :gaps, :align_len, :density,
!           :qseq, :hseq, :midline,
!           :percent_identity, :mismatch_count	 # only for '-m 8'
        end
  

Index: wublast.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/wublast.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** wublast.rb	11 Aug 2003 15:27:35 -0000	1.1
--- wublast.rb	8 Sep 2005 01:22:08 -0000	1.2
***************
*** 29,267 ****
        class Report < Default::Report
  
! 	def parameters
! 	  parse_parameters
! 	  @parameters
! 	end
  
! 	def parameter_matrix
! 	  parse_parameters
! 	  @parameter_matrix
! 	end
  
! 	def expect; parse_parameters; @parameters['E']; end
  
! 	def warnings
! 	  unless defined?(@warnings)
! 	    @warnings = @f0warnings
! 	    iterations.each { |x| @warnings.concat(x.warnings) }
! 	  end
! 	  @warnings
! 	end
  
! 	def notice
! 	  unless defined?(@notice)
! 	    @notice = @f0notice.to_s.gsub(/\s+/, ' ').strip
! 	  end #unless
! 	  @notice
! 	end
  
! 	private
! 	def format0_split_headers(data)
! 	  @f0header = data.shift
! 	  while r = data.first
! 	    case r
! 	    when /^Reference\: /
! 	      @f0reference = data.shift
! 	    when /^Copyright /
! 	      @f0copyright = data.shift
! 	    when /^Notice\: /
! 	      @f0notice = data.shift
! 	    when /^Query\= /
! 	      break
! 	    else
! 	      break
! 	    end
! 	  end
! 	  @f0query = data.shift
! 	  if r = data.first and !(/^Database\: / =~ r)
! 	    @f0translate_info = data.shift
! 	  end
! 	  @f0database = data.shift
! 	end
  
! 	def format0_split_search(data)
! 	  [ Iteration.new(data) ]
! 	end
  
! 	def format0_split_stat_params(data)
! 	  @f0warnings = []
! 	  if r = data.first and r =~ /^WARNING\: / then
! 	    @f0warnings << data.shift
! 	  end
! 	  @f0wu_params = []
! 	  @f0wu_stats = []
! 	  while r = data.shift and !(r =~ /^Statistics\:/)
! 	    @f0wu_params << r
! 	  end
! 	  @f0wu_stats << r if r
! 	  while r = data.shift
! 	    @f0wu_stats << r
! 	  end
! 	  @f0dbstat = F0dbstat.new(@f0wu_stats)
! 	  itr = @iterations[0]
! 	  itr.f0dbstat = @f0dbstat if itr
! 	end
  
! 	def parse_parameters
! 	  unless defined?(@parse_parameters)
! 	    @parameters = {}
! 	    @parameter_matrix = []
! 	    @f0wu_params.each do |x|
! 	      if /^  Query/ =~ x then
! 		@parameter_matrix << x
! 	      else
! 		x.split(/^/).each do |y|
! 		  if /\A\s*(.+)\s*\=\s*(.*)\s*/ =~ y then
! 		    @parameters[$1] = $2
! 		  elsif /\AParameters\:/ =~ y then
! 		    ; #ignore this
! 		  elsif /\A\s*(.+)\s*$/ =~ y then
! 		    @parameters[$1] = true
! 		  end
! 		end
! 	      end
! 	    end
! 	    @parse_parameters = true
! 	  end
! 	end
  
! 	class F0dbstat < Default::Report::F0dbstat
! 	  def initialize(ary)
! 	    @f0stat = ary
! 	    @hash = {}
! 	  end
  
! 	  #undef :f0params
! 	  #undef :matrix, :gap_open, :gap_extend,
! 	  #  :eff_space, :expect, :sc_match, :sc_mismatch,
! 	  #  :num_hits
  
! 	  def parse_dbstat
! 	    unless defined?(@parse_dbstat)
! 	      @f0stat.each do |x|
! 		parse_colon_separated(@hash, x)
! 	      end
! 	      @database = @hash['Database']
! 	      @posted_date = @hash['Posted']
! 	      if val = @hash['# of letters in database'] then
! 		@db_len =  val.tr(',', '').to_i
! 	      end
! 	      if val = @hash['# of sequences in database'] then
! 		@db_num = val.tr(',', '').to_i
! 	      end
! 	      @parse_dbstat = true
! 	    end #unless
! 	  end #def
! 	  private :parse_dbstat
  
! 	end #class F0dbstat
  
! 	class Frame
! 	end #class FrameParams
  
! 	class Iteration < Default::Report::Iteration
! 	  def initialize(data)
! 	    @f0stat = []
! 	    @f0dbstat = nil
! 	    @f0hitlist = []
! 	    @hits = []
! 	    @num = 1
! 	    @f0message = []
! 	    @f0warnings = []
! 	    return unless r = data.shift
! 	    @f0hitlist << r
! 	    return unless r = data.shift
! 	    unless /\*{3} +NONE +\*{3}/ =~ r then
! 	      @f0hitlist << r
! 	      while r = data.first and /^WARNING\: / =~ r
! 		@f0warnings << data.shift
! 	      end
! 	      while r = data.first and /^\>/ =~ r
! 		@hits << Hit.new(data)
! 	      end
! 	    end #unless
! 	  end
  
! 	  def warnings
! 	    @f0warnings
! 	  end
  
! 	  private
! 	  def parse_hitlist
! 	    unless defined?(@parse_hitlist)
! 	      r = @f0hitlist.shift.to_s
! 	      if /Reading/ =~ r and /Frame/ =~ r then
! 		flag_tblast = true 
! 		spnum = 5
! 	      else
! 		flag_tblast = nil
! 		spnum = 4
! 	      end
! 	      i = 0
! 	      @f0hitlist.each do |x|
! 		b = x.split(/^/)
! 		b.collect! { |y| y.empty? ? nil : y }
! 		b.compact!
! 		b.each do |y|
! 		  y.strip!
! 		  y.reverse!
! 		  z = y.split(/\s+/, spnum)
! 		  z.each { |y| y.reverse! }
! 		  dfl  = z.pop
! 		  h = @hits[i] 
! 		  unless h then
! 		    h = Hit.new([ dfl.to_s.sub(/\.+\z/, '') ])
! 		    @hits[i] = h
! 		  end
! 		  z.pop if flag_tblast #ignore Reading Frame
! 		  scr = z.pop.to_s
! 		  pval = z.pop.to_s
! 		  nnum = z.pop.to_i
! 		  #ev = '1' + ev if ev[0] == ?e
! 		  h.instance_eval {
! 		    @score = scr
! 		    @pvalue = pval
! 		    @n_number = nnum
! 		  }
! 		  i += 1
! 		end
! 	      end #each
! 	      @parse_hitlist = true
! 	    end #unless
! 	  end
! 	end #class Iteration
  
! 	class Hit < Default::Report::Hit
! 	  def initialize(data)
! 	    @f0hitname = data.shift
! 	    @hsps = []
! 	    while r = data.first
! 	      if r =~ /^\s*(?:Plus|Minus) +Strand +HSPs\:/ then
! 		data.shift
! 		r = data.first
! 	      end
! 	      if /^\s+Score/ =~ r then
! 		@hsps << HSP.new(data)
! 	      else
! 		break
! 	      end
! 	    end
! 	    @again = false
! 	  end
  
! 	  def score
! 	    @score
! 	  end
! 	  attr_reader :pvalue, :n_number
! 	end #class Hit
  
! 	class HSP < Default::Report::HSP
! 	  method_after_parse_score :pvalue, :p_sum_n
! 	end #class HSP
  
        end #class Report
  
        class Report_TBlast < Report
! 	DELIMITER = RS = "\nTBLAST"
        end #class Report_TBlast
  
--- 29,267 ----
        class Report < Default::Report
  
!         def parameters
!           parse_parameters
!           @parameters
!         end
  
!         def parameter_matrix
!           parse_parameters
!           @parameter_matrix
!         end
  
!         def expect; parse_parameters; @parameters['E']; end
  
!         def warnings
!           unless defined?(@warnings)
!             @warnings = @f0warnings
!             iterations.each { |x| @warnings.concat(x.warnings) }
!           end
!           @warnings
!         end
  
!         def notice
!           unless defined?(@notice)
!             @notice = @f0notice.to_s.gsub(/\s+/, ' ').strip
!           end #unless
!           @notice
!         end
  
!         private
!         def format0_split_headers(data)
!           @f0header = data.shift
!           while r = data.first
!             case r
!             when /^Reference\: /
!               @f0reference = data.shift
!             when /^Copyright /
!               @f0copyright = data.shift
!             when /^Notice\: /
!               @f0notice = data.shift
!             when /^Query\= /
!               break
!             else
!               break
!             end
!           end
!           @f0query = data.shift
!           if r = data.first and !(/^Database\: / =~ r)
!             @f0translate_info = data.shift
!           end
!           @f0database = data.shift
!         end
  
!         def format0_split_search(data)
!           [ Iteration.new(data) ]
!         end
  
!         def format0_split_stat_params(data)
!           @f0warnings = []
!           if r = data.first and r =~ /^WARNING\: / then
!             @f0warnings << data.shift
!           end
!           @f0wu_params = []
!           @f0wu_stats = []
!           while r = data.shift and !(r =~ /^Statistics\:/)
!             @f0wu_params << r
!           end
!           @f0wu_stats << r if r
!           while r = data.shift
!             @f0wu_stats << r
!           end
!           @f0dbstat = F0dbstat.new(@f0wu_stats)
!           itr = @iterations[0]
!           itr.f0dbstat = @f0dbstat if itr
!         end
  
!         def parse_parameters
!           unless defined?(@parse_parameters)
!             @parameters = {}
!             @parameter_matrix = []
!             @f0wu_params.each do |x|
!               if /^  Query/ =~ x then
!                 @parameter_matrix << x
!               else
!                 x.split(/^/).each do |y|
!                   if /\A\s*(.+)\s*\=\s*(.*)\s*/ =~ y then
!                     @parameters[$1] = $2
!                   elsif /\AParameters\:/ =~ y then
!                     ; #ignore this
!                   elsif /\A\s*(.+)\s*$/ =~ y then
!                     @parameters[$1] = true
!                   end
!                 end
!               end
!             end
!             @parse_parameters = true
!           end
!         end
  
!         class F0dbstat < Default::Report::F0dbstat
!           def initialize(ary)
!             @f0stat = ary
!             @hash = {}
!           end
  
!           #undef :f0params
!           #undef :matrix, :gap_open, :gap_extend,
!           #  :eff_space, :expect, :sc_match, :sc_mismatch,
!           #  :num_hits
  
!           def parse_dbstat
!             unless defined?(@parse_dbstat)
!               @f0stat.each do |x|
!                 parse_colon_separated(@hash, x)
!               end
!               @database = @hash['Database']
!               @posted_date = @hash['Posted']
!               if val = @hash['# of letters in database'] then
!                 @db_len =  val.tr(',', '').to_i
!               end
!               if val = @hash['# of sequences in database'] then
!                 @db_num = val.tr(',', '').to_i
!               end
!               @parse_dbstat = true
!             end #unless
!           end #def
!           private :parse_dbstat
  
!         end #class F0dbstat
  
!         class Frame
!         end #class FrameParams
  
!         class Iteration < Default::Report::Iteration
!           def initialize(data)
!             @f0stat = []
!             @f0dbstat = nil
!             @f0hitlist = []
!             @hits = []
!             @num = 1
!             @f0message = []
!             @f0warnings = []
!             return unless r = data.shift
!             @f0hitlist << r
!             return unless r = data.shift
!             unless /\*{3} +NONE +\*{3}/ =~ r then
!               @f0hitlist << r
!               while r = data.first and /^WARNING\: / =~ r
!                 @f0warnings << data.shift
!               end
!               while r = data.first and /^\>/ =~ r
!                 @hits << Hit.new(data)
!               end
!             end #unless
!           end
  
!           def warnings
!             @f0warnings
!           end
  
!           private
!           def parse_hitlist
!             unless defined?(@parse_hitlist)
!               r = @f0hitlist.shift.to_s
!               if /Reading/ =~ r and /Frame/ =~ r then
!                 flag_tblast = true 
!                 spnum = 5
!               else
!                 flag_tblast = nil
!                 spnum = 4
!               end
!               i = 0
!               @f0hitlist.each do |x|
!                 b = x.split(/^/)
!                 b.collect! { |y| y.empty? ? nil : y }
!                 b.compact!
!                 b.each do |y|
!                   y.strip!
!                   y.reverse!
!                   z = y.split(/\s+/, spnum)
!                   z.each { |y| y.reverse! }
!                   dfl  = z.pop
!                   h = @hits[i] 
!                   unless h then
!                     h = Hit.new([ dfl.to_s.sub(/\.+\z/, '') ])
!                     @hits[i] = h
!                   end
!                   z.pop if flag_tblast #ignore Reading Frame
!                   scr = z.pop.to_s
!                   pval = z.pop.to_s
!                   nnum = z.pop.to_i
!                   #ev = '1' + ev if ev[0] == ?e
!                   h.instance_eval {
!                     @score = scr
!                     @pvalue = pval
!                     @n_number = nnum
!                   }
!                   i += 1
!                 end
!               end #each
!               @parse_hitlist = true
!             end #unless
!           end
!         end #class Iteration
  
!         class Hit < Default::Report::Hit
!           def initialize(data)
!             @f0hitname = data.shift
!             @hsps = []
!             while r = data.first
!               if r =~ /^\s*(?:Plus|Minus) +Strand +HSPs\:/ then
!                 data.shift
!                 r = data.first
!               end
!               if /^\s+Score/ =~ r then
!                 @hsps << HSP.new(data)
!               else
!                 break
!               end
!             end
!             @again = false
!           end
  
!           def score
!             @score
!           end
!           attr_reader :pvalue, :n_number
!         end #class Hit
  
!         class HSP < Default::Report::HSP
!           method_after_parse_score :pvalue, :p_sum_n
!         end #class HSP
  
        end #class Report
  
        class Report_TBlast < Report
!         DELIMITER = RS = "\nTBLAST"
        end #class Report_TBlast
  

Index: format8.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format8.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** format8.rb	5 Feb 2003 03:28:26 -0000	1.4
--- format8.rb	8 Sep 2005 01:22:08 -0000	1.5
***************
*** 28,85 ****
  
        def tab_parse(data)
! 	iteration = Iteration.new
! 	@iterations.push(iteration)
! 	@query_id = @query_def = data[/\S+/]
  
! 	target_prev = ''
! 	hit_num = 1
! 	hsp_num = 1
! 	hit = ''
! 	data.each do |line|
! 	  ary = line.chomp.split("\t")
! 	  query_id, target_id, hsp = tab_parse_hsp(ary)
! 	  if target_prev != target_id
! 	    hit = Hit.new
! 	    hit.num = hit_num
! 	    hit_num += 1
! 	    hit.query_id = hit.query_def = query_id
! 	    hit.accession = hit.definition = target_id
! 	    iteration.hits.push(hit)
! 	    hsp_num = 1
! 	  end
! 	  hsp.num = hsp_num
! 	  hsp_num += 1
! 	  hit.hsps.push(hsp)
! 	  target_prev = target_id
! 	end
        end
  
        def tab_parse_hsp(ary)
! 	query_id, target_id,
! 	  percent_identity,
! 	  align_len,
! 	  mismatch_count,
! 	  gaps,
! 	  query_from,
! 	  query_to,
! 	  hit_from,
! 	  hit_to,
! 	  evalue,
! 	  bit_score = *ary
  
! 	hsp = Hsp.new
! 	hsp.align_len		= align_len.to_i
! 	hsp.gaps		= gaps.to_i
! 	hsp.query_from		= query_from.to_i
! 	hsp.query_to		= query_to.to_i
! 	hsp.hit_from		= hit_from.to_i
! 	hsp.hit_to		= hit_to.to_i
! 	hsp.evalue		= evalue.strip.to_f
! 	hsp.bit_score		= bit_score.to_f
  
! 	hsp.percent_identity	= percent_identity.to_f
! 	hsp.mismatch_count	= mismatch_count.to_i
  
! 	return query_id, target_id, hsp
        end
  
--- 28,85 ----
  
        def tab_parse(data)
!         iteration = Iteration.new
!         @iterations.push(iteration)
!         @query_id = @query_def = data[/\S+/]
  
!         target_prev = ''
!         hit_num = 1
!         hsp_num = 1
!         hit = ''
!         data.each do |line|
!           ary = line.chomp.split("\t")
!           query_id, target_id, hsp = tab_parse_hsp(ary)
!           if target_prev != target_id
!             hit = Hit.new
!             hit.num = hit_num
!             hit_num += 1
!             hit.query_id = hit.query_def = query_id
!             hit.accession = hit.definition = target_id
!             iteration.hits.push(hit)
!             hsp_num = 1
!           end
!           hsp.num = hsp_num
!           hsp_num += 1
!           hit.hsps.push(hsp)
!           target_prev = target_id
!         end
        end
  
        def tab_parse_hsp(ary)
!         query_id, target_id,
!           percent_identity,
!           align_len,
!           mismatch_count,
!           gaps,
!           query_from,
!           query_to,
!           hit_from,
!           hit_to,
!           evalue,
!           bit_score = *ary
  
!         hsp = Hsp.new
!         hsp.align_len		= align_len.to_i
!         hsp.gaps		= gaps.to_i
!         hsp.query_from		= query_from.to_i
!         hsp.query_to		= query_to.to_i
!         hsp.hit_from		= hit_from.to_i
!         hsp.hit_to		= hit_to.to_i
!         hsp.evalue		= evalue.strip.to_f
!         hsp.bit_score		= bit_score.to_f
  
!         hsp.percent_identity	= percent_identity.to_f
!         hsp.mismatch_count	= mismatch_count.to_i
  
!         return query_id, target_id, hsp
        end
  

Index: rexml.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/rexml.rb,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rexml.rb	29 Sep 2003 10:03:59 -0000	1.9
--- rexml.rb	8 Sep 2005 01:22:08 -0000	1.10
***************
*** 33,141 ****
  
        def rexml_parse(xml)
! 	dom = REXML::Document.new(xml)
! 	rexml_parse_program(dom)
! 	dom.elements.each("*//Iteration") do |e|
! 	  @iterations.push(rexml_parse_iteration(e))
! 	end
        end
  
        def rexml_parse_program(dom)
! 	hash = {}
! 	dom.root.each_element_with_text do |e|
! 	  name, text = e.name, e.text
! 	  case name
! 	  when 'BlastOutput_param'
! 	    e.elements["Parameters"].each_element_with_text do |p|
! 	      k = p.name.sub(/Parameters_/, '')
! 	      v = p.text =~ /\D/ ? p.text : p.text.to_i
! 	      @parameters[k] = v
! 	    end
! 	  else
! 	    hash[name] = text if text.strip.size > 0
! 	  end
! 	end
! 	@program	= hash['BlastOutput_program']
! 	@version	= hash['BlastOutput_version']
! 	@reference	= hash['BlastOutput_reference']
! 	@db		= hash['BlastOutput_db']
! 	@query_id	= hash['BlastOutput_query-ID']
! 	@query_def	= hash['BlastOutput_query-def']
! 	@query_len	= hash['BlastOutput_query-len'].to_i
        end
  
        def rexml_parse_iteration(e)
! 	iteration = Iteration.new
! 	e.elements.each do |i|
! 	  case i.name
! 	  when 'Iteration_iter-num'
! 	    iteration.num = i.text.to_i
! 	  when 'Iteration_hits'
! 	    i.elements.each("Hit") do |h|
! 	      iteration.hits.push(rexml_parse_hit(h))
! 	    end
! 	  when 'Iteration_message'
! 	    iteration.message = i.text
! 	  when 'Iteration_stat'
! 	    i.elements["Statistics"].each_element_with_text do |s|
! 	      k = s.name.sub(/Statistics_/, '')
! 	      v = s.text =~ /\D/ ? s.text.to_f : s.text.to_i
! 	      iteration.statistics[k] = v
! 	    end
! 	  end
! 	end
! 	return iteration
        end
  
        def rexml_parse_hit(e)
! 	hit = Hit.new
! 	hash = {}
! 	hit.query_id = @query_id
! 	hit.query_def = @query_def
! 	hit.query_len = @query_len
! 	e.elements.each do |h|
! 	  case h.name
! 	  when 'Hit_hsps'
! 	    h.elements.each("Hsp") do |s|
! 	      hit.hsps.push(rexml_parse_hsp(s))
! 	    end
! 	  else
! 	    hash[h.name] = h.text
! 	  end
! 	end
! 	hit.num		= hash['Hit_num'].to_i
! 	hit.hit_id	= hash['Hit_id']
! 	hit.len		= hash['Hit_len'].to_i
! 	hit.definition	= hash['Hit_def']
! 	hit.accession	= hash['Hit_accession']
! 	return hit
        end
  
        def rexml_parse_hsp(e)
! 	hsp = Hsp.new
! 	hash = {}
! 	e.each_element_with_text do |h|
! 	  hash[h.name] = h.text
! 	end
! 	hsp.num			= hash['Hsp_num'].to_i
! 	hsp.bit_score		= hash['Hsp_bit-score'].to_f
! 	hsp.score		= hash['Hsp_score'].to_i
! 	hsp.evalue		= hash['Hsp_evalue'].to_f
! 	hsp.query_from		= hash['Hsp_query-from'].to_i
! 	hsp.query_to		= hash['Hsp_query-to'].to_i
! 	hsp.hit_from		= hash['Hsp_hit-from'].to_i
! 	hsp.hit_to		= hash['Hsp_hit-to'].to_i
! 	hsp.pattern_from	= hash['Hsp_pattern-from'].to_i
! 	hsp.pattern_to		= hash['Hsp_pattern-to'].to_i
! 	hsp.query_frame		= hash['Hsp_query-frame'].to_i
! 	hsp.hit_frame		= hash['Hsp_hit-frame'].to_i
! 	hsp.identity		= hash['Hsp_identity'].to_i
! 	hsp.positive		= hash['Hsp_positive'].to_i
! 	hsp.gaps		= hash['Hsp_gaps'].to_i
! 	hsp.align_len		= hash['Hsp_align-len'].to_i
! 	hsp.density		= hash['Hsp_density'].to_i
! 	hsp.qseq		= hash['Hsp_qseq']
! 	hsp.hseq		= hash['Hsp_hseq']
! 	hsp.midline		= hash['Hsp_midline']
! 	return hsp
        end
  
--- 33,141 ----
  
        def rexml_parse(xml)
!         dom = REXML::Document.new(xml)
!         rexml_parse_program(dom)
!         dom.elements.each("*//Iteration") do |e|
!           @iterations.push(rexml_parse_iteration(e))
!         end
        end
  
        def rexml_parse_program(dom)
!         hash = {}
!         dom.root.each_element_with_text do |e|
!           name, text = e.name, e.text
!           case name
!           when 'BlastOutput_param'
!             e.elements["Parameters"].each_element_with_text do |p|
!               k = p.name.sub(/Parameters_/, '')
!               v = p.text =~ /\D/ ? p.text : p.text.to_i
!               @parameters[k] = v
!             end
!           else
!             hash[name] = text if text.strip.size > 0
!           end
!         end
!         @program	= hash['BlastOutput_program']
!         @version	= hash['BlastOutput_version']
!         @reference	= hash['BlastOutput_reference']
!         @db		= hash['BlastOutput_db']
!         @query_id	= hash['BlastOutput_query-ID']
!         @query_def	= hash['BlastOutput_query-def']
!         @query_len	= hash['BlastOutput_query-len'].to_i
        end
  
        def rexml_parse_iteration(e)
!         iteration = Iteration.new
!         e.elements.each do |i|
!           case i.name
!           when 'Iteration_iter-num'
!             iteration.num = i.text.to_i
!           when 'Iteration_hits'
!             i.elements.each("Hit") do |h|
!               iteration.hits.push(rexml_parse_hit(h))
!             end
!           when 'Iteration_message'
!             iteration.message = i.text
!           when 'Iteration_stat'
!             i.elements["Statistics"].each_element_with_text do |s|
!               k = s.name.sub(/Statistics_/, '')
!               v = s.text =~ /\D/ ? s.text.to_f : s.text.to_i
!               iteration.statistics[k] = v
!             end
!           end
!         end
!         return iteration
        end
  
        def rexml_parse_hit(e)
!         hit = Hit.new
!         hash = {}
!         hit.query_id = @query_id
!         hit.query_def = @query_def
!         hit.query_len = @query_len
!         e.elements.each do |h|
!           case h.name
!           when 'Hit_hsps'
!             h.elements.each("Hsp") do |s|
!               hit.hsps.push(rexml_parse_hsp(s))
!             end
!           else
!             hash[h.name] = h.text
!           end
!         end
!         hit.num		= hash['Hit_num'].to_i
!         hit.hit_id	= hash['Hit_id']
!         hit.len		= hash['Hit_len'].to_i
!         hit.definition	= hash['Hit_def']
!         hit.accession	= hash['Hit_accession']
!         return hit
        end
  
        def rexml_parse_hsp(e)
!         hsp = Hsp.new
!         hash = {}
!         e.each_element_with_text do |h|
!           hash[h.name] = h.text
!         end
!         hsp.num			= hash['Hsp_num'].to_i
!         hsp.bit_score		= hash['Hsp_bit-score'].to_f
!         hsp.score		= hash['Hsp_score'].to_i
!         hsp.evalue		= hash['Hsp_evalue'].to_f
!         hsp.query_from		= hash['Hsp_query-from'].to_i
!         hsp.query_to		= hash['Hsp_query-to'].to_i
!         hsp.hit_from		= hash['Hsp_hit-from'].to_i
!         hsp.hit_to		= hash['Hsp_hit-to'].to_i
!         hsp.pattern_from	= hash['Hsp_pattern-from'].to_i
!         hsp.pattern_to		= hash['Hsp_pattern-to'].to_i
!         hsp.query_frame		= hash['Hsp_query-frame'].to_i
!         hsp.hit_frame		= hash['Hsp_hit-frame'].to_i
!         hsp.identity		= hash['Hsp_identity'].to_i
!         hsp.positive		= hash['Hsp_positive'].to_i
!         hsp.gaps		= hash['Hsp_gaps'].to_i
!         hsp.align_len		= hash['Hsp_align-len'].to_i
!         hsp.density		= hash['Hsp_density'].to_i
!         hsp.qseq		= hash['Hsp_qseq']
!         hsp.hseq		= hash['Hsp_hseq']
!         hsp.midline		= hash['Hsp_midline']
!         return hsp
        end
  

Index: format0.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/blast/format0.rb,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** format0.rb	7 Aug 2005 16:42:28 -0000	1.9
--- format0.rb	8 Sep 2005 01:22:08 -0000	1.10
***************
*** 34,280 ****
  
        class Report #< DB
! 	DELIMITER = RS = "\nBLAST"
  
! 	def self.open(filename, *mode)
! 	  Bio::FlatFile.open(self, filename, *mode)
! 	end
  
! 	def initialize(str)
! 	  str = str.sub(/\A\s+/, '')
[...1502 lines suppressed...]
!             end #unless
!           end #def
!           private :parse_alignment
  
!           def self.method_after_parse_alignment(*names)
!             names.each do |x|
!               module_eval("def #{x}; parse_alignment; @#{x}; end")
!             end
!           end
!           private_class_method :method_after_parse_alignment
!           method_after_parse_alignment :qseq, :hseq, :midline,
!             :query_from, :query_to, :hit_from, :hit_to
!         end #class HSP
  
        end #class Report
  
        class Report_TBlast < Report
!         DELIMITER = RS = "\nTBLAST"
        end #class Report_TBlast
  



More information about the bioruby-cvs mailing list