[Biopython] Questions about rooting trees using Phylo
Eric Talevich
etal at uga.edu
Fri Nov 2 03:48:40 UTC 2012
On Thu, Nov 1, 2012 at 12:50 PM, 阮铮 <...> wrote:
> Hi Eric,
>
> Thanks for your previous help about changing terminal tip names of
> trees. I now come into another problem about rooting trees with outgroup.
> For example, I use root_with_outgroup method to root the tree below:
>
> ((S1:0.010277,S2:0.010277):0.007777,S4:0.018054,S3:0.018431);
>
> Phylo will give me the following output:
>
>
> (((S1:0.01028,S2:0.01028):0.00778,S3:0.01843):0.01805,S4:0.00000):1.00000;
>
> This is great. But there is an optional branch length ":1.00000". Can I
> possibly remove this, because it may puzzle some programs to read the tree.
>
> PS: It seems Phylo cookbook is not working now. Will you come to have a
> check about it?
>
> Thanks!
> Zheng
>
>
Hi Zheng,
The Newick parser in Bio.Phylo automatically fills in missing branch
lengths as 1.0 (probably a misfeature), which is where the extra branch
length is coming from. You can remove it like this:
tree = Phylo.read("example.nwk", "newick")
tree.root_with_outgroup("S4")
# Overwrite the root-node's branch length
tree.root.branch_length = 0.0
# Or:
tree.root.branch_length = None
# Save a copy
Phylo.write(tree, "example-rerooted.nwk", "newick")
For quick help with any part of Biopython, consider signing up for the
Biopython users mailing list:
http://lists.open-bio.org/mailman/listinfo/biopython
(The Biopython wiki, which includes the Phylo_cookbook page, is currently
out of service right now, but should be back up soon.)
Cheers,
Eric
More information about the Biopython
mailing list