def checkproducebilty(self): self.set_busy(True) self.textBox.append('\nChecking draftnet for unproducible targets ...') model = query.get_unproducible(self.draftnet, self.targets, self.seeds) self.textBox.append('done.') self.textBox.append(' '+str(len(model))+' unproducible targets:') self.print_met(model.to_list()) unproducible_targets = TermSet() for a in model : target= str(a)[13:] t = String2TermSet(target) unproducible_targets = unproducible_targets.union(t) if(self.repairnet != 0): all_reactions = self.draftnet all_reactions = all_reactions.union(self.repairnet) self.textBox.append('\nChecking draftnet + repairnet for unproducible targets ...') model = query.get_unproducible(all_reactions, self.seeds, self.targets) self.textBox.append('done.') self.textBox.append(' still '+str(len(model))+' unproducible targets:') self.print_met(model.to_list()) never_producible = TermSet() for a in model : target= str(a)[13:] #print target t = String2TermSet(target) never_producible = never_producible.union(t) reconstructable_targets = TermSet() for t in unproducible_targets: if not (t in never_producible) : reconstructable_targets.add(t) self.textBox.append('\n '+str(len(reconstructable_targets))+' targets to reconstruct:') self.print_met(reconstructable_targets) utils.clean_up() self.set_busy(False) self.checkState() return
print(' still',len(model),'unproducible targets:') utils.print_met(model.to_list()) never_producible = TermSet() for a in model : target= str(a)[13:] t = String2TermSet(target) never_producible = TermSet(never_producible.union(t)) reconstructable_targets = TermSet() for t in unproducible_targets: if not (t in never_producible) : reconstructable_targets.add(t) print('\n ',len(reconstructable_targets),'targets to reconstruct:') utils.print_met(reconstructable_targets) if len(reconstructable_targets)== 0 : utils.clean_up() quit() essential_reactions = TermSet() for t in reconstructable_targets: single_target = TermSet() single_target.add(t) print('\nComputing essential reactions for',t,'...',end=' ') sys.stdout.flush() essentials = query.get_intersection_of_completions(draftnet, repairnet, seeds, single_target) print('done.') print(' ',len(essentials), 'essential reactions found:') utils.print_met(essentials.to_list()) essential_reactions = TermSet(essential_reactions.union(essentials)) print('\nOverall',len(essential_reactions), 'essential reactions found.')
def run(self): self.emit(SIGNAL("asignal"),'\nChecking draftnet for unproducible targets ...') model = query.get_unproducible(self.wid.draftnet, self.wid.targets, self.wid.seeds) self.emit(SIGNAL("asignal"),'done.') self.emit(SIGNAL("asignal"),' '+str(len(model))+' unproducible targets:') self.print_met(model.to_list()) unproducible_targets = TermSet() for a in model : target = str(a)[13:] t = String2TermSet(target) unproducible_targets = unproducible_targets.union(t) if(self.wid.repairnet != 0): all_reactions = self.wid.draftnet all_reactions = all_reactions.union(self.wid.repairnet) self.emit(SIGNAL("asignal"),'\nChecking draftnet + repairnet for unproducible targets ...') model = query.get_unproducible(all_reactions, self.wid.seeds, self.wid.targets) self.emit(SIGNAL("asignal"),'done.') self.emit(SIGNAL("asignal"),' still '+str(len(model))+' unproducible targets:') self.print_met(model.to_list()) never_producible = TermSet() for a in model : target = str(a)[13:] t = String2TermSet(target) never_producible = never_producible.union(t) reconstructable_targets = TermSet() for t in unproducible_targets: if not (t in never_producible) : reconstructable_targets.add(t) self.emit(SIGNAL("asignal"),'\n '+str(len(reconstructable_targets))+' targets to reconstruct:') self.print_met(reconstructable_targets) if len(reconstructable_targets)== 0 : utils.clean_up() self.emit(SIGNAL("finishedsignal"),False) return essential_reactions = TermSet() for t in reconstructable_targets: single_target = TermSet() single_target.add(t) self.emit(SIGNAL("asignal"),'\nComputing essential reactions for '+str(t)+' ...') essentials = query.get_intersection_of_completions(self.wid.draftnet, self.wid.repairnet, self.wid.seeds, single_target) self.emit(SIGNAL("asignal"),'done.') self.emit(SIGNAL("asignal"),' '+str(len(essentials))+' essential reactions found:') self.print_met(essentials.to_list()) essential_reactions = essential_reactions.union(essentials) self.emit(SIGNAL("asignal"),'\n Overall '+str(len(essential_reactions))+' essential reactions found.') self.print_met(essential_reactions) self.emit(SIGNAL("asignal"),'\n Add essential reactions to network.') ndraftnet = essential_reactions.union(self.wid.draftnet) utils.clean_up() self.emit(SIGNAL("asignal"),'\nComputing one minimal completion to produce all targets ...') optimum, models = query.get_minimal_completion_size(ndraftnet, self.wid.repairnet, self.wid.seeds, reconstructable_targets) self.emit(SIGNAL("asignal"),'done.') self.emit(SIGNAL("asignal"),' minimal size = '+str(optimum[0])) self.print_met(models[0].to_list()) self.emit(SIGNAL("asignal"),'\nComputing common reactions in all completion with size '+str(optimum[0])+' ...') model = query.get_intersection_of_optimal_completions(ndraftnet, self.wid.repairnet, self.wid.seeds, reconstructable_targets, optimum[0]) self.emit(SIGNAL("asignal"),'done.') self.print_met(model.to_list()) self.emit(SIGNAL("asignal"),'\nComputing union of reactions from all completion with size '+str(optimum[0])+' ...') model = query.get_union_of_optimal_completions(ndraftnet, self.wid.repairnet, self.wid.seeds, reconstructable_targets, optimum[0]) self.emit(SIGNAL("asignal"),'done.') self.print_met(model.to_list()) #do_repair= raw_input('\nDo you want to compute all completions with size '+str(optimum[0])+' Y/n:') #if wid.do_repair: #self.emit(SIGNAL("asignal"),'\nComputing all completions with size '+str(optimum[0])+' ...') #models = query.get_optimal_completions(ndraftnet, self.wid.repairnet, self.wid.seeds, reconstructable_targets, optimum[0]) #self.emit(SIGNAL("asignal"),'done.') #count = 1 #for model in models: #self.emit(SIGNAL("asignal"),'Completion '+str(count)+':') #count+=1 #self.print_met(model.to_list()) utils.clean_up() self.emit(SIGNAL("finishedsignal"),False)