Class: TopPred::Parser_Text

Inherits:
Object show all
Includes:
Parser
Defined in:
lib/transmembrane/toppred.rb

Instance Method Summary collapse

Methods included from Parser

#add_sequences_to_segments, #file_to_index, filetype, new

Instance Method Details

#to_index(io, index = {}) ⇒ Object

returns a hash structure in this form: {identifier => {aaseq => String, num_found: Int, num_certain_transmembrane_segments => Int, num_putative_transmembrane_segments => Int, best_structure_probability => Float, transmembrane_segments => [probability => Float, start => Int, stop

> Int, aaseq => String] } }



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/transmembrane/toppred.rb', line 214

def to_index(io, index={})
  current_record = nil

  io.each do |line|
    if line =~ /^Sequence : (.*?) +\(/
      current_identifier = $1.dup
      index[current_identifier] = {}
      current_record = index[current_identifier]
      current_record[:aaseq] = read_aaseq(io)
      read_segment_summary(io, current_record)
    elsif line =~ /^HEADER\s+START\s+STOP/
      top_struc = top_structure( read_structures(io) )
      current_record[:best_structure_probability] = top_struc[:probability]
      current_record[:transmembrane_segments] = top_struc[:tm]
      add_sequences_to_segments(current_record[:transmembrane_segments], current_record[:aaseq])
      segment_arrays_to_hashes(current_record[:transmembrane_segments])
    end
  end
  index
end