Property Graphs for Open Biological and Biomedical Ontologies
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygobo-0.3.1.tar.gz
.
File metadata
- Download URL: pygobo-0.3.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83ccd1edd2bbfc73276529b17736b64f6ff326f25a31d7b7ea868c42514fb38a |
|
MD5 | bce421695ce54816ef0779f229851fa7 |
|
BLAKE2b-256 | be605273b0f3fd37796f247598d79c9cc1e8d8d175de7f82e73cd94aad1fe4eb |
File details
Details for the file pygobo-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: pygobo-0.3.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f069022a71463ba7720dc55fd7da3e0a9f0a39540dbf970913bfcf1f29cfe8b9 |
|
MD5 | a76823bc97c8991eba26ba5c77467c54 |
|
BLAKE2b-256 | 9f24f5610be2d3c99db4e80e4bf2ec116b19c5bd402bdc7ed8efd8795bd59de1 |