[Biopython-dev] [biopython] Bugfix in test_Phylo; branch length formatter for Newick trees (#7)

Eric Talevich eric.talevich at gmail.com
Fri May 27 03:57:14 UTC 2011


Aaron & folks,

I've committed the original patch and another based on this discussion.
https://github.com/biopython/biopython/commit/cc48ad211266cb9ac118df15889597912c79a994


On Wed, May 25, 2011 at 10:44 AM, Aaron Gallagher <habnabit at gmail.com>wrote:

> On May 25, 2011, at 7:33 AM, Eric Talevich wrote:
>
> > 1. [...]
> > Since the branch length is always supposed to be a numeric type or
> > None, format strings alone should be sufficient to do whatever the
> > user wants, right?
>
> Maybe this is more sensible; I've been struggling to come up with a use
> case of a full callable though it seemed to make sense when I was
> implementing it.
>
> > Alternatively, the switch in _info_factory could go: [...]
>
> I'm not a huge fan of implementing APIs like this in python, really. It is
> seeming more and more like the most sensible thing is to just specify a
> format string.
>

I changed the format_branch_length argument to take a simple format string
instead of a function:
https://github.com/biopython/biopython/commit/decd2a19fa3631cc34aaaf4c79d3af96c26fa1d9



>  > 2. Out of curiousity, is there a certain program out there that uses
> > branch length in a different format? I hadn't considered this before,
> > but I can see how scientific notation would be useful sometimes if the
> > target program can handle it.
>
> The issue in my case was not so much needing a different format (though the
> tools I work on /do/ support scientific notation) so much as that the Newick
> trees I generate have precision down to 1e-6. Round-tripping them through
> biopython was truncating branches with very small lengths.
>

Good to know. The format for confidences is also hard-coded ("%1.2f"), do
you suppose that should be given the same treatment?

Thanks again,
Eric



More information about the Biopython-dev mailing list