Beispiel #1
0
def SMILEY(model, metabolite_id, Universal=None):
    """
    runs the SMILEY algorithm to determine which gaps should be
    filled in order for the model to create the metabolite with the
    given metabolite_id.

    This function is good for running the algorithm once. For more fine-
    grained control, create a SUXModelMILP object, add a demand reaction
    for the given metabolite_id, and call the solve function on the
    SUXModelMILP object.
    """
    if Universal is None:
        Universal = import_kegg_reactions()
    SUX = SUXModelMILP(model, Universal)
    # change the objective to be the metabolite
    for reaction in SUX.original_reactions:
        reaction.objective_coefficient = 0
    demand_reaction = cobra.Reaction("SMILEY_DEMAND_RXN_%s" % metabolite_id)
    demand_reaction.objective_coefficient = 1
    demand_reaction.add_metabolites(
        {SUX.metabolites[SUX.metabolites.index(metabolite_id)]: -1})
    SUX.add_reaction(demand_reaction)
    used_reactions = SUX.solve()
    for reaction in used_reactions:
        print reaction, SUX.solution.x_dict[reaction.id]
    return used_reactions
Beispiel #2
0
def growMatch(model, Universal=None):
    """runs growMatch"""
    if Universal is None:
        Universal = import_kegg_reactions()
    SUX = SUXModelMILP(model, Universal)
    used_reactions = SUX.solve()
    for reaction in used_reactions:
        print reaction, SUX.solution.x_dict[reaction.id]
    return used_reactions
Beispiel #3
0
        print reaction, SUX.solution.x_dict[reaction.id]
    return used_reactions

if __name__ == "__main__":
    from cPickle import load
    from os.path import join, abspath, dirname
    from time import time

    import cobra

    test_file_path = join(dirname(cobra.__file__), "test", "data", \
                          "salmonella.pickle")
    test_file = open(test_file_path, "rb")
    model = load(test_file)
    test_file.close()

    tic = time()
    Universal = import_kegg_reactions()
    toc = time()
    print "%.2f sec to import kegg reactions" % (toc - tic)
    tic = toc
    print "growMatch: "
    growMatch(model, Universal)
    toc = time()
    print "%.2f sec for growmatch" % (toc - tic)
    tic = toc
    print "SMILEY results"
    SMILEY(model, "atp_c", Universal)
    toc = time()
    print "%.2f sec for smiley" % (toc - tic)