Class: MzID::ParserSax::PeptideHandler
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- MzID::ParserSax::PeptideHandler
- Defined in:
- lib/mzid/parser_sax.rb
Overview
handler for Peptide elements
Constant Summary collapse
- ATTR =
[:Peptide, :PeptideSequence, :Modification]
Instance Attribute Summary collapse
-
#mod_h ⇒ Object
Returns the value of attribute mod_h.
-
#pbar ⇒ Object
Returns the value of attribute pbar.
-
#pep_h ⇒ Object
Returns the value of attribute pep_h.
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(num_pep = nil) ⇒ PeptideHandler
constructor
A new instance of PeptideHandler.
- #start_element(name) ⇒ Object
- #text(value) ⇒ Object
Constructor Details
#initialize(num_pep = nil) ⇒ PeptideHandler
Returns a new instance of PeptideHandler.
79 80 81 82 83 |
# File 'lib/mzid/parser_sax.rb', line 79 def initialize(num_pep=nil) @pbar = num_pep.nil? ? nil : ProgressBar.new("Peptides", num_pep) @pep_h = Hash.new @mod_h = Hash.new end |
Instance Attribute Details
#mod_h ⇒ Object
Returns the value of attribute mod_h.
85 86 87 |
# File 'lib/mzid/parser_sax.rb', line 85 def mod_h @mod_h end |
#pbar ⇒ Object
Returns the value of attribute pbar.
85 86 87 |
# File 'lib/mzid/parser_sax.rb', line 85 def @pbar end |
#pep_h ⇒ Object
Returns the value of attribute pep_h.
85 86 87 |
# File 'lib/mzid/parser_sax.rb', line 85 def pep_h @pep_h end |
Instance Method Details
#attr(name, value) ⇒ Object
93 94 95 96 97 |
# File 'lib/mzid/parser_sax.rb', line 93 def attr(name, value) return unless ATTR.include?(@curr_node) @h[name] = value if @curr_node != :Modification @mh.push(value) if @curr_node == :Modification end |
#end_element(name) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mzid/parser_sax.rb', line 104 def end_element(name) return unless name == :Peptide @pbar.inc if !@pbar.nil? @pep_h[@h[:id].to_sym] = @h[:PeptideSequence] if !@mh.empty? then @mod_h[@h[:id].to_sym] = {} (1..@mh.size-1).step(2) do |i| @mod_h[@h[:id].to_sym][@mh[i].to_i] = @mh[i-1] end end end |
#start_element(name) ⇒ Object
87 88 89 90 91 |
# File 'lib/mzid/parser_sax.rb', line 87 def start_element(name) @h = {} if name == :Peptide @mh = [] if name == :Peptide @curr_node = name end |
#text(value) ⇒ Object
99 100 101 102 |
# File 'lib/mzid/parser_sax.rb', line 99 def text(value) return unless ATTR.include?(@curr_node) @h[@curr_node] = value end |