Class: Ms::Mascot::Dat::Query

Inherits:
Section
  • Object
show all
Includes:
Utils
Defined in:
lib/ms/mascot/dat/query.rb

Overview

Query is a generic section for all queryN sections. Query contains query data that has different meaning depending on the type of search performed. Here is data from an MS/MS search:

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

charge=3+
mass_min=50.175000
mass_max=1998.960000
int_min=0.0364
int_max=7366
num_vals=3411
num_used1=-1
Ions1=129.098825:384.8,187.070000:461.5...
...

Query is a standard Section and simply defines methods for convenient access. See Section for parsing details.

Defined Under Namespace

Modules: Utils

Constant Summary

Constants inherited from Section

Section::CONTENT_TYPE_REGEXP, Section::TO_S_FORMAT

Instance Attribute Summary collapse

Attributes inherited from Section

#dat, #data, #section_name

Instance Method Summary collapse

Methods included from Utils

parse_ions, scan_ions

Methods inherited from Section

parse, section_name, #to_s

Constructor Details

#initialize(data = {}, section_name = self.class.section_name, dat = nil) ⇒ Query

Returns a new instance of Query.



88
89
90
91
92
93
# File 'lib/ms/mascot/dat/query.rb', line 88

def initialize(data={}, section_name=self.class.section_name, dat=nil)
  super(data, section_name, dat)
  data['title'] = Rack::Utils.unescape(data['title'].to_s)
  @index = section_name.strip[5..-1].to_i
  @ions=[]
end

Instance Attribute Details

#indexObject (readonly)

Returns the query index for self (ie 60 when section_name is ‘query60’)



86
87
88
# File 'lib/ms/mascot/dat/query.rb', line 86

def index
  @index
end

Instance Method Details

#ion_str(n = 1) ⇒ Object

Returns the nth ion string in self.



96
97
98
# File 'lib/ms/mascot/dat/query.rb', line 96

def ion_str(n=1)
  data["Ions#{n}"]
end

#ions(n = 1) ⇒ Object

Returns a simple array of the parsed nth ion string.



101
102
103
# File 'lib/ms/mascot/dat/query.rb', line 101

def ions(n=1)
  @ions[n] ||= parse_ions(ion_str(n))
end

#titleObject



105
106
107
# File 'lib/ms/mascot/dat/query.rb', line 105

def title
  data['title']
end

#to_mgf(pepmass, opts = {}) ⇒ Object

returns a Ms::Mascot::Mgf::Entry object.

pepmass may be a Numeric OR a PeptideHit object (extracting the pepmass by PeptideHit#peptide_mass + PeptideHit#delta_mass options are:

:valid_headers = true (default) | false


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/ms/mascot/dat/query.rb', line 124

def to_mgf(pepmass, opts={})
  opts = {:valid_headers => true}.merge(opts)
  valid_headers = opts[:valid_headers]
  header = {}
  header['PEPMASS'] = 
    if pepmass.is_a? Numeric
      pepmass
    else
      hit = pepmass
      hit.peptide_mass + hit.delta_mass
    end
  data.each_pair do |key,value|
    up = key.to_s.upcase
    next if key =~ /Ions/ 
    next if valid_headers && !Ms::Mascot::Mgf::VALID_LOCAL_HEADERS.include?(up)
    header[up] = value
  end
  # note that we sort the ions because I think I've seen files without
  # them being sorted
  Ms::Mascot::Mgf::Entry.new(header, self.ions.sort)
end