def make_predicate(statement): if isinstance(statement, indra.statements.Phosphorylation): # <enzyme> phosphorylates <substrate> # str() because sometimes these are Unicode enzyme = str(statement.enz.name) substrate = str(statement.sub.name) return macros.directly_phosphorylates(enzyme, substrate) elif isinstance(statement, indra.statements.ActivityActivity): # <enzyme> activates <substrate> upstream = str(statement.subj.name) downstream = str(statement.obj.name) if statement.subj_activity == 'Activity' and statement.obj_activity == 'Activity': return macros.directly_activates(upstream, downstream) else: raise NotImplementedError(str(statement)) elif isinstance(statement, indra.statements.ActivityModification): name = str(statement.monomer.name) return macros.phosphorylated_is_active(name) raise NotImplementedError(str(statement))
def make_predicate(statement): if isinstance(statement, indra.statements.Phosphorylation): # <enzyme> phosphorylates <substrate> # str() because sometimes these are Unicode enzyme = statement.enz.name.encode('utf-8') substrate = statement.sub.name.encode('utf-8') return macros.directly_phosphorylates(enzyme, substrate) elif isinstance(statement, indra.statements.Activation): # <enzyme> activates <substrate> upstream = statement.subj.name.encode('utf-8') downstream = statement.obj.name.encode('utf-8') if statement.subj_activity == 'activity' and statement.obj_activity == 'activity': return macros.directly_activates(upstream, downstream) else: raise NotImplementedError(str(statement)) elif isinstance(statement, indra.statements.ActiveForm): if len(statement.mods) == 1 and \ statement.mods[0].mod_type == 'phosphorylation' and \ statement.is_active: name = statement.agent.name.encode('utf-8') return macros.phosphorylated_is_active(name) raise NotImplementedError(str(statement))
# 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() 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)..."
# 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() print i.check_sat() assert ii.check_sat() print ii.check_sat() assert iii.check_sat() print iii.check_sat()