Class: Bioworks::Pep
- Inherits:
-
Object
- Object
- Bioworks::Pep
- Includes:
- XML, SpecID::Pep, SpecIDXML
- Defined in:
- lib/ms/sequest/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
Class Method Summary collapse
-
.extract_file_info(arg) ⇒ Object
takes arguments in one of two forms: 1.
Instance Method Summary collapse
- #file=(arg) ⇒ Object
-
#get(*args) ⇒ Object
returns array of values of the attributes given (as symbols).
- #inspect ⇒ Object
- #mh ⇒ Object
-
#ppm ⇒ Object
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).
-
#probability ⇒ Object
other accessors:.
-
#set_from_hash_given_text(hash) ⇒ Object
if cast == true, then all the data will be cast.
- #set_from_xml_stream(fh) ⇒ Object
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
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/ms/sequest/bioworks.rb', line 430 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
449 450 451 452 453 454 |
# File 'lib/ms/sequest/bioworks.rb', line 449 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)
412 413 414 415 416 |
# File 'lib/ms/sequest/bioworks.rb', line 412 def get(*args) args.collect do |arg| send(arg) end end |
#inspect ⇒ Object
458 459 460 461 462 |
# File 'lib/ms/sequest/bioworks.rb', line 458 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 |
#mh ⇒ Object
402 |
# File 'lib/ms/sequest/bioworks.rb', line 402 def mh ; self[1] end |
#ppm ⇒ Object
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)
406 407 408 409 |
# File 'lib/ms/sequest/bioworks.rb', line 406 def ppm 1.0e6 * (self[2].abs/self[1]) #1.0e6 * (self.deltamass.abs/self.mh) end |
#probability ⇒ Object
other accessors:
401 |
# File 'lib/ms/sequest/bioworks.rb', line 401 def probability ; self[15] end |
#set_from_hash_given_text(hash) ⇒ Object
if cast == true, then all the data will be cast
465 466 467 468 469 470 |
# File 'lib/ms/sequest/bioworks.rb', line 465 def set_from_hash_given_text(hash) self[0,11] = [hash["sequence"], hash["mass"].to_f, hash["deltamass"].to_f, hash["charge"].to_i, hash["xcorr"].to_f, hash["deltacn"].to_f, hash["sp"].to_f, hash["rsp"].to_i, hash["ions"], hash["count"].to_i, hash["tic"].to_i] 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
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/ms/sequest/bioworks.rb', line 472 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_given_text(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 |