class MzID::ParserSax::SpectraIDHandler

handler for SpectrumIDItem elements

Constants

ATTR
SPEC_ATTR_MAP
SPEC_PROB_ACC
SPEC_PROB_ATTR_MAP

Attributes

pbar[RW]
spec_h[RW]

Public Class Methods

new(dbseq_h, pep_h, pep_ev_h, block, num_spec=nil) click to toggle source
# 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

Public Instance Methods

attr(name, value) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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