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

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

Defined Under Namespace

Classes: Hsp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader) ⇒ Hit

Returns a new instance of Hit.



106
107
108
109
110
111
112
113
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 106

def initialize(reader)
  @nodes = Enumerator.new do |yielder|
    until (reader.name == "Hit" 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_hit_values
end

Instance Attribute Details

#accessionObject (readonly)

Returns the value of attribute accession.



104
105
106
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 104

def accession
  @accession
end

#definitionObject (readonly)

Returns the value of attribute definition.



104
105
106
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 104

def definition
  @definition
end

#hit_idObject (readonly)

Returns the value of attribute hit_id.



104
105
106
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 104

def hit_id
  @hit_id
end

#lenObject (readonly)

Returns the value of attribute len.



104
105
106
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 104

def len
  @len
end

#numObject (readonly)

Returns the value of attribute num.



104
105
106
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 104

def num
  @num
end

Instance Method Details

#eachObject Also known as: each_hsp



133
134
135
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 133

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

#setup_hit_valuesObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 115

def setup_hit_values
  @nodes.each do |node|
    return if node.name == 'Hit_hsps'
    case node.name
    when 'Hit_num'
      @num = node.read_inner_xml.to_i
    when 'Hit_id'
      @hit_id = node.read_inner_xml.to_i
    when 'Hit_def'
      @definition = node.read_inner_xml
    when 'Hit_accession'
      @accession = node.read_inner_xml
    when 'Hit_len'
      @len = node.read_inner_xml
    end
  end
end