本文整理汇总了Python中dendropy.Tree.__str__方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.__str__方法的具体用法?Python Tree.__str__怎么用?Python Tree.__str__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dendropy.Tree
的用法示例。
在下文中一共展示了Tree.__str__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pretty_print_trees
# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import __str__ [as 别名]
def pretty_print_trees():
print "\n. OK, I'm reformatting the RAxML results for nice printing..."
"""Reformats the phylogeny, such that each taxon label looks like this:
trna12-AlaTCT[6/7]
. . . where 6 is the number of sequences collapsed into this sequence, and 7 is the number of total tRNAs in the databse."""
species_list = species_trna_seq.keys()
species_list.sort()
for species in species_list:
#print species_trna_dups[species]
treepath = RAXMLDIR + "/RAxML_result." + species
if False == os.path.exists( treepath ):
continue
newtreepath = TREEDIR + "/" + species + ".tree"
t = Tree()
t.read_from_path(treepath, "newick")
print " -->", treepath
trna_count = count_trna_types(species)
#print trna_count
newts = t.__str__()
for taxon in t.taxon_set:
#print "372:", taxon.label
#thisac = get_ac_from_name(taxon.label)
thisac = species_trna_mtrip[species][taxon.label]
count_this_type = trna_count[thisac]
count_dups = 0
if taxon.label in species_trna_dups[species]:
count_dups = species_trna_dups[species][taxon.label].__len__() + 1
if count_dups <= 1:
count_dups = ""
else:
count_dups = "(" + count_dups.__str__() + ")"
mark = ""
if species in species_switchedtrnas:
print "534:", species_switchedtrnas[species]
if species_switchedtrnas[species].__contains__(taxon.label):
mark = "***"
newts = re.sub( taxon.label, (taxon.label + count_dups + "[" + count_this_type.__str__()+ "]" + mark), newts)
fout = open(newtreepath, "w")
fout.write( newts + "\n" )
fout.close()