class MzID::BaseParser

class to parse an mzIdentML file

Public Class Methods

new(file) click to toggle source
# File lib/mzid/base_parser.rb, line 10
def initialize(file)
  @mzid_file = file
end

Private Instance Methods

get_modifications(pep_node) click to toggle source

given an XML.parse output from the peptide block, extract modifications

# File lib/mzid/base_parser.rb, line 24
def get_modifications(pep_node)
  mods = pep_node.xpath('.//Modification')
  id = pep_node['id']
  mod_h = Hash.new
  # parse any modifications
  mods.each do |mod|
    loc = mod['location'].to_i-1
    delta_mass = mod['monoisotopicMassDelta'].to_f
    if !mod_h.empty? then 
      mod_h.merge!( loc => delta_mass )
    else
      mod_h = {mod['location'].to_i-1 => delta_mass}
    end
  end
  mod_h.empty? ? nil : mod_h
end
get_peptide_sequence(pnode) click to toggle source

given an XML.parse output from the peptide block, extract peptide sequence

# File lib/mzid/base_parser.rb, line 16
def get_peptide_sequence(pnode)
  plst = pnode.xpath('.//PeptideSequence')
  id = pnode['id']
  seq = plst[0].content
end