示例#1
0
 def check_ingroup_clade_composition(self, ingrp_clade_node, species_dict):
     ingrp_clade_leaves_arr = get_node_leaves(ingrp_clade_node)
     ingrp_clade_species_dict = self.ingrp_clade_species_count(ingrp_clade_leaves_arr)
     no_of_represented_species = self.compare_species_compositions(ingrp_clade_species_dict, species_dict)
     if no_of_represented_species:
         return 1
     else:
         return 0
示例#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 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
示例#4
0
 def get_regex_matching_sequence_list_from_node(fam_tree, regex):
     leaf_arr = get_node_leaves(fam_tree)
     sequence_matches_arr = list(filter(regex.search, leaf_arr))
     return sequence_matches_arr
 def get_ingroup_sequence_list(self, fam_tree, ingrp_re):
     leaf_arr = get_node_leaves(fam_tree)
     ingroup_matches_arr = self.get_ingroup_sequences(leaf_arr, ingrp_re)
     return ingroup_matches_arr
 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