Class: Bioworks::Prot

Inherits:
Object
  • Object
show all
Includes:
XML, ProteinReferenceable, SpecID::Prot
Defined in:
lib/ms/sequest/bioworks.rb

Constant Summary collapse

@@end_prot_re =
/<\/protein>/o
@@pep_re =
/<peptide>/o
@@atts =
%w(reference protein_probability consensus_score sf unified_score coverage pi weight accession peps)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProt

Returns a new instance of Prot.



307
308
309
310
# File 'lib/ms/sequest/bioworks.rb', line 307

def initialize
  @peps = []
  @peptide_hit_counts = [0,0,0,0,0,0]
end

Instance Attribute Details

#accessionObject

Returns the value of attribute accession.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def accession
  @accession
end

#bioworksObject

Returns the value of attribute bioworks.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def bioworks
  @bioworks
end

#consensus_scoreObject

Returns the value of attribute consensus_score.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def consensus_score
  @consensus_score
end

#coverageObject

Returns the value of attribute coverage.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def coverage
  @coverage
end

#pepsObject

Returns the value of attribute peps.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def peps
  @peps
end

#peptide_hit_countsObject

Returns the value of attribute peptide_hit_counts.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def peptide_hit_counts
  @peptide_hit_counts
end

#piObject

Returns the value of attribute pi.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def pi
  @pi
end

#protein_probabilityObject

Returns the value of attribute protein_probability.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def protein_probability
  @protein_probability
end

#referenceObject

Returns the value of attribute reference.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def reference
  @reference
end

#sfObject

Returns the value of attribute sf.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def sf
  @sf
end

#unified_scoreObject

Returns the value of attribute unified_score.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def unified_score
  @unified_score
end

#weightObject

Returns the value of attribute weight.



305
306
307
# File 'lib/ms/sequest/bioworks.rb', line 305

def weight
  @weight
end

Instance Method Details

#get(*args) ⇒ Object

returns array of values of the attributes given (as symbols)



314
315
316
317
318
# File 'lib/ms/sequest/bioworks.rb', line 314

def get(*args)
  args.collect do |arg|
    send(arg)
  end
end

#set_from_xml_hash(hash) ⇒ Object

changes the sf to Sf and pI to pi



367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/ms/sequest/bioworks.rb', line 367

def set_from_xml_hash(hash)
  @reference = hash["reference"]
  @protein_probability = hash["protein_probability"].to_f
  #@probability = @protein_probability.to_f
  @consensus_score = hash["consensus_score"].to_f
  @sf = hash["Sf"].to_f
  @unified_score = hash["unified_score"].to_f
  @coverage = hash["coverage"].to_f
  @pi = hash["pI"].to_f
  @weight = hash["weight"].to_f
  @accession = hash["accession"]
end

#set_from_xml_hash_xmlparser(hash) ⇒ Object



358
359
360
361
362
363
364
# File 'lib/ms/sequest/bioworks.rb', line 358

def set_from_xml_hash_xmlparser(hash)
  hash.delete("sequestresults")
  hash.delete("bioworksinfo")
  hash["sf"] = hash.delete("Sf")
  hash["pi"] = hash.delete("pI")
  set_from_xml_hash(hash)
end

#set_from_xml_stream(fh, uniq_pephit_hash) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/ms/sequest/bioworks.rb', line 320

def set_from_xml_stream(fh, uniq_pephit_hash)
  hash = {}
  @peps = []
  while line = fh.gets
    if line =~ @@att_re
      hash[$1] = $2
    elsif line =~ @@pep_re
      ## Could do a look ahead to grab the file and sequence to check
      ## uniqueness to increase speed here.
      pep = Bioworks::Pep.new.set_from_xml_stream(fh)
      # normal search results files have a global filename
      # while multi-consensus do not
      pep[12] ||= bioworks.global_filename

      ## figure out uniqueness 
      ky = [pep.base_name, pep.first_scan, pep.charge, pep.sequence]
      if uniq_pephit_hash.key? ky
        pep = uniq_pephit_hash[ky]
      else
        ## insert the new protein
        pep.prots = []
        uniq_pephit_hash[ky] = pep
      end
      pep.prots << self
      @peps << pep
      
    elsif line =~ @@end_prot_re
      set_from_xml_hash(hash)
      break
    else
      puts "Bad parsing on: #{line}"
      puts "EXITING!"
      exit
    end
  end
  self
end