Yay for DendroPy 4!
(1) What you are doing looks correct, i.e., explicitly passing in the
taxon namespace. You can check that you are referencing the same taxon
namespace, of course, by something like:
~~~
assert tree.taxon_namespace is d.taxon_namespace
~~~
Now, if the above is true, then the issue is whether or not the taxa are
correctly being mapped to the proper taxon instances across the data.
The ``preserve_underscores=True`` is almost certainly correct and need
when working with taxa spanning FASTA and Newick/Nexus formats, so that
looks fine too. What do the taxon labels look like across the data sets?
Can you post the data or representative data?
(2) For the renaming of the taxa, just change the label of the taxon
instance, and everything will update across the board, as long as the
taxon and taxon namespace references are correct. E.g
~~~
import dendropy
tree = dendropy.Tree.get(
data="(A,(B,(C,D)));",
schema="newick")
dna = dendropy.DnaCharacterMatrix.get(
data=">A\nACGT\n >B\nACGT\n >C\nACGT\n >D\nACGT\n",
schema="fasta",
taxon_namespace=tree.taxon_namespace)
print(tree.as_string("newick"))
print(dna.as_string("fasta"))
assert tree.taxon_namespace is dna.taxon_namespace
assert tree.taxon_namespace[0].label == "A"
tree.taxon_namespace[0].label = "hello"
s = dna.taxon_namespace.get_taxon(label="B")
s.label = "world"
print(tree.as_string("newick"))
print(dna.as_string("fasta"))
~~~
> --
> 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/
--------------------------------------