Coder Social home page Coder Social logo

reaction's Introduction

Kappa and Reaction Networks

Quick start:

  • [optional] Make sure you have a recent version of the cabal tool that supports "sandbox" and do
% cabal sandbox init
  • Install dependencies
% cabal install --only-dependencies
  • Check that everything is working properly
% cabal build
% cabal test
...
1 of 1 test suites (1 of 1 test cases) passed.
  • Investigate things in the REPL. For example,
% cabal repl
Flow.Kappa> declare [complex| A(x!1), A(x~2!1,y~p), A(x~1), B(u,v,w~1) |]
[A(x~1~2,y),B(w,u,v)]
  • Look at a materialised RDF version of an example model
% ./dist/build/krdf/krdf -f examples/tcs.kappa -a -n -m

The krdf tool

The krdf tool transforms annotated Kappa files into RDF. By default it will produce an empty graph as output. It has command line flags to extract the annotations from the comments in the file (see the examples/tcs.kappa file), to normalise agent patterns in rules according to the declarations, and to materialise the rules into RDF. All three of these options used together will extract the maximum information from the source file. Using the normalise flag only makes sense together with materialise since it operates on the information latent in the Kappa rules.

Kappa -> RDF

Usage: krdf (-f|--filename FILENAME) [-a|--annotations] [-m|--materialise]
            [-n|--normalise]
  Transform Kappa rules to RDF

Available options:
  -h,--help                Show this help text
  -f,--filename FILENAME   Kappa file to read
  -a,--annotations         Extract annotations
  -m,--materialise         Materialise Kappa statements to RDF
  -n,--normalise           Normalise agent patterns according to declarations

The serialiser that this tool uses does not produce the prettiest RDF/turtle serialisation. For a nicer looking version, the rapper tool does a much better job. This tool, and its very useful query counterpart roqet are available in most recent operating systems.

To prettify the examples/tcs.kappa file, it can be used in conjunction with krdf like so:

krdf -f examples/tcs.kappa -a -m -n | \
    rapper -i turtle -o turtle - file://examples/tcs.kappa

This representation is particularly useful for understanding the pattern of the output in order to write queries against it.

Queries

Using roqet it is possible to run queries in the SPARQL language angainst the RDF graph produced by krdf. The examples/binding.sparql file contains a query to extract the forward part of the contact graph -- which agents and sites become bound under a particular rule. An example command line is,

krdf -f examples/tcs.kappa -a -m -n | \
    roqet -D - -r table examples/binding.sparql

roqet can produce output in a variety of machine-readable formats (json, xml, csv) as well as some human readable ones (html, table).

reaction's People

Contributors

wwaites avatar

Watchers

 avatar vd1 avatar James Cloos avatar  avatar

Forkers

edinburgh-rbm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.