[Biopython-dev] Adding format method to phylo tree object?
Eric Talevich
eric.talevich at gmail.com
Thu Mar 11 22:54:38 UTC 2010
On Thu, Mar 11, 2010 at 6:30 AM, Peter <biopython at maubp.freeserve.co.uk>wrote:
> Hi Eric (et al),
>
> Are you familiar with the format method of the SeqRecord and alignment
> object (plus the __format__ method which does the same thing aiming to
> work nicely with the Python 2.6 built in function format)? This allows
> the user to turn their data into a string in a specified output
> format. Internally the method calls Bio.SeqIO.write (or AlignIO) with
> a StringIO handle.
>
> Do you think it would it make sense to have this for the tree objects
> in Bio.Phylo, allowing easy access to the object as a Newick tree
> format etc?
>
Sure, I could do that. It makes a lot of sense for Newick trees, and could
be useful with the XML formats for debugging.
>
> For people using IPython, the __pretty__ method looks related. I know
> the Bio.Nexus tree has a "prity print" method which might be exposed
> like this. I wonder if this convention will become more widespread?
>
> http://ipython.scipy.org/doc/stable/html/api/generated/IPython.external.pretty.html
>
I didn't know about that. I also have a pretty_print method in Bio.Phylo
which does something much different from the Bio.Nexus printer -- the Nexus
one looks more like it's more useful for debugging the Tree object's
internal structure in terms of references, so (highly biased judgment) I'm
inclined to use the code from Bio.Phylo._utils.pretty_print to implement
__pretty__ for IPython. But I'll play with this IPython feature to see how
it's supposed to behave in general.
-Eric
More information about the Biopython-dev
mailing list