def test_majorityRule(self): """Tests for majority rule consensus trees""" trees = [t for (w,t) in self.trees] outtrees = majorityRule(trees, strict=False) self.assertEqual(len(outtrees), 1) self.assert_(outtrees[0].sameTopology(Tree("((c,d),(a,b));"))) outtrees = majorityRule(trees, strict=True) self.assertEqual(len(outtrees), 1) self.assert_(outtrees[0].sameTopology(Tree("(c,d,(a,b));")))
def main(): option_parser, opts, args =\ parse_command_line_parameters(**script_info) trees = load_tree_files(opts.input_dir) consensus = majorityRule(trees=trees, strict=opts.strict)[0] # don't know why returns a list f = open(opts.output_fname, 'w') f.write(consensus.getNewick(with_distances=True)) f.close()