This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython PAML CodeML Error [Errno 2]

I try integrate PAML in a pipeline in order to analyse a large number of alignment. But, I met a problem with the python interface to codeML. Indeed, while codeML works perfectly when I call it directly, I don't manage to make it work through the codeml.py interface. I launch Python3.5 in the directory "/home/PAML" and all files are in this directory.

I launch codeML through those command lines in python3.5:

>>> from Bio.Phylo.PAML import codeml
>>> cml = codeml.Codeml()
>>> cml.alignment = "lysozymeLarge.nuc"
>>> cml.tree = "lysozymeLarge.trees"
>>> cml.out_file = "results.out"
>>> cml.working_dir = "/home/PAML"
>>> cml.set_options(noisy = 4)
>>> cml.set_options(verbose = 5)
>>> cml.set_options(NSsites=[0])
>>> cml.set_options(runmode = 0)
>>> cml.set_options(seqtype = 1)
>>> cml.set_options(omega = 0.4)
>>> cml.set_options(kappa = 2)
>>> cml.set_options(fix_alpha = 1)
>>> cml.set_options(CodonFreq = 2)
>>> 
>>> cml.run()

And, I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/Bio/Phylo/PAML/codeml.py", line 186, in run
    Paml.run(self, ctl_file, verbose, command)
  File "/usr/local/lib/python3.5/site-packages/Bio/Phylo/PAML/_paml.py", line 145, in run
    stdout=subprocess.PIPE)
  File "/usr/local/lib/python3.5/subprocess.py", line 560, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'codeml'

It doesn't find codeML, but it is integrated in the PATH, and works perfectly anywhere through the terminal with only this command:

codeml codeml.ctl

Do you have any idea what could be the problem?

biopython paml codeml

2 answers

Does it work if you specify the full, absolute path to the codeml binary within Biopython? E.g.:

cml.run(command="/home/PAML/codeml")

It works! I wasn't expecting that kind of problem since CodeML is in the PATH, I will check everything next time.

Thank you very much.

Log in to answer this question.