Class: Bioworks::XMLParser

Inherits:
XMLParser
  • Object
show all
Defined in:
lib/ms/sequest/bioworks.rb

Overview

Implements fast parsing via XMLParser (wrapper around Expat) It is actually slower (about %25 slower) than regular expression parsing

Constant Summary collapse

@@at =
'@'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXMLParser

Returns a new instance of XMLParser.



245
246
247
248
249
250
251
# File 'lib/ms/sequest/bioworks.rb', line 245

def initialize
  @current_obj = nil
  @current_hash = {}
  @current_name = nil
  @current_data = nil
  @prots = []
end

Instance Attribute Details

#protsObject

Returns the value of attribute prots.



243
244
245
# File 'lib/ms/sequest/bioworks.rb', line 243

def prots
  @prots
end

Instance Method Details

#character(data) ⇒ Object



286
287
288
# File 'lib/ms/sequest/bioworks.rb', line 286

def character(data)
  @current_data = data
end

#endElement(name) ⇒ Object



276
277
278
279
280
281
282
283
284
# File 'lib/ms/sequest/bioworks.rb', line 276

def endElement(name)
  case name
  when "peptide"
    @current_obj.set_from_hash_given_text(@current_hash)
  when "protein"
  else
    @current_hash[name] = @current_data
  end
end

#startElement(name, attrs) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/ms/sequest/bioworks.rb', line 253

def startElement(name, attrs)
  case name
  when "peptide"
    curr_prot = @current_obj
    if @current_obj.class == Bioworks::Prot
      @current_obj.set_from_xml_hash_xmlparser(@current_hash)
    else
      curr_prot = @current_obj.prot  ## unless previous was a peptide
    end
    peptide = Bioworks::Pep.new
    peptide.prot = curr_prot
    curr_prot.peps << peptide
    @current_obj = peptide
    @current_hash = {}
  when "protein"
    @current_obj = Bioworks::Prot.new
    @current_hash = {}
    @prots << @current_obj
  else
    @current_name = name  
  end
end