Exemple #1
0
 def get_good_edges( subtree, node_position, sizes, real_sizes ):
     if score_trees_devel.IsALeaf( subtree ):
         return []
     else:
         big_rmsd = subtree[2]
         edges = []
         for ii in range(2):
             iitree = subtree[ii]
             little_rmsd = iitree[2]
             center= score_trees_devel.Center( iitree, node_position, sizes, use_sizes_as_weights=True )
             real_size = score_trees_devel.Size( iitree, real_sizes )
             if little_rmsd <= max_rmsd_for_glyphs and real_size >= my_min_cluster_size_for_glyphs:
                 ## this tree is OK
                 edges.append( tuple( ( little_rmsd, big_rmsd, center, real_size,
                                        tuple( sorted( score_trees_devel.Node_members(iitree) ) ) ) ) )
             edges.extend( get_good_edges( iitree, node_position, sizes, real_sizes ) )
     return edges
Exemple #2
0
def label_pval_edges(cmds, edge_pvals, subtree, plotting_info):
    sizes, node_position, Transform, canvas_tree_w_factor, canvas_tree_min_rmsd = plotting_info

    if score_trees_devel.IsALeaf(subtree):
        return
    else:
        big_rmsd = subtree[2]
        for ii in range(2):
            iitree = subtree[ii]
            little_rmsd = iitree[2]
            #assert little_rmsd<=big_rmsd
            assert little_rmsd <= big_rmsd + 1e-3
            if little_rmsd > big_rmsd:
                print 'WHOAH:', little_rmsd, big_rmsd
            leaves = tuple(sorted(score_trees_devel.Node_members(iitree)))
            if leaves in edge_pvals:
                pvals = edge_pvals[leaves]
                symbol = pvals[-1]

                center = score_trees_devel.Center(iitree,
                                                  node_position,
                                                  sizes,
                                                  use_sizes_as_weights=True)
                size = score_trees_devel.Size(iitree, sizes)

                line_width = max(1,
                                 int(floor(0.5 + size * canvas_tree_w_factor)))
                box_x0 = Transform(max(canvas_tree_min_rmsd, little_rmsd))
                box_x1 = Transform(big_rmsd)
                sep = 3

                cmds.append(
                    svg_basic.make_text(
                        '{:.0E} {}'.format(pvals[0], symbol),
                        (box_x0 + sep, center - line_width / 2 - sep),
                        10,
                        font_family="Droid Sans Mono"))

            label_pval_edges(cmds, edge_pvals, iitree, plotting_info)