Exemple #1
0
    #     lumping = do_lumping(
    #             system["equations"],
    #             [SparsePolynomial.from_string("C3GActive", system["variables"])],
    #             print_reduction=False,
    #             discard_useless_matrices=True,
    #     )
    #     time += timeit.default_timer() - start
    # print("Average Time: ", time/N)
    # check_lumping("BIOMD0000000033", system["equations"], lumping)
    

    # MODEL1502270000
    system = read_system("../examples/RationalFunctions/MODEL1502270000.ode")
    lumping = do_lumping(
            system["equations"],
            [SparsePolynomial.from_string("gmax*Kp+a", system["variables"])],
            print_reduction=False,
            discard_useless_matrices=True,
    )
    print("Lumping Size: ", len(lumping['rhs']))
    check_lumping("MODEL1502270000", system["equations"], lumping)
    lumping = do_lumping(
            system["equations"],
            [SparsePolynomial.from_string("si", system["variables"])],
            print_reduction=False,
            discard_useless_matrices=False,
    )
    print("Lumping Size: ", len(lumping['rhs']))
    check_lumping("MODEL1502270000", system["equations"], lumping)
    # print(lumping)

############################################
# Model generated from:
# Borisov, N. M., Chistopolsky, A. S., Faeder, J. R., & Kholodenko, B. N.
# Domain-oriented reduction of rule-based network models. IET systems biology, 2(5), 342-351, 2008.
# Source: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2628550/bin/NIHMS80246-supplement-Supplement_4.doc
##
import sys
import time

from sympy import QQ

sys.path.insert(0, "../")
sys.path.insert(0, "./../../")
import parser
import clue
from sparse_polynomial import SparsePolynomial

system = parser.read_system("OrderedPhosphorylation.ode")
obs = SparsePolynomial.from_string("s0", system['variables'])

start = time.time()
lumped = clue.do_lumping(system['equations'], [obs])
end = time.time()

print(f"The size of the original model is {len(system['equations'])}")
print(f"The size of the reduced model is {len(lumped['polynomials'])}")
print(f"Computation took {end - start} seconds")
Exemple #3
0
from sympy import QQ

sys.path.insert(0, "../")
sys.path.insert(0, "./../../")
import parser
import clue
from sparse_polynomial import SparsePolynomial

system = parser.read_system("BIOMD0000000504.ode")

obs_sets = [["cFos_P", "cJun_P"], ["MMP1_mRNA", "MMP13_mRNA", "TIMP1_mRNA"],
            ["MMP1", "MMP13", "ColFrag"],
            [
                "JAK1_P", "JNK_P", "cJun_P", "cJun_dimer", "STAT3_P_nuc",
                "STAT3_P_cyt"
            ]]

for obs_set in obs_sets:
    print("===============================================")
    obs_polys = [
        SparsePolynomial.from_string(s, system['variables']) for s in obs_set
    ]

    start = time.time()
    lumped = clue.do_lumping(system['equations'], obs_polys)
    end = time.time()

    print(f"The size of the original model is {len(system['equations'])}")
    print(f"The size of the reduced model is {len(lumped['polynomials'])}")
    print(f"Computation took {end - start} seconds")
###############################################

obss = {
    "BIOMD0000000504.ode":
    [["cFos_P", "cJun_P"], ["MMP1_mRNA", "MMP13_mRNA", "TIMP1_mRNA"],
     ["MMP1", "MMP13", "ColFrag"],
     ["JAK1_P", "JNK_P", "cJun_P", "cJun_dimer", "STAT3_P_nuc",
      "STAT3_P_cyt"]],
    "fceri_ji.ode": [["S0"], ["S2", "S178", "S267", "S77"],
                     ["S2 + S178 + S267 + S77"], ["S7"], ["S1"]],
    "e2.ode": [["S0"], ["S1"]],
    "Barua.ode": [["aS000"], ["aS027"]]
}

if __name__ == "__main__":

    path = sys.argv[1]
    name = path[path.rindex('/') + 1:]

    system = read_system("{0}".format(path))

    obs_sets = obss[name]

    for obs_set in obs_sets:
        obs_polys = [
            SparsePolynomial.from_string(s, system['variables'])
            for s in obs_set
        ]

        do_lumping(system["equations"], obs_polys)
Exemple #5
0
    polys_values = [evalp(p, specialization) for p in polys]
    polys_values_lumped = [dot_product(polys_values, var) for var in new_vars]

    specialization_lumped = [dot_product(specialization, var) for var in new_vars]
    lumped_polys_values = [evalp(p, specialization_lumped) for p in lumped_system]

    assert(polys_values_lumped == lumped_polys_values)
    print(test_name + ": lumping is correct")
        
###############################################

if __name__ == "__main__":
    # Example 1
    R = sympy.polys.rings.vring(["x0", "x1", "x2"], QQ)
    polys = [x0**2 + x1 + x2, x2, x1]
    lumping = do_lumping(polys, [x0], print_reduction=False, initial_conditions={"x0" : 1, "x1" : 2, "x2" : 5})
    check_lumping("Example 1", polys, lumping, 2)
    assert lumping["new_ic"] == [QQ(1), QQ(7)]

    # Example 2
    polys = [x1**2 + 4 * x1 * x2 + 4 * x2**2, x1 + 2 * x0**2, x2 - x0**2]
    lumping = do_lumping(polys, [x0], print_reduction=False)
    check_lumping("Example 2", polys, lumping, 2)

    # PP for n = 2
    system = read_system("e2.ode") 
    lumping = do_lumping(
            system["equations"],
            [SparsePolynomial.from_string("S0", system["variables"])], 
            print_reduction=False
    )
Exemple #6
0
import sys
import time

from sympy import QQ

sys.path.insert(0, "../")
sys.path.insert(0, "./../../")
import parser
import clue
from sparse_polynomial import SparsePolynomial

system = parser.read_system("BIOMD0000000033.ode")
obs = SparsePolynomial.from_string("AktInactive", system['variables'])

start = time.time()
lumped = clue.do_lumping(system['equations'], [obs], print_system=True)
end = time.time()

print(f"The size of the original model is {len(system['equations'])}")
print(f"The size of the reduced model is {len(lumped['polynomials'])}")
print(f"Computation took {end - start} seconds")