Property Graphs for Open Biological Ontologies
Property Graphs library for Open Biological and Biomedical Ontologies (OBO) in Python. This library supports reading OBO formatted ontologies into python data structures. It also supports generation of cypher statements to load the ontology into a property graph database like RedisGraph.
Installing
You can install the package via:
pip install pygobo
Using the command-line interface
The module can be invoked directly and provides a set of basic commands that allow parsing, inspection, cypher statement generation, and loading ontologies.
The invocation is:
python -m pygobo {operation} {file ...}?
where operation is one of:
parse- parse the ontology syntaxcypher- generate cypher create/merge statementsload- load the ontology into a property graph databasestructure- output the general structure of the ontology
The operations can be scoped via the --scope option that takes the values:
all- all the componentsontology- only the top-level ontology metadataterm- only the ontology termsxref- only the cross referencestypedef- only the type definitions.
The scope option can be used multiple times to display different items.
If the file is omitted, the command will read from stdin. Otherwise, each file specified will be read and operated on in the order they are specified.
Loading ontology property graphs
The module currently supports loading ontologies directly into RedisGraph.
The following options can be specified for connecting to the database:
--host {name}|{ip}- the host of the database, defaults to 0.0.0.0--port {port}- the port, defaults to 6379--password {password}- the database password, default is no password--graph {key}- the graph key, defaults to "obo"
Adding the --show-query option will allow you to see the Cypher statements as
they are executed.
The --scope option will limit the loading to a specific aspect of the
ontology but the order is presumed to be: ontology, term, xref, typedef. If you
violate this ordering, the cypher statements may fail.
Formats Supported
The library only currently supprts the OBO formatted ontologies. That is, it can't currently load the OWL/XML format.
You can convert OWL/XML formatted ontologies into OBO format using the robot tool.
API
OBOParser
An ontology can be easily loaded from a stream source:
from pygobo import OBOParser
parser = OBOParser()
with open('ontology.obo','r') as input:
ontology = parser.parse(input)
Ontology
An ontology is a simple class with the following fields:
metadata- a dictionary of ontology metadataterms- a dictionary of ontology termstypedefs- a dictionary of ontology type definitions
Some property values are structured dictionaries, some are tuples, and some are simple values.
Generating Cypher
Once an ontology is loaded, the query_generate function can be used
to generate cypher load statements. The usage is:
for query in query_generate(ontology,scope=['ontology']):
print(query)
print(';')
The scope keyword argument is a list of scope values. The values are the
same as the command-line interface (see above).
Property graph structure
Release files for pygobo 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygobo-0.3.1.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygobo-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.8 kB
Release files / pygobo-0.3.1.tar.gz
| Download URL | pygobo-0.3.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83ccd1edd2bbfc73276529b17736b64f6ff326f25a31d7b7ea868c42514fb38a
|
|
BLAKE2b-256 checksum How to use checksums |
be605273b0f3fd37796f247598d79c9cc1e8d8d175de7f82e73cd94aad1fe4eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|
Release files / pygobo-0.3.1-py3-none-any.whl
| Download URL | pygobo-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f069022a71463ba7720dc55fd7da3e0a9f0a39540dbf970913bfcf1f29cfe8b9
|
|
BLAKE2b-256 checksum How to use checksums |
9f24f5610be2d3c99db4e80e4bf2ec116b19c5bd402bdc7ed8efd8795bd59de1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|