Class | Bio::PAML::Codeml::Model |
In: |
lib/bio/appl/paml/codeml/report.rb
|
Parent: | Object |
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.
Create a model using the relevant information from the codeml result data (text buffer)
# File lib/bio/appl/paml/codeml/report.rb, line 405 405: def initialize buf 406: @buf = buf 407: end
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 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
Return codeml log likelihood of model
# File lib/bio/appl/paml/codeml/report.rb, line 420 420: def lnL 421: @buf[/lnL\(.+\):\s+(-?\d+(\.\d+)?)/,1].to_f 422: end
Return the model number
# File lib/bio/appl/paml/codeml/report.rb, line 410 410: def modelnum 411: @buf[0..0].to_i 412: end