def tree_from_order(order): nodes = script_tree.getNodes(tree) for n in nodes: if not script_tree.isRoot(tree, n): if script_tree.isLeaf(tree, n): index = len(order) else: index = order.index(script_tree.getBootstrap(tree, n)) index_parent = order.index(script_tree.getBootstrap(tree, script_tree.getParent(tree, n))) script_tree.setLength(tree, n, index - index_parent) return script_tree.writeTree(tree, root, False)
def tree_from_order(order): nodes = script_tree.getNodes(tree) for n in nodes: if not script_tree.isRoot(tree,n): if script_tree.isLeaf(tree,n): index = len(order) else: index = order.index(script_tree.getBootstrap(tree,n)) index_parent = order.index(script_tree.getBootstrap(tree,script_tree.getParent(tree,n))) script_tree.setLength(tree,n,index-index_parent) return script_tree.writeTree(tree,root,False)
def donnor_search(t, n): current_node = n result = -1 while result == -1 and not script_tree.isRoot(t, current_node): current_node = script_tree.getParent(t, current_node) annot = script_tree.getBootstrap(t, current_node) event = annot[1:].split(".")[0] if event[:2] != "T@" and event[:2] != "D@": result = event if annot.find("@T") >= 0: current_node = script_tree.getRoot(t) result = -1 return result
def donnor_search(t,n): current_node = n result = -1 while result == -1 and not script_tree.isRoot(t,current_node): current_node = script_tree.getParent(t,current_node) annot = script_tree.getBootstrap(t,current_node) event = annot[1:].split(".")[0] if event[:2] != "T@" and event[:2] != "D@": result = event if annot.find("@T") >= 0: current_node = script_tree.getRoot(t) result = -1 return result
def parent(x): #print x nodes = script_tree.getNodes(species_tree) for n in nodes: if script_tree.isLeaf(species_tree,n): name = script_tree.getName(species_tree,n) else: name = script_tree.getBootstrap(species_tree,n) if name == x: if script_tree.isRoot(species_tree,n): result = -1 else: result = script_tree.getBootstrap(species_tree,script_tree.getParent(species_tree,n)) return result
def parent(x): #print x nodes = script_tree.getNodes(species_tree) for n in nodes: if script_tree.isLeaf(species_tree, n): name = script_tree.getName(species_tree, n) else: name = script_tree.getBootstrap(species_tree, n) if name == x: if script_tree.isRoot(species_tree, n): result = -1 else: result = script_tree.getBootstrap( species_tree, script_tree.getParent(species_tree, n)) return result
line.strip(), " ...ignored" # sortie = open("distribution_by_family","w") # keys = by_family.keys() # keys.sort() # for f in keys: # sortie.write(f+" "+str(by_family[f])+"\n") total_transfers = sum(edge.values()) to_desc = 0 uninformative = 0 # initialise from branches for n in nodes: if (not script_tree.isLeaf(tree, n)): if (not script_tree.isRoot(tree, n)): parent = script_tree.getBootstrap(tree, script_tree.getParent(tree, n)) child = script_tree.getBootstrap(tree, n) if edge.has_key(parent + "," + child): to_desc = to_desc + edge[parent + "," + child] uninformative = uninformative + edge[parent + "," + child] else: graph[parent].append(child) edge[parent + "," + child] = MAX_NUMBER else: parent = script_tree.getBootstrap(tree, script_tree.getParent(tree, n)) child = script_tree.getName(tree, n) if not child in graph[parent]: graph[parent].append(child) edge_keys = edge.keys()
# initialise from nodes for n in nodes: if (not script_tree.isLeaf(tree,n)): node = script_tree.getBootstrap(tree,n) graph[node] = [] degre_entrant[node] = [] internal_nodes.append(node) else: node = script_tree.getName(tree,n) graph[node] = [] # initialise from branches for n in nodes: if (not script_tree.isLeaf(tree,n)): if (not script_tree.isRoot(tree,n)): parent = script_tree.getBootstrap(tree,script_tree.getParent(tree,n)) child = script_tree.getBootstrap(tree,n) graph[parent].append(child) edge[parent+","+child] = MAX_NUMBER else: parent = script_tree.getBootstrap(tree,script_tree.getParent(tree,n)) child = script_tree.getName(tree,n) graph[parent].append(child) # parse transfers total_transfers = 0 uninformative = 0 by_family = {} for line in constraints: #print line