continue (element, number) = elements[0].split(":") #print("Adjusting: "+rxn,element,number) #Parse old stoichiometry into array old_stoichiometry = Reactions_Dict[rxn]["stoichiometry"] Rxn_Cpds_Array = ReactionsHelper.parseStoich(old_stoichiometry) #Adjust for protons ReactionsHelper.adjustCompound(Rxn_Cpds_Array, "cpd00067", float(number)) #Recompute new status and stoichiometry new_status = ReactionsHelper.balanceReaction(Rxn_Cpds_Array) new_stoichiometry = ReactionsHelper.buildStoich(Rxn_Cpds_Array) if (new_status != Reactions_Dict[rxn]['status']): status_file.write(rxn + "\t" + Reactions_Dict[rxn]['status'] + "\t" + new_status + "\n") if (new_stoichiometry != old_stoichiometry): print("Rebuilding reaction :", rxn) ReactionsHelper.rebuildReaction(Reactions_Dict[rxn], new_stoichiometry) Reactions_Dict[rxn]["status"] = new_status if ("HB" not in Reactions_Dict[rxn]["notes"]): Reactions_Dict[rxn]["notes"].append("HB") Update_Reactions += 1 if (Update_Reactions > 0):
if (compounds_dict[cpd]['linked_compound'] == 'null'): print( "Warning: missing linked compound for obsolete compound: " + cpd) continue lnkd_cpd = sorted( compounds_dict[cpd]['linked_compound'].split(';'))[0] # Replace cpd with lnkd_cpd in reaction fields: # code, compound_ids, equation, stoichiometry old_stoichiometry = reactions_dict[rxn]["stoichiometry"] rxn_cpds_array = reactions_helper.parseStoich(old_stoichiometry) reactions_helper.replaceCompound(rxn_cpds_array, cpd, lnkd_cpd) new_stoichiometry = reactions_helper.buildStoich(rxn_cpds_array) reactions_helper.rebuildReaction(reactions_dict[rxn], new_stoichiometry) print("Replacting obsolete " + cpd + " with " + lnkd_cpd + " in " + rxn) Update_Reactions += 1 # if(Update_Reactions>0): # break if (Update_Reactions > 0): print("Saving replacement of " + str(Update_Reactions) + " obsolete compounds in reactions") reactions_helper.saveReactions(reactions_dict)