def main(): global CandidateCVlist print("Eventscape %s" % xscape.PROGRAM_VERSION_TEXT) hostTree, parasiteTree, phi, switchLo, switchHi, lossLo, lossHi, outfile = \ getInput.getInput(outputExtension ="csv") while True: merge_type = input("[U]nion or [I]ntersection? ") if merge_type == "U" or merge_type == "I": break print("Invalid input. Please try again.") CONFIG.intersection = merge_type == "I" print("Reconciling trees...") startTime = time.time() print(" Preprocessing...") preCVlist = reconcile.reconcile(parasiteTree, hostTree, phi, \ switchLo, switchHi, lossLo, lossHi) CandidateCVlist.extend(restrict(preCVlist, \ switchLo, switchHi, lossLo, lossHi)) print(" Solving...") CVlist = reconcileEvents(parasiteTree, hostTree, phi, \ switchLo, switchHi, lossLo, lossHi) endTime = time.time() elapsedTime = endTime- startTime print("Elapsed time %.2f seconds" % elapsedTime) output(outfile, CVlist, hostTree, switchLo, switchHi, lossLo, lossHi, root=parasiteTree["pTop"][1]) print("Output written to file ", outfile)
def seqTrials(parasiteTree, hostTree, phi, numTrials, switchLo, switchHi, lossLo, lossHi, verbose=True): ''' Perform numTrials randomization trials sequentially. Although parTrials could be used to do this too, this function doesn't require the multiprocessing package and thus may be preferable to some users in some situation.''' parasiteTips, hostTips = getTipLists(parasiteTree, hostTree, phi) output = [] for t in range(numTrials): if verbose: print(".", end=' ') # Progress indicator! sys.stdout.flush() newPhi = randomizeTips(parasiteTips, hostTips) output.append( reconcile.reconcile(parasiteTree, hostTree, newPhi, switchLo, switchHi, lossLo, lossHi)) if verbose: print() # Newline return output
def parTrials(parasiteTree, hostTree, phi, numTrials, \ switchLo, switchHi, lossLo, lossHi, result, verbose=True): ''' Perform numTrials randomization trials in one process. ''' parasiteTips, hostTips = getTipLists(parasiteTree, hostTree, phi) output = [] for t in range(numTrials): if verbose: print(".", end=' ') # Progress indicator! sys.stdout.flush() newPhi = randomizeTips(parasiteTips, hostTips) output.append(reconcile.reconcile(parasiteTree, hostTree, newPhi, \ switchLo, switchHi, lossLo, lossHi)) result.put(output)
def solve(newick_data, transferMin, transferMax, dupMin, dupMax, outfile, log): print("Costscape %s" % xscape.PROGRAM_VERSION_TEXT) hostTree = newick_data.host_dict parasiteTree = newick_data.parasite_dict tip_mapping = newick_data.tip_mapping print("Reconciling trees...") startTime = time.time() CVlist = reconcile.reconcile(parasiteTree, hostTree, tip_mapping, transferMin, transferMax, dupMin, dupMax) endTime = time.time() elapsedTime = endTime - startTime print("Elapsed time %.2f seconds" % elapsedTime) plotcosts.plotcosts(CVlist, transferMin, transferMax, dupMin, dupMax, outfile, log) if outfile is not None: print("Output written to: ", outfile)
def solve(newick_data, transferMin, transferMax, dupMin, dupMax, optional): print("Costscape %s" % xscape.PROGRAM_VERSION_TEXT) hostTree, parasiteTree, phi, = newick_data if optional.outfile == "": display = True else: display = optional.display print("Reconciling trees...") startTime = time.time() CVlist = reconcile.reconcile(parasiteTree, hostTree, phi, \ transferMin, transferMax, dupMin, dupMax) endTime = time.time() elapsedTime = endTime- startTime print("Elapsed time %.2f seconds" % elapsedTime) plotcosts.plotcosts(CVlist, transferMin, transferMax, dupMin, dupMax, \ optional.outfile, \ optional.log, display) if optional.outfile != "": print("Output written to file: ", optional.outfile)
def main(): print("Sigscape %s" % xscape.PROGRAM_VERSION_TEXT) hostTree, parasiteTree, phi, switchLo, switchHi, lossLo, lossHi, \ outfile = getInput.getInput(outputExtension ="pdf", allowEmptyOutfile = True) log = getInput.boolInput("Display in log coordinates? ") if outfile == "": display = True else: display = getInput.boolInput("Display to screen? ") numTrials = getInput.intInput("Enter the number of randomization trials: ", 1) numProcs = getInput.intInput( "Enter the number of cores for parallelization: ", 1) seed = getSeed("Enter random seed (leave blank if none): ") if seed: random.seed(seed) print("Reconciling trees...") CVlist = reconcile.reconcile(parasiteTree, hostTree, phi, \ switchLo, switchHi, lossLo, lossHi) startTime = time.time() if numProcs == 1: randomTrialsCVlist = seqTrials(parasiteTree, hostTree, phi, \ numTrials, switchLo, switchHi, \ lossLo, lossHi) else: randomTrialsCVlist = parallelTrials(parasiteTree, hostTree, phi, \ numTrials, numProcs, \ switchLo, switchHi, \ lossLo, lossHi) endTime = time.time() elapsedTime = endTime - startTime print("\nElapsed time %.2f seconds" % elapsedTime) print("Plotting...") plotsig.plotsig(CVlist, randomTrialsCVlist, switchLo, switchHi, \ lossLo, lossHi, DOTS, outfile, \ log, display) if outfile != "": print("Output written in file ", outfile)