Class: SQT::Spectrum

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_id/sqt.rb

Overview

0=first_scan 1=last_scan 2=charge 3=time_to_process 4=node 5=mh 6=total_intensity 7=lowest_sp 8=num_matched_peptides 9=matches

Constant Summary collapse

Leader =
'S'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_deltacn(spectra) ⇒ Object



231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/spec_id/sqt.rb', line 231

def self.set_deltacn(spectra)
  spectra.each do |spec|
    matches = spec.matches
    if matches.size > 0

      (0...(matches.size-1)).each do |i|
        matches[i].deltacn = matches[i+1].deltacn_orig 
      end
      matches[-1].deltacn = 1.1
    end
  end
  spectra
end

.spectra_from_handle(fh, base_name, peps = [], global_ref_hash = {}, percolator_results = false) ⇒ Object

assumes the first line starts with an ā€˜Sā€™



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/spec_id/sqt.rb', line 187

def self.spectra_from_handle(fh, base_name, peps=[], global_ref_hash={}, percolator_results=false)
  spectra = []
  
  while line = fh.gets
    case line[0,1]
    when SQT::Spectrum::Leader
      spectrum = SQT::Spectrum.new.from_line( line )
      spectra << spectrum
      matches = []
      spectrum.matches = matches
    when SQT::Match::Leader
      match_klass = if percolator_results
                      SQT::Match::Percolator
                    else
                      SQT::Match
                    end
      match = match_klass.new.from_line( line )
      match[10,3] = spectrum[0,3]
      match[15] = base_name
      matches << match
      peps << match
      loci = []
      match.loci = loci
      matches << match
    when SQT::Locus::Leader
      line.chomp!
      key = line.split(SQT::Delimiter)[1]
      locus =
        if global_ref_hash.key?(key)
          global_ref_hash[key]
        else
          locus = SQT::Locus.new.from_line( line )
          locus.peps = []
          global_ref_hash[key] = locus
        end
      locus.peps << match
      loci << locus
    end
  end
  # set the deltacn:
  set_deltacn(spectra)
  spectra
end

Instance Method Details

#from_line(line) ⇒ Object

returns an array -> [the next spectra line (or nil if eof), spectrum]



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/spec_id/sqt.rb', line 247

def from_line(line)
  line.chomp!
  ar = line.split(SQT::Delimiter)
  self[0] = ar[1].to_i
  self[1] = ar[2].to_i
  self[2] = ar[3].to_i
  self[3] = ar[4].to_f
  self[4] = ar[5]
  self[5] = ar[6].to_f
  self[6] = ar[7].to_f
  self[7] = ar[8].to_f
  self[8] = ar[9].to_i
  self[9] = []
  self
end