[Biopython] saving tree data in phyloXML format

Michael Thon mike.thon at gmail.com
Mon Oct 11 15:13:08 UTC 2010


> 
> Example:
> 
> from Bio.Phylo import PhyloXML
> # Get a clade...
> myclade = mytree.find_any(...)
> myclade.node_id = PhyloXML.Id("foo")
> myclade.uri = PhyloXML.Uri("http://foo-db.org")
> Phylo.write(mytree, "mytree.xml", "phyloxml")
> 
> (*untested*)
> 

I was assigning a string to node_id . I just switched to using a PhyloXML.Id.
Note that the tree I'm adding data to is a Bio.Phylo.Newick.Tree .  I found a method as_phyloxml() which seems to return a Phylogeny object.   I tried this on my tree before I added the node_id and other stuff to the clades and now my phyloXML files look fine (i.e. the node_id appears in the file as I expect).

> 
> 
> myclade.other = [PhyloXML.Other("annotation", namespace="", children=[
>                    PhyloXML.Other("desc", value="Base of many coffees"),
>                    PhyloXML.Other("uri",
> value="http://en.wikipedia.org/wiki/Espresso")])]
> 
> (*untested*)
> 
> Note that the Clade.other attribute is expected to be a list. This is low-level
> stuff meant for adding elements outside the phyloXML spec, so if it seems a
> little ugly... yes, it is.

I will give this a try.

Thanks for your help.
Mike



More information about the Biopython mailing list