Class: Mascot::DAT::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/mascot/dat/query.rb

Overview

A class to represent mass spectrum query objects in Mascot DAT files. Here is an example:

--gc0p4Jq0M2Yt08jU534c0p
Content-Type: application/x-Mascot; name="query3"

title=253%2e131203405971_503
rtinseconds=503
index=5
charge=2+
mass_min=88.063115
mass_max=392.171066
int_min=6.064e+05
int_max=6.064e+05
num_vals=10
num_used1=-1
Ions1=88.063115:6.064e+05,196.589171:6.064e+05,331.143454:6.064e+05,392.171066:6.064e+05,114.570773:6.064e+05,228.134269:6.064e+05,139.567707:6.064e+05,278.128138:6.064e+05,166.075365:6.064e+05,175.118953:6.064e+05

Things to note are:

* the spectrum title is encoded to produce nice output in HTML
* the m/z and intensity values are given as pairs of values
* the m/z and intensity values are not in increasing values of m/z

This parser accounts for these in the attributes like so:

* spectrum title is de-encoded
* the pairs of m/z and intensity are accessible via the {#peaks} method
* the {#peaks} are ordered in accordance to increasing m/z
* there are {#mz} and {#intensity} methods to get the individual array of values for each

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_str) ⇒ Query

Returns a new instance of Query.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/mascot/dat/query.rb', line 68

def initialize(query_str)
  query_str.split(/\n/).each do |l|
    next unless l =~ /(\w+)\=(.+)$/
    k,v = $1,$2
    case k
    when "name"
      @name = v.gsub('"','')
    when "title"
      @title = URI.decode(v)
    when "index"
      @index = v.to_i
    when "rtinseconds"
      @rtinseconds = v.to_i
    when "charge"
      @charge = v
    when "mass_min"
      @mass_min = v.to_f
    when "mass_max"
      @mass_max = v.to_f
    when "int_min"
      @int_min = v.to_f
    when "int_max"
      @int_max = v.to_f
    when "num_vals"
      @num_vals = v.to_i
    when "num_used1"
      @num_used1 = v.to_i
    when "Ions1"
      parse_ions1(v)
    else
      @attributes[k.to_sym] = v
    end
  end
end

Instance Attribute Details

#attributesObject (readonly)

All other attributes from DAT query sections not covered above



66
67
68
# File 'lib/mascot/dat/query.rb', line 66

def attributes
  @attributes
end

#chargeObject (readonly)

Charge state of the parent MS1 ion



45
46
47
# File 'lib/mascot/dat/query.rb', line 45

def charge
  @charge
end

#indexObject (readonly)

No clue what this is



41
42
43
# File 'lib/mascot/dat/query.rb', line 41

def index
  @index
end

#int_maxObject (readonly)

The maximum intensity of the values



53
54
55
# File 'lib/mascot/dat/query.rb', line 53

def int_max
  @int_max
end

#int_minObject (readonly)

The minimum intensity of the values



51
52
53
# File 'lib/mascot/dat/query.rb', line 51

def int_min
  @int_min
end

#intensityObject (readonly)

An Array of intensity values, ordered by the corresponding m/z value in the #mz Array



63
64
65
# File 'lib/mascot/dat/query.rb', line 63

def intensity
  @intensity
end

#mass_maxObject (readonly)

The maximum m/z of the values



49
50
51
# File 'lib/mascot/dat/query.rb', line 49

def mass_max
  @mass_max
end

#mass_minObject (readonly)

The minimum m/z of the values



47
48
49
# File 'lib/mascot/dat/query.rb', line 47

def mass_min
  @mass_min
end

#mzObject (readonly)

An Array of m/z values, ordered by increasing m/z



61
62
63
# File 'lib/mascot/dat/query.rb', line 61

def mz
  @mz
end

#nameObject (readonly)

The name of the query in Mascot DAT file, e.g. the MIME section header



37
38
39
# File 'lib/mascot/dat/query.rb', line 37

def name
  @name
end

#num_used1Object (readonly)

No clue what this is



57
58
59
# File 'lib/mascot/dat/query.rb', line 57

def num_used1
  @num_used1
end

#num_valsObject (readonly)

The number of peaks



55
56
57
# File 'lib/mascot/dat/query.rb', line 55

def num_vals
  @num_vals
end

#peaksObject (readonly)

An Array of [m/z, intensity] tuples, ordered by increasing m/z values



59
60
61
# File 'lib/mascot/dat/query.rb', line 59

def peaks
  @peaks
end

#rtinsecondsObject (readonly)

Retention time in seconds



43
44
45
# File 'lib/mascot/dat/query.rb', line 43

def rtinseconds
  @rtinseconds
end

#titleObject (readonly)

The spectrum title from the source mass spectrum file



39
40
41
# File 'lib/mascot/dat/query.rb', line 39

def title
  @title
end