Biopython: Bio.Phylo.PAML.codeml's results parser quietly fails to read all the data

Created on 10 Mar 2015  路  11Comments  路  Source: biopython/biopython

For a prettier version of the following go here: http://stackoverflow.com/posts/20872441/edit, or here: https://www.biostars.org/p/89848/.

Biopython comes with methods to interface with the PAML package for phylogenetic analysis.

In particular I am using Bio.Phylo.PAML to run analyses using PAML's codeml.exe program which in my case does Ka/Ks (dN/dS) ratio analysis on pairs of orthologous gene sequences.

After running the analysis using results = cml.run() I can see it has successfully generated result.out files that look about right. Most importantly the final line of the file is what I need to parse into Python:

t= 0.2173  S=   703.9  N=  1489.1  dN/dS=  0.2247  dN = 0.0344  dS = 0.1529

What I am most interested in is dN/dS = 0.2247

According to Biopython's PAML wiki this value can be obtained from Python by doing results = cml.run() which generates a dictionary with a set of values I am interested in after running the analysis. The wiki claims I can find the values I need in a key called 'parameters'. But this only returns one of the values I need t= 0.2173, look:

>>> results.values()
['Fcodon', 'One dN/dS ratio for branches, ', '4.7b', {0: {'description': 'one-ratio', 'parameters': {'t': 0.1982}}}, {'htlv': {}, 'stlv': {}}]

Notice, that my parameters key only contains the t= 0.2173 and has omitted S= 703.9 N= 1489.1 dN/dS= 0.2247 dN = 0.0344 dS = 0.1529

Could anybody with codeml experience explain to me why the parser fails to yield most of the parameters (values) I am interested in?

Extra details

  • Using Python2.7, PAML4.7a
  • Running on Windows 7
  • I will readily edit in any data or info you require to help me fix this

All 11 comments

I thought this looked familiar - your BioStar question was originally over a year ago https://www.biostars.org/p/89848/

Which version of Biopython are you using here? CC @brandoninvergo

Could you please provide the results file? Even better would be an alignment, tree and parameters that cause the problem.

The huge combination of possible parameters, the changing output under different parameter combos, and the occasionally changing output from one PAML version to the next all mean that it is very likely that the parser doesn't know how to handle your particular situation.

Also, as a sanity check, have you run the Bio.Phylo.PAML unit tests?

Hi @brandoninvergo,

Do you still want me to replicate this bug/get the results file for you? Maybe it's already fixed by now?

I think it's sorted now @a1ultima, thanks.

I still have this bug in PAML4.9. Should I just reinstall the older version (4.7) to fix it? Or is there another way around it?

Very sorry for the late reply, @jconover11. Are you using the latest Biopython version on Git?

Yes, I did find the newest updates. Thanks for the reply!

Sorry, do you mean you've updated and it now works, or that you've updated and you still have the problem?

Whoops, I should have been more specific. I have the correct update, and I've gotten it to work now. Thanks!

OK, glad to hear it works now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

harryjubb picture harryjubb  路  10Comments

peterjc picture peterjc  路  8Comments

MarkusPiotrowski picture MarkusPiotrowski  路  6Comments

graph1994 picture graph1994  路  5Comments

Nelson-Gon picture Nelson-Gon  路  6Comments