Class: Bio::BlastXMLParser::NokogiriBlastIterator

Inherits:
Object
  • Object
show all
Includes:
MapXPath
Defined in:
lib/bio/db/blast/parser/nokogiri.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MapXPath

#[], define_f, define_i, define_s

Methods included from XPath

#field

Constructor Details

#initialize(iterator, parent, opts = { :prefix => nil }) ⇒ NokogiriBlastIterator

Returns a new instance of NokogiriBlastIterator.



140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 140

def initialize iterator, parent, opts = { :prefix => nil }
  @parent = parent
  @prefix = opts[:prefix]
  @xml = if iterator.name == 'document'
           iterator.children.first
         else
           iterator
         end
  name2 = @xml.name
  raise "Error in BLAST XML, expected Iteration node, but got #{name2}" if name2 != 'Iteration'
  # p [:iter,@prefix,'@@Iteratition_iter-num',field('Iteration_iter-num')]
  # print @xml.to_s
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



132
133
134
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 132

def parent
  @parent
end

Instance Method Details

#eachObject



168
169
170
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 168

def each
  hits.each { | h | yield h }
end

#hitsObject



154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 154

def hits
  Enumerator.new { |yielder|
    @xml.children.each do | iter_field |
      if iter_field.name == 'Iteration_hits'
        iter_field.children.each do | hit |
          if hit.name == 'Hit'
            yielder.yield NokogiriBlastHit.new(hit,self)
          end
        end
      end
    end
  }
end

#to_sObject



172
173
174
175
176
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 172

def to_s
  s = <<EOM
iter_num=#{iter_num}, query_id=#{query_id}
EOM
end