def plot_tree(tree, base_name='tree', dir_name='gram'):
    read(tree)
    t = var.trees[-1]
    for n in t.iterNodes():
        if n.isLeaf:
            try:
                img = Image.open(get_image_path(n.name))
            except IOError as e:
                print n.name
                raise e
            w, h = img.size
            width, height = None, 6.5
            if w > h and (n.name in _wide_images):
                width, height = 12, None
            vmargin = 0
            lmargin = 11
            dimension_name = 'height'
            dimension = height
            if height is None:
                dimension_name = 'width'
                dimension = width
            node_name = n.name
            n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format(
                lmargin, dimension_name, dimension, get_image_path(node_name))

    tg = TreeGram(t, yScale=0.8, widthToHeight=0.8)
    tg.tgDefaultLineThickness = 'very thick'
    tg.baseName = base_name
    tg.dirName = dir_name
    tg.epdf()
def plot_tree(tree, base_name = 'tree', dir_name = 'gram'):
    read(tree)
    t = var.trees[-1]
    for n in t.iterNodes():
        if n.isLeaf:
            try:
                img = Image.open(get_image_path(n.name))
            except IOError as e:
                print n.name
                raise e
            w, h = img.size
            width, height = None, 6.5
            if w > h and (n.name in _wide_images):
                width, height = 12, None
            vmargin = 0
            lmargin = 11
            dimension_name = 'height'
            dimension = height
            if height is None:
                dimension_name = 'width'
                dimension = width
            node_name = n.name
            n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format(
                    lmargin,
                    dimension_name,
                    dimension,
                    get_image_path(node_name))
            

    tg = TreeGram(t, yScale=0.8, widthToHeight=0.8)
    tg.tgDefaultLineThickness = 'very thick'
    tg.baseName = base_name
    tg.dirName = dir_name
    tg.epdf()
예제 #3
0
if 0:
    # First prepare the tree
    t = func.readAndPop("29dpann_catgtr_pretty.tre")
    n = t.addNodeBetweenNodes(25,26)
    t.reRoot(n)
    t.rotateAround(t.root)
    t.writePhylip('rearrangedTree.phy')

if 1:
    from Gram import TreeGram
    t = func.readAndPop('rearrangedTree.phy')
    # tg = TreeGram(t, yScale=0.4, widthToHeight=1.2, doNodeNums=(var.argvAfterDoubleDash[2] == "True"))
    tg = TreeGram(t, yScale=0.45, doNodeNums=False)

    tg.latexUsePackages.append('xcolor')
    tg.latexOtherPreambleCommands.append(r"\definecolor{bact2}{HTML}{A0522D}")  # Sienna
    tg.latexOtherPreambleCommands.append(r"\definecolor{eury2}{HTML}{0000FF}")
    tg.latexOtherPreambleCommands.append(r"\definecolor{euka2}{HTML}{31B34A}")
    tg.latexOtherPreambleCommands.append(r"\definecolor{cren2}{HTML}{703E98}")
    tg.latexOtherPreambleCommands.append(r"\definecolor{thau2}{HTML}{FF0000}") # Red
    tg.latexOtherPreambleCommands.append(r"\definecolor{aiga2}{HTML}{FF8C00}") # Dark Orange
    tg.latexOtherPreambleCommands.append(r"\definecolor{kora2}{HTML}{D11C7E}")
    tg.latexOtherPreambleCommands.append(r"\definecolor{ther2}{HTML}{008080}")  # Teal
    tg.latexOtherPreambleCommands.append(r"\definecolor{dpan2}{HTML}{FF1493}")  # Tealish


    tg.latexOtherPreambleCommands.append(r"\colorlet{bact3}{bact2!20!white}")
    tg.latexOtherPreambleCommands.append(r"\colorlet{eury3}{eury2!15!white}")
    tg.latexOtherPreambleCommands.append(r"\colorlet{euka3}{euka2!30!white}")
    tg.latexOtherPreambleCommands.append(r"\colorlet{cren3}{cren2!20!white}")
    tg.latexOtherPreambleCommands.append(r"\colorlet{thau3}{thau2!30!white}")
예제 #4
0
#transfer node labels to branches
for n in t.iterInternalsNoRoot():
    if n.name:
        n.br.uName = n.name
    n.name = None
#add new node and root on this node to create the proper effect
n = t.addNodeBetweenNodes(int(var.argvAfterDoubleDash[3]),
                          int(var.argvAfterDoubleDash[4]))
t.reRoot(n)

if var.argvAfterDoubleDash[5] == "y":
    t.rotateAround(t.root)

#t.reRoot(int(var.argvAfterDoubleDash[2]))
tg = TreeGram(t,
              yScale=0.4,
              widthToHeight=1.2,
              doNodeNums=(var.argvAfterDoubleDash[2] == "True"))
#tg = TreeGramRadial(t,maxLinesDim=10.,equalDaylight=False)
tg.latexUsePackages.append('pifont')
tg.latexUsePackages.append('xcolor')
tg.latexOtherPreambleCommands.append(
    r"\definecolor{bact2}{HTML}{A0522D}")  # Sienna
