Those numbers in bold are parsed as strings. It is up to you to coerce
them to values of types that you know them to be.
The "None" type is for cases where there are no internal node labels.
You will need special logic to handle those cases, e.g.
~~~
if nd.label is None:
support = 0.0 # (or None or something else)
else:
support = float(nd.label)
~~~
A full working example is at the bottom of this email.
There are some quirks with the NEWICK format you need to be aware of
when using bipartitions. These are covered in the Primer, and I suggest
you look through that carefully. The two biggest ones are:
(1) You will need to be sure to use the same taxon namespace instance to
manage all trees if you want to relate splits across trees or across files.
(2) The basal bifurcation of unrooted trees will be collapsed when
encoding bipartitions. DendroPy assumes trees are unrooted unless
explicitly told otherwise using either a "[&R]" token in the data string
or a ``rooting='force-rooted'`` in the read instruction.
I should also note that, for future reference, either with this software
or any other, issues such as this could be handle a lot more efficiently
if you were to provide a minimum working example (MWE) in your question,
as well as the fundamental/basic information required for someone else
to understand your problem. In this case, a sample tree would have been
not just helpful, but actually necessary.
~~~
#! /usr/bin/env python
import dendropy
s =
"(0:0.0101840927893,((8:7.47093214137e-07,6:0.00972396196851)48:7.47093214137e-07,(((9:0.0206723482777,(((4:7.47093214137e-07,1:7.47093214137e-07)31:7.47093214137e-07,7:7.47093214137e-07)51:7.47093214137e-07,10:0.0100623536065)38:7.47093214137e-07)71:0.00999640825353,(5:7.47093214137e-07,2:7.47093214137e-07)95:0.0215823143978)33:7.47093214137e-07,3:0.0321207186687)84:0.0204664382225):0.0101840927893);"
tree = dendropy.Tree.get(data=s, schema="newick")
tree.encode_bipartitions()
for nd in tree:
try:
nd.support = float(nd.label)
except TypeError:
nd.support = None
if nd.support is not None:
print("{}: {}".format(
nd.bipartition.split_as_bitstring(),
nd.support))
~~~
On 6/8/16 2:34 PM, Will Chandler wrote:
> Sorry, I may have been a bit misleading. The link I posted is just the
> format of the Newick file with bootstraps I'm using -- my actual files
> have no strings in them. An example:
>
> (0:0.0101840927893,((8:7.47093214137e-07,6:0.00972396196851)*48*:7.47093214137e-07,(((9:0.0206723482777,(((4:7.47093214137e-07,1:7.47093214137e-07)*31*:7.47093214137e-07,7:7.47093214137e-07)*51*:7.47093214137e-07,10:0.0100623536065)*38*:7.47093214137e-07)*71*:0.00999640825353,(5:7.47093214137e-07,2:7.47093214137e-07)*95*:0.0215823143978)*33*:7.47093214137e-07,3:0.0321207186687)*84*:0.0204664382225):0.0101840927893);
> > > <mailto:
dendropy-user...@googlegroups.com
> <javascript:> <javascript:>>.
> <
http://github.com/jeetsukumaran> <
http://github.com/jeetsukumaran
> > an email to
dendropy-user...@googlegroups.com <javascript:>
> > <mailto:
dendropy-user...@googlegroups.com <javascript:>>.
> <mailto:
dendropy-user...@googlegroups.com>.