def updateReconciliation(guiltyTransferList, HostTree, ParasiteTree, reconciliation): """This function takes as input a list guiltyTransferList of transfers that are responsible for cycles, a host tree and parasite tree, and the original reconciliation of host and parasite. It returns a new reconciliation in which all of the guilty transfers have been marked as a new event 'GT'.""" parents = ReconciliationGraph.parentsDict(HostTree, ParasiteTree) newReconciliation = copy.deepcopy(reconciliation) for transfer in guiltyTransferList: for key in newReconciliation.keys(): if reconciliation[key][0] == "T": if transfer[0] == key[0]: newReconciliation[key] = ["GT"] + reconciliation[key][1:] return newReconciliation
def updateReconciliation(guiltyTransferList, HostTree, ParasiteTree, \ reconciliation): """This function takes as input a list guiltyTransferList of transfers that are responsible for cycles, a host tree and parasite tree, and the original reconciliation of host and parasite. It returns a new reconciliation in which all of the guilty transfers have been marked as a new event 'GT'.""" parents = ReconciliationGraph.parentsDict(HostTree, ParasiteTree) newReconciliation = copy.deepcopy(reconciliation) for transfer in guiltyTransferList: for key in newReconciliation.keys(): if reconciliation[key][0] == 'T': if transfer[0] == key[0]: newReconciliation[key] = ['GT'] + reconciliation[key][1:] return newReconciliation
def buildReconciliation(HostTree, ParasiteTree, reconciliation): """Takes as input a host tree, a parasite tree, and a reconciliation, and returns a graph where the keys are host or parasite nodes, and the values are a list of the children of a particular node. The graph represents temporal relationships between events.""" parents = ReconciliationGraph.parentsDict(HostTree, ParasiteTree) H = ReconciliationGraph.treeFormat(HostTree) P = ReconciliationGraph.treeFormat(ParasiteTree) reconGraph = H reconGraph.update(P) transferList = [] for key in reconciliation: if reconciliation[key][0] == 'T': reconGraph[key[0]] = P[key[0]] + [reconciliation[key][1][1], \ reconciliation[key][2][1]] parent1 = parents[reconciliation[key][1][1]] parent2 = parents[reconciliation[key][2][1]] reconGraph[parent1] = reconGraph[parent1] + [key[0]] reconGraph[parent2] = reconGraph[parent2] + [key[0]] transferEdge1 = reconciliation[key][1][1] transferEdge2 = reconciliation[key][2][1] transferList.append([key[0], parent1, transferEdge1, parent2, \ transferEdge2]) elif reconciliation[key][0] == 'S': parent = parents[key[0]] if parent != 'Top': reconGraph[parent] = reconGraph[parent] + [key[1]] reconGraph[key[1]] = reconGraph[key[1]] + reconGraph[key[0]] elif reconciliation[key][0] == 'D': parent = parents[key[1]] if parent != 'Top': reconGraph[parent] = reconGraph[parent] + [key[0]] reconGraph[key[0]] = reconGraph[key[0]] + [key[1]] elif reconciliation[key][0] == 'C': reconGraph[key[1]] = [None] reconGraph[key[0]] = [None] for key in reconGraph: reconGraph[key] = ReconciliationGraph.uniquify(reconGraph[key]) return reconGraph, transferList
def buildReconciliation(HostTree, ParasiteTree, reconciliation): """Takes as input a host tree, a parasite tree, and a reconciliation, and returns a graph where the keys are host or parasite nodes, and the values are a list of the children of a particular node. The graph represents temporal relationships between events.""" parents = ReconciliationGraph.parentsDict(HostTree, ParasiteTree) H = ReconciliationGraph.treeFormat(HostTree) P = ReconciliationGraph.treeFormat(ParasiteTree) reconGraph = H reconGraph.update(P) transferList = [] for key in reconciliation: if reconciliation[key][0] == "T": reconGraph[key[0]] = P[key[0]] + [reconciliation[key][1][1], reconciliation[key][2][1]] parent1 = parents[reconciliation[key][1][1]] parent2 = parents[reconciliation[key][2][1]] reconGraph[parent1] = reconGraph[parent1] + [key[0]] reconGraph[parent2] = reconGraph[parent2] + [key[0]] transferEdge1 = reconciliation[key][1][1] transferEdge2 = reconciliation[key][2][1] transferList.append([key[0], parent1, transferEdge1, parent2, transferEdge2]) elif reconciliation[key][0] == "S": parent = parents[key[0]] if parent != "Top": reconGraph[parent] = reconGraph[parent] + [key[1]] reconGraph[key[1]] = reconGraph[key[1]] + reconGraph[key[0]] elif reconciliation[key][0] == "D": parent = parents[key[1]] if parent != "Top": reconGraph[parent] = reconGraph[parent] + [key[0]] reconGraph[key[0]] = reconGraph[key[0]] + [key[1]] elif reconciliation[key][0] == "C": reconGraph[key[1]] = [None] reconGraph[key[0]] = [None] for key in reconGraph: reconGraph[key] = ReconciliationGraph.uniquify(reconGraph[key]) return reconGraph, transferList