예제 #1
0
        continue

    #Parse old stoichiometry into array
    old_stoichiometry = Reactions_Dict[rxn]["stoichiometry"]
    Rxn_Cpds_Array = ReactionsHelper.parseStoich(old_stoichiometry)

    #Don't adjust reactions that only have water
    if (len(Rxn_Cpds_Array) == 1):
        continue

    Water_Adjustment = 1
    if ("-1" in Reactions_Dict[rxn]["status"]):
        Water_Adjustment = -1

    #Adjust for water
    ReactionsHelper.adjustCompound(Rxn_Cpds_Array, "cpd00001",
                                   float(Water_Adjustment))

    #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 ("WB" not in Reactions_Dict[rxn]["notes"]):
            if (Reactions_Dict[rxn]["notes"] == ""
        elements = block.split("/")

        #only making adjustments if mass imbalance is a single element,
        #and the element is hydrogen
        if (len(elements) > 1 or not elements[0].startswith("H:")):
            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"]):
예제 #3
0
            if (rxn_code in reactions_codes):
                matched_rxn = sorted(list(reactions_codes[rxn_code]))[0]

        #Because we adjust for water a posterior
        #We need to include water when matching codes, in case
        if (matched_rxn is None):

            #Find statuses that only have water imbalance
            new_status = reactions_helper.balanceReaction(new_rxn_cpds_array)
            if (new_status == "MI:H:2/O:1" or new_status == "MI:H:-2/O:-1"):
                Water_Adjustment = 1
                if ("-1" in new_status):
                    Water_Adjustment = -1

                #Adjust for water
                reactions_helper.adjustCompound(new_rxn_cpds_array, "cpd00001",
                                                float(Water_Adjustment))
                rxn_code = reactions_helper.generateCode(new_rxn_cpds_array)
                if (rxn_code in reactions_codes):
                    matched_rxn = sorted(list(reactions_codes[rxn_code]))[0]

        if (matched_rxn is not None):
            #Add Names, EC and Alias
            #Regardless of match-type, add new names
            #NB at this point, names shouldn't match _anything_ already in the database
            #Names are saved separately as part of the aliases at the end of the script
            for name in rxn['NAMES'].split('|'):
                if (name not in All_Names):
                    #Possible for there to be no names in biochemistry?
                    if (matched_rxn not in Names_Dict):
                        Names_Dict[matched_rxn] = list()
                    Names_Dict[matched_rxn].append(name)