Class: Ms::Ident::Pepxml::MsmsRunSummary

Inherits:
Object
  • Object
show all
Includes:
Merge
Defined in:
lib/ms/ident/pepxml/msms_run_summary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Merge

#merge!

Constructor Details

#initialize(hash = {}, &block) ⇒ MsmsRunSummary

takes a hash of name, value pairs if block given, yields a SampleEnzyme object, a SearchSummary and an array for SpectrumQueries



42
43
44
45
46
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 42

def initialize(hash={}, &block)
  @spectrum_queries = []
  merge!(hash, &block)
  block.call(block_arg) if block
end

Instance Attribute Details

#base_nameObject

The name of the pep xml file without any extension



15
16
17
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 15

def base_name
  @base_name
end

#ms_detectorObject

Returns the value of attribute ms_detector.



20
21
22
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 20

def ms_detector
  @ms_detector
end

#ms_ionizationObject

Returns the value of attribute ms_ionization.



23
24
25
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 23

def ms_ionization
  @ms_ionization
end

#ms_manufacturerObject

The name of the mass spec manufacturer



17
18
19
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 17

def ms_manufacturer
  @ms_manufacturer
end

#ms_mass_analyzerObject

Returns the value of attribute ms_mass_analyzer.



19
20
21
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 19

def ms_mass_analyzer
  @ms_mass_analyzer
end

#ms_modelObject

Returns the value of attribute ms_model.



18
19
20
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 18

def ms_model
  @ms_model
end

#pepxml_versionObject

Returns the value of attribute pepxml_version.



24
25
26
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 24

def pepxml_version
  @pepxml_version
end

#raw_dataObject

Returns the value of attribute raw_data.



22
23
24
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 22

def raw_data
  @raw_data
end

#raw_data_typeObject

Returns the value of attribute raw_data_type.



21
22
23
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 21

def raw_data_type
  @raw_data_type
end

#sample_enzymeObject

A SampleEnzyme object (responds to: name, cut, no_cut, sense)



27
28
29
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 27

def sample_enzyme
  @sample_enzyme
end

#search_summaryObject

A SearchSummary object



29
30
31
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 29

def search_summary
  @search_summary
end

#spectrum_queriesObject

An array of spectrum_queries



31
32
33
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 31

def spectrum_queries
  @spectrum_queries
end

Class Method Details

.from_pepxml_node(node) ⇒ Object



66
67
68
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 66

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

Instance Method Details

#block_argObject



33
34
35
36
37
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 33

def block_arg
  [@sample_enzyme = Ms::Ident::Pepxml::SampleEnzyme.new,    
    @search_summary = Ms::Ident::Pepxml::SearchSummary.new,
    @spectrum_queries ]
end

#from_pepxml_node(node) ⇒ Object

peps correspond to search_results



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 71

def from_pepxml_node(node)
  @base_name = node['base_name']
  @ms_manufacturer = node['msManufacturer']
  @ms_model = node['msModel']
  @ms_manufacturer = node['msIonization']
  @ms_mass_analyzer = node['msMassAnalyzer']
  @ms_detector = node['msDetector']
  @raw_data_type = node['raw_data_type']
  @raw_data = node['raw_data']
  self
end

#to_xml(builder = nil) ⇒ Object

optionally takes an xml builder object and returns the builder, or the xml string if no builder was given sets the index attribute of each spectrum query if it is not already set



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ms/ident/pepxml/msms_run_summary.rb', line 51

def to_xml(builder=nil)
  xmlb = builder || Nokogiri::XML::Builder.new
  hash = {:base_name => base_name, :msManufacturer => ms_manufacturer, :msModel => ms_model, :msIonization => ms_ionization, :msMassAnalyzer => ms_mass_analyzer, :msDetector => ms_detector, :raw_data_type => raw_data_type, :raw_data => raw_data}
  hash.each {|k,v| hash.delete(k) unless v }
  xmlb.msms_run_summary(hash) do |xmlb|
    sample_enzyme.to_xml(xmlb) if sample_enzyme
    search_summary.to_xml(xmlb) if search_summary
    spectrum_queries.each_with_index do |sq,i| 
      sq.index = i+1 unless sq.index
      sq.to_xml(xmlb)
    end
  end
  builder || xmlb.doc.root.to_xml
end