class Bio::TMHMM::Report

TMHMM report parser class.

Attributes

entry_id[R]

Returns

exp_aas_in_tmhs[R]

Returns

exp_first_60aa[R]

Returns

length[R]

Returns

predicted_tmhs[R]

Returns

query_len[R]

Returns

tmhs[R]

Returns an Array of Bio::TMHMM::TMH.

total_prob_of_N_in[R]

Returns

Public Class Methods

new(entry = nil) click to toggle source
# File lib/bio/appl/tmhmm/report.rb, line 85
def initialize(entry = nil)
  begin
    str = entry.to_str
  rescue NoMethodError
  end
  if str then
    entry = str.enum_for(:each_line)
  end
  parse_header(entry)
  @tmhs = parse_tmhs(entry)
end

Public Instance Methods

helix() click to toggle source

Returns an Array of Bio::TMHMM::TMH including only “TMhelix”.

# File lib/bio/appl/tmhmm/report.rb, line 98
def helix
  @tmhs.map {|t| t if t.status == 'TMhelix' }.compact
end
to_s() click to toggle source
# File lib/bio/appl/tmhmm/report.rb, line 103
def to_s
  [
    [
      ["Length:",                    @query_len],
      ["Number of predicted TMHs:",  @predicted_tmhs],
      ["Exp number of AAs in THMs:", @exp_aas_in_tmhs],
      ["Exp number, first 60 AAs:",  @exp_first_60aa],
      ["Total prob of N-in:",        @total_prob_of_N_in]
    ].map {|e| "\# " + [@entry_id, e].flatten.join("\t") },
    tmhs.map {|ent| ent.to_s }
  ].flatten.join("\n")
end

Private Instance Methods

parse_header(raw) click to toggle source
# File lib/bio/appl/tmhmm/report.rb, line 120
def parse_header(raw)
  raw.each do |line|
    next unless /^#/.match(line)

    case line
    when / (\S.+) Length: +(\d+)/
      @entry_id  = $1.strip
      @query_len = $2.to_i
    when /Number of predicted TMHs: +(\d+)/
      @predicted_tmhs  = $1.to_i
    when /Exp number of AAs in TMHs: +([\d\.]+)/
      @exp_aas_in_tmhs = $1.to_f
    when /Exp number, first 60 AAs: +([\d\.]+)/
      @exp_first_60aa  = $1.to_f
    when /Total prob of N-in: +([\d\.]+)/
      @total_prob_of_N_in = $1.to_f
    end
  end
end
parse_tmhs(raw) click to toggle source
# File lib/bio/appl/tmhmm/report.rb, line 141
def parse_tmhs(raw)
  tmhs = []
  raw.each do |line|
    case line
    when /^[^\#]/
      eid,version,status,r0,r1 = line.split(/\s+/)
      tmhs << Bio::TMHMM::TMH.new(eid.strip,
                                  version.strip, 
                                  status.strip, 
                                  Range.new(r0.to_i, r1.to_i))
    end
  end
  tmhs
end