def build_trees(self):
<EOL>nodes = {}<EOL>idxarr = np.arange(len(self.fclade_counts[<NUM_LIT:0>][<NUM_LIT:0>]))<EOL>queue = []<EOL>countdict = defaultdict(int)<EOL>for clade, count in self.fclade_counts:<EOL><INDENT>mask = np.int_(list(clade)).astype(np.bool)<EOL>ccx = idxarr[mask]<EOL>queue.append((len(ccx), frozenset(ccx)))<EOL>countdict[frozenset(ccx)] = count<EOL><DEDENT>while queue:<EOL><INDENT>queue.sort()<EOL>(clade_size, clade) = queue.pop(<NUM_LIT:0>)<EOL>new_queue = []<EOL>for (_, ancestor) in queue:<EOL><INDENT>if clade.issubset(ancestor):<EOL><INDENT>new_ancestor = (ancestor - clade) | frozenset([clade])<EOL>countdict[new_ancestor] = countdict.pop(ancestor)<EOL>ancestor = new_ancestor<EOL><DEDENT>new_queue.append((len(ancestor), ancestor))<EOL><DEDENT>if clade_size == <NUM_LIT:1>:<EOL><INDENT>name = list(clade)[<NUM_LIT:0>]<EOL>name = self.namedict[name]<EOL><DEDENT>else:<EOL><INDENT>name = None<EOL><DEDENT>children = [nodes.pop(c) for c in clade if c in nodes]<EOL>node = TreeNode(name=name)<EOL>for child in children:<EOL><INDENT>node.add_child(child)<EOL><DEDENT>if not node.is_leaf():<EOL><INDENT>node.dist = int(round(<NUM_LIT:100> * countdict[clade]))<EOL>node.support = int(round(<NUM_LIT:100> * countdict[clade]))<EOL><DEDENT>else:<EOL><INDENT>node.dist = int(<NUM_LIT:100>)<EOL>node.support = int(<NUM_LIT:100>)<EOL><DEDENT>nodes[clade] = node<EOL>queue = new_queue<EOL><DEDENT>nodelist = list(nodes.values())<EOL>tre = nodelist[<NUM_LIT:0>]<EOL>self.ttree = ToyTree(tre.write(format=<NUM_LIT:0>))<EOL>self.ttree._coords.update()<EOL>self.nodelist = nodelist<EOL>
Build an unrooted consensus tree from filtered clade counts.