Exemple #1
0
def layout(node):
    node.img_style["size"] = 5
    node.img_style["hz_line_width"] = 0
    node.img_style["vt_line_width"] = 0
    if node.is_leaf():
        f = faces.AttrFace("name", fgcolor="steelblue", fsize=20)
        faces.add_face_to_node(f, node, 0, position="aligned")

        f = faces.AttrFace("name", fsize=15)
        faces.add_face_to_node(f, node, 0, position="branch-right")
    else:
        f = faces.TextFace("uno", fsize=8)
        for x in xrange(random.randint(1, 5)):
            faces.add_face_to_node(f, node, 0, position="branch-top")

        f = faces.TextFace("otromassssssssssss", fsize=8)
        for x in xrange(random.randint(1, 5)):
            faces.add_face_to_node(f, node, 0, position="branch-bottom")

    f = faces.CircleFace(20, "red")
    f.opacity = 0.3
    faces.add_face_to_node(f, node, 0, position="float")
    f = faces.CircleFace(23, "blue")
    f.opacity = 0.3
    faces.add_face_to_node(f, node, 0, position="float-behind")
Exemple #2
0
 def layout(node):
     if node.is_leaf():
         N = AttrFace("name", fsize=7)
         faces.add_face_to_node(faces.AttrFace("name", "Arial", 10, None),
                                node,
                                0,
                                position='branch-right')
def layout(node):
    if node.is_leaf():

        #######################################################
        #~ Taxon Label Size and Margin Adjustment
        N = AttrFace("name", fsize=1200, fgcolor="#000000")
        N.margin_top = 250
        N.margin_right = 100  #outside
        N.margin_left = 1000  #inside
        N.margin_bottom = 250
        #######################################################

        #######################################################
        #~ Taxon Label Background Color Setting
        tmp = "<myTaxaonLabel>"
        #~ if not(node.name.find(tmp)) : N.background.color="#FF9999"
        #######################################################

        faces.add_face_to_node(N, node, 0, position="aligned")

    if (not node.is_leaf()):
        S = faces.AttrFace("support", fsize=200, fgcolor="#000000")
        S.margin_top = 20
        S.margin_right = 10
        S.margin_left = 20
        S.margin_bottom = 20
        faces.add_face_to_node(S, node, column=0, position="float")
        if "support" in node.features:
            # Creates a sphere face whose size is proportional to node's
            # feature "weight"
            C = CircleFace(radius=node.support * 20,
                           color="RoyalBlue",
                           style="sphere")
            # Let's make the sphere transparent
            C.opacity = 0.3
            # And place as a float face over the tree
            faces.add_face_to_node(C, node, position="float", column=1)
    style = NodeStyle()
    style["size"] = 0
    style["vt_line_width"] = 150
    style["hz_line_width"] = 150
    style["vt_line_type"] = 0  # 0 solid, 1 dashed, 2 dotted
    style["hz_line_type"] = 0
    node.set_style(style)

    bgcol1 = "#FFCCCC"
    bgcol2 = "#FFE5CC"
    bgcol3 = "#FFFFCC"
    bgcol4 = "#E5FFCC"
    bgcol5 = "#CCFFCC"
    bgcol6 = "#CCFFE5"
    bgcol7 = "#FFCCE5"
    bgcol8 = "#CCFFFF"
    bgcol9 = "#CCE5FF"
    bgcol10 = "#CCCCFF"
    bgcol11 = "#E5CCFF"
Exemple #4
0
 def _colorize(self, palette):
     """
     Assigns faces and colours to the locus trees for pretty rendering.
     :param palette: list
         List of strings representing colours in hexadecimal format.
     :return:
     """
     from ete2 import NodeStyle, faces
     if not self.L:
         self.locus_tree()  # computes & stores the tree
     ncol = len(palette)
     iFace = faces.AttrFace("I", fsize=8, text_suffix='/')
     pFace = faces.AttrFace("P", fsize=8)
     # idFace = faces.AttrFace("id", fsize=8)
     # suppFace = faces.AttrFace("support", text_suffix=" ", formatter="%.2f", fsize=8)
     coloured = dict((i, False) for i, g in enumerate(self.L.traverse(strategy="postorder")))
     current_colour = -1
     for g in self.L.traverse(strategy="postorder"):
         if not g.is_leaf():
             # g.add_face(suppFace, position="branch-bottom", column=-2)
             g.add_face(iFace, position="branch-top", column=-1)
             g.add_face(pFace, position="branch-top", column=0)
         if g.source:
             current_colour += 1
             current_colour %= ncol
             style = NodeStyle()
             style['vt_line_color'] = palette[current_colour]
             style['hz_line_color'] = palette[current_colour]
             style['size'] = 0
             style['fgcolor'] = '#000000'
             style["vt_line_width"] = 2
             style["hz_line_width"] = 2
             for gg in g.traverse():
                 if not coloured[gg.nid]:
                     gg.set_style(style)
                     coloured[gg.nid] = True
Exemple #5
0
def test_ultrametric():
    t = Tree()
    # Creates a random tree (not ultrametric)
    t.populate(100)

    # Convert tree to a ultrametric topology in which distance from
    # leaf to root is always 100. Two strategies are available:
    # balanced or fixed
    convert_to_ultrametric(t, 1.0, "balanced")

    # Print distances from all leaves to root. Due to precision issues
    # with the float type.  Branch lengths may show differences at
    # high precision levels, that's way I round to 6 decimal
    # positions.
    print "distance from all leaves to root:", \
          set([round(l.get_distance(t), 6)for l in t.iter_leaves()])
    nameFace = faces.AttrFace("name")
    t.show(ultrametric_layout)