Пример #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_multiple_bnd_templates(self):
        dummy_partner = SiteActor(
            protoform=Protoform("C"),
            region=Region(name="C_RegionActor"),
            site=Site(name="C_SiteActor"))

        enzyme = SiteActor(
            protoform=Protoform("A", bound_to=[dummy_partner]),
            region=Region(name="A_RegionActor", bound_to=[dummy_partner]),
            site=Site(name="A_SiteActor", bound_to=[dummy_partner]))
        substrate = SiteActor(
            protoform=Protoform("B", bound_to=[dummy_partner]),
            region=Region(name="B_RegionActor", bound_to=[dummy_partner]),
            site=Site(name="B_SiteActor", bound_to=[dummy_partner]))

        mod = Modification(
            enzyme,
            substrate,
            target=Residue("Y", 100, State("phosphorylation", False)),
            value=True)

        corpus = KamiCorpus("test")
        identifier = EntityIdentifier(
            corpus.action_graph,
            corpus.get_action_graph_typing())
        generator = ModGenerator(identifier)
        n, _, _, _ = generator.generate(mod)
Пример #3
0
    def test_mod_generator(self):
        """Test generation of a modification nugget graph."""
        enzyme_gene = Protoform("A")
        enzyme_region_actor = RegionActor(
            protoform=enzyme_gene,
            region=Region("Pkinase"))
        enzyme_site_actor = SiteActor(
            protoform=enzyme_gene,
            region=Region("Pkinase"),
            site=Site("tail"))

        substrate_gene = Protoform("B")
        substrate_region_actor = RegionActor(
            protoform=substrate_gene,
            region=Region("SH2"))
        substrate_site_actor = SiteActor(
            protoform=substrate_gene,
            region=Region("SH2"),
            site=Site("finger"))

        residue_mod_target = Residue("Y", 100, State("activity", False))
        state_mod_target = State("activity", False)

        mod1 = Modification(
            enzyme=enzyme_gene,
            substrate=substrate_gene,
            target=state_mod_target
        )

        mod2 = Modification(
            enzyme=enzyme_region_actor,
            substrate=substrate_gene,
            target=state_mod_target
        )

        mod3 = Modification(
            enzyme=enzyme_site_actor,
            substrate=substrate_gene,
            target=state_mod_target
        )

        mod4 = Modification(
            enzyme=enzyme_site_actor,
            substrate=substrate_region_actor,
            target=state_mod_target
        )

        mod5 = Modification(
            enzyme=enzyme_site_actor,
            substrate=substrate_site_actor,
            target=residue_mod_target
        )
        corpus = KamiCorpus("test")
        identifier = EntityIdentifier(
            corpus.action_graph,
            corpus.get_action_graph_typing())
        generator = ModGenerator(identifier)
        n, _, _, _ = generator.generate(mod5)
        print_graph(n.graph)
Пример #4
0
    def test_siteactor(self):
        """Generate sh2 pY bnd interactions."""
        # General phosphorylation state.
        phos = State("phosphorylation", True)
        unphos = State("phosphorylation", False)

        # General SH2 regions.
        sh2 = Region(name="SH2")
        sh2n = Region(name="SH2", order=1)
        sh2c = Region(name="SH2", order=2)

        inters = []

        enz_uniprot = 'P00519'
        sub_uniprot = 'P00533'
        rsd = 'Y1092'
        location = int(rsd[1:])
        strt = location - 4
        stop = location + 4
        site_name = 'b%i' % location

        m = Modification(enzyme=Protoform(enz_uniprot),
                         substrate=SiteActor(protoform=Protoform(sub_uniprot),
                                             site=Site(name=site_name,
                                                       start=strt,
                                                       end=stop)),
                         target=Residue(aa="Y", loc=location, state=unphos),
                         value=True)
        inters.append(m)
        corpus = KamiCorpus("test")
        corpus.add_interactions(inters, anatomize=True)
