Ejemplo n.º 1
0
def binds(name_a, name_b):
    """Rule for 'A binds B'."""
    A = new_variable(nickname=name_a)
    B = new_variable(nickname=name_b)

    return predicate.Exists(predicate.Implies(predicate.Named(A, name_a),
            predicate.Implies(predicate.Named(B, name_b),
                predicate.Not(predicate.And(predicate.PreLink(A, B)),
                    predicate.PostLink(A, B)))))
Ejemplo n.º 2
0
def make_predicate_many(statements):
    # TODO: Switch this back to using predicate.Top and predicate.And
    # once the macros are returning Predicate predicates instead of z3 predicates.
    if len(statements) == 0:
        return predicate.Top()
    elif len(statements) == 1:
        return make_predicate(statements[0])
    else:
        predicates = [make_predicate(statement) for statement in statements]
        return predicate.And(*predicates)
Ejemplo n.º 3
0
 def setUp(self):
     enzyme = structure.Agent("enzyme")
     enzyme_site = structure.Agent("enzyme_site")
     substrate = structure.Agent("substrate")
     # This one asserts that some molecule labeled Protein can bind to some
     # molecule labeled Substrate via some site labeled Site.
     self.phi = predicate.ModelHasRule(lambda r: predicate.And(
             predicate.PregraphHas(r, enzyme.with_site(enzyme_site)),
             predicate.PregraphHas(r, substrate),
             predicate.PostgraphHas(r, enzyme.with_site(enzyme_site.bound(substrate)))
     ))
     # This one asserts that some molecule labeled D can bind directly to
     # some molecule labeled E.
     d = structure.Agent("d")
     e = structure.Agent("e")
     self.psi = predicate.ModelHasRule(lambda r: predicate.And(
             predicate.PregraphHas(r, d),
             predicate.PregraphHas(r, e),
             predicate.PostgraphHas(r, e.bound(d))
     ))
Ejemplo n.º 4
0
def phosphorylated_is_active(name_b):
    """
    Macro for 'phosphorylated "B" is active'.
    """
    # Forall Model, *Forall* Rule in Model, Forall B, Named B named_b => and(...)
    B = new_variable(nickname=name_b)

    intp = datatypes.new_interpretation()

    return predicate.ForAll(predicate.Implies(predicate.Named(B, name_b),
        predicate.And(predicate.Implies(predicate.PreLabeled(B, PHOSPHORYLATED),
                    predicate.PreLabeled(B, ACTIVE)),
            predicate.Implies(predicate.PostLabeled(B, PHOSPHORYLATED),
                    predicate.PostLabeled(B, ACTIVE)))))
Ejemplo n.º 5
0
def directly_activates(name_a, name_b):
    """
    Macro for 'activated "A" activates "B"'.
    """
    # Forall Model, Exists Rule in Model, [...]
    A = new_variable(nickname=name_a)
    B = new_variable(nickname=name_b)

    intp = datatypes.new_interpretation()

    return predicate.Exists(predicate.Implies(predicate.Named(A, name_a),
            predicate.Implies(predicate.Named(B, name_b),
                predicate.And(predicate.PreLabeled(A, ACTIVE),
                    predicate.PreUnlabeled(B, ACTIVE),
                    predicate.PostLabeled(A, ACTIVE),
                    predicate.PostLabeled(B, ACTIVE)))))
Ejemplo n.º 6
0
def directly_phosphorylates(name_a, name_b):
    """
    Macro for 'activated "A" phosphorylates "B"'.
    """
    A = new_variable(nickname=name_a)
    B = new_variable(nickname=name_b)

    # Okay, so what I actually want this to say is as follows:
    # Forall Model, Exists Rule in Model, reaction stuff holds over rule
    # reaction stuff = Forall A B, Named A name_a /\ Named B name_b => prelabeled etc
    intp = datatypes.new_interpretation()

    return predicate.Exists(predicate.Implies(predicate.Named(A, name_a),
            predicate.Implies(predicate.Named(B, name_b),
                predicate.And(predicate.PreLabeled(A, ACTIVE),
                    predicate.PreUnlabeled(B, PHOSPHORYLATED),
                    predicate.PostLabeled(A, ACTIVE),
                    predicate.PostLabeled(B, PHOSPHORYLATED)))))
Ejemplo n.º 7
0
 def test_and_unsat(self):
     p1 = predicate.Top()
     p2 = predicate.Bottom()
     status = solver.quick_check(predicate.And(p1, p2))
     self.assertFalse(status)
Ejemplo n.º 8
0
 def test_and_sat(self):
     p1 = predicate.Top()
     p2 = predicate.Top()
     status = solver.quick_check(predicate.And(p1, p2))
     self.assertTrue(status)
Ejemplo n.º 9
0
import atomic_predicate
import datatypes
from labels import ACTIVE, PHOSPHORYLATED
from macros import directly_phosphorylates, directly_activates, phosphorylated_is_active
import predicate
from solver import solver
import z3

# Sanity checks.
assert not predicate.Bottom().check_sat()
assert predicate.Top().check_sat()
assert not predicate.And(predicate.Bottom(), predicate.Top()).check_sat()
assert not predicate.ForAll(predicate.Bottom()).check_sat()
assert predicate.ForAll(predicate.Top()).check_sat()
assert not predicate.Exists(predicate.Bottom()).check_sat()
assert predicate.Exists(predicate.Top()).check_sat()

print "Predicate I: MEK directly phosphorylates ERK in a single step.\nTranslated to z3:"
i = directly_phosphorylates("MEK", "ERK")
print i.get_predicate()

print "\nPredicate II: ERK, when phosphorylated, is always active.\nTranslated to z3:"
ii = phosphorylated_is_active("ERK")
print ii.get_predicate()

print "\nPredicate III: MEK directly activates ERK in a single step.\nTranslated to z3:"
iii = directly_activates("MEK", "ERK")
print iii.get_predicate()

print "\nEach of these predicates is satisfiable (True) on their own: checking..."
assert i.check_sat()
Ejemplo n.º 10
0
 def test_and_unsat(self):
     p1 = predicate.Top()
     p2 = predicate.Bottom()
     status = predicate.And(p1, p2)
     self.assertTrue(status)