Class: Mspire::Mascot::Dat::Peptide

Inherits:
Struct
  • Object
show all
Includes:
Castable
Defined in:
lib/mspire/mascot/dat/peptide.rb,
lib/mspire/mascot/dat/peptide.rb

Overview

mr = relative molecular mass; data contains keys of relative

Constant Summary collapse

CAST =
{
  missed_cleavages: :to_i, 
  mr: :to_f, 
  delta: :to_f, 
  num_ions_matched: :to_i,
  ions: :string, 
  ions_score: :to_f, 
  peaks_from_ions_2: :to_i,
  peaks_from_ions_3: :to_i,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Castable

#cast!

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def data
  @data
end

#deltaObject

Returns the value of attribute delta

Returns:

  • (Object)

    the current value of delta



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def delta
  @delta
end

#ion_series_foundObject

Returns the value of attribute ion_series_found

Returns:

  • (Object)

    the current value of ion_series_found



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def ion_series_found
  @ion_series_found
end

#ions_scoreObject

Returns the value of attribute ions_score

Returns:

  • (Object)

    the current value of ions_score



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def ions_score
  @ions_score
end

#missed_cleavagesObject

Returns the value of attribute missed_cleavages

Returns:

  • (Object)

    the current value of missed_cleavages



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def missed_cleavages
  @missed_cleavages
end

#mrObject

Returns the value of attribute mr

Returns:

  • (Object)

    the current value of mr



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def mr
  @mr
end

#num_ions_matchedObject

Returns the value of attribute num_ions_matched

Returns:

  • (Object)

    the current value of num_ions_matched



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def num_ions_matched
  @num_ions_matched
end

#peaks_from_ions_1Object

Returns the value of attribute peaks_from_ions_1

Returns:

  • (Object)

    the current value of peaks_from_ions_1



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def peaks_from_ions_1
  @peaks_from_ions_1
end

#peaks_from_ions_2Object

Returns the value of attribute peaks_from_ions_2

Returns:

  • (Object)

    the current value of peaks_from_ions_2



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def peaks_from_ions_2
  @peaks_from_ions_2
end

#peaks_from_ions_3Object

Returns the value of attribute peaks_from_ions_3

Returns:

  • (Object)

    the current value of peaks_from_ions_3



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def peaks_from_ions_3
  @peaks_from_ions_3
end

#peptide_numObject

Returns the value of attribute peptide_num

Returns:

  • (Object)

    the current value of peptide_num



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def peptide_num
  @peptide_num
end

#proteinsObject

Returns the value of attribute proteins

Returns:

  • (Object)

    the current value of proteins



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def proteins
  @proteins
end

#query_numObject

Returns the value of attribute query_num

Returns:

  • (Object)

    the current value of query_num



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def query_num
  @query_num
end

#seqObject

Returns the value of attribute seq

Returns:

  • (Object)

    the current value of seq



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def seq
  @seq
end

#var_mods_stringObject

Returns the value of attribute var_mods_string

Returns:

  • (Object)

    the current value of var_mods_string



7
8
9
# File 'lib/mspire/mascot/dat/peptide.rb', line 7

def var_mods_string
  @var_mods_string
end

Class Method Details

.dissect_line(line) ⇒ Object

returns the query num and peptide num and info_tag and string. nil if they don’t exist.



40
41
42
43
44
# File 'lib/mspire/mascot/dat/peptide.rb', line 40

def self.dissect_line(line)
  if md=/q(\d+)_p_?(\d+)(\w*)=(.*)/.match(line)
    [md[1].to_i, md[2].to_i, md[3], md[4]]
  end
end

.each(io, &block) ⇒ Object

returns each peptide hit. Some queries will not have any hits, and these are not yielded.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mspire/mascot/dat/peptide.rb', line 49

def self.each(io, &block)
  return to_enum(__method__, io) unless block
  before = io.pos
  peptide = nil
  while reply=dissect_line(io.readline("\n"))
    (qnum, pnum, info_tag, value) = reply
    if info_tag == ''
      track_pos = io.pos
      block.call(peptide) if peptide # yield the previous peptide
      io.pos = track_pos
      peptide = 
        (value == "-1") ? nil : self.from_value_string(value, qnum, pnum)
    else
      # implement reading in future
    end
    before = io.pos
  end
  # yield that last peptide

  track_pos = io.pos
  block.call(peptide) if peptide
  io.pos = track_pos
end

.from_value_string(value, qnum, pnum) ⇒ Object

given the value part of the initial peptide data (q1_p1=<value>), sets the object’s properties. returns the pephit



32
33
34
35
36
37
# File 'lib/mspire/mascot/dat/peptide.rb', line 32

def self.from_value_string(value, qnum, pnum)
  (core, prots) = value.split(';', 2)
  pephit = self.new(*core.split(','), qnum, pnum)
  pephit.cast!
  pephit
end

.next_qp_data(io) ⇒ Object

reads the next line. If it contains valid query information returns an array [query_num, peptide_num, info_tag, value]. If it no valid query information, resets the io position to the beginning of the string and returns nil.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mspire/mascot/dat/peptide.rb', line 15

def self.next_qp_data(io)
  before = io.pos
  line = io.readline("\n")
  if line[0,2] == '--'
    io.pos = before
    nil
  else
    line.chomp!
    (qpstring, value) = line.split('=',2)
    (qns, pns, info_tag) = qpstring.split('_', 3)
    (qnum, pnum) = [qns, pns].map {|ns| ns[1..-1].to_i }
    [qnum, pnum, info_tag, value]
  end
end