Class: MzID::ParserSax::SpectraIDHandler
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- MzID::ParserSax::SpectraIDHandler
- Defined in:
- lib/mzid/parser_sax.rb
Overview
handler for SpectrumIDItem elements
Constant Summary collapse
- ATTR =
[:SpectrumIdentificationItem, :PeptideEvidenceRef]
- SPEC_ATTR_MAP =
[:peptide_ref, :id, :passThreshold]
- SPEC_PROB_ATTR_MAP =
[:accession, :value]
- SPEC_PROB_ACC =
code for spec-prob
"MS:1002052"
Instance Attribute Summary collapse
-
#pbar ⇒ Object
Returns the value of attribute pbar.
-
#spec_h ⇒ Object
Returns the value of attribute spec_h.
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #attrs_done ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(dbseq_h, pep_h, pep_ev_h, block, num_spec = nil) ⇒ SpectraIDHandler
constructor
A new instance of SpectraIDHandler.
- #start_element(name) ⇒ Object
Constructor Details
#initialize(dbseq_h, pep_h, pep_ev_h, block, num_spec = nil) ⇒ SpectraIDHandler
Returns a new instance of SpectraIDHandler.
161 162 163 164 165 166 167 168 |
# File 'lib/mzid/parser_sax.rb', line 161 def initialize(dbseq_h, pep_h, pep_ev_h, block, num_spec=nil) @yield_to = block @dbseq_h = dbseq_h @pep_h = pep_h @pep_ev_h = pep_ev_h @spec_h = Hash.new @pbar = num_spec.nil? ? nil : ProgressBar.new("Spectra", num_spec) end |
Instance Attribute Details
#pbar ⇒ Object
Returns the value of attribute pbar.
170 171 172 |
# File 'lib/mzid/parser_sax.rb', line 170 def @pbar end |
#spec_h ⇒ Object
Returns the value of attribute spec_h.
170 171 172 |
# File 'lib/mzid/parser_sax.rb', line 170 def spec_h @spec_h end |
Instance Method Details
#attr(name, value) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/mzid/parser_sax.rb', line 178 def attr(name, value) return unless ATTR.include?(@curr_node) || (@curr_node == :cvParam && SPEC_PROB_ATTR_MAP.include?(name)) @h_param[name] = value if !@h_param.nil? @h_param = {} if name == :accession && value == SPEC_PROB_ACC if name == :peptideEvidence_ref then # if peptideEvidence, force into list @h[name].nil? ? @h[name] = [value.to_sym] : @h[name].push(value.to_sym) end @h[name] = value.to_sym if SPEC_ATTR_MAP.include?(name) @h[name] = value.split("_")[1].to_i if name == :id end |
#attrs_done ⇒ Object
191 192 193 194 |
# File 'lib/mzid/parser_sax.rb', line 191 def attrs_done() return unless (!@h_param.nil? && !@h.nil?) @h[:spec_prob] = @h_param[:value].to_f end |
#end_element(name) ⇒ Object
196 197 198 199 200 |
# File 'lib/mzid/parser_sax.rb', line 196 def end_element(name) return unless name == :SpectrumIdentificationItem @yield_to.call(@h) @pbar.inc if !@pbar.nil? end |
#start_element(name) ⇒ Object
172 173 174 175 176 |
# File 'lib/mzid/parser_sax.rb', line 172 def start_element(name) @h = {} if name == :SpectrumIdentificationItem @curr_node = name @h_param = nil if name == :cvParam end |