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 405 def initialize buf 406 @buf = buf 407 end
Public Instance Methods
alpha()
click to toggle source
Return codeml alpha of model, when available
# File lib/bio/appl/paml/codeml/report.rb 438 def alpha 439 return nil if @buf !~ /alpha/ 440 @buf[/alpha .+ =\s+(-?\d+(\.\d+)?)/,1].to_f 441 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 463 def classes 464 return nil if @buf !~ /classes/ 465 # probs = @buf.scan(/\np:\s+(\w+)\s+(\S+)\s+(\S+)/) 466 probs = @buf.scan(/\np:.*?\n/).to_s.split[1..3].map { |f| f.to_f } 467 ws = @buf.scan(/\nw:.*?\n/).to_s.split[1..3].map { |f| f.to_f } 468 ret = [] 469 probs.each_with_index do | prob, i | 470 ret.push :p => prob, :w => ws[i] 471 end 472 ret 473 end
kappa()
click to toggle source
Return codeml kappa of model, when available
# File lib/bio/appl/paml/codeml/report.rb 432 def kappa 433 return nil if @buf !~ /kappa/ 434 @buf[/kappa \(ts\/tv\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f 435 end
lnL()
click to toggle source
Return codeml log likelihood of model
# File lib/bio/appl/paml/codeml/report.rb 420 def lnL 421 @buf[/lnL\(.+\):\s+(-?\d+(\.\d+)?)/,1].to_f 422 end
modelnum()
click to toggle source
Return the model number
# File lib/bio/appl/paml/codeml/report.rb 410 def modelnum 411 @buf[0..0].to_i 412 end
name()
click to toggle source
Return the model name, e.g. ‘M0’ or ‘M7’
# File lib/bio/appl/paml/codeml/report.rb 415 def name 416 'M'.to_s+modelnum.to_s 417 end
omega()
click to toggle source
Return codeml omega of model
# File lib/bio/appl/paml/codeml/report.rb 425 def omega 426 @buf[/omega \(dN\/dS\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f 427 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 476 def to_s 477 @buf 478 end
tree()
click to toggle source
Return codeml tree
# File lib/bio/appl/paml/codeml/report.rb 449 def tree 450 @buf[/([^\n]+)\n\nDetailed/m,1] 451 end
tree_length()
click to toggle source
Return codeml treee length
# File lib/bio/appl/paml/codeml/report.rb 444 def tree_length 445 @buf[/tree length\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f 446 end