Example #1
0
def format_nodes(node, node_style, sus_clades, t):
    """This function visually formats the nodes in the svg file based on the nodes' support values and whether or not
    the clade is suspicous"""
    supp = TextFace(f'{int(node.support)}', fsize=8)
    if node.support >= 70:
        supp.bold = True
        taxons = set()
        orgs = node.get_leaf_names()
        if len(orgs) > 1:
            for org in orgs:
                if '..' in org:  # for paralogs
                    org = org.split('..')[0]
                else:
                    org = org.split('_')[0]  # for potential orthologs
                taxons.add(metadata[org]['Higher Taxonomy'])
        if len(taxons) > 1 and (len(node) < (len(t) / 2)):
            node_style['shape'] = 'sphere'
            node_style['size'] = 12
            node_style['fgcolor'] = 'red'
            node_style['bgcolor'] = 'Silver'
            sus_clades += 1
    else:
        supp.fsize = 7
    return supp, sus_clades