Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
113 stars 41 forks source link

tutorial on using the ocaml API #544

Open nilsbecker opened 6 years ago

nilsbecker commented 6 years ago

For using kasim as an ocaml library, we can browse the autogenerated API, which is also linked from the README. However, it's very difficult to get started with that just from the autogenerated API.

It would be much easier if a working .ml sample program, e.g. one that recapitulates the ABC example, were provided somewhere. Even better would be an API documentation that is written with a proper introduction, and some minimal examples, such as in the documentation of daniel buenzli's packages for example.

pirbo commented 5 years ago

Hi, Sorry to reply that late.

There isn't really the necessary infrastructure to use KaSim as an OCaml library I fully agree but it is deeper than documentation is missing. The mandatory wrapping function to make the experience bearable are probably missing! What would you like to do? I can try to do these wrapping function (and their documentation/tutorial) on demand :-)

nilsbecker commented 5 years ago

hm, i was exploring using kasim for stochastic chemical reaction kinetics of protein complexes -- but that was only a potential use case. i do not have an actual problem at hand right now. of course, this can be done using kasim from the command line. but i would then also like to do data analysis on the simulation output, so it would be nicer not to have to deal with reading stuff back in.

anyway, i guess what would be needed in principle is a way to set up a set of rules within ocaml and then operate on the resulting rule-set, by running simulations, making interventions etc. just what the DSL allows, only within ocaml. building from there, this could give also freedom to implement interventions that do more than what is accessible through the DSL... it just seems more extensible and modular in general.

hmedina commented 5 years ago

Until the OCaml API gets developed, could you use the Python API instead?

nilsbecker commented 5 years ago

sure.

pirbo commented 5 years ago

The python API is not better documented than the missing OCaml one :-) ... I've just added in python/README.rst a very minimal example of a session using it but we're far from what we can call a real "Getting start".

What the python API offers is to drive a simulation (and get the outputs) of a model imported as a big blob of kappa written in a string (or a file). This would also be what a potential OCaml API would "cheaply" offer too.

Offering a usable API to programmatically build and edit a model is an important quest that we'll have to tackle soon© but we are far from that for now.

nilsbecker commented 5 years ago

i would imagine that once such an API in ocaml is in place, it could be used to rebuild the kappa parsing and model construction in terms of it. that would presumably make the codebase more modular / cleaner, so there could be a payoff independently of the actual usage of the API by a user.

pirbo commented 5 years ago

Not really. The pipeline for building a model from kappa files is more or less OK but it relies on the fact that 1/ you get all the element at once 2/ the signature is known and immutable Removing these invariants is mandatory for allowing incremental construction but it would only create inefficiencies in the compilation from kappa files pipeline.

Anyway, as I said, we'll go there but in January the earliest...

nilsbecker commented 5 years ago

i see.