zakandrewking / escher

Build, share, and embed visualizations of metabolic pathways.
https://escher.github.io
Other
210 stars 78 forks source link

Feature Request: Wrapper around cobrapy to allow simultaneous editing. #203

Closed ChristianLieven closed 5 years ago

ChristianLieven commented 7 years ago

Hi @zakandrewking ,

I was wondering if it was possible to implement a way for Escher to wrap around a model object in cobrapy or cameo, such that if one makes changes to the model, they are reflected in the map too.

For example, let's say I'm reconstructing a model from scratch and I wanted to build an Escher map alongside. I would always have to work on the model first, then stop, load it into Escher, layout the reactions and then continue with working on the model. And later, once the draft is reconstructed, if I needed to change let's say IDs or reaction-directionality, I would have to do this in the model and the escher map separately. So my suggestion would be some form of wrapping that captures certain operations done in cobrapy and replicates them in Escher.

Here is a bit of mock-up code to illustrate how this could look like:

from cobrapy.io.json import read_json_model

model = read_json_model('SOMEMODEL.json')
wrapper = Wrapper(model)
builder = Builder(map_json='SOMEMAP.json', model=wrapper)
builder.display_in_browser()

wrapper.add_reaction('MDH')

wrapper.reaction.MDH.id = 'MNXR101439'
zakandrewking commented 7 years ago

This would be fantastic. I have been thinking about the kinds of features we would want if we re-wrote the Python package for Escher. Right now, we are using an old-school approach for embedding Escher in Jupyter, and the data only goes in one direction. But now, with Jupyter Widgets, we could implement two-way bindings like you describe.

It would take some work, but I'm excited to see it happen. I added it to our roadmap:

https://github.com/zakandrewking/escher/wiki/Development-Roadmap

@z-haiman has expressed interest in helping out.

ChristianLieven commented 7 years ago

Awesome! Looking forward to see what you guys come up with!

zakandrewking commented 6 years ago

As further support for this task, the current approach used by Escher-Python is not supported in JupyterLab:

screen shot 2018-02-20 at 9 39 57 am