Class: Ms::Sequest::Srf::Out::Peptide

Inherits:
Object
  • Object
show all
Defined in:
lib/ms/sequest/srf.rb

Overview

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

Constant Summary collapse

Unpack_35 =
'@64Ex8ex8eeeIx18Ivx2vvx8Z*@246Z*'
Unpack_32 =

translation: @64=(64 bytes in to the record), E=mH, x8=8unknown bytes, e=deltacn, x8=8unknown bytes, e=sf, e=sp, e=xcorr, I=ID#, x18=18 unknown bytes, v=rsp, v=ions_matched, v=ions_total, x8=8unknown bytes, Z*=sequence, 240Z*=at byte 240 grab the string (which is proteins). Unpack_32 = ‘@64Ex8ex12eeIx18vvvx8Z*@240Z*’

'@64Ex8ex8eeeIx14Ivvvx8Z*@240Z*'
Unpack_four_null_bytes =
'a*'
Unpack_Zstar =
'Z*'
Read_35 =
426
Read_32 =
320
FourNullBytes_as_string =
"\0\0\0\0"
NewRecordStart =

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

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_io(fh, unpack_35) ⇒ Object

extra_references_array is an array that grows with peptides as extra references are discovered.



703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# File 'lib/ms/sequest/srf.rb', line 703

def self.from_io(fh, unpack_35)
  ## get the first part of the info
  st = fh.read( unpack_35 ? Read_35 : Read_32 ) ## read all the hit data

  
  # sets the the first 11 attributes
  peptide = self.new( *st.unpack( unpack_35 ? Unpack_35 : Unpack_32 ) )

  # set deltacn_orig_updated 
  peptide[21] = peptide[1]

  # we are slicing the reference to 38 chars to be the same length as
  # duplicate references
  peptide[11] = [Ms::Sequest::Srf::Out::Protein.new(peptide[11][0,38])]

  peptide[14] = Ms::Ident::Peptide.sequence_to_aaseq(peptide[10])

  fh.read(6) if unpack_35

  peptide
end

.read_extra_references(fh, num_extra_references, pep_hits) ⇒ Object



654
655
656
657
658
659
660
661
662
663
# File 'lib/ms/sequest/srf.rb', line 654

def self.read_extra_references(fh, num_extra_references, pep_hits)
  num_extra_references.times do
    # 80 bytes total (with index number)
    pep = pep_hits[fh.read(8).unpack('x4I').first - 1]

    ref = fh.read(80).unpack('A*').first
    pep[11] << Ms::Sequest::Srf::Out::Protein.new(ref[0,38])
  end
  #  fh.read(6) if unpack_35
end

.set_deltacn_from_deltacn_orig(ar) ⇒ Object

creates the deltacn that is meaningful for the top hit (the deltacn_orig or the second best hit and so on). assumes sorted



632
633
634
635
# File 'lib/ms/sequest/srf.rb', line 632

def self.set_deltacn_from_deltacn_orig(ar)
  (1...ar.size).each {|i| ar[i-1].deltacn = ar[i].deltacn_orig }
  ar[-1].deltacn = 1.1
end

.update_deltacns_from_xcorr(ar) ⇒ Object

(assumes sorted) recalculates deltacn from xcorrs and sets deltacn_orig_updated and deltacn



639
640
641
642
643
644
645
646
647
648
649
650
651
652
# File 'lib/ms/sequest/srf.rb', line 639

def self.update_deltacns_from_xcorr(ar)
  if ar.size > 0
    top_score = ar.first[4]
    other_scores = (1...(ar.size)).to_a.map do |i|
      1.0 - (ar[i][4]/top_score)
    end
    ar.first[21] = 0.0
    (0...(ar.size-1)).each do |i|
      ar[i][20] = other_scores[i]    # deltacn
      ar[i+1][21] = other_scores[i]  # deltacn_orig_updated
    end
    ar.last[20] = 1.1
  end
end

Instance Method Details

#inspectObject



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/ms/sequest/srf.rb', line 683

def inspect
  st = %w(aaseq sequence mh deltacn_orig sf sp xcorr id rsp ions_matched ions_total proteins deltamass ppm base_name first_scan last_scan charge deltacn).map do |v| 
    if v == 'proteins'
      "#{v}(#)=#{send(v.to_sym).size}"
    elsif v.is_a? Array
      "##{v}=#{send(v.to_sym).size}"
    else
      "#{v}=#{send(v.to_sym).inspect}"
    end
  end
  st.unshift("<#{self.class}")
  if srf
    st.push("srf(base_name)=#{srf.base_name.inspect}")
  end
  st.push('>')
  st.join(' ')
  #"<Ms::Sequest::Srf::Out::Peptide @mh=#{mh}, @deltacn=#{deltacn}, @sp=#{sp}, @xcorr=#{xcorr}, @id=#{id}, @rsp=#{rsp}, @ions_matched=#{ions_matched}, @ions_total=#{ions_total}, @sequence=#{sequence}, @proteins(count)=#{proteins.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