class Bio::PAML::Codeml

Description

Bio::PAML::Codeml is a wrapper for estimating evolutionary rate using the CODEML tool. The class provides methods for generating the necessary configuration file, and running codeml with the specified binary. Codeml output is returned when codeml is run. Bio::PAML::Codeml::Report and Bio::PAML::Codeml::Rates provide simple classes for parsing and accessing the Codeml report and rates files respectively.

Examples

Example 1:

require 'bio'
# Reads multi-fasta formatted file and gets a Bio::Alignment object.
alignment = Bio::FlatFile.open(Bio::Alignment::MultiFastaFormat,
                               'example.fst').next_entry.alignment
# Reads newick tree from a file
tree = Bio::FlatFile.open(Bio::Newick, 'example.tree').next_entry.tree
# Creates a Codeml object
codeml = Bio::PAML::Codeml.new
# Sets parameters
codeml.parameters[:runmode] = 0
codeml.parameters[:RateAncestor] = 1
# You can also set many parameters at a time.
codeml.parameters.update({ :alpha => 0.5, :fix_alpha => 0 })
# Executes codeml with the alignment and the tree
report = codeml.query(alignment, tree)

Example 2 (Obsolete usage):

# Create a control file, setting some Codeml options
# Default parameters are used otherwise, see RDoc for defaults
# The names of the parameters correspond to those specified
# in the Codeml documentation
control_file = Tempfile.new('codeml_ctl')
control_file.close(false)
# Prepare output file as a temporary file
output_file = Tempfile.new('codeml_test')
output_file.close(false)
Bio::PAML::Codeml.create_control_file(config_file.path, {
  :model       => 1,
  :fix_kappa   => 1,
  :aaRatefile  => TEST_DATA + '/wag.dat',
  :seqfile     => TEST_DATA + '/abglobin.aa',
  :treefile    => TEST_DATA + '/abglobin.trees',
  :outfile     => output_file.path,
})

# Create an instance of Codeml specifying where the codeml binary is
codeml = Bio::PAML::Codeml.new('/path/to/codeml')

# Run codeml using a control file
# Returns the command line output
codeml_output = codeml.run(control_file)