def compute_tree_stats(self, ipyclient):
<EOL>names = self.samples<EOL>if self.params.nboots:<EOL><INDENT>fulltre = ete3.Tree(self.trees.tree, format=<NUM_LIT:0>)<EOL>fulltre.unroot()<EOL>with open(self.trees.boots, '<STR_LIT:r>') as inboots:<EOL><INDENT>bb = [ete3.Tree(i.strip(), format=<NUM_LIT:0>) for i in inboots.readlines()]<EOL>wboots = [fulltre] + bb[-self.params.nboots:]<EOL><DEDENT>wctre, wcounts = consensus_tree(wboots, names=names)<EOL>self.trees.cons = os.path.join(self.dirs, self.name + "<STR_LIT>")<EOL>with open(self.trees.cons, '<STR_LIT:w>') as ocons:<EOL><INDENT>ocons.write(wctre.write(format=<NUM_LIT:0>))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>wctre = ete3.Tree(self.trees.tree, format=<NUM_LIT:0>)<EOL>wctre.unroot()<EOL><DEDENT>self.trees.nhx = os.path.join(self.dirs, self.name + "<STR_LIT>")<EOL>with open(self.files.stats, '<STR_LIT:w>') as ostats:<EOL><INDENT>if self.params.nboots:<EOL><INDENT>ostats.write("<STR_LIT>".format(len(wboots)))<EOL>for i, j in enumerate(self.samples):<EOL><INDENT>ostats.write("<STR_LIT>".format(i, j))<EOL><DEDENT>ostats.write("<STR_LIT:\n>")<EOL>for split, freq in wcounts:<EOL><INDENT>if split.count('<STR_LIT:1>') > <NUM_LIT:1>:<EOL><INDENT>ostats.write("<STR_LIT>".format(split, round(freq, <NUM_LIT:2>)))<EOL><DEDENT><DEDENT>ostats.write("<STR_LIT:\n>")<EOL><DEDENT><DEDENT>lbview = ipyclient.load_balanced_view()<EOL>qtots = {}<EOL>qsamp = {}<EOL>tots = sum(<NUM_LIT:1> for i in wctre.iter_leaves())<EOL>totn = set(wctre.get_leaf_names())<EOL>for node in wctre.traverse():<EOL><INDENT>qtots[node] = lbview.apply(_get_total, *(tots, node))<EOL>qsamp[node] = lbview.apply(_get_sampled, *(self, totn, node))<EOL><DEDENT>ipyclient.wait()<EOL>for node in wctre.traverse():<EOL><INDENT>total = qtots[node].result()<EOL>sampled = qsamp[node].result()<EOL>node.add_feature("<STR_LIT>", total)<EOL>node.add_feature("<STR_LIT>", sampled)<EOL><DEDENT>features = ["<STR_LIT>", "<STR_LIT>"]<EOL>with open(self.trees.nhx, '<STR_LIT:w>') as outtre:<EOL><INDENT>outtre.write(wctre.write(format=<NUM_LIT:0>, features=features))<EOL><DEDENT>
compute stats for stats file and NHX tree features