[Biopython-dev] Bio.Phylo, Python 3 and Notebooks

Eric Talevich eric.talevich at gmail.com
Tue Oct 7 17:05:50 UTC 2014

On Tue, Oct 7, 2014 at 8:34 AM, Tiago Antao <tra at popgen.net> wrote:

> Hi,
> Sorry for the convoluted email, but the 3 topics of Bio.Phylo, Python 3
> and Notebooks are related.
> So, Biopython currently does not support Python3 completely because of
> Bio.Phylo dependency on networkx, which itself depends on either
> pygraphviz or pydot. Neither of which supports Python3. The pygraphviz
> version on github (not released) currently supports Python3 and it is
> good enough to at least run the cookbook. I am going to contact the
> pygraphviz developers with an encouragement to release whenever
> possible. So, that problem is probably be solved soon.
> I am trying to wrap up the notebook of Bio.Phylo (which is a copy of
> the chapter cookbook with a few adaptations). I have stumbled on a few
> problems. This will be used for reference:
> http://nbviewer.ipython.org/github/tiagoantao/biopython-notebook/blob/master/notebooks/13%20-%20Phylogenetics%20with%20Bio.Phylo.ipynb
Hi Tiago,

First off, I love this idea of converting the tutorial chapter/demo into a
notebook. Thanks for doing this.

> 1. Input 13 on the notebook above: There seems to be a Python3 problem
> (the typical str/bytes issue)? Potential P3 bug?

I suppose so. ElementTree compatibility with Python 3 strings/bytes has
always been weird. It might be as simple as a hard-coded version flag that
was only needed for Py3.1-3.3.

2. 14: Do you know where I can find the file other_trees.xml ? Could
> not find it

As Peter noted, that file is generated in the previous steps:
1. Parse data/phyloxml_examples.xml;
2. Write the first tree in that iterator to tree1.xml;
3. Write the remaining trees in the iterator to other_trees.xml.

Does IPython Notebook allow files to persist like that? If not, maybe a
StringIO object could take the place of the file outputs for this demo.

3. 15: The same from tree1.dnd

I don't see any line that generates that file, so maybe it was edited out
at some point. You could replace Line 15 with:

Phylo.convert("data/tree1.xml", "phyloxml", "data/tree1.nexml", "nexml")


Phylo.convert("data/int_node_labels.nwk", "newick", "data/tree1.nexml", "nexml")

> 4. 42: It seems that paml is not generating a 'lnL max' (just see the
> full dictionary appended there)? Potential cookbook bug?

Dunno. PAML versions vary in their output. Which version are you using?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython-dev/attachments/20141007/577fc69c/attachment.html>

More information about the Biopython-dev mailing list