Class: Bio::LazyBlast::Report::Iteration

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bio/appl/blast/lazyblastxml.rb

Defined Under Namespace

Classes: Hit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader) ⇒ Iteration

Returns a new instance of Iteration.



70
71
72
73
74
75
76
77
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 70

def initialize(reader)
  @nodes = Enumerator.new do |yielder|
    until (reader.name == "Iteration" and reader.node_type == LibXML::XML::Reader::TYPE_END_ELEMENT) or !reader.read
      yielder << reader if reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT
    end
  end
  setup_iteration_values
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def message
  @message
end

#numObject (readonly)

Returns the value of attribute num.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def num
  @num
end

#parametersObject (readonly)

Returns the value of attribute parameters.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def parameters
  @parameters
end

#query_defObject (readonly)

Returns the value of attribute query_def.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def query_def
  @query_def
end

#query_idObject (readonly)

Returns the value of attribute query_id.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def query_id
  @query_id
end

#query_lenObject (readonly)

Returns the value of attribute query_len.



68
69
70
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 68

def query_len
  @query_len
end

Instance Method Details

#eachObject Also known as: each_hit



97
98
99
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 97

def each
  @nodes.each{|node| yield Hit.new(node) if node.name == "Hit"}
end

#setup_iteration_valuesObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 79

def setup_iteration_values
  @nodes.each do |node|
    return if node.name == 'Iteration_hits'
    case node.name
    when 'Iteration_iter-num'
      @num = node.read_inner_xml.to_i
    when 'Iteration_query-ID'
      @query_id = node.read_inner_xml
    when 'Iteration_query-def'
      @query_def = node.read_inner_xml
    when 'Iteration_query-len'
      @query_len = node.read_inner_xml.to_i
    when 'Iteration_message'
      @message = node.read_inner_xml
    end
  end
end