<p><strong>Biopython</strong> comes with methods to interface with the <strong>PAML</strong> package for phylogenetic analysis.</p>

<p>In particular I am using <a href='http://biopython.org/wiki/PAML'>Bio.Phylo.PAML</a> 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.</p>

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

<pre><code>t= 0.2173  S=   703.9  N=  1489.1  dN/dS=  0.2247  dN = 0.0344  dS = 0.1529
</code></pre>

<p>What I am most interested in is <code>dN/dS = 0.2247</code></p>

<p>According to Biopython's <a href='http://biopython.org/wiki/PAML'>PAML wiki</a> this value can be obtained from Python by doing <code>results = cml.run()</code> 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 <code>'parameters'</code>. But this only returns one of the values I need <code>t= 0.2173</code>, look: </p>

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

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

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

<p>Thank you</p>

<p>Hi,</p>

<p>You can obtain omega values for each branch using the following commands:</p>

<p>from Bio.Phylo.PAML import codeml</p>

<p>results = codeml.read(paml_outputfile)</p>

<p>print results[&quot;NSsites&quot;][0][&quot;parameters&quot;][&quot;omega&quot;]</p>

<p>This gives you a list of omega (dn/ds) for each branch</p>

<p>I am using version 4.7b and biopython-1.6.3</p>

<p>Hope that helps!</p>

<p>A</p>
