Class: SRF::OUT::Pep

Inherits:
Object
  • Object
show all
Includes:
SpecID::Pep
Defined in:
lib/spec_id/srf.rb

Overview

0=mh 1=deltacn 2=sp 3=xcorr 4=id 5=rsp 6=ions_matched 7=ions_total 8=sequence 9=prots 10=deltamass 11=ppm 12=aaseq 13=base_name 14=first_scan 15=last_scan 16=charge 17=srf

Constant Summary collapse

Unpack =
'@64Ex8ex12eeIx18vvvx8Z*@240Z*'
Unpack_four_null_bytes =
'a*'
Unpack_Zstar =
'Z*'
FourNullBytes_as_string =
"\0\0\0\0"
NewRecordStart =

NewRecordStart = “00” + 0x3a.chr + 0x1a.chr + “00”

0x01.chr + 0x00.chr
Sequest_record_start =
"[SEQUEST]"

Constants included from SpecID::Pep

SpecID::Pep::Non_standard_amino_acid_char_re

Instance Attribute Summary

Attributes included from SpecID::Pep

#aaseq, #charge, #probability, #sequence

Instance Method Summary collapse

Methods included from SpecID::Pep

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

Instance Method Details

#from_handle(fh, global_ref_hash) ⇒ Object



501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/spec_id/srf.rb', line 501

def from_handle(fh, global_ref_hash)
  ## get the first part of the info
  st = fh.read(320) ## read all the hit data
  self[0,10] = st.unpack(Unpack)
  # we are slicing the reference to 38 chars to be the same length as
  # duplicate references
  self[9] = [new_protein(self[9][0,38], self, global_ref_hash)]
  self[12] = SpecID::Pep.sequence_to_aaseq(self[8])
  read_extra_references(fh, global_ref_hash) 
  
  self
end

#inspectObject



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/spec_id/srf.rb', line 430

def inspect
  st = %w(aaseq sequence mh deltacn sp xcorr id rsp ions_matched ions_total prots deltamass ppm base_name first_scan last_scan charge).map do |v| 
    if v.is_a? Array
      "##{v}=#{send(v.to_sym).size}"
    else
      "@#{v}=#{send(v.to_sym)}"
    end
  end
  st.unshift("<#{self.class}")
  if srf
    st.push("@srf(base_name)=#{srf.base_name}")
  end
  st.push('>')
  st.join(' ')
  #"<SRF::OUT::Pep @mh=#{mh}, @deltacn=#{deltacn}, @sp=#{sp}, @xcorr=#{xcorr}, @id=#{id}, @rsp=#{rsp}, @ions_matched=#{ions_matched}, @ions_total=#{ions_total}, @sequence=#{sequence}, @prots(count)=#{prots.size}, @deltamass=#{deltamass}, @ppm=#{ppm} @aaseq=#{aaseq}, @base_name=#{base_name}, @first_scan=#{first_scan}, @last_scan=#{last_scan}, @charge=#{charge}, @srf(base_name)=#{srf.base_name}>"
end

#new_protein(reference, peptide, global_ref_hash) ⇒ Object



492
493
494
495
496
497
498
499
# File 'lib/spec_id/srf.rb', line 492

def new_protein(reference, peptide, global_ref_hash)
  if global_ref_hash.key? reference
    global_ref_hash[reference].peps << peptide
  else
    global_ref_hash[reference] = SRF::OUT::Prot.new(reference, [peptide])
  end
  global_ref_hash[reference] 
end

#protsObject



427
# File 'lib/spec_id/srf.rb', line 427

def prots() self[9] end

#read_extra_references(fh, global_ref_hash) ⇒ Object

There must be a better way to do this. We are checking that there are no additional protein references only so that we are in register for the next reading



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/spec_id/srf.rb', line 450

def read_extra_references(fh, global_ref_hash)
  $SRF_OUT_HIT_FH_POS = fh.pos
  st = fh.read(4)
  #puts "HHH: " + st.unpack("H*").first
  ## if we see 0000 0000 we are done
  if st.unpack(Unpack_four_null_bytes).first == FourNullBytes_as_string
    fh.pos = $SRF_OUT_HIT_FH_POS 
    return nil
  end
  # read in context of 4 bytes read above:

  ## NOTE: in context of 4 bytes read above!
  st = fh.read(36)
  if st[34,2] == NewRecordStart
    fh.pos = $SRF_OUT_HIT_FH_POS 
    return nil
  end

  # is this the end of the outfiles?
  ## BACK to beginning of this section
  fh.pos = $SRF_OUT_HIT_FH_POS
  if fh.read(9) == Sequest_record_start 
    fh.pos = $SRF_OUT_HIT_FH_POS
    return
  end

  ## we have extra references
  ## original read was fh.read(79)
  fh.seek(-1, IO::SEEK_CUR)
  self[9].push( new_protein(fh.read(80).unpack(Unpack_Zstar).first, self, global_ref_hash ) )
  
  #p self.prots
  #puts self.prots.size
  #$glob ||= 0
  #$glob += 1
  #if $glob == 20
  #  abort 
  #end

  read_extra_references(fh,global_ref_hash)
end