Esempio n. 1
0
def get_response_content(fs):
    # get a properly formatted newick tree with branch lengths
    tree_string = '((1:1, 2:1)6:1, 3:1, (4:1, 5:1)7:1)8;'
    tree = Newick.parse(tree_string, SpatialTree.SpatialTree)
    # get the fiedler-like vertex valuation
    fiedler = [1, 1, -1, -1, -1, 1, -1, -1]
    # create a node id map
    ids = [None]*8
    for node in tree.preorder():
        index = int(node.name) - 1
        ids[index] = id(node)
    # convert fiedler into a dictionary
    v1 = dict((ids[i], float(fiedler[i])) for i in range(8))
    # convert the annotations into dictionaries
    v2s = [dict((ids[i], float(v[i])) for i in range(8)) for v in g_annotation]
    # do the layout
    try:
        layout = FastDaylightLayout.StraightBranchLayout()
        layout.do_layout(tree)
    except RuntimeError as e:
        pass
    # draw the image
    try:
        ext = Form.g_imageformat_to_ext[fs.imageformat]
        return DrawEigenLacing.get_eg2_image(
                tree, (640, 480), ext,
                v1, v2s,
                fs.draw_background, fs.draw_vertices, fs.draw_labels)
    except CairoUtil.CairoUtilError as e:
        raise HandlingError(e)
Esempio n. 2
0
def get_response_content(fs):
    # get a properly formatted newick tree with branch lengths
    tree_string = '((1:1, 2:1)6:1, 3:1, (4:1, 5:1)7:1)8;'
    tree = Newick.parse(tree_string, SpatialTree.SpatialTree)
    # get the fiedler-like vertex valuation
    fiedler = [1, 1, -1, -1, -1, 1, -1, -1]
    # create a node id map
    ids = [None] * 8
    for node in tree.preorder():
        index = int(node.name) - 1
        ids[index] = id(node)
    # convert fiedler into a dictionary
    v1 = dict((ids[i], float(fiedler[i])) for i in range(8))
    # convert the annotations into dictionaries
    v2s = [dict((ids[i], float(v[i])) for i in range(8)) for v in g_annotation]
    # do the layout
    try:
        layout = FastDaylightLayout.StraightBranchLayout()
        layout.do_layout(tree)
    except RuntimeError as e:
        pass
    # draw the image
    try:
        ext = Form.g_imageformat_to_ext[fs.imageformat]
        return DrawEigenLacing.get_eg2_image(tree, (640, 480), ext, v1, v2s,
                                             fs.draw_background,
                                             fs.draw_vertices, fs.draw_labels)
    except CairoUtil.CairoUtilError as e:
        raise HandlingError(e)