obonet

OBO-formatted ontologies → networkx (Python 3)

https://github.com/dhimmel/obonet

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary

Keywords

network networkx obo obo-files obo-formatted-ontologies ontology parser python rephetio

Keywords from Contributors

complex-networks graph-algorithms graph-analysis graph-generation graph-theory graph-visualization biocuration biopragmatics bioregistry bioinformatics
Last synced: 6 months ago · JSON representation

Repository

OBO-formatted ontologies → networkx (Python 3)

Basic Info
Statistics
  • Stars: 143
  • Watchers: 8
  • Forks: 30
  • Open Issues: 1
  • Releases: 7
Topics
network networkx obo obo-files obo-formatted-ontologies ontology parser python rephetio
Created almost 11 years ago · Last pushed 11 months ago
Metadata Files
Readme License

README.md

obonet: load OBO-formatted ontologies into networkx

GitHub Actions CI Build Status
Software License
PyPI

Read OBO-formatted ontologies in Python. obonet is

  • user friendly
  • succinct
  • pythonic
  • modern
  • simple and tested
  • lightweight
  • networkx leveraging

This Python package loads OBO serialized ontologies into networks. The function obonet.read_obo() takes an .obo file and returns a networkx.MultiDiGraph representation of the ontology. The parser was designed for the OBO specification version 1.2 & 1.4.

Usage

See pyproject.toml for the minimum Python version required and the dependencies. OBO files can be read from a path, URL, or open file handle. Compression is inferred from the path's extension. See example usage below:

```python import networkx import obonet

Read the taxrank ontology

url = 'https://github.com/dhimmel/obonet/raw/main/tests/data/taxrank.obo' graph = obonet.read_obo(url)

Or read the xz-compressed taxrank ontology

url = 'https://github.com/dhimmel/obonet/raw/main/tests/data/taxrank.obo.xz' graph = obonet.read_obo(url)

Number of nodes

len(graph)

Number of edges

graph.numberofedges()

Check if the ontology is a DAG

networkx.isdirectedacyclic_graph(graph)

Mapping from term ID to name

idtoname = {id: data.get('name') for id, data in graph.nodes(data=True)} idtoname['TAXRANK:0000006'] # TAXRANK:0000006 is species

Find all superterms of species. Note that networkx.descendants gets

superterms, while networkx.ancestors returns subterms.

networkx.descendants(graph, 'TAXRANK:0000006') ```

For a more detailed tutorial, see the Gene Ontology example notebook.

Comparison

This package specializes in reading OBO files into a newtorkx.MultiDiGraph. A more general ontology-to-NetworkX reader is available in the Python nxontology package via the nxontology.imports.pronto_to_multidigraph function. This function takes a pronto.Ontology object, which can be loaded from an OBO file, OBO Graphs JSON file, or Ontology Web Language 2 RDF/XML file (OWL). Using pronto_to_multidigraph allows creating a MultiDiGraph similar to the created by obonet, with some differences in the amount of metadata retained.

The primary focus of the nxontology package is to provide an NXOntology class for representing ontologies based around a networkx.DiGraph. NXOntology provides optimized implementations for computing node similarity and other intrinsic ontology metrics. There are two important differences between a DiGraph for NXOntology and the MultiDiGraph produced by obonet:

  1. NXOntology is based on a DiGraph that does not allow multiple edges between the same two nodes. Multiple edges between the same two nodes must therefore be collapsed. By default, it only considers is a / rdfs:subClassOf relationships, but using pronto_to_multidigraph to create the NXOntology allows for retaining additional relationship types, like part of in the case of the Gene Ontology.

  2. NXOntology reverses the direction of relationships so edges go from superterm to subterm. Traditionally in ontologies, the is a relationships go from subterm to superterm, but this is confusing. NXOntology reverses edges so functions such as ancestors refer to more general concepts and descendants refer to more specific concepts.

The nxontology.imports.multidigraph_to_digraph function converts from a MultiDiGraph, like the one produced by obonet, to a DiGraph by filtering to the desired relationship types, reversing edges, and collapsing parallel edges.

Installation

The recommended approach is to install the latest release from PyPI using:

sh pip install obonet

However, if you'd like to install the most recent version from GitHub, use:

sh pip install git+https://github.com/dhimmel/obonet.git#egg=obonet

Contributing

GitHub issues

We welcome feature suggestions and community contributions. Currently, only reading OBO files is supported.

Develop

Some development commands:

```bash

create virtual environment

python3 -m venv ./env

activate virtual environment

source env/bin/activate

editable installation for development

pip install --editable ".[dev]"

install pre-commit hooks

pre-commit install

run all pre-commit checks

pre-commit run --all

run tests

pytest

generate changelog for release notes

git fetch --tags origin main OLDTAG=$(git describe --tags --abbrev=0) git log --oneline --decorate=no --reverse $OLDTAG..HEAD ```

Maintainers can make a new release at https://github.com/dhimmel/obonet/releases/new.

Owner

  • Name: Daniel Himmelstein
  • Login: dhimmel
  • Kind: user
  • Location: New Hampshire
  • Company: @related-sciences

Founding @radoverlay · Data at @related-sciences · Digital craftsman of the biodata revolution · Open sourceror · Previously @greenelab & @baranzini-lab

GitHub Events

Total
  • Watch event: 7
  • Issue comment event: 3
  • Push event: 4
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 3
  • Fork event: 2
Last Year
  • Watch event: 7
  • Issue comment event: 3
  • Push event: 4
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 3
  • Fork event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 117
  • Total Committers: 6
  • Avg Commits per committer: 19.5
  • Development Distribution Score (DDS): 0.068
Past Year
  • Commits: 11
  • Committers: 2
  • Avg Commits per committer: 5.5
  • Development Distribution Score (DDS): 0.182
Top Committers
Name Email Commits
Daniel Himmelstein d****n@g****m 109
Kevin Arvai a****i@g****m 2
Charles Tapley Hoyt c****t@g****m 2
Benjamin M. Gyori b****i@g****m 2
Eric Torstenson e****n@v****g 1
Chris Mungall c****m@b****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 18
  • Total pull requests: 15
  • Average time to close issues: 9 months
  • Average time to close pull requests: about 16 hours
  • Total issue authors: 17
  • Total pull request authors: 7
  • Average comments per issue: 4.44
  • Average comments per pull request: 1.13
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 4
  • Average time to close issues: N/A
  • Average time to close pull requests: about 2 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.75
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cthoyt (2)
  • thomcsmits (1)
  • ItWasLGS (1)
  • PetrovskYYY (1)
  • csbayrak (1)
  • azneto (1)
  • BSharmi (1)
  • lyschoening (1)
  • colinkcurtis (1)
  • gtsitsiridis (1)
  • msinclair2 (1)
  • cmungall (1)
  • MahboobehJannesari (1)
  • marcomoretto (1)
  • YojanaGadiya (1)
Pull Request Authors
  • dhimmel (4)
  • bgyori (4)
  • cthoyt (2)
  • arvkevi (2)
  • murtazaverse (2)
  • cmungall (1)
  • torstees (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 17,913 last-month
  • Total docker downloads: 597
  • Total dependent packages: 20
    (may contain duplicates)
  • Total dependent repositories: 64
    (may contain duplicates)
  • Total versions: 24
  • Total maintainers: 1
pypi.org: obonet

Parse OBO formatted ontologies into networkx

  • Versions: 12
  • Dependent Packages: 20
  • Dependent Repositories: 64
  • Downloads: 17,913 Last month
  • Docker Downloads: 597
Rankings
Dependent packages count: 0.6%
Dependent repos count: 1.9%
Docker downloads count: 2.7%
Downloads: 3.1%
Average: 3.7%
Stargazers count: 6.3%
Forks count: 7.4%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/dhimmel/obonet
  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago

Dependencies

.github/workflows/build.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/release.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish v1.5.1 composite