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)))))
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)))))
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)))))
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)))))
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() print i.check_sat() assert ii.check_sat() print ii.check_sat() assert iii.check_sat() print iii.check_sat() print "\nI and II are satisfiable together: checking And(I, II)..." and_i_ii = predicate.And(i, ii) assert and_i_ii.check_sat() print and_i_ii.check_sat() print "\nI and II imply III: checking Implies(And(I, II), III)..." implication = predicate.Implies(and_i_ii, iii) assert implication.check_sat() print implication.check_sat() print "\nI and II and III are satisfiable together: checking And(I, II, III)..." and_i_ii_iii = predicate.And(i, ii, iii) assert and_i_ii_iii.check_sat() print and_i_ii_iii.check_sat() print "\nHector's examples"