def phosphorylated_is_active(agent): """ Macro for 'phosphorylated "B" is active'. Arguments: agent: an instance of structure.Structure Returns: a Syndra predicate (that is, an instance of predicate.Predicate) """ return ForAllRules(lambda r: And( Implies(PregraphHas(r, agent.labeled(phosphate)), PregraphHas(r, agent.labeled(active))), Implies(PostgraphHas(r, agent.labeled(phosphate)), PostgraphHas(r, agent.labeled(active)))))
def directly_activates(kinase, substrate): """ Macro for 'activated "kinase" activates "substrate"'. Arguments: kinase: an instance of structure.Structure substrate: an instance of structure.Structure Returns: a Syndra predicate (that is, an instance of predicate.Predicate) """ return ModelHasRule(lambda r: And( PregraphHas(r, kinase.labeled(active)), PregraphHas(r, substrate), PostgraphHas(r, kinase.labeled(active)), PostgraphHas(r, substrate.labeled(active)), Not(PregraphHas(r, substrate.labeled(active))), ))
def detect_ambiguous(*predicates): from datatypes import Rule, Graph, Node, Edge, Nodeset, Edgeset, Labelset, Labelmap pred = And(*predicates) model = pred.get_python_model()
from datatypes import Rule, Graph, Node, Edge, Nodeset, Edgeset, Labelset, Labelmap pred = And(*predicates) model = pred.get_python_model() # TODO assert that the model is not true, etc etc if __name__ == '__main__': print "---" kinase = Agent("kinase") # phosphate = Label("phosphate") # oxalate = Label("oxalate") substrate = Agent("substrate") pred = ModelHasRule(lambda r: And( PregraphHas(r, kinase.bound(substrate)), PostgraphHas(r, kinase), PostgraphHas(r, substrate), )) solver = MySolver("kinase", "substrate") print "---" solver.add(pred) print solver.check() print solver.model() print "---" # RAF = Agent("RAF") # HRAS = Agent("HRAS") # MEK1 = Agent("MEK1") # ERK1 = Agent("ERK1") # SAF1 = Agent("SAF1")