Skip to content

Commit

Permalink
Merge commit 'blessed/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoto committed Sep 3, 2008
2 parents f636faa + 1440b76 commit 14fc7dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/bio/appl/paml/codeml/report.rb
Expand Up @@ -34,12 +34,13 @@ class Codeml
# report.tree_lengh # => Estimated phylogetic tree length
class Report

attr_reader :tree_log_likelihood, :tree_length, :alpha
attr_reader :tree_log_likelihood, :tree_length, :alpha, :tree

def initialize(codeml_report)
@tree_log_likelihood = pull_tree_log_likelihood(codeml_report)
@tree_length = pull_tree_length(codeml_report)
@alpha = pull_alpha(codeml_report)
@tree = pull_tree(codeml_report)
end

private
Expand All @@ -57,6 +58,10 @@ def pull_alpha(text)
text[/alpha .+ =\s+(-?\d+(\.\d+)?)/,1].to_f
end

def pull_tree(text)
text[/([^\n]+)\n\nDetailed/m,1]
end

end # End Report
end # End Codeml
end # End Bio::PAML
5 changes: 5 additions & 0 deletions test/unit/bio/appl/paml/codeml/test_report.rb
Expand Up @@ -34,4 +34,9 @@ def test_alpha
assert_equal(0.58871, @example_report.alpha)
end

def test_tree
tree = "(((rabbit: 0.082889, rat: 0.187866): 0.038008, human: 0.055050): 0.033639, goat-cow: 0.096992, marsupial: 0.284574);"
assert_equal(tree, @example_report.tree)
end

end

0 comments on commit 14fc7dd

Please sign in to comment.