Beispiel #1
0
from ete_dev import Tree
# Loads a tree with internal node names
t = Tree('(A:1,(B:1,(E:1,D:1)Internal_1:0.5)Internal_2:0.5)Root;', format=1)
# And prints its newick representation omiting all the information but
# the tree topology
print t.write(format=100) # (,(,(,)));
# We can also write into a file
t.write(format=100, outfile="/tmp/tree.new")
Beispiel #2
0
    #node.img_style["bgcolor"] = random_color()

#Tree().show()
ts = TreeStyle()
ts.mode = "c"
ts.layout_fn = layout 
ts.show_leaf_name = False
ts.arc_span = 340
ts.arc_start = -70
#ts.allow_face_overlap = True
#ts.show_branch_length = True
ts.draw_guiding_lines = False
ts.optimal_scale_level = "mid"
ts.extra_branch_line_color = "red"
ts.root_opening_factor = 0.50
ts.show_border = True
ts.scale = None
t = Tree()
t.populate(200, random_branches=True, branch_range=(0, 0))
t.dist = 0.0
dists = [n.dist for n in t.traverse() if n.dist != 0]
#print max(dists), min(dists)
t.write(outfile="test.nw")
#for s in [5, None]:
#    ts.scale = s
#    t.render("img_scale_%s.png" %s, tree_style = ts, w=600)
t.show(tree_style=ts)


    
        
Beispiel #3
0
ancestor = t.get_common_ancestor("J", "F", "C")
# Let's label  leaf nodes
for leaf in t.traverse():
    if leaf.name in "AEIOU":
        leaf.add_features(vowel=True, confidence=random.random())
    else:
        leaf.add_features(vowel=False, confidence=random.random())
# Let's detect leaf nodes under "ancestor" with distance higher thatn
# 1. Note that I'm traversing a subtree which starts from "ancestor"
matches = [leaf for leaf in ancestor.traverse() if leaf.dist > 1.0]
# And save this pre-computed information into the ancestor node
ancestor.add_feature("long_branch_nodes", matches)
print
print "NHX notation including vowel and confidence attributes"
print
print t.write(features=["vowel", "confidence"])
print
print "NHX notation including all node's data"
print
# Note that when all features are requested, only those with values
# equal to text-strings or numbers are considered. "long_branch_nodes"
# is not included into the newick string.
print t.write(features=[])
print
print "basic newick formats are still available"
print
print t.write(format=9, features=["vowel"])
# You don't need to do anything speciall to read NHX notation. Just
# specify the newick format and the NHX tags will be automatically
# detected.
nw = """
Beispiel #4
0
from ete_dev import Tree
tree = Tree('(A:1,(B:1,(C:1,D:1):0.5):0.5);')
# Prints the name of every leaf under the tree root
print "Leaf names:"
for leaf in tree.get_leaves():
    print leaf.name
# Label nodes as terminal or internal. If internal, saves also the
# number of leaves that it contains.
print "Labeled tree:"
for node in tree.get_descendants():
    if node.is_leaf():
        node.add_features(ntype="terminal")
    else:
        node.add_features(ntype="internal", size=len(node))
# Gets the extended newick of the tree including new node features
print tree.write(features=[])
Beispiel #5
0
ancestor=t.get_common_ancestor("J", "F", "C")
# Let's label  leaf nodes
for leaf in t.traverse():
    if leaf.name in "AEIOU":
        leaf.add_features(vowel=True, confidence=random.random())
    else:
        leaf.add_features(vowel=False, confidence=random.random())
# Let's detect leaf nodes under "ancestor" with distance higher thatn
# 1. Note that I'm traversing a subtree which starts from "ancestor"
matches = [leaf for leaf in ancestor.traverse() if leaf.dist>1.0]
# And save this pre-computed information into the ancestor node
ancestor.add_feature("long_branch_nodes", matches)
print
print "NHX notation including vowel and confidence attributes"
print
print t.write(features=["vowel", "confidence"])
print
print "NHX notation including all node's data"
print
# Note that when all features are requested, only those with values
# equal to text-strings or numbers are considered. "long_branch_nodes"
# is not included into the newick string.
print t.write(features=[])
print
print "basic newick formats are still available"
print
print t.write(format=9, features=["vowel"])
# You don't need to do anything speciall to read NHX notation. Just
# specify the newick format and the NHX tags will be automatically
# detected.
nw = """
Beispiel #6
0
        # faces.add_face_to_node(f, node, 0, position="branch-right")
        f.border.width = 0
    # node.img_style["bgcolor"] = random_color()


# Tree().show()
ts = TreeStyle()
ts.mode = "c"
ts.layout_fn = layout
ts.show_leaf_name = False
ts.arc_span = 340
ts.arc_start = -70
# ts.allow_face_overlap = True
# ts.show_branch_length = True
ts.draw_guiding_lines = False
ts.optimal_scale_level = "mid"
ts.extra_branch_line_color = "red"
ts.root_opening_factor = 0.50
ts.show_border = True
ts.scale = None
t = Tree()
t.populate(200, random_branches=True, branch_range=(0, 0))
t.dist = 0.0
dists = [n.dist for n in t.traverse() if n.dist != 0]
# print max(dists), min(dists)
t.write(outfile="test.nw")
# for s in [5, None]:
#    ts.scale = s
#    t.render("img_scale_%s.png" %s, tree_style = ts, w=600)
t.show(tree_style=ts)
Beispiel #7
0
from ete_dev import Tree
tree = Tree( '(A:1,(B:1,(C:1,D:1):0.5):0.5);' )
# Prints the name of every leaf under the tree root
print "Leaf names:"
for leaf in tree.get_leaves():
    print leaf.name
# Label nodes as terminal or internal. If internal, saves also the
# number of leaves that it contains.
print "Labeled tree:"
for node in tree.get_descendants():
    if node.is_leaf():
        node.add_features(ntype="terminal")
    else:
        node.add_features(ntype="internal", size=len(node))
# Gets the extended newick of the tree including new node features
print tree.write(features=[])