Python frontend to ontologies - a library to parse, create, browse and export ontologies.
Project description
Overview
Pronto is a python module to parse, create, browse and export ontologies from some popular formats. For now, obo and owl/xml are available, but more formats are to be added in the future (you can even add your own to work with the current API).
Installation
Installing with pip is the easiest:
pip install pronto # if you have the admin rights pip install pronto --user # if you want to install it for only one user
If for some reason you do not like pip, you can also clone the repository and install it with the setup script (still requires setuptools):
git clone https://github.com/althonos/pronto cd pronto python3 setup.py install # may also require admin rights
Usage
The class Ontology is likely the one you’ll use the most if all you want is to browse ontologies. It can be used to import ontologies in .owl (sometimes seen as .ont) and .obo formats, merge, and export ontologies to a rudimentary obo file.
Instantiate an obo ontology and getting a term by accession number:
import pronto ont = pronto.Ontology('path/to/file.obo') term = ont['REF:ACCESSION']
Display an ontology in obo format and in json format:
import pronto ont = pronto.Ontology('https://net.path.should/work/too.owl') print(ont.obo) print(ont.json)
Merge two ontologies:
import pronto nmr = pronto.Ontology('https://raw.githubusercontent.com/nmrML/nmrML/' 'master/ontologies/nmrCV.owl') ms = pronto.Ontology('http://psidev.cvs.sourceforge.net/viewvc/psidev/psi' '/psi-ms/mzML/controlledVocabulary/psi-ms.obo') ms.merge(nmr) # MS ontology keeps its metadata but now contains NMR terms # as well. assert('NMR:1000004' in ms)
Explore every term of an ontology and print those with children:
import pronto ont = pronto.Ontology('path/to/file.obo') for term in ont: if term.children: print(term)
Get grandchildrens of an ontology term:
import pronto ont = pronto.Ontology('path/to/file.obo') print(ont['RF:XXXXXXX'].children.children)
TODO
- test with many different ontologies
- extract data from OwlXML where attributes are ontologic terms
- extract metadatas from OwlXML
- add other owl serialized formats
- (maybe) add serialization to owl
Reference
If you wish to use this library in a scientific publication, please cite it (see the Zenodo record).
Author: Martin Larralde
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size pronto-0.7.3-py2.py3-none-any.whl (38.1 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size pronto-0.7.3.tar.gz (35.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for pronto-0.7.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2e527edf8b6cba9e76721ee8c4036bbfd20f336929c1ed1791bbfe4833df0b9 |
|
MD5 | ea8933c7f039db078f0bbf3c6f0a4202 |
|
BLAKE2-256 | 79aed04a7a525666ce5d2cae99e67f63ab186c021eb60d62ad67a0fe841f7d92 |