Skip to content

leonqli/pronto

This branch is 567 commits behind althonos/pronto:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Martin Larralde
Jun 24, 2018
4c092fd · Jun 24, 2018
Jun 24, 2018
Nov 20, 2017
Oct 30, 2017
May 20, 2017
Jul 5, 2016
Oct 23, 2017
Oct 23, 2017
Oct 23, 2017
Jan 9, 2017
Jun 24, 2018
Nov 20, 2017
Oct 23, 2017

Repository files navigation

pronto : Python frontend to Ontologies

PyPI Conda Py versions Build Status Dev repo Codacy Grade License DOI coverage Documentation Status

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

There is also a conda recipe in the bioconda channel:

conda install -c bioconda pronto

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
python setup.py install    # may also require admin rights

Usage

The Ontology class is the main entrypoint of pronto. It can be instantiated with a given ontology file (.owl, .ont or .obo) or from scratch, without any existing terms.

Open an ontology and get a term by accession:

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:

Example here uses the NMR controlled vocabulary and the HUPO-PSI MS controlled vocabulary

import pronto
nmr = pronto.Ontology('http://nmrml.org/cv/v1.1.0/nmrCV.owl')
ms  = pronto.Ontology('https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo')
ms.merge(nmr)
>>> 'NMR:1000004' in ms
True
>>> ms.meta['coverage']
'Mass spectrometer output files and spectra interpretation'

Find ontology terms with children

import pronto
ont = pronto.Ontology('path/to/file.obo')
for term in ont:
    if term.children:
        print(term)

Get all the transitive children of an ontology term

import pronto
ont = pronto.Ontology('path/to/file.obo')
print(ont['RF:XXXXXXX'].rchildren())

Reference

If you wish to use this library in a scientific publication, please cite it ! (see the Zenodo record to get a DOI or a BibTEX record).

About

Python frontend to Ontologies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.5%
  • Makefile 2.5%