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.

Methods

alpha   classes   dN_dS   kappa   lnL   modelnum   name   new   omega   to_s   tree   tree_length  

Public Class methods

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

[Source]

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

Public Instance methods

Return codeml alpha of model, when available

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 438
438:       def alpha
439:         return nil if @buf !~ /alpha/
440:         @buf[/alpha .+ =\s+(-?\d+(\.\d+)?)/,1].to_f
441:       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}

[Source]

     # 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
dN_dS()

Alias for omega

Return codeml kappa of model, when available

[Source]

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

Return codeml log likelihood of model

[Source]

     # 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

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 410
410:       def modelnum
411:         @buf[0..0].to_i
412:       end

Return the model name, e.g. ‘M0’ or ‘M7‘

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 415
415:       def name
416:         'M'.to_s+modelnum.to_s
417:       end

Return codeml omega of model

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 425
425:       def omega
426:         @buf[/omega \(dN\/dS\)\s+=\s+ (-?\d+(\.\d+)?)/,1].to_f
427:       end

Return the model information as a String

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 476
476:       def to_s
477:         @buf
478:       end

Return codeml tree

[Source]

     # File lib/bio/appl/paml/codeml/report.rb, line 449
449:       def tree
450:         @buf[/([^\n]+)\n\nDetailed/m,1]
451:       end

Return codeml treee length

[Source]

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

[Validate]