def inspect_ingroup_pairs(self, fam_tree, ingroup_pair_arr, outgrp_re):
        fp_pair_count = 0
        tp_pair_count = 0
        for ingroup_pair in ingroup_pair_arr:
            pair_mrca = fam_tree.get_common_ancestor(ingroup_pair[0],
                                                     ingroup_pair[1])
            pair_mrca_leaf_arr = get_node_leaves(pair_mrca)
            outgrp_flag = check_for_outgroups(pair_mrca_leaf_arr, outgrp_re)
            if outgrp_flag == 1:
                tp_pair_count += 1
            else:
                fp_pair_count += 1

        precision_val = self.calculate_precison_value(tp_pair_count,
                                                      fp_pair_count)
        return precision_val
Beispiel #2
0
    def process_family_tree(self, fam_tree, outgrp_re, species_dict):
        ingroup_clade_arr = list()
        clade_counter = 1
        clade_filename = BasePath.outpath + "/" + self.fam_id + "/" + self.fam_id + BasePath.clade_fileextension
        clade_file = open(clade_filename, "w")
        for node in fam_tree.traverse("levelorder"):
            leaf_arr = get_node_leaves(node)
            if check_for_outgroups(leaf_arr, outgrp_re):
                flag = self.check_for_clade_overlap(leaf_arr, ingroup_clade_arr)
                if flag == 1:
                    clade_flag = self.check_ingroup_clade_composition(node, species_dict)
                    if clade_flag == 1:
                        self.print_clade_sequences(node, self.fam_id, clade_counter, clade_file)
                        clade_counter += 1

        clade_file.close()
 def check_if_tree_contains_outgroups(fam_tree, outgrp_re):
     leaf_arr = get_node_leaves(fam_tree)
     flag = check_for_outgroups(leaf_arr, outgrp_re)
     return flag