Class: Mascot::MGF::Query
- Inherits:
-
Object
- Object
- Mascot::MGF::Query
- Defined in:
- lib/mascot/mgf/query.rb
Instance Attribute Summary collapse
-
#charge ⇒ Object
Returns the value of attribute charge.
-
#entry ⇒ Object
Returns the value of attribute entry.
-
#ions ⇒ Object
Returns the value of attribute ions.
-
#pepmass ⇒ Object
Returns the value of attribute pepmass.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(entry = nil) ⇒ Query
constructor
Initializes a spectrum entry from a MGF formatted string or from an Array that is the newline split of MGF ‘BEGIN IONSn…nEND IONS’.
- #method_missing(m) ⇒ Object
-
#to_s ⇒ Object
Returns the formatted MGF entry string.
Constructor Details
#initialize(entry = nil) ⇒ Query
Initializes a spectrum entry from a MGF formatted string or from an Array that is the newline split of MGF ‘BEGIN IONSn…nEND IONS’
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mascot/mgf/query.rb', line 9 def initialize(entry=nil) if entry.kind_of? String entry = entry.split(/\n/) end @title = 'id=1' @pepmass = [] @atts = {} @ions = [] @charge = nil parse(entry) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/mascot/mgf/query.rb', line 34 def method_missing(m) if @atts.has_key? m.to_sym return @atts[m.to_sym] else return nil end end |
Instance Attribute Details
#charge ⇒ Object
Returns the value of attribute charge.
5 6 7 |
# File 'lib/mascot/mgf/query.rb', line 5 def charge @charge end |
#entry ⇒ Object
Returns the value of attribute entry.
5 6 7 |
# File 'lib/mascot/mgf/query.rb', line 5 def entry @entry end |
#ions ⇒ Object
Returns the value of attribute ions.
5 6 7 |
# File 'lib/mascot/mgf/query.rb', line 5 def ions @ions end |
#pepmass ⇒ Object
Returns the value of attribute pepmass.
5 6 7 |
# File 'lib/mascot/mgf/query.rb', line 5 def pepmass @pepmass end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/mascot/mgf/query.rb', line 5 def title @title end |
Instance Method Details
#to_s ⇒ Object
Returns the formatted MGF entry string
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mascot/mgf/query.rb', line 22 def to_s tmp = "BEGIN IONS\nTITLE=#{@title}\n" tmp += "PEPMASS=#{@pepmass.join(' ')}\n" if @pepmass.length > 0 tmp += "CHARGE=#{@charge}+\n" if @charge @atts.each_pair do |k,v| tmp += "#{k.to_s.upcase}=#{v}\n" end tmp += @ions.collect { |i| i.join(" ")}.join("\n") tmp += "\nEND IONS\n" return tmp end |