# bubble-tools
python routines related to bubble format, usable in CLI or as a library.
## Installation
pip install bubbletools
See below for usage.
## Features
- [X] bubble to python
- [X] bubble to [gexf](https://gephi.org/gexf/format/)
- [ ] bubble to cytoscape.js
- [X] working implementation
- [X] test on fully valid bubble
- [ ] unit testing
- [ ] test on big graphs, for benchmarking (will probably not scale)
- [ ] bubble to dot (via [graphviz](http://graphviz.readthedocs.io/en/latest/))
- [X] working implementation
- [X] test on fully valid bubble
- [ ] unit testing
- [ ] test on big graphs, for benchmarking (will probably not scale)
- [ ] python to bubble
- [ ] dot to python
- [ ] unit testing on bubble describing cliques
## CLI
`bubbletools` is usable through CLI.
### validation
usage:
python3 -m bubbletools validate path/to/bubble/file
Try hard to find errors and inconsistancies in the given bubble file
Spot powernode overlapping, inclusions inconsistancies
and empty or singleton powernodes.
Profiling gives general informations about the file data.
### conversion to dot
usage:
python3 bubbletool.py dot path/to/bubble/file path/to/output/file
Convert given bubble file in dot format.
The optional `--render` flag can be used to show the graph after saving.
Same API is available for gexf format.
### conversion to cytoscape.js
usage:
python3 -m bubbletools js path/to/bubble/file path/to/output/dir
Convert given bubble file in a fully working website using cytoscape.js to render the graph.
The optional `--render` flag can be used to run the default web browser on the generated website.
See Makefile recipe `js` for a usage example.
A website is a collection of files (css, js, html), with only one of them (`js/graph.js`)
that changes according to the input data.
If the `path/to/output/dir` has a `.js` extension, only the `js/graph.js` file will be generated.
This allow one to generates only the changing parts, not the full website each time.
See Makefile recipe `js-per-file` for a usage example.
## python API
Submodules `validator` and `converter` provides the functionnalities described above for CLI:
from bubbletools import validate, convert
for log in validate(open('path/to/bubble.lp'), profiling=True):
print(log)
convert.to_dot(open('path/to/bubble.lp'), dotfile='path/to/dot.dot')
### python representation of the graph
A lower level interface is the `BubbleTree` object, allowing one to manipulate the graph depicted by bubble data as python object.
See [unit tests](bubbletools/test/test_bbltree.py) for example of `BubbleTree` usage.
from bubbletools import BubbleTree
tree = BubbleTree.from_bubble_file('path/to/bubble.lp')
print(tree.edges, tree.inclusions, tree.roots)
`edges` is a mapping `predecessor -> set of successors`,
`inclusions` is a mapping `(power)node -> set of (power)nodes directly contained`,
and `roots` is a set of (power)nodes that are contained by nothing.
This representation holds all the data necessary for most work on the bubble.
The `BubbleTree.connected_components` function maps a graph with its connected components:
cc, subroots = BubbleTree.connected_components()
Where `cc` and `subroots` are both mappings, respectively linking *the* root of a connected component with all nodes of the connected component,
and *the* root of a connected component with the other roots of the same connected component.
Thus, connected components are identified by one of their roots, which is key is both dictionaries.
### access powernodes and their data
Follow an example of `BubbleTree` usage, retrieving data on powernodes:
tree = BubbleTree.from_bubble_file('bubbles/basic.bbl')
for pnode in tree.powernodes:
data = tree.powernode_data(pnode)
print(
"{} contains nodes {{{}}}, and powernodes {{{}}}."
"".format(pnode, data.contained_nodes, data.contained_pnodes)
)
Raw data
{
"_id": null,
"home_page": "https://github.com/aluriak/bubble-tools",
"name": "bubbletools",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "graph,format",
"author": "Lucas Bourneuf",
"author_email": "lucas.bourneuf@laposte.net",
"download_url": "https://files.pythonhosted.org/packages/dc/4f/03c1ac93b090d669d23965fbeede5ad07801ff56e0aaac8648fb6f0f029f/bubbletools-0.6.11.tar.gz",
"platform": "",
"description": "# bubble-tools\npython routines related to bubble format, usable in CLI or as a library.\n\n## Installation\n\n pip install bubbletools\n\nSee below for usage.\n\n\n## Features\n- [X] bubble to python\n- [X] bubble to [gexf](https://gephi.org/gexf/format/)\n- [ ] bubble to cytoscape.js\n - [X] working implementation\n - [X] test on fully valid bubble\n - [ ] unit testing\n - [ ] test on big graphs, for benchmarking (will probably not scale)\n- [ ] bubble to dot (via [graphviz](http://graphviz.readthedocs.io/en/latest/))\n - [X] working implementation\n - [X] test on fully valid bubble\n - [ ] unit testing\n - [ ] test on big graphs, for benchmarking (will probably not scale)\n- [ ] python to bubble\n- [ ] dot to python\n- [ ] unit testing on bubble describing cliques\n\n\n## CLI\n`bubbletools` is usable through CLI.\n\n### validation\nusage:\n\n python3 -m bubbletools validate path/to/bubble/file\n\nTry hard to find errors and inconsistancies in the given bubble file\n\nSpot powernode overlapping, inclusions inconsistancies\nand empty or singleton powernodes.\nProfiling gives general informations about the file data.\n\n### conversion to dot\nusage:\n\n python3 bubbletool.py dot path/to/bubble/file path/to/output/file\n\nConvert given bubble file in dot format.\nThe optional `--render` flag can be used to show the graph after saving.\n\nSame API is available for gexf format.\n\n### conversion to cytoscape.js\nusage:\n\n python3 -m bubbletools js path/to/bubble/file path/to/output/dir\n\nConvert given bubble file in a fully working website using cytoscape.js to render the graph.\nThe optional `--render` flag can be used to run the default web browser on the generated website.\nSee Makefile recipe `js` for a usage example.\n\nA website is a collection of files (css, js, html), with only one of them (`js/graph.js`)\nthat changes according to the input data.\n\nIf the `path/to/output/dir` has a `.js` extension, only the `js/graph.js` file will be generated.\nThis allow one to generates only the changing parts, not the full website each time.\nSee Makefile recipe `js-per-file` for a usage example.\n\n\n## python API\nSubmodules `validator` and `converter` provides the functionnalities described above for CLI:\n\n from bubbletools import validate, convert\n\n for log in validate(open('path/to/bubble.lp'), profiling=True):\n print(log)\n convert.to_dot(open('path/to/bubble.lp'), dotfile='path/to/dot.dot')\n\n### python representation of the graph\nA lower level interface is the `BubbleTree` object, allowing one to manipulate the graph depicted by bubble data as python object.\nSee [unit tests](bubbletools/test/test_bbltree.py) for example of `BubbleTree` usage.\n\n from bubbletools import BubbleTree\n\n tree = BubbleTree.from_bubble_file('path/to/bubble.lp')\n print(tree.edges, tree.inclusions, tree.roots)\n\n`edges` is a mapping `predecessor -> set of successors`,\n`inclusions` is a mapping `(power)node -> set of (power)nodes directly contained`,\nand `roots` is a set of (power)nodes that are contained by nothing.\n\nThis representation holds all the data necessary for most work on the bubble.\nThe `BubbleTree.connected_components` function maps a graph with its connected components:\n\n cc, subroots = BubbleTree.connected_components()\n\nWhere `cc` and `subroots` are both mappings, respectively linking *the* root of a connected component with all nodes of the connected component,\nand *the* root of a connected component with the other roots of the same connected component.\nThus, connected components are identified by one of their roots, which is key is both dictionaries.\n\n\n### access powernodes and their data\nFollow an example of `BubbleTree` usage, retrieving data on powernodes:\n\n tree = BubbleTree.from_bubble_file('bubbles/basic.bbl')\n for pnode in tree.powernodes:\n data = tree.powernode_data(pnode)\n print(\n \"{} contains nodes {{{}}}, and powernodes {{{}}}.\"\n \"\".format(pnode, data.contained_nodes, data.contained_pnodes)\n )",
"bugtrack_url": null,
"license": "GPL",
"summary": "Tools around the bubble format",
"version": "0.6.11",
"project_urls": {
"Homepage": "https://github.com/aluriak/bubble-tools"
},
"split_keywords": [
"graph",
"format"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dc4f03c1ac93b090d669d23965fbeede5ad07801ff56e0aaac8648fb6f0f029f",
"md5": "7465326908c39d8bbd8c086a190cd00b",
"sha256": "c2df9f45d13b5b6bed70c30ab7421b4249af1457ab09f7bf723acbb3cc11f9c9"
},
"downloads": -1,
"filename": "bubbletools-0.6.11.tar.gz",
"has_sig": false,
"md5_digest": "7465326908c39d8bbd8c086a190cd00b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 146616,
"upload_time": "2019-01-17T14:38:08",
"upload_time_iso_8601": "2019-01-17T14:38:08.499058Z",
"url": "https://files.pythonhosted.org/packages/dc/4f/03c1ac93b090d669d23965fbeede5ad07801ff56e0aaac8648fb6f0f029f/bubbletools-0.6.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2019-01-17 14:38:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aluriak",
"github_project": "bubble-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "bubbletools"
}