Class: Mspire::Mascot::Dat::Peptide
- Inherits:
-
Struct
- Object
- Struct
- Mspire::Mascot::Dat::Peptide
- 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
-
#data ⇒ Object
Returns the value of attribute data.
-
#delta ⇒ Object
Returns the value of attribute delta.
-
#ion_series_found ⇒ Object
Returns the value of attribute ion_series_found.
-
#ions_score ⇒ Object
Returns the value of attribute ions_score.
-
#missed_cleavages ⇒ Object
Returns the value of attribute missed_cleavages.
-
#mr ⇒ Object
Returns the value of attribute mr.
-
#num_ions_matched ⇒ Object
Returns the value of attribute num_ions_matched.
-
#peaks_from_ions_1 ⇒ Object
Returns the value of attribute peaks_from_ions_1.
-
#peaks_from_ions_2 ⇒ Object
Returns the value of attribute peaks_from_ions_2.
-
#peaks_from_ions_3 ⇒ Object
Returns the value of attribute peaks_from_ions_3.
-
#peptide_num ⇒ Object
Returns the value of attribute peptide_num.
-
#proteins ⇒ Object
Returns the value of attribute proteins.
-
#query_num ⇒ Object
Returns the value of attribute query_num.
-
#seq ⇒ Object
Returns the value of attribute seq.
-
#var_mods_string ⇒ Object
Returns the value of attribute var_mods_string.
Class Method Summary collapse
-
.dissect_line(line) ⇒ Object
returns the query num and peptide num and info_tag and string.
-
.each(io, &block) ⇒ Object
returns each peptide hit.
-
.from_value_string(value, qnum, pnum) ⇒ Object
given the value part of the initial peptide data (q1_p1=<value>), sets the object’s properties.
-
.next_qp_data(io) ⇒ Object
reads the next line.
Methods included from Castable
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def data @data end |
#delta ⇒ Object
Returns the value of attribute delta
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def delta @delta end |
#ion_series_found ⇒ Object
Returns the value of attribute ion_series_found
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def ion_series_found @ion_series_found end |
#ions_score ⇒ Object
Returns the value of attribute ions_score
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def ions_score @ions_score end |
#missed_cleavages ⇒ Object
Returns the value of attribute missed_cleavages
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def missed_cleavages @missed_cleavages end |
#mr ⇒ Object
Returns the value of attribute mr
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def mr @mr end |
#num_ions_matched ⇒ Object
Returns the value of attribute 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_1 ⇒ Object
Returns the value of attribute 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_2 ⇒ Object
Returns the value of attribute 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_3 ⇒ Object
Returns the value of attribute 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_num ⇒ Object
Returns the value of attribute peptide_num
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def peptide_num @peptide_num end |
#proteins ⇒ Object
Returns the value of attribute proteins
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def proteins @proteins end |
#query_num ⇒ Object
Returns the value of attribute query_num
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def query_num @query_num end |
#seq ⇒ Object
Returns the value of attribute seq
7 8 9 |
# File 'lib/mspire/mascot/dat/peptide.rb', line 7 def seq @seq end |
#var_mods_string ⇒ Object
Returns the value of attribute 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 |