Class: Sequest::PepXML::SearchHit::ModificationInfo

Inherits:
Object
  • Object
show all
Includes:
SpecIDXML
Defined in:
lib/ms/sequest/pepxml.rb

Overview

Positions and masses of modifications

Constant Summary collapse

ModAminoacidMass =
Arrayclass.new(%w(position mass))

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_pepxml_node(node) ⇒ Object



1433
1434
1435
# File 'lib/ms/sequest/pepxml.rb', line 1433

def self.from_pepxml_node(node)
  self.new.from_pepxml_node(node)
end

Instance Method Details

#from_pepxml_node(node) ⇒ Object

returns self



1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
# File 'lib/ms/sequest/pepxml.rb', line 1438

def from_pepxml_node(node)
  self[0] = node['modified_peptide'] 
  self[2] = node['mod_nterm_mass']
  self[3] = node['mod_cterm_mass']
  masses = []
  node.children do |mass_n|
    masses << Sequest::PepXML::SearchHit::ModificationInfo::ModAminoacidMass.new([mass_n['position'].to_i, mass_n['mass'].to_f])
  end
  self[1] = masses
  self 
end

#to_pepxmlObject

Will escape any xml special chars in modified_peptide



1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
# File 'lib/ms/sequest/pepxml.rb', line 1409

def to_pepxml
  ## Collect the modifications:
  mod_strings = []
  if masses and masses.size > 0
    mod_strings = masses.map do |ar|
      "position=\"#{ar[0]}\" mass=\"#{ar[1]}\""
    end
  end
  ## Create the attribute string:
  att_parts = []
  if mod_nterm_mass
    att_parts << "mod_nterm_mass=\"#{mod_nterm_mass}\""
  end
  if mod_cterm_mass
    att_parts << "mod_cterm_mass=\"#{mod_cterm_mass}\""
  end
  if modified_peptide
    att_parts << "modified_peptide=\"#{escape_special_chars(modified_peptide)}\""
  end
  element_xml_and_att_string('modification_info', att_parts.join(" ")) do
    mod_strings.map {|st| short_element_xml_and_att_string('mod_aminoacid_mass', st) }.join
  end
end