tg.latexOtherPreambleCommands.append(r"\definecolor{eury2}{HTML}{0000FF}")
tg.latexOtherPreambleCommands.append(r"\definecolor{euka2}{HTML}{31B34A}")
tg.latexOtherPreambleCommands.append(r"\definecolor{cren2}{HTML}{703E98}")
tg.latexOtherPreambleCommands.append(
    r"\definecolor{thau2}{HTML}{FF0000}")  # Red
tg.latexOtherPreambleCommands.append(
    r"\definecolor{aiga2}{HTML}{FF8C00}")  # Dark Orange
tg.latexOtherPreambleCommands.append(r"\definecolor{kora2}{HTML}{D11C7E}")
tg.latexOtherPreambleCommands.append(
def plot_tree(tree, base_name="tree", dir_name="gram", show_events=False):
    read(tree)
    print var.trees
    t = var.trees[-1]
    for n in t.iterNodes():
        if n.isLeaf:
            try:
                img = Image.open(get_image_path(n.name))
            except IOError as e:
                print n.name
                raise e
            w, h = img.size
            width, height = None, 6.5
            if w > h and (n.name in _wide_images):
                width, height = 8, None
            vmargin = 0
            lmargin = 9
            dimension_name = "height"
            dimension = height
            if height is None:
                dimension_name = "width"
                dimension = width
            node_name = n.name
            if node_name in _extinct_images:
                lmargin += 2
            n.name = r"\hspace{{{0}mm}}\includegraphics[{1}={2}mm,resolution=150]{{{3}}}".format(
                lmargin, dimension_name, dimension, get_image_path(node_name)
            )

    tg = TreeGram(t, yScale=0.65, widthToHeight=1.3)
    tg.tgDefaultLineThickness = "very thick"
    tg.baseName = base_name
    tg.dirName = dir_name
    l1 = tg.gramLine(6.34, -0.5, 6.34, 11)
    # l1.lineStyle = 'loosely dashed'
    # l1.lineThickness = 'ultra thick'
    l1.lineThickness = 10.0
    l2 = tg.gramLine(13.4, -0.5, 13.4, 11)
    # l2.lineStyle = 'loosely dashed'
    # l2.lineThickness = 'ultra thick'
    l2.lineThickness = 10.0
    l1.colour = "black!40"
    l2.colour = "black!40"
    if not show_events:
        # print dir(l1)
        l1.colour = "black!00"
        l2.colour = "black!00"
    s = tg.code(
        r"""\draw [draw=none] (10.97, 9.75) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};"""
    )
    if tree == _sec_tree:
        s = tg.code(
            r"""\draw [draw=none] (7.08, 10.4) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};"""
        )
        s = tg.code(
            r"""\draw [draw=none] (13.17, 7.15) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};"""
        )
    else:
        s = tg.code(
            r"""\draw [draw=none] (6.34, 10.4) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};"""
        )
        s = tg.code(
            r"""\draw [draw=none] (13.4, 7.15) node[circle, minimum width=10pt, draw=none, inner sep=0pt, path picture={\draw[red] (path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}] {};"""
        )
    tg.epdf()
예제 #6
0
#            n.name = ' '

#transfer node labels to branches
for n in t.iterInternalsNoRoot():
    if n.name:
        n.br.uName = n.name
    n.name = None
#add new node and root on this node to create the proper effect
n = t.addNodeBetweenNodes(int(var.argvAfterDoubleDash[3]),int(var.argvAfterDoubleDash[4]))
t.reRoot(n)

if var.argvAfterDoubleDash[5] == "y":
    t.rotateAround(t.root)

#t.reRoot(int(var.argvAfterDoubleDash[2]))
tg = TreeGram(t, yScale=0.4, widthToHeight=1.2, doNodeNums=(var.argvAfterDoubleDash[2] == "True"))        
#tg = TreeGramRadial(t,maxLinesDim=10.,equalDaylight=False)
tg.latexUsePackages.append('pifont')
tg.latexUsePackages.append('xcolor')
tg.latexOtherPreambleCommands.append(r"\definecolor{bact2}{HTML}{A0522D}")  # Sienna
tg.latexOtherPreambleCommands.append(r"\definecolor{eury2}{HTML}{0000FF}")
tg.latexOtherPreambleCommands.append(r"\definecolor{euka2}{HTML}{31B34A}")
tg.latexOtherPreambleCommands.append(r"\definecolor{cren2}{HTML}{703E98}")
tg.latexOtherPreambleCommands.append(r"\definecolor{thau2}{HTML}{FF0000}") # Red
tg.latexOtherPreambleCommands.append(r"\definecolor{aiga2}{HTML}{FF8C00}") # Dark Orange
tg.latexOtherPreambleCommands.append(r"\definecolor{kora2}{HTML}{D11C7E}")
tg.latexOtherPreambleCommands.append(r"\definecolor{ther2}{HTML}{008080}")  # Teal
tg.latexOtherPreambleCommands.append(r"\definecolor{dpan2}{HTML}{FF1493}")  # Tealish


tg.latexOtherPreambleCommands.append(r"\colorlet{bact3}{bact2!20!white}")