Kappa-Dev / KAMI

Bio-curation library for modelling cellular signalling
MIT License
7 stars 0 forks source link

Unable to use "bounds" #11

Closed slegare2 closed 6 years ago

slegare2 commented 6 years ago

Trying to build an interaction "A binds B if A is bound to C".

import json
import pickle
from kami.entities import (Gene, Region, Site, Residue, State, RegionActor, SiteActor)
from kami.interactions import (Binding, Modification)
from kami.hierarchy import (KamiHierarchy)
from kami.resolvers.black_box import create_nuggets

rule_list = []

rule_list.append(
    Binding(
        [Gene("A", bounds=[Gene("C")])],
        [Gene("B")]
    )
)

for inter in rule_list:
    print(inter)

hierarchy = KamiHierarchy()
create_nuggets(rule_list, hierarchy, anatomize=False)

print(hierarchy.graph['kami'].nodes())

When I print the Binding, I get no reference to C. Left members: A Right members: B Direct? True

Strangely, when I print(hierarchy.graph['kami'].nodes()), I see that the test node "A_is_bnd_C" along with its two loci was added at the level of kami instead of the action graph.

eugeniashurko commented 6 years ago

Hi! As I told you before, the fact that you cannot see any reference to C in the output of printing is because of the implementation of __str__ method of Binding (there I choose not to print all the details of an agent, but simply its id, though this can be easily changed to any representation the user prefers), but the bound with C is there, for example:

bnd = Binding([Gene("A", bounds=[Gene("C")])], [Gene("B")]) bnd.left [Gene(uniprot=A, bounds=[[Gene(uniprot=C)]])]

Concerning the fact that some nodes are added to the meta-model: it's definitely a bug, I forgot to add the meta-model typing for this nodes in the nugget generation. Will be fixed by the next commit.