Class: Bio::LazyBlast::Report
- Inherits:
-
Object
- Object
- Bio::LazyBlast::Report
- Includes:
- Enumerable
- Defined in:
- lib/bio/appl/blast/lazyblastxml.rb
Defined Under Namespace
Classes: Iteration
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#program ⇒ Object
readonly
Returns the value of attribute program.
-
#query_def ⇒ Object
readonly
Returns the value of attribute query_def.
-
#query_id ⇒ Object
readonly
Returns the value of attribute query_id.
-
#query_len ⇒ Object
readonly
Returns the value of attribute query_len.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #each ⇒ Object (also: #each_iteration)
-
#initialize(filename) ⇒ Report
constructor
A new instance of Report.
- #rewind ⇒ Object
- #setup_report_values ⇒ Object
Constructor Details
#initialize(filename) ⇒ Report
Returns a new instance of Report.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 9 def initialize(filename) @filename = filename @reader = LibXML::XML::Reader.file(@filename) @nodes = Enumerator.new do |yielder| while @reader.read yielder << @reader if @reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT end end setup_report_values end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def db @db end |
#program ⇒ Object (readonly)
Returns the value of attribute program.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def program @program end |
#query_def ⇒ Object (readonly)
Returns the value of attribute query_def.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def query_def @query_def end |
#query_id ⇒ Object (readonly)
Returns the value of attribute query_id.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def query_id @query_id end |
#query_len ⇒ Object (readonly)
Returns the value of attribute query_len.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def query_len @query_len end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def statistics @statistics end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 7 def version @version end |
Instance Method Details
#each ⇒ Object Also known as: each_iteration
51 52 53 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 51 def each @nodes.each{|node| yield Iteration.new(node) if node.name == "Iteration"} end |
#rewind ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 56 def rewind @reader.close @reader = LibXML::XML::Reader.file(@filename) @nodes = Enumerator.new do |yielder| while @reader.read yielder << @reader if @reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT end end end |
#setup_report_values ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bio/appl/blast/lazyblastxml.rb', line 20 def setup_report_values @statistics = Hash.new @nodes.each do |node| return if node.name == "BlastOutput_iterations" case node.name when 'BlastOutput_program' @program = node.read_inner_xml when 'BlastOutput_version' @version = node.read_inner_xml when 'BlastOutput_db' @db = node.read_inner_xml when 'BlastOutput_query-ID' @query_id = node.read_inner_xml when 'BlastOutput_query-def' @query_def = node.read_inner_xml when 'BlastOutput_query-len' @query_len = node.read_inner_xml.to_i when 'Parameters_matrix' @statistics['matrix'] = node.read_inner_xml when 'Parameters_expect' @statistics['expect'] = node.read_inner_xml.to_i when 'Parameters_gap-open' @statistics['gap-open'] = node.read_inner_xml.to_i when 'Parameters_gap-extend' @statistics['gap-extend'] = node.read_inner_xml.to_i when 'Parameters_filter' @statistics['filter'] = node.read_inner_xml end end end |