Introducing Topkappy: a Kappy wrapper for easier Python model building and results analysis

28 views
Skip to first unread message

Valentin Z

unread,
Jan 10, 2019, 10:57:46 AM1/10/19
to kappa-users
Hi all,

Thanks for the Kappa project. I wanted to share Topkappy, a Python library I wrote on top of Kappy to make it easier to dynamically generate large Kappa models, with hundreds of interactions between dozens of agents.

Topkappy provides Python classes so that models can be built by assembling objects (using for loops, conditions,etc.) which are then compiled into a Kappa model string. I also provides methods to analyse the results (plot time series or graphs of the different agents/species returned in a snapshot), and it can print Kappa script syntax errors in a user-friendly way in a Python/Jupyter notebook.

Topkappy is admitedly incomplete but could be easily extended. Right now it is oriented towards my use case, which is predicting the proportion of valid constructs when assembling many DNA parts with the Golden Gate standard in Synthetic Biology (have a look at the Kappagate project if you are interested).

Hopefully I didn't reinvent a wheel and it can be useful to others! I haven't had much time to fully understand Kappa yet, and I went straight to what "works for me", so any criticism or ideas for future development are welcome.

Cheers,

Valentin

Pierre Boutillier

unread,
Jan 17, 2019, 4:41:05 AM1/17/19
to Valentin Z, kappa-users
Hi,
Very nice, thank you for sharing. (With 1 week of delay, my enthusiasm will sound fake but it's not. I wanted to do a more deeper review but as always time flies...)
This is very valuable (and pleasing) for developers to see how and what for their tools have been used. It's even more exciting when they have even been extended!

Your error reporting wrapper and the way you reshape simulation_plots are things kappy would clearly immediately benefit from! I still need to figure out the computational cost of (what is still to me voodoo incantation :-)) `dict(zip(plot_data['legend'], zip(*plot_data['series'])))` in order to convince myself that it is reasonable to always do it (even when you have thousands of data points) but we'll go there one way or another...

If you want something to compare to in term of python framework to build and analyse biological model, http://pysb.org is a big player and it has a kappa backend.

Pierre B.
> --
> You received this message because you are subscribed to the Google Groups "kappa-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kappa-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Valentin

unread,
Jan 17, 2019, 8:22:40 AM1/17/19
to Pierre Boutillier, kappa-users
Hi Pierre,

Glad you liked it, feel free to integrate the error formatting and
possibly the plot data reshaping to Kappy, this would allow me to remove
the code from topkappy.

The reshaping of the plot_data is advantageous for people using e.g.
Matplotlib, but other people may prefer the original format. The
computing time is simply proportional to the number of data points - it
takes 233ms to reshape 100 lists of 100k values on a good computer, to
give you an idea. I don't think this is much time compared to the
duration of the simulation that would generate the data.

I also got a message from John Bachman pointing me to PySB. It looks
like something I could have used but I didn't find it at the time. One
advantage of Kappy is that it automatically installs Kappa, which makes
it a very friendly dependency. PySB could benefit from that (right now
you need to install Kappa by hand to use it).

Cheers,

Valentin

David C Sterratt

unread,
Jan 18, 2019, 8:29:32 AM1/18/19
to Valentin, Pierre Boutillier, kappa-users
Talking about python interfaces, SpatialKappa now has a python
interface, which allows for simulation building and control:
https://github.com/davidcsterratt/SpatialKappa/blob/master/README.md

It's used to incorporate SpatialKappa in NEURON, in the KappaNEURON
package:
https://github.com/davidcsterratt/KappaNEURON

David.
--
David C Sterratt, Senior Research Associate
Institute for Adaptive and Neural Computation, School of Informatics
University of Edinburgh, 10 Crichton Street, Edinburgh EH8 9AB, Scotland, UK
http://homepages.inf.ed.ac.uk/sterratt - tel: +44 131 651 1739

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Sébastien Légaré

unread,
Jan 22, 2019, 6:22:14 AM1/22/19
to kappa-users
Hi Valentin,

Thank you for Topkappy. I tried it for a new project and so far it works great. I was wondering however, is there a way to get a kappa script in the edit notation ( i.e. A([./1]), B([./1]) ).
Up to now I get the script in arrow notation from model._full_kappa_script() .

Regards,
Sebastien
Reply all
Reply to author
Forward
0 new messages