class Ms::Ident::Pepxml::SpectrumQuery

search_specification is a search constraint applied specifically to this query (a String)

Constants

DEFAULT_MEMBERS
Optional
Required

Attributes

members[W]

Public Class Methods

calc_precursor_neutral_mass(m_plus_h, deltamass, h_plus=Ms::Mass::H_PLUS) click to toggle source
# File lib/ms/ident/pepxml/spectrum_query.rb, line 80
def self.calc_precursor_neutral_mass(m_plus_h, deltamass, h_plus=Ms::Mass::H_PLUS)
  m_plus_h - h_plus + deltamass
end
from_pepxml_node(node) click to toggle source
# File lib/ms/ident/pepxml/spectrum_query.rb, line 66
def self.from_pepxml_node(node)
  self.new.from_pepxml_node(node)
end
members() click to toggle source
# File lib/ms/ident/pepxml/spectrum_query.rb, line 18
def members
  @members || DEFAULT_MEMBERS
end
new(*args, &block) click to toggle source

takes either a hash or an ordered list of values to set yeilds an empty search_results array if given a block

# File lib/ms/ident/pepxml/spectrum_query.rb, line 30
def initialize(*args, &block)
  @search_results = [] 
  if args.first.is_a?(Hash)
    merge!(args.first)
  else
    self.class.members.zip(args) do |k,v|
      send("#{k}=", v)
    end
  end
  block.call(@search_results) if block
end

Public Instance Methods

from_pepxml_node(node) click to toggle source
# File lib/ms/ident/pepxml/spectrum_query.rb, line 70
def from_pepxml_node(node)
  @spectrum = node['spectrum']
  @start_scan = node['start_scan'].to_i
  @end_scan = node['end_scan'].to_i
  @precursor_neutral_mass = node['precursor_neutral_mass'].to_f
  @index = node['index'].to_i
  @assumed_charge = node['assumed_charge'].to_i
  self
end
members() click to toggle source
# File lib/ms/ident/pepxml/spectrum_query.rb, line 42
def members
  self.class.members
end
to_xml(builder=nil) click to toggle source

FOR PEPXML:

# File lib/ms/ident/pepxml/spectrum_query.rb, line 49
def to_xml(builder=nil)
  xmlb = builder || Nokogiri::XML::Builder.new
  # all through search_specification
  attrs = members[0, 8].map {|at| v=send(at) ; [at, v] if v }
  attrs_hash = Hash[attrs]
  case pepxml_version
  when 18
    attrs_hash.delete(:retention_time_sec)
  end
  xmlb.spectrum_query(attrs_hash) do |xmlb|
    search_results.each do |search_result|
      search_result.to_xml(xmlb) 
    end
  end
  builder || xmlb.doc.root.to_xml
end