Class: Sequest::PepXML::SpectrumQuery

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.calc_precursor_neutral_mass(by, *args) ⇒ Object

Returns the precursor_neutral based on the scans and an array indexed by scan numbers. first and last scan and charge should be integers. This is the precursor_mz - h_plus! by=:prec_mz_arr|:deltamass if prec_mz_arr then the following arguments must be supplied: :first_scan = int, :last_scan = int, :prec_mz_arr = array with the precursor m/z for each product scan, :charge = int if deltamass then the following arguments must be supplied: m_plus_h = float, deltamass = float For both flavors, a final additional argument ‘average_weights’ can be used. If true (default), average weights will be used, if false, monoisotopic weights (currently this is simply the mass of the proton)



1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
# File 'lib/ms/sequest/pepxml.rb', line 1252

def self.calc_precursor_neutral_mass(by, *args)
  average_weights = true
  case by
  when :prec_mz_arr
    (first_scan, last_scan, prec_mz_arr, charge, average_weights) = args
  when :deltamass
    (m_plus_h, deltamass, average_weights) = args
  end

  if average_weights 
    mass_h_plus = SpecID::AVG[:h_plus] 
  else
    mass_h_plus = SpecID::MONO[:h_plus] 
  end

  case by
  when :prec_mz_arr
    mz = nil
    if first_scan != last_scan
      sum = 0.0
      tot_num = 0
      (first_scan..last_scan).each do |scan|
        val = prec_mz_arr[scan]
        if val  # if the scan is not an mslevel 2
          sum += val
          tot_num += 1
        end
      end
      mz = sum/tot_num
    else
      mz = prec_mz_arr[first_scan]
    end
    charge * (mz - mass_h_plus)
  when :deltamass
    m_plus_h - mass_h_plus + deltamass
  else
    abort "don't recognize 'by' in calc_precursor_neutral_mass: #{by}"
  end
end

.from_pepxml_node(node) ⇒ Object



1226
1227
1228
# File 'lib/ms/sequest/pepxml.rb', line 1226

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

Instance Method Details

#from_pepxml_node(node) ⇒ Object



1230
1231
1232
1233
1234
1235
1236
1237
1238
# File 'lib/ms/sequest/pepxml.rb', line 1230

def from_pepxml_node(node)
  self[0] = node['spectrum']
  self[1] = node['start_scan'].to_i
  self[2] = node['end_scan'].to_i
  self[3] = node['precursor_neutral_mass'].to_f
  self[4] = node['index'].to_i
  self[5] = node['assumed_charge'].to_i
  self
end

#to_pepxmlObject

FOR PEPXML:



1217
1218
1219
1220
1221
1222
1223
1224
# File 'lib/ms/sequest/pepxml.rb', line 1217

def to_pepxml
  case Sequest::PepXML.pepxml_version
  when 18
    element_xml("spectrum_query", [:spectrum, :start_scan, :end_scan, :precursor_neutral_mass, :assumed_charge, :index]) do
      search_results.collect { |sr| sr.to_pepxml }.join
    end
  end
end