bionty.base.Ontology¶
- class bionty.base.Ontology(handle=None, import_depth=-1, timeout=100, threads=None, prefix='')¶
Bases:
Ontology
Interface with ontologies via pronto.
Also see: https://pronto.readthedocs.io/en/stable/api/pronto.Ontology.html
- Parameters:
handle (
str
|Path
|BinaryIO
|None
, default:None
) – Path to an ontology source file.import_depth (
int
, default:-1
) – The maximum depth of imports to resolve in the ontology tree.timeout (
int
, default:100
) – The timeout in seconds to use when performing network I/O.threads (
int
|None
, default:None
) – The number of threads to use when parsing.url – The url of the ontology.
prefix (
str
, default:''
) – Dev only -> prefix for get_term.
Methods¶
- get_term(term)¶
Search an ontology by its id.
- to_df(source=None, include_rel=None, include_id_prefixes=None)¶
Convert pronto.Ontology to a DataFrame with columns id, name, parents, definition, and synonyms.
- Parameters:
source (
str
|None
, default:None
) – The source of the ontology terms to include. If None, all terms are included.include_rel (
str
|None
, default:None
) – The relationship ID to include when gathering parent relationships. If provided, it extends the superclasses with the specified relationship.include_id_prefixes (
dict
[str
,list
[str
]] |None
, default:None
) – A dictionary mapping sources to lists of ID prefixes. Only terms with IDs starting with these prefixes will be included for the specified source.
- Returns:
A DataFrame containing the filtered ontology terms with columns –
ontology_id (index): The unique identifier for each term.
name: The name of the term.
definition: The definition of the term (None if not available).
synonyms: A pipe-separated string of exact synonyms (None if no synonyms).
parents: A list of parent term IDs, including superclasses and optionally the specified relationship.