使用 python 模块 dendropy 计算系统发育树上节点之间的成对距离时打印提示标签?

Printing tip labels when using the python module dendropy to calculate pairwise distances between nodes on a phylogenetic tree?

我正在尝试在 python 中创建一个数组,它将包含系统发育树上每对节点之间的所有成对距离。我目前正在使用 dendropy 来执行此操作。 (我最初查看了 biopython 但找不到执行此操作的选项)。到目前为止我的代码如下所示:

import dendropy

tree_data = []
tree = dendropy.Tree.get(path="gonno_microreact_tree.nwk",schema="newick")
pdc = tree.phylogenetic_distance_matrix()
for i, t1 in enumerate(tree.taxon_namespace[:-1]):
    for t2 in tree.taxon_namespace[i+1:]:
        tip_pair = {}
        tip_dist_list = []
        tip_pair[t1] = t2
        distance = pdc(t1, t2)
        tip_dist_list.append(tip_pair)
        tip_dist_list.append(distance)
        tree_data.append(tip_dist_list)
print tree_data

除提示标签的书写方式外,此方法效果很好。例如,tree_data 列表中的条目如下所示:

[{<Taxon 0x7fc4c160b090 'ERS135651'>: <Taxon 0x7fc4c160b150 'ERS135335'>}, 0.0001294946558138355]

但是newick文件中的提示只是分别标记为ERS135651和ERS135335。我怎样才能让 dendropy 只用原始提示标签编写数组,所以这个条目看起来像这样:

 [{ERS135651:ERS135335}, 0.0001294946558138355]

(我还阅读了 dendropy 文档,我知道它说要使用 treecalc 来执行此操作,如下所示:

pdc = treecalc.PatristicDistanceMatrix(tree)

但我只是收到一条错误消息,提示该命令不存在:

AttributeError: 'module' object has no attribute 'PairisticDistanceMatrix'

)

关于如何使它正常工作有什么建议吗?

将提示标签转换为字符串将它们转换为被语音标记包围的名称,例如:

t1 = str(t1)
print t1

给出:

"'ERS135651'"

因此,使用字符串拼接删除多余的语音标记可以将提示标签转换回其正确名称,例如:

t1 = t1.replace("'","")