Пример #1
0
 def test_complicated_site_actor(self):
     m = Modification(enzyme=SiteActor(protoform=Protoform(
         "P00519",
         sites=[Site(name="bob", start=120, end=150)],
         regions=[Region(name="alice", start=100, end=200)],
         residues=[Residue("Y", 122)]),
                                       site=Site(name="jack",
                                                 start=550,
                                                 end=600,
                                                 residues=[Residue("T")]),
                                       region=Region(
                                           name="Pkinase",
                                           start=500,
                                           end=800,
                                           sites=[Site(name="billy")])),
                      substrate=SiteActor(protoform=Protoform("P00533"),
                                          site=Site(name="target"),
                                          region=Region(name="bla")),
                      target=Residue("Y", 100,
                                     State("phosphorylation", False)),
                      value=True)
     corpus = KamiCorpus("test")
     corpus.add_interactions([m], anatomize=True)
     print_graph(corpus.get_nugget("test_nugget_1"))
     print(ag_to_edge_list(corpus))
Пример #2
0
    def test_regionactor(self):
        # Phosphorylated and unphosphrylated states.
        phos = State("phosphorylation", True)
        unphos = State("phosphorylation", False)

        inters = []
        # Phosphorylation with RegionActor as substrate.
        m = Modification(enzyme=Protoform("P00519"),
                         substrate=RegionActor(
                             Protoform("P00533",
                                       regions=[
                                           Region(name='PVPEyINQS',
                                                  start=280,
                                                  end=290),
                                           Region(name="L receptor",
                                                  start=57,
                                                  end=167,
                                                  states=[phos])
                                       ]), Region(start=1000, end=1500)),
                         target=Residue(aa="Y", loc=1092, state=unphos),
                         value=True)
        inters.append(m)

        corpus = KamiCorpus("test")
        corpus.add_interactions(inters, anatomize=True)
        print_graph(corpus.get_nugget("test_nugget_1"))
Пример #3
0
    def test_ligandmod_generation(self):
        """Test generation of a transmodification nugget graph."""
        enzyme_gene = Protoform("A")
        enzyme_region_actor = RegionActor(
            protoform=enzyme_gene,
            region=Region("Pkinase"))

        substrate = Protoform("B")

        automod = LigandModification(
            enzyme_region_actor,
            substrate,
            Residue("Y", 100, State("phosphorylation", True)),
            value=True,
            enzyme_bnd_region=Region("EbndRegion"),
            substrate_bnd_region=Region("SbndRegion"),
            substrate_bnd_site=Site("SbndSite"))

        corpus = KamiCorpus("test")
        identifier = EntityIdentifier(
            corpus.action_graph,
            corpus.get_action_graph_typing())
        generator = LigandModGenerator(identifier)
        n, _, _, _ = generator.generate(automod)
        print_graph(n.graph)

        inter = LigandModification(
            enzyme=RegionActor(protoform=Protoform(uniprotid="P30530",
                                         hgnc_symbol="AXL"),
                               region=Region(name="Tyr_kinase",
                                             interproid="IPR020635",
                                             start=536, end=807)),
            substrate=SiteActor(protoform=Protoform(uniprotid="P06239",
                                          hgnc_symbol="LCK"),
                                site=Site(name="pY394",
                                          start=391, end=397)),
            target=Residue(aa="Y", loc=394,
                           state=State("phosphorylation", False)),
            value=True,
            rate=10,
            enzyme_bnd_region=Region(name="Tyr_kinase",
                                     interproid="IPR020635",
                                     start=536, end=807),
            substrate_bnd_site=Site(name='pY394',
                                    start=391, end=397)
        )
        corpus = KamiCorpus("test")
        corpus.add_interaction(inter, anatomize=False)
        print_graph(corpus.get_nugget('test_nugget_1'))
Пример #4
0
    def test_sites(self):
        # Create genes.
        egfr = Protoform("P00533")
        grb2 = Protoform("P62993")

        # Create a RegionActor and a SiteActor fo GRB2.
        grb2_sh2 = RegionActor(protoform=grb2, region=Region(name="SH2"))
        grb2_site = SiteActor(protoform=grb2, site=Site(name="pY"))

        inters = []
        # This works (RegionActor).
        # inters.append(BinaryBinding([egfr], [grb2_sh2]))
        # This does not work (SiteActor)
        inters.append(Binding(egfr, grb2_site))

        corpus = KamiCorpus("test")
        corpus.add_interactions(inters, anatomize=True)
        print_graph(corpus.get_nugget("test_nugget_1"))
Пример #5
0
    def test_sh2_py_semantics(self):
        """."""
        phos = State("phosphorylation", True)
        dok1_py398 = Protoform("Q99704",
                               synonyms=["DOK1", "p62DOK1"],
                               residues=[Residue("Y", 398, phos)])

        abl2 = Protoform("P42684", synonyms=["ABL2"])
        sh2 = Region(name="SH2")

        abl2_sh2 = RegionActor(abl2, sh2)

        bnd = Binding(dok1_py398, abl2_sh2)

        corpus = KamiCorpus("test")
        nugget_id = corpus.add_interaction(bnd)

        semantic_entities = [
            "sh2_domain", "sh2_domain_pY_bnd", "pY_site", "pY_residue",
            "phosphorylation"
        ]

        print(corpus.get_nugget(nugget_id).nodes())
        assert ("pY_site" in corpus.get_nugget(nugget_id).nodes())
        assert ("pY_residue" in corpus.get_nugget(nugget_id).nodes())
        assert ("pY_residue_phospho" in corpus.get_nugget(nugget_id).nodes())

        assert ((nugget_id, "sh2_pY_binding_semantic_nugget")
                in corpus.nugget_relations())

        for entity in semantic_entities:
            assert (entity in corpus._hierarchy.get_relation(
                "sh2_pY_binding_semantic_nugget", nugget_id).keys())

        site_actor_no_residue = SiteActor(Protoform("A"),
                                          Site("pY-site", start=100, end=150))

        bnd = Binding(abl2_sh2, site_actor_no_residue)
        nugget_id = corpus.add_interaction(bnd)
        assert (len(corpus.get_nugget(nugget_id).nodes()) == 7)
        binding_nodes = []
        for n in corpus.action_graph.nodes():
            if corpus.get_action_graph_typing()[n] == "bnd":
                binding_nodes.append(n)
        assert (len(binding_nodes) == 1)

        assert ((nugget_id, "sh2_pY_binding_semantic_nugget")
                in corpus.nugget_relations())

        for entity in semantic_entities:
            assert (entity in corpus._hierarchy.get_relation(
                "sh2_pY_binding_semantic_nugget", nugget_id).keys())

        site_actor_no_phospho = SiteActor(
            Protoform("A"),
            Site("pY-site", start=100, end=150, residues=[Residue("Y")]))
        bnd = Binding(abl2_sh2, site_actor_no_phospho)
        nugget_id = corpus.add_interaction(bnd)
        assert (len(corpus.get_nugget(nugget_id).nodes()) == 8)
        binding_nodes = []
        for n in corpus.action_graph.nodes():
            if corpus.get_action_graph_typing()[n] == "bnd":
                binding_nodes.append(n)
        assert (len(binding_nodes) == 1)
        assert ((nugget_id, "sh2_pY_binding_semantic_nugget")
                in corpus.nugget_relations())

        for entity in semantic_entities:
            assert (entity in corpus._hierarchy.get_relation(
                "sh2_pY_binding_semantic_nugget", nugget_id).keys())

        site_actor_with_residue = SiteActor(
            Protoform("A"),
            Site("pY-site",
                 start=100,
                 end=150,
                 residues=[
                     Residue("Y", loc=145, state=State("phosphorylation"))
                 ]))

        bnd = Binding(abl2_sh2, site_actor_with_residue)
        nugget_id = corpus.add_interaction(bnd)
        assert (len(corpus.get_nugget(nugget_id).nodes()) == 7)
        binding_nodes = []
        for n in corpus.action_graph.nodes():
            if corpus.get_action_graph_typing()[n] == "bnd":
                binding_nodes.append(n)
        assert (len(binding_nodes) == 1)
        assert ((nugget_id, "sh2_pY_binding_semantic_nugget")
                in corpus.nugget_relations())

        for entity in semantic_entities:
            assert (entity in corpus._hierarchy.get_relation(
                "sh2_pY_binding_semantic_nugget", nugget_id).keys())

        site_actor_with_residue1 = SiteActor(
            Protoform("B"),
            Site("pY-site",
                 residues=[
                     Residue("Y", loc=145, state=State("phosphorylation"))
                 ]))
        site_actor_with_residue2 = SiteActor(
            Protoform("B"),
            Site("some site",
                 residues=[
                     Residue("Y", loc=145, state=State("phosphorylation"))
                 ]))
        bnd1 = Binding(abl2_sh2, site_actor_with_residue1)
        bnd2 = Binding(abl2_sh2, site_actor_with_residue2)
        corpus.add_interactions([bnd1, bnd2])
        print_graph(corpus.action_graph)