Пример #5
0
    def test_advanced_site_actor(self):
        # General phosphorylation state.
        phos = State("phosphorylation", True)
        unphos = State("phosphorylation", False)

        # General SH2 regions.
        sh2 = Region(name="SH2")
        sh2n = Region(name="SH2", order=1)
        sh2c = Region(name="SH2", order=2)

        # Test site.
        s1 = Site(name="test_site")

        inters = []

        # Modification using SiteActor.
        m = Modification(enzyme=Protoform("P00519", hgnc_symbol="ABL1"),
                         substrate=SiteActor(protoform=Protoform(
                             "P00519", hgnc_symbol="ABL1"),
                                             site=Site(name="site800",
                                                       start=796,
                                                       end=804)),
                         target=Residue("Y", 800,
                                        State("phosphorylation", False)),
                         value=True)
        inters.append(m)
        m = Modification(enzyme=Protoform("P00519", hgnc_symbol="ABL1"),
                         substrate=SiteActor(protoform=Protoform(
                             "P00533", hgnc_symbol="EGFR"),
                                             site=Site(name="site800",
                                                       start=796,
                                                       end=804)),
                         target=Residue("Y", 800,
                                        State("phosphorylation", False)),
                         value=True)
        inters.append(m)

        # Binding using SiteActor.
        b = Binding(
            SiteActor(protoform=Protoform("P00533", hgnc_symbol="EGFR"),
                      site=Site(name="site800", start=796, end=804)),
            RegionActor(protoform=Protoform("P62993", hgnc_symbol="GRB2"),
                        region=sh2))
        inters.append(b)
        corpus = KamiCorpus("test")
        corpus.add_interactions(inters, anatomize=True)
Пример #6
0
    def __init__(self):
        uniprotid = "P00533"
        simple_region = Region("SH2")
        regions = [simple_region]

        sites = [Site("pY")]

        residues = [
            Residue("Y", 100),
            Residue("S", 155, State("phosphorylation", True))
        ]

        states = [State("activity", True), State("phosphorylation", True)]

        bounds = [
            SiteActor(protoform=Protoform("Q07890"),
                      site=Site("binding_site")),
            Protoform("P00519")
        ]

        self.protoform = Protoform(
            uniprotid,
            regions=regions,
            residues=residues,
            sites=sites,
            states=states,
            bound_to=bounds,
            hgnc_symbol="EGFR",
            synonyms=["EGFR", "Epidermal growth factor receptor"])

        self.enzyme_gene = Protoform("Q07890")

        self.enzyme_site_actor = SiteActor(protoform=self.enzyme_gene,
                                           region=Region("Pkinase"),
                                           site=Site("tail"))

        self.substrate_gene = Protoform("P00519")
        self.substrate_region_actor = RegionActor(
            protoform=self.substrate_gene, region=Region("SH2"))

        self.residue_mod_target = Residue("Y", 100, State("activity", False))
Пример #7
0
    def test_bnd_generation(self):
        """Test generation of a binding nugget graph."""
        left = SiteActor(Protoform("A"), Site("pY"), Region("Reg"))
        right = Protoform("B")
        bnd = Binding(left, right)

        corpus = KamiCorpus("test")
        identifier = EntityIdentifier(
            corpus.action_graph,
            corpus.get_action_graph_typing())
        generator = BndGenerator(identifier)
        n, _, _, _ = generator.generate(bnd)
        print_graph(n.graph)
Пример #8
0
    def test_site_actor_generator(self):
        """Test generation of graph components for a SiteActor object."""
        # no region
        site_actor = SiteActor(
            protoform=Protoform("B"), site=Site("pY"))

        nugget = KamiGraph()
        nugget.reference_typing[self.default_ag_gene] = self.default_ag_gene

        (gene_id, site_id, region_id, _) =\
            self.generator.generate_site_actor(nugget, site_actor)
        assert((site_id, gene_id) in nugget.edges())

        # with a region in the middle
        site_actor_with_region = SiteActor(
            protoform=Protoform("B"), site=Site("pY"), region=Region("kinase"))

        (gene_id, site_id, region_id, _) =\
            self.generator.generate_site_actor(nugget, site_actor_with_region)

        assert((site_id, region_id) in nugget.edges())
        assert((region_id, gene_id) in nugget.edges())
Пример #9
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'))
Пример #10
0
 def test_site_residue_reconnect(self):
     sh2 = Region(name="SH2")
     b = Binding(
         SiteActor(protoform=Protoform(uniprotid="P00533",
                                       hgnc_symbol="EGFR",
                                       residues=[
                                           Residue("Y",
                                                   1092,
                                                   state=State(
                                                       "phosphorylation",
                                                       True))
                                       ]),
                   site=Site(name="motif1092", start=1088, end=1096)),
         RegionActor(protoform=Protoform("P62993", hgnc_symbol="GRB2"),
                     region=sh2))
     corpus = KamiCorpus("test")
     corpus.add_interaction(b)
Пример #11
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"))
Пример #12
0
    def __init__(self):
        """Initialize test class with a model."""
        self.model = KamiCorpus("test")

        egfr = Protoform("P00533")
        fgfr1 = Protoform("P11362")
        fgfr1_pysite = SiteActor(
            Protoform("P11362"),
            Site("pY",
                 residues=[Residue("Y", 463, State("phosphorylation", True))]))
        abl1_sh2 = RegionActor(Protoform("P00519"), Region("SH2"))

        target = Residue("Y", 463, State("phosphorylation", False))
        modification = Modification(enzyme=egfr,
                                    substrate=fgfr1,
                                    target=target)
        binding = Binding(abl1_sh2, fgfr1_pysite)

        self.model.add_interactions([modification, binding])
Пример #13
0
    def test_bookkeeping(self):
        interactions = []

        i1 = LigandModification(
            RegionActor(Protoform("P00533"), Region(start=712, end=979)),
            Protoform("P00533"),
            Residue("Y", 1092, state=State("phosphorylation", False)))
        interactions.append(i1)

        i2 = Modification(
            Protoform("P00519"), Protoform("P00533"),
            Residue("S", 800, state=State("phosphorylation", False)))
        interactions.append(i2)

        i3 = Binding(Protoform("P00424"),
                     SiteActor(Protoform("P00533"), Site(start=799, end=900)))
        interactions.append(i3)

        corpus = KamiCorpus("test")
        corpus.add_interactions(interactions)
Пример #14
0
    def test_is_bnd_generator(self):
        """Test generation of graph components for a bound condition."""
        protoform = Protoform("A")
        site_actor = SiteActor(protoform=Protoform("A"), site=Site("pY"))
        region_actor = RegionActor(
            protoform=Protoform("A"), region=Region("Pkinase"))

        nugget = KamiGraph()
        nugget.reference_typing[self.default_ag_gene] = self.default_ag_gene

        site = Site(
            "lala",
            bound_to=[protoform, protoform]
        )
        site_id, _ =\
            self.generator.generate_site(
                nugget, site,
                self.default_ag_gene, self.default_ag_gene)

        nugget = KamiGraph()
        nugget.reference_typing[self.default_ag_gene] = self.default_ag_gene

        site = Site(
            "lala",
            bound_to=[site_actor]
        )
        site_id, _ =\
            self.generator.generate_site(
                nugget, site, self.default_ag_gene,
                self.default_ag_gene)

        nugget = KamiGraph()
        nugget.reference_typing[self.default_ag_gene] = self.default_ag_gene

        site = Site(
            "lala",
            bound_to=[region_actor]
        )
        self.generator.generate_site(
            nugget, site, self.default_ag_gene, self.default_ag_gene)
Пример #15
0
    def __init__(self):
        """Initialize tests."""
        # Create an empty KAMI corpus
        self.nxcorpus = KamiCorpus("EGFR_signalling")
        try:
            h = Neo4jHierarchy(uri="bolt://localhost:7687",
                               user="******",
                               password="******")
            h._clear()
            self.neo4jcorpus = KamiCorpus("egfr",
                                          backend="neo4j",
                                          uri="bolt://localhost:7687",
                                          user="******",
                                          password="******")
        except:
            warnings.warn("Neo4j is down, skipping Neo4j-related tests")
            self.neo4jcorpus = None

        # Create an interaction object
        egfr = Protoform("P00533")
        egf = Protoform("P01133")

        kinase = Region(name="Protein kinase",
                        start=712,
                        end=979,
                        states=[State("activity", True)])

        egfr_kinase = RegionActor(protoform=egfr, region=kinase)

        interaction1 = LigandModification(
            enzyme=egfr_kinase,
            substrate=egfr,
            target=Residue("Y", 1092, state=State("phosphorylation", False)),
            value=True,
            rate=1,
            desc="Phosphorylation of EGFR homodimer")

        # Aggregate the interaction object to the corpus
        self.nxcorpus.add_interaction(interaction1)
        self.neo4jcorpus.add_interaction(interaction1)

        grb2 = Protoform("P62993", states=[State("activity", True)])
        grb2_sh2 = RegionActor(protoform=grb2, region=Region(name="SH2"))

        shc1 = Protoform("P29353")
        shc1_pY = SiteActor(
            protoform=shc1,
            site=Site(
                name="pY",
                residues=[Residue("Y", 317, State("phosphorylation", True))]))
        interaction1 = Binding(grb2_sh2, shc1_pY)

        grb2_sh2_with_residues = RegionActor(protoform=grb2,
                                             region=Region(
                                                 name="SH2",
                                                 residues=[
                                                     Residue("S",
                                                             90,
                                                             test=True),
                                                     Residue("D",
                                                             90,
                                                             test=False)
                                                 ]))

        egfr_pY = SiteActor(
            protoform=egfr,
            site=Site(
                name="pY",
                residues=[Residue("Y", 1092, State("phosphorylation", True))]))

        interaction2 = Binding(grb2_sh2_with_residues, egfr_pY)

        axl_PK = RegionActor(protoform=Protoform("P30530", hgnc_symbol="AXL"),
                             region=Region("Protein kinase",
                                           start=536,
                                           end=807))
        interaction3 = SelfModification(axl_PK,
                                        target=Residue(
                                            "Y", 821,
                                            State("phosphorylation", False)),
                                        value=True)

        interaction4 = AnonymousModification(RegionActor(protoform=Protoform(
            "P30530",
            hgnc_symbol="AXL",
            residues=[
                Residue("Y", 703, state=State("phosphorylation", True)),
                Residue("Y", 779, state=State("phosphorylation", True))
            ]),
                                                         region=Region(
                                                             "Protein kinase",
                                                             start=536,
                                                             end=807)),
                                             target=State("activity", False),
                                             value=True)

        egf_egfr = Protoform(egfr.uniprotid, bound_to=[egf])
        interaction5 = Binding(egf_egfr, egf_egfr)
        interaction6 = Unbinding(egf_egfr, egf_egfr)

        interaction7 = LigandModification(
            egfr_kinase,
            shc1,
            target=Residue("Y", 317, State("phosphorylation", False)),
            value=True,
            enzyme_bnd_region=Region("egfr_BND"),
            enzyme_bnd_site=Site("egfr_BND"),
            substrate_bnd_region=Region("shc1_BND"),
            substrate_bnd_site=Site("sch1_BND"))

        interactions = [
            interaction1, interaction2, interaction3, interaction4,
            interaction5, interaction6, interaction7
        ]

        self.nxcorpus.add_interactions(interactions)
        self.neo4jcorpus.add_interactions(interactions)

        # Create a protein definition for GRB2
        # protoform = Protoform(
        #     "P62993",
        #     regions=[Region(
        #         name="SH2",
        #         residues=[
        #             Residue("S", 90, test=True),
        #             Residue("D", 90, test=False)])])

        # ashl = Product("Ash-L", residues=[Residue("S", 90)])
        # s90d = Product("S90D", residues=[Residue("D", 90)])
        # grb3 = Product("Grb3", removed_components={"regions": [Region("SH2")]})

        # self.grb2_definition = Definition(protoform, [ashl, s90d, grb3])

        # self.model = self.nxcorpus.instantiate(
        #     "EGFR_signalling_GRB2", [self.grb2_definition],
        #     default_bnd_rate=0.1,
        #     default_brk_rate=0.1,
        #     default_mod_rate=0.1)
        self.query1 = ("""
            MATCH (:protoform)<--(r1:REGION)-->(i:interaction)-*-(n4:protoform)
            RETURN p1, i, p2;
            """)
Пример #16
0
    def test_advanced_ligand_mod_generator(self):
        """Test generation with advanced usage of LigandModification."""

        corpus = KamiCorpus("test")
        identifier = EntityIdentifier(
            corpus.action_graph,
            corpus.get_action_graph_typing())
        generator = LigandModGenerator(identifier)

        enzyme = SiteActor(
            protoform=Protoform("A"),
            region=Region(name="RegionActor"),
            site=Site(name="SiteActor"))
        substrate = SiteActor(
            protoform=Protoform("B"),
            region=Region(name="RegionActor"),
            site=Site(name="SiteActor"))

        # simple subactors switching
        subactors = ["protoform", "region", "site"]
        for ea in subactors:
            for sa in subactors:
                mod = LigandModification(
                    enzyme=enzyme,
                    substrate=substrate,
                    target=Residue("Y", 100, State("phosphorylation", True)),
                    value=False,
                    enzyme_bnd_subactor=ea,
                    substrate_bnd_subactor=sa)

            n, _, _, _ = generator.generate(mod)

        mod = LigandModification(
            enzyme=enzyme,
            substrate=substrate,
            target=Residue("Y", 100, State("phosphorylation", True)),
            value=False,
            enzyme_bnd_region=Region(name="SpecialBindingRegion"),
            substrate_bnd_region=Region(name="SpecialBindingRegion"))

        n, _, _, _ = generator.generate(mod)

        mod = LigandModification(
            enzyme=enzyme,
            substrate=substrate,
            target=Residue("Y", 100, State("phosphorylation", True)),
            value=False,
            enzyme_bnd_subactor="region",
            substrate_bnd_subactor="region",
            enzyme_bnd_site=Site(name="SpecialBindingSite"),
            substrate_bnd_site=Site(name="SpecialBindingSite"))

        n, _, _, _ = generator.generate(mod)

        mod = LigandModification(
            enzyme=enzyme,
            substrate=substrate,
            target=Residue("Y", 100, State("phosphorylation", True)),
            value=False,
            enzyme_bnd_region=Region(name="SpecialBindingRegion"),
            substrate_bnd_region=Region(name="SpecialBindingRegion"),
            enzyme_bnd_site=Site(name="SpecialBindingSite"),
            substrate_bnd_site=Site(name="SpecialBindingSite"))

        n, _, _, _ = generator.generate(mod)
        print_graph(n.graph)
Пример #17
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)