Obo
- class pyobo.Obo(date=<factory>, data_version=None, force=False)[source]
Bases:
object
An OBO document.
Attributes Summary
An annotation about how an ontology was generated
The ontology version
Get the date as a formatted string.
Set to true for resources that are unversioned/very dynamic, like HGNC
Should this ontology be reloaded?
The OBO format
A graph representing the parent/child relationships between the entities.
The idspaces used in the document
For super-sized datasets that shouldn't be read into memory
The name of the ontology.
Property dataframe header.
Header for the relations dataframe.
Set to a static version for the resource (i.e., the resource is not itself versioned)
Synonym type definitions
Type definitions
The header for the xref dataframe.
Methods Summary
ancestors
(identifier)Return a set of identifiers for parents of the given identifier.
cli
()Run the CLI for this class.
descendants
(identifier)Return a set of identifiers for the children of the given identifier.
Get the CLI for this class.
get_filtered_multixrefs_mapping
(prefix, *[, ...])Get filtered xrefs as a dictionary.
get_filtered_properties_df
(prop, *[, use_tqdm])Get a dataframe of terms' identifiers to the given property's values.
get_filtered_properties_mapping
(prop, *[, ...])Get a mapping from a term's identifier to the property.
get_filtered_properties_multimapping
(prop, *)Get a mapping from a term's identifier to the property values.
get_filtered_relations_df
(relation, *[, ...])Get a specific relation from OBO.
get_filtered_xrefs_mapping
(prefix, *[, use_tqdm])Get filtered xrefs as a dictionary.
Get a mapping from identifiers to a list of alternative identifiers.
get_id_definition_mapping
(*[, use_tqdm])Get a mapping from identifiers to definitions.
get_id_multirelations_mapping
(typedef, *[, ...])Get a mapping from identifiers to a list of all references for the given relation.
get_id_name_mapping
(*[, use_tqdm])Get a mapping from identifiers to names.
get_id_species_mapping
(*[, prefix, use_tqdm])Get a mapping from identifiers to species.
get_id_synonyms_mapping
(*[, use_tqdm])Get a mapping from identifiers to a list of sorted synonym strings.
get_ids
(*[, use_tqdm])Get the set of identifiers.
Get metadata.
get_properties_df
(*[, use_tqdm])Get all properties as a dataframe.
get_relation
(source_identifier, relation, ...)Get the value for a bijective relation mapping between this resource and a target resource.
get_relation_mapping
(relation, target_prefix, *)Get a mapping from the term's identifier to the target's identifier.
get_relation_multimapping
(relation, ...[, ...])Get a mapping from the term's identifier to the target's identifiers.
get_relations_df
(*[, use_tqdm])Get all relations from the OBO.
get_typedef_df
([use_tqdm])Get a typedef dataframe.
Get a mapping from typedefs' identifiers to names.
get_xrefs_df
(*[, use_tqdm])Get a dataframe of all xrefs extracted from the OBO document.
is_descendant
(descendant, ancestor)Return if the given identifier is a descendent of the ancestor.
iter_property_rows
(*[, use_tqdm])Iterate property rows.
iter_relation_rows
([use_tqdm])Iterate the relations' rows.
iter_terms
([force])Iterate over terms in this ontology.
Iterate over typedefs' identifiers and their respective names.
Iterate over pairs of terms' primary identifiers and alternate identifiers.
Iterate over alternative identifiers.
iterate_filtered_properties
(prop, *[, use_tqdm])Iterate over tuples of terms and the values for the given property.
iterate_filtered_relations
(relation, *[, ...])Iterate over tuples of terms and ther targets for the given relation.
Iterate over relationships between one identifier and another.
iterate_filtered_xrefs
(prefix, *[, use_tqdm])Iterate over xrefs to a given prefix.
iterate_id_definition
(*[, use_tqdm])Iterate over pairs of terms' identifiers and their respective definitions.
iterate_id_name
(*[, use_tqdm])Iterate identifier name pairs.
iterate_id_species
(*[, prefix, use_tqdm])Iterate over terms' identifiers and respective species (if available).
iterate_ids
(*[, use_tqdm])Iterate over identifiers.
Iterate over the lines to write in an OBO file.
iterate_properties
(*[, use_tqdm])Iterate over tuples of terms, properties, and their values.
iterate_relations
(*[, use_tqdm])Iterate over tuples of terms, relations, and their targets.
iterate_synonym_rows
(*[, use_tqdm])Iterate over pairs of identifier and synonym text.
iterate_synonyms
(*[, use_tqdm])Iterate over pairs of term and synonym object.
iterate_xref_rows
(*[, use_tqdm])Iterate over terms' identifiers, xref prefixes, and xref identifiers.
iterate_xrefs
(*[, use_tqdm])Iterate over xrefs.
to_obonet
(*[, use_tqdm])Export as a :mod`obonet` style graph.
write_default
([use_tqdm, force, write_obo, ...])Write the OBO to the default path.
write_obo
([file, use_tqdm])Write the OBO to a file.
write_obonet_gz
(path)Write the OBO to a gzipped dump in Obonet JSON.
Attributes Documentation
-
auto_generated_by:
ClassVar
[Optional
[str
]] = None An annotation about how an ontology was generated
- date_formatted
Get the date as a formatted string.
-
dynamic_version:
ClassVar
[bool
] = False Set to true for resources that are unversioned/very dynamic, like HGNC
- hierarchy
A graph representing the parent/child relationships between the entities.
To get all children of a given entity, do:
from pyobo import get_obo obo = get_obo('go') identifier = '1905571' # interleukin-10 receptor complex is_complex = '0032991' in nx.descendants(obo.hierarchy, identifier) # should be true
-
name:
ClassVar
[Optional
[str
]] = None The name of the ontology. If not given, tries looking up with the Bioregistry.
- properties_header
Property dataframe header.
- relations_header
Header for the relations dataframe.
-
static_version:
ClassVar
[Optional
[str
]] = None Set to a static version for the resource (i.e., the resource is not itself versioned)
-
synonym_typedefs:
ClassVar
[Optional
[List
[SynonymTypeDef
]]] = None Synonym type definitions
- xrefs_header
The header for the xref dataframe.
Methods Documentation
- descendants(identifier)[source]
Return a set of identifiers for the children of the given identifier.
- get_filtered_multixrefs_mapping(prefix, *, use_tqdm=False)[source]
Get filtered xrefs as a dictionary.
- get_filtered_properties_df(prop, *, use_tqdm=False)[source]
Get a dataframe of terms’ identifiers to the given property’s values.
- Return type:
DataFrame
- get_filtered_properties_mapping(prop, *, use_tqdm=False)[source]
Get a mapping from a term’s identifier to the property. :rtype:
Mapping
[str
,str
]Warning
Assumes there’s only one version of the property for each term.
- get_filtered_properties_multimapping(prop, *, use_tqdm=False)[source]
Get a mapping from a term’s identifier to the property values.
- get_filtered_relations_df(relation, *, use_tqdm=False)[source]
Get a specific relation from OBO.
- Return type:
DataFrame
- get_id_definition_mapping(*, use_tqdm=False)[source]
Get a mapping from identifiers to definitions.
- get_id_multirelations_mapping(typedef, *, use_tqdm=False)[source]
Get a mapping from identifiers to a list of all references for the given relation.
- get_id_species_mapping(*, prefix=None, use_tqdm=False)[source]
Get a mapping from identifiers to species.
- get_id_synonyms_mapping(*, use_tqdm=False)[source]
Get a mapping from identifiers to a list of sorted synonym strings.
- get_properties_df(*, use_tqdm=False)[source]
Get all properties as a dataframe.
- Return type:
DataFrame
- get_relation(source_identifier, relation, target_prefix, *, use_tqdm=False)[source]
Get the value for a bijective relation mapping between this resource and a target resource.
>>> from pyobo.sources.hgnc import get_obo >>> obo = get_obo() >>> human_mapt_hgnc_id = '6893' :rtype: :py:data:`~typing.Optional`\[:py:class:`str`]
>>> mouse_mapt_mgi_id = '97180' >>> assert mouse_mapt_mgi_id == obo.get_relation(human_mapt_hgnc_id, 'ro:HOM0000017', 'mgi')
- get_relation_mapping(relation, target_prefix, *, use_tqdm=False)[source]
Get a mapping from the term’s identifier to the target’s identifier. :rtype:
Mapping
[str
,str
]Warning
Assumes there’s only one version of the property for each term.
Example usage: get homology between HGNC and MGI:
>>> from pyobo.sources.hgnc import get_obo >>> obo = get_obo() >>> human_mapt_hgnc_id = '6893' >>> mouse_mapt_mgi_id = '97180' >>> hgnc_mgi_orthology_mapping = obo.get_relation_mapping('ro:HOM0000017', 'mgi') >>> assert mouse_mapt_mgi_id == hgnc_mgi_orthology_mapping[human_mapt_hgnc_id]
- get_relation_multimapping(relation, target_prefix, *, use_tqdm=False)[source]
Get a mapping from the term’s identifier to the target’s identifiers.
- get_xrefs_df(*, use_tqdm=False)[source]
Get a dataframe of all xrefs extracted from the OBO document.
- Return type:
DataFrame
- is_descendant(descendant, ancestor)[source]
Return if the given identifier is a descendent of the ancestor.
from pyobo import get_obo obo = get_obo('go') interleukin_10_complex = '1905571' # interleukin-10 receptor complex all_complexes = '0032991' assert obo.is_descendant('1905571', '0032991')
- Return type:
- iterate_alt_rows()[source]
Iterate over pairs of terms’ primary identifiers and alternate identifiers.
- iterate_filtered_properties(prop, *, use_tqdm=False)[source]
Iterate over tuples of terms and the values for the given property.
- iterate_filtered_relations(relation, *, use_tqdm=False)[source]
Iterate over tuples of terms and ther targets for the given relation.
- iterate_filtered_relations_filtered_targets(relation, target_prefix, *, use_tqdm=False)[source]
Iterate over relationships between one identifier and another.
- iterate_id_definition(*, use_tqdm=False)[source]
Iterate over pairs of terms’ identifiers and their respective definitions.
- iterate_id_species(*, prefix=None, use_tqdm=False)[source]
Iterate over terms’ identifiers and respective species (if available).
- iterate_properties(*, use_tqdm=False)[source]
Iterate over tuples of terms, properties, and their values.
- iterate_relations(*, use_tqdm=False)[source]
Iterate over tuples of terms, relations, and their targets.
- iterate_xref_rows(*, use_tqdm=False)[source]
Iterate over terms’ identifiers, xref prefixes, and xref identifiers.
- write_default(use_tqdm=False, force=False, write_obo=False, write_obonet=False, write_obograph=False, write_owl=False)[source]
Write the OBO to the default path.
- Return type:
-
auto_generated_by: