Codeml python wrapper


Copyright (C) 2018 Arthur Zwaenepoel

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Contact: arzwa@psb.vib-ugent.be

A python wrapper for codeml (PAML package, Yang 2007)


class wgd.codeml.Codeml(codeml='codeml', tmp='./', id='tmp', out_file=None, **kwargs)

Class for codeml (PAML Yang 2007) python wrapper. Defines the controle file and enables running codeml from within python in one line of code.

Parameters:
  • codeml – path to codeml executable (by default will look for codeml in the system PATH)
  • tmp – path to temporary directory, will default to the current working directory (‘./’)
  • id – filename prefix for output/tmp files
  • kwargs

    other codeml keyword arguments (see PAML user guide):

    'seqfile': None,
    'outfile': self.out_file,
    'noisy': 0,
    'verbose': 0,
    'runmode': -2,
    'seqtype': 1,
    'CodonFreq': 2,
    'clock': 0,
    'aaDist': 0,
    'aaRatefile': 'dat/jones.dat',
    'model': 0,
    'NSsites': 0,
    'icode': 0,
    'Mgene': 0,
    'fix_kappa': 0,
    'kappa': 2,
    'fix_omega': 0,
    'omega': .4,
    'fix_alpha': 1,
    'alpha': 0,
    'Malpha': 0,
    'ncatG': 8,
    'getSE': 0,
    'RateAncestor': 1,
    'Small_Diff': .5e-6,
    'cleandata': 1,
    'method': 0
    

Usage examples:

Run codeml with default (Ks analysis) settings on a multiple sequence alignment (msa.fasta)::

>>> codeml = Codeml()
>>> codeml.run_codeml('msa.fasta')

Change control setting CodonFreq to the F1x4 option (1) and rerun above example::

>>> codeml.control['CodonFreq'] = 1
>>> codeml.run_codeml('msa.fasta')

Do the above example directly without modifying the control settings in the dict directly::

>>> codeml = Codeml(CodonFreq=1)
>>> codeml.run_codeml('msa.fasta')

Print the default control settings::

>>> codeml = Codeml()
>>> print(codeml)
__init__(codeml='codeml', tmp='./', id='tmp', out_file=None, **kwargs)

Codeml wrapper init. Initializes the default control file for Ks analysis as proposed by Vanneste et al. (2013). Takes as keyword arguments the options from the normal codeml distribution. Control settings are stored in a dictionary that can be accessed with the .control attribute

Parameters:
  • codeml – path to codeml executable (by default will look for codeml in the system PATH)
  • tmp – path to temporary directory, will default to the current working directory (‘./’)
  • id – filename prefix for output/tmp files
  • kwargs – any codeml control option (see PAML user guide)
run_codeml(msa=None, raw=False, preserve=False, times=1)

Run codeml on a multiple sequence alignment file

Parameters:
  • msa – multiple sequence alignment file
  • raw – boolean, return raw results?
  • preserve – boolean, preserve intermediate files?
  • times – integer, perform codeml multiple times (average results)
Returns:

dictionary with Ks, Kn and Kn/Ks (omega) values