Class: Bioworks::Pep

Inherits:
Object
  • Object
show all
Includes:
XML, SpecID::Pep, SpecIDXML
Defined in:
lib/spec_id/bioworks.rb

Overview

0=sequence 1=mass 2=deltamass 3=charge 4=xcorr 5=deltacn 6=sp 7=rsp 8=ions 9=count 10=tic 11=prots 12=base_name 13=first_scan 14=last_scan 15=peptide_probability 16=file 17=_num_prots 18=_first_prot 19=aaseq

Constant Summary collapse

@@file_split_first_re =
/, /o
@@file_split_second_re =
/ - /o
@@end_pep_re =

@@att_re = /<(.*)>(.*)</(.*)>/

/<\/peptide>/o
@@file_one_scan_re =
/(.*), (\d+)/o
@@file_mult_scan_re =
/(.*), (\d+) - (\d+)/o

Constants included from SpecIDXML

SpecIDXML::Special_chrs_hash

Constants included from SpecID::Pep

SpecID::Pep::Non_standard_amino_acid_char_re

Instance Attribute Summary

Attributes included from SpecID::Pep

#aaseq, #charge, #prots, #sequence

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SpecIDXML

#attr_xml, #attrs_xml, #element_xml, #element_xml_and_att_string, #element_xml_no_atts, #escape_special_chars, #param_xml, #params_xml, #short_element_xml, #short_element_xml_and_att_string, #short_element_xml_from_instance_vars, #tabs

Methods included from SpecID::Pep

#<=>, #mass_accuracy, prepare_sequence, protein_groups_by_sequence, remove_non_amino_acids, sequence_to_aaseq, split_sequence

Class Method Details

.extract_file_info(arg) ⇒ Object

takes arguments in one of two forms:

1. file, first_scan[ - last_scan]
2. scan[ - last_scan]

returns base_name, first_scan, last_scan base_name will be set for #1, nil for #2



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/spec_id/bioworks.rb', line 425

def self.extract_file_info(arg)
  last_scan = nil
  (base_name, first_scan) = arg.split(@@file_split_first_re)
  unless first_scan
    first_scan = base_name
    base_name = nil
  end
  first_scan = first_scan.split(@@file_split_second_re)
  if first_scan.size > 1
    (first_scan, last_scan) = first_scan
  else
    first_scan = first_scan[0]
    last_scan = first_scan
  end
  [base_name, first_scan, last_scan]
end

Instance Method Details

#file=(arg) ⇒ Object



444
445
446
447
448
449
# File 'lib/spec_id/bioworks.rb', line 444

def file=(arg)
  ## Set these vals by index:
  #puts "AERRG: #{arg}"
  self[16] = arg
  self[12,3] = self.class.extract_file_info(arg)
end

#get(*args) ⇒ Object

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



407
408
409
410
411
# File 'lib/spec_id/bioworks.rb', line 407

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

#inspectObject



452
453
454
455
456
# File 'lib/spec_id/bioworks.rb', line 452

def inspect
  "<Bioworks::Pep sequence: #{sequence}, mass: #{mass}, deltamass: #{deltamass}, charge: #{charge}, xcorr: #{xcorr}, deltacn: #{deltacn}, prots(count):#{prots.size}, base_name: #{base_name}, first_scan: #{first_scan}, last_scan: #{last_scan}, file: #{file}, peptide_probability: #{peptide_probability}, aaseq:#{aaseq}>"


end

#mhObject



397
# File 'lib/spec_id/bioworks.rb', line 397

def mh ; self[1] end

#ppmObject

This is not a true ppm since it should be divided by the actual mh instead of the theoretical (but it is as close as we can get for this object)



401
402
403
404
# File 'lib/spec_id/bioworks.rb', line 401

def ppm 
  1.0e6 * (self[2].abs/self[1])
  #1.0e6 * (self.deltamass.abs/self.mh)
end

#probabilityObject

other accessors:



396
# File 'lib/spec_id/bioworks.rb', line 396

def probability ; self[15] end

#set_from_hash(hash) ⇒ Object



458
459
460
461
462
463
# File 'lib/spec_id/bioworks.rb', line 458

def set_from_hash(hash)
  self[0,11] = [hash["sequence"], hash["mass"], hash["deltamass"], hash["charge"], hash["xcorr"], hash["deltacn"], hash["sp"], hash["rsp"], hash["ions"], hash["count"], hash["tic"]]
  self.file = hash["file"]
  self[15] = hash["peptide_probability"].to_f
  self[19] = SpecID::Pep.sequence_to_aaseq(self[0])  ## aaseq
end

#set_from_xml_stream(fh) ⇒ Object



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/spec_id/bioworks.rb', line 465

def set_from_xml_stream(fh)
  hash = {}
  while line = fh.gets
    if line =~ @@att_re
      #hash[$1] = $2.dup
      hash[$1] = $2
      #puts "IN PEP: " + $1 + ": " + $2
    elsif line =~ @@end_pep_re
      set_from_hash(hash)
      #puts "SELF[12]: #{self[12]}"
      #puts "SELF[12]: #{self[12]}"
      break
    else
      puts "Bad parsing on: #{line}"
      puts "EXITING!"
      exit
    end
  end
  self
end