Module: Ms::Mascot::Dat::Peptides::Utils

Included in:
Ms::Mascot::Dat::Peptides
Defined in:
lib/ms/mascot/dat/peptides.rb

Class Method Summary collapse

Class Method Details

.parse_peptide_hit(str, terms) ⇒ Object

Parses a PeptideHit from the query-hit string.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ms/mascot/dat/peptides.rb', line 129

def parse_peptide_hit(str, terms)
  return nil if str == nil || str == "-1"
  
  peptide_data, protein_maps = str.split(";", 2)
  protein_maps = protein_maps.split(",")
  terms = terms.split(":")
  
  # parse peptide data
  peptide_data = peptide_data.split(",")
  
  PeptideHitFloatIndicies.each do |index|
    peptide_data[index] = peptide_data[index].to_f
  end
  
  PeptideHitIntIndicies.each do |index|
    peptide_data[index] = peptide_data[index].to_i
  end

  # parse protein_map data
  protein_maps = protein_maps.zip(terms).collect do |map_data, terms|
    data = map_data.split(":") + terms.split(',')
    
    # removes quotes from protein id
    data[0] = data[0][1...-1]
    
    ProteinMapIntIndicies.each {|index| data[index] = data[index].to_i }
    ProteinMap.new(*data)
  end
  
  peptide_data << protein_maps
  PeptideHit.new(*peptide_data)
end