Class: Bio::TMHMM

Inherits:
Object show all
Defined in:
lib/bio/appl/tmhmm/report.rb

Overview

Defined Under Namespace

Classes: Report, TMH

Class Method Summary collapse

Class Method Details

.reports(data) ⇒ Object

Splits multiple reports into a report entry.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bio/appl/tmhmm/report.rb', line 25

def TMHMM.reports(data)
  entry     = []
  ent_state = ''
  data.each_line do |line|
    if /^\#/ =~ line
      if ent_state == 'next'
        ent_state = 'entry'
      elsif ent_state == 'tmh'
        ent_state = 'next'
      end
    else
      ent_state = 'tmh'
    end

    if ent_state != 'next'
      entry << line
    else
      if block_given?
        yield Bio::TMHMM::Report.new(entry)
      else
        Bio::TMHMM::Report.new(entry)
      end
      entry = [line]
    end
  end

  if block_given?
    yield Bio::TMHMM::Report.new(entry)
  else
    Bio::TMHMM::Report.new(entry)
  end
end