Class: Mspire::Ident::Pepxml::SearchSummary

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

Constant Summary collapse

DEFAULT_SEARCH_ID =
'1'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Merge

#merge!

Constructor Details

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

initializes modifications to an empty array



58
59
60
61
62
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 58

def initialize(hash={}, &block)
  @modifications = []
  @search_id = DEFAULT_SEARCH_ID
  merge!(hash, &block)
end

Instance Attribute Details

#base_nameObject

Returns the value of attribute base_name.



26
27
28
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 26

def base_name
  @base_name
end

#enzymatic_search_constraintObject

An EnzymaticSearchConstraint object (at the moment this is merely a hash with a few required keys



47
48
49
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 47

def enzymatic_search_constraint
  @enzymatic_search_constraint
end

#fragment_mass_typeObject

required: ‘average’ or ‘monoisotopic’



44
45
46
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 44

def fragment_mass_type
  @fragment_mass_type
end

#modificationsObject

an array of Mspire::Ident::Pepxml::Modification objects



34
35
36
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 34

def modifications
  @modifications
end

#out_dataObject

required in v18-19, optional in later versions



30
31
32
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 30

def out_data
  @out_data
end

#out_data_typeObject

required in v18-19, optional in later versions



28
29
30
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 28

def out_data_type
  @out_data_type
end

#parametersObject

the other search paramaters as a hash



38
39
40
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 38

def parameters
  @parameters
end

#precursor_mass_typeObject

required: ‘average’ or ‘monoisotopic’



42
43
44
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 42

def precursor_mass_type
  @precursor_mass_type
end

#search_databaseObject

A SearchDatabase object (responds to :local_path and :type)



36
37
38
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 36

def search_database
  @search_database
end

#search_engineObject

the search engine used, SEQUEST, Mascot, Comet, etc.



40
41
42
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 40

def search_engine
  @search_engine
end

#search_idObject

by default, “1”



32
33
34
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 32

def search_id
  @search_id
end

Class Method Details

.from_pepxml_node(node) ⇒ Object



81
82
83
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 81

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

Instance Method Details

#block_argObject



49
50
51
52
53
54
55
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 49

def block_arg
  [@search_database = Mspire::Ident::Pepxml::SearchDatabase.new,
    @enzymatic_search_constraint = Mspire::Ident::Pepxml::EnzymaticSearchConstraint.new,
    @modifications,
    @parameters = Mspire::Ident::Pepxml::Parameters.new,
  ]
end

#from_pepxml_node(node) ⇒ Object

Raises:

  • (NotImplementedError)


85
86
87
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 85

def from_pepxml_node(node)
  raise NotImplementedError, "not implemented just yet (just use the raw xml node)"
end

#to_xml(builder = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/mspire/ident/pepxml/search_summary.rb', line 64

def to_xml(builder=nil)
  # TODO: out_data and out_data_type are optional in later pepxml versions...
  # should work that in...
  attrs = [:base_name, :search_engine, :precursor_mass_type, :fragment_mass_type, :out_data_type, :out_data, :search_id]
  hash = Hash[ attrs.map {|at| v=send(at) ; [at, v] if v }.compact ]
  xmlb = builder || Nokogiri::XML::Builder.new
  builder.search_summary(hash) do |xmlb|
    search_database.to_xml(xmlb)
    xmlb.enzymatic_search_constraint(enzymatic_search_constraint) if enzymatic_search_constraint
    modifications.each do |mod|
      mod.to_xml(xmlb)
    end
    parameters.to_xml(xmlb) if parameters
  end
  builder || xmlb.doc.root.to_xml 
end