def rootify(self, center_branch): # remember the old branch: self.root_branch = center_branch # create a new node center_name = center_branch.ends[0].name center_name += "-" + center_branch.ends[1].name center_node = node.node(center_name, self) self.root = center_node # give it children branches child1 = branch.branch(center_branch.length / 2) child1.addNode(center_node) child1.addNode(center_branch.ends[0]) child2 = branch.branch(center_branch.length / 2) child2.addNode(center_node) child2.addNode(center_branch.ends[1]) center_node.child_branches.append(child1) center_node.child_branches.append(child2) # erase the original branch from the child nodes branch_list for kids in center_branch.ends: kids.branch_list.remove(center_branch) # impose a hierarchy from the root center_node.imposeHierarchy() self.labelSubtrees() self.Get_Subnodes() self.root.Fill_Node_Dict()
def rootify(self,center_branch): # remember the old branch: self.root_branch = center_branch # create a new node center_name = center_branch.ends[0].name center_name += "-" + center_branch.ends[1].name center_node = node.node(center_name,self) self.root = center_node # give it children branches child1 = branch.branch(center_branch.length/2) child1.addNode(center_node) child1.addNode(center_branch.ends[0]) child2 = branch.branch(center_branch.length/2) child2.addNode(center_node) child2.addNode(center_branch.ends[1]) center_node.child_branches.append(child1) center_node.child_branches.append(child2) # erase the original branch from the child nodes branch_list for kids in center_branch.ends: kids.branch_list.remove(center_branch) # impose a hierarchy from the root center_node.imposeHierarchy() self.labelSubtrees() self.Get_Subnodes() self.root.Fill_Node_Dict()
def BuildNode(this_tree, node_string): splitSon = re.split(':', node_string) # see if anyone in the queue has the same name node1match = False for i in range(len(this_tree.build_queue)): if this_tree.build_queue[i].name == splitSon[0]: node1 = this_tree.build_queue[i] this_tree.build_queue.remove(node1) node1match = True break if node1match is not True: node1 = node.node(splitSon[0], this_tree) this_tree.leaf_count += 1 # another leaf added to tree node1.addBranch(splitSon[1]) return node1
def BuildNode(this_tree,node_string): splitSon = re.split(':',node_string) # see if anyone in the queue has the same name node1match = False for i in range(len(this_tree.build_queue)): if this_tree.build_queue[i].name == splitSon[0]: node1 = this_tree.build_queue[i] this_tree.build_queue.remove(node1) node1match = True break if node1match is not True: node1 = node.node(splitSon[0],this_tree) this_tree.leaf_count += 1 # another leaf added to tree node1.addBranch(splitSon[1]) return node1