Question: Issue with running Codeml using Biopython
gravatar for laurenmee17
2.0 years ago by
laurenmee170 wrote:

Hi there

This is my first post so please be kind if my terminology is incorrect!

I've been trying to run a python script that uses the BioPython module Phylo.Paml to try and automate codeml on a number of alignments.

Here is my script (in progress)


import sys
from Bio.Phylo.PAML import codeml

#USAGE python aln tree ctrl output

cml = codeml.Codeml(alignment = sys.argv[1], 
        tree = sys.argv[2],
        out_file = sys.argv[4],
        working_dir = ".")
ctl_file = sys.argv[3]
verbose = TRUE

Wrote as per direction from the BioPython.Phylo.PAML page (

This code works when I use it singly but not as I want it to. The console freezes as if the script is running indefinitely and does not stop until I cancel it. When I do I get this error message

Traceback (most recent call last):
  File "", line 14, in <module>
  File "/home/mee/miniconda3/lib/python3.6/site-packages/Bio/Phylo/PAML/", line 182, in run, ctl_file, verbose, command)
  File "/home/mee/miniconda3/lib/python3.6/site-packages/Bio/Phylo/PAML/", line 121, in run
    result_code =[command, ctl_file], stdout=dn, stderr=dn)
  File "/home/mee/miniconda3/lib/python3.6/", line 269, in call
    return p.wait(timeout=timeout)
  File "/home/mee/miniconda3/lib/python3.6/", line 1457, in wait
    (pid, sts) = self._try_wait(0)
  File "/home/mee/miniconda3/lib/python3.6/", line 1404, in _try_wait
    (pid, sts) = os.waitpid(, wait_flags)

But when I check my working directory all the output files of the run are waiting there. Similarly, if I cancel the command quickly enough and initiate codeml I am taken to a working screen where codeml is actively running through the files I have input into the script.


linux codeml biopython python paml • 977 views
ADD COMMENTlink written 2.0 years ago by laurenmee170

Could you explain a little more what you mean by,

This code works when I use it singly but not as I want it to.

I don't thing your verbose = TRUE line is doing anything FYI. You should be running it as Could you do that and post what output you get in that case?

ADD REPLYlink written 2.0 years ago by Joe18k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1853 users visited in the last hour