Class: Bio::PAML::Codeml::Model
- Defined in:
- lib/bio/appl/paml/codeml/report.rb
Overview
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.
Instance Method Summary collapse
-
#alpha ⇒ Object
Return codeml alpha of model, when available.
-
#classes ⇒ Object
Return classes when available.
-
#initialize(buf) ⇒ Model
constructor
Create a model using the relevant information from the codeml result data (text buffer).
-
#kappa ⇒ Object
Return codeml kappa of model, when available.
-
#lnL ⇒ Object
Return codeml log likelihood of model.
-
#modelnum ⇒ Object
Return the model number.
-
#name ⇒ Object
Return the model name, e.g.
-
#omega ⇒ Object
(also: #dN_dS)
Return codeml omega of model.
-
#to_s ⇒ Object
Return the model information as a String.
-
#tree ⇒ Object
Return codeml tree.
-
#tree_length ⇒ Object
Return codeml treee length.
Constructor Details
#initialize(buf) ⇒ Model
Create a model using the relevant information from the codeml result data (text buffer)
405 406 407 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 405 def initialize buf @buf = buf end |
Instance Method Details
#alpha ⇒ Object
Return codeml alpha of model, when available
438 439 440 441 |
# 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 ⇒ Object
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}
463 464 465 466 467 468 469 470 471 472 473 |
# 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 |
#kappa ⇒ Object
Return codeml kappa of model, when available
432 433 434 435 |
# 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 ⇒ Object
Return codeml log likelihood of model
420 421 422 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 420 def lnL @buf[/lnL\(.+\):\s+(-?\d+(\.\d+)?)/,1].to_f end |
#modelnum ⇒ Object
Return the model number
410 411 412 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 410 def modelnum @buf[0..0].to_i end |
#name ⇒ Object
Return the model name, e.g. ‘M0’ or ‘M7’
415 416 417 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 415 def name 'M'.to_s+modelnum.to_s end |
#omega ⇒ Object Also known as: dN_dS
Return codeml omega of model
425 426 427 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 425 def omega @buf[/omega \(dN\/dS\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f end |
#to_s ⇒ Object
Return the model information as a String
476 477 478 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 476 def to_s @buf end |
#tree ⇒ Object
Return codeml tree
449 450 451 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 449 def tree @buf[/([^\n]+)\n\nDetailed/m,1] end |
#tree_length ⇒ Object
Return codeml treee length
444 445 446 |
# File 'lib/bio/appl/paml/codeml/report.rb', line 444 def tree_length @buf[/tree length\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f end |