ontolopy.obo.Obo

class ontolopy.obo.Obo(source_dict={})

Creates Obo ontology object from dict with ontology terms for keys, mapping to term attributes and relations.

Each key/term is a dictionary with key: value pairs mapping either:

  1. Attribute (str) to value (str), e.g. ‘name’: ‘scapula’

  2. Type of relationship (str) to term identifiers (list), e.g. ‘is_a’: [‘UBERON:0002513’]

Info: Obo stands for Open Biological Ontology: a popular file format for building biological ontologies.

__init__(source_dict={})

Initialise self from a source dictionary.

Parameters

source_dictdict mapping terms to their attributes and relationships.

Methods

__init__([source_dict])

Initialise self from a source dictionary.

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

merge(new[, prefer])

Recursively merges new into self and returns a merged Obo ontology.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

2-tuple; but raise KeyError if D is empty.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

terms_from(ont_id)

Returns a set of terms in Obo ontology with prefix in list ont_id :param ont_id: list of ontology prefixes e.g.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Attributes

leaves

Leaf terms are the most specific terms in the ontology; they have no children, only parents (a set object).

terms

The ontology terms (a dict_keys object).