Hi Yan Wong,
Mark is correct with respect to DendroPy 3: this is not possible.
With DendroPy 4, however, this *is* possible, if you are willing to
forgo the rich taxon object mapping and read in the labels as *node*
labels rather than taxon labels:
######
import dendropy
tree = dendropy.Tree.get_from_string(
"(,(,,),);",
schema="newick",
suppress_internal_node_taxa=True,
suppress_external_node_taxa=True)
print(tree.as_string("newick"))
#####
(The cost of this is that there is no rich taxon management, which means
all functionality that relies on this will not be applicable. In
particular, bipartitions/splits hashes will not be able to be
calculated, and many functions, from patristic distances to RF distances
will not be able available.
The reason anonymous taxa in NEWICK format is not supported is that it
is more important, IMHO, to support incomplete leaf-set trees, and the
book-keeping for these would be a nightmare to handle with anonymous taxa.)
I might back-port support for the above to DendroPy 3 in the future, but
it will not be for a while, and definitely not before DendroPy 4 goes
public.
On the other hand, apart from SumTrees and functionality in the
`treesum` module, DendroPy 4 should be stable enough for you to work
with. Documentation is lagging, but most of the DendroPy 3 API is still
supported, either directly as DendroPy 3 or with deprecation warnings,
and, of course, you could always turn to this group for questions on the
new API if there is any confusion or lack of legacy support.
At this point, I would encourage you to (permanently) switch to using
DendroPy 4. But if you are uncomfortable with that and really need to
process files with anonymous taxa, you could run the following in
DendroPy 4 to convert the labeling scheme to one parseable by DendroPy 3:
####
import dendropy
tree = dendropy.Tree.get_from_string(
"(,(,,),);",
schema="newick",
suppress_internal_node_taxa=True,
suppress_external_node_taxa=True)
for idx, nd in enumerate(tree):
nd.taxon = tree.taxon_namespace.new_taxon(
label="t{}".format(idx+1))
print(tree.as_string("newick"))
###
-- jeet
> --
> You received this message because you are subscribed to the Google
> Groups "DendroPy Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
dendropy-user...@googlegroups.com
> <mailto:
dendropy-user...@googlegroups.com>.
--------------------------------------
Jeet Sukumaran
--------------------------------------
jeetsu...@gmail.com
--------------------------------------
Blog/Personal Pages:
http://jeetworks.org/
GitHub Repositories:
http://github.com/jeetsukumaran
Photographs (as stream):
http://www.flickr.com/photos/jeetsukumaran/
Photographs (by galleries):
http://www.flickr.com/photos/jeetsukumaran/sets/
--------------------------------------