class Bio::PAML::Codeml::Model

Model class contains one of the models of a codeml run (e.g. M0) which is used as a test hypothesis for positive selection. This class is used by Codeml::Report.

Public Class Methods

new(buf) click to toggle source

Create a model using the relevant information from the codeml result data (text buffer)

# File lib/bio/appl/paml/codeml/report.rb, line 405
def initialize buf
  @buf = buf
end

Public Instance Methods

alpha() click to toggle source

Return codeml alpha of model, when available

# File lib/bio/appl/paml/codeml/report.rb, line 438
def alpha
  return nil if @buf !~ /alpha/
  @buf[/alpha .+ =\s+(-?\d+(\.\d+)?)/,1].to_f
end
classes() click to toggle source

Return classes when available. For M3 it parses

dN/dS (w) for site classes (K=3) p: 0.56413 0.35613 0.07974 w: 0.00928 1.98252 23.44160

and turns it into an array of Hash

>> m3.classes[0]
=> {:w=>0.00928, :p=>0.56413}
# File lib/bio/appl/paml/codeml/report.rb, line 463
def classes
  return nil if @buf !~ /classes/
  # probs = @buf.scan(/\np:\s+(\w+)\s+(\S+)\s+(\S+)/)
  probs = @buf.scan(/\np:.*?\n/).to_s.split[1..3].map { |f| f.to_f }
  ws = @buf.scan(/\nw:.*?\n/).to_s.split[1..3].map { |f| f.to_f }
  ret = []
  probs.each_with_index do | prob, i |
    ret.push  :p => prob, :w => ws[i] 
  end
  ret
end
dN_dS()
Alias for: omega
kappa() click to toggle source

Return codeml kappa of model, when available

# File lib/bio/appl/paml/codeml/report.rb, line 432
def kappa
  return nil if @buf !~ /kappa/
  @buf[/kappa \(ts\/tv\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f
end
lnL() click to toggle source

Return codeml log likelihood of model

# File lib/bio/appl/paml/codeml/report.rb, line 420
def lnL
  @buf[/lnL\(.+\):\s+(-?\d+(\.\d+)?)/,1].to_f
end
modelnum() click to toggle source

Return the model number

# File lib/bio/appl/paml/codeml/report.rb, line 410
def modelnum
  @buf[0..0].to_i
end
name() click to toggle source

Return the model name, e.g. 'M0' or 'M7'

# File lib/bio/appl/paml/codeml/report.rb, line 415
def name
  'M'.to_s+modelnum.to_s
end
omega() click to toggle source

Return codeml omega of model

# File lib/bio/appl/paml/codeml/report.rb, line 425
def omega
  @buf[/omega \(dN\/dS\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f
end
Also aliased as: dN_dS
to_s() click to toggle source

Return the model information as a String

# File lib/bio/appl/paml/codeml/report.rb, line 476
def to_s
  @buf
end
tree() click to toggle source

Return codeml tree

# File lib/bio/appl/paml/codeml/report.rb, line 449
def tree
  @buf[/([^\n]+)\n\nDetailed/m,1]
end
tree_length() click to toggle source

Return codeml treee length

# File lib/bio/appl/paml/codeml/report.rb, line 444
def tree_length
  @buf[/tree length\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f
end