Graph
- class Graph(*, id: str | None = None, meta: Meta | None = None, nodes: List[Node] = None, edges: List[Edge] = None, equivalentNodesSets: List[Any] = None, logicalDefinitionAxioms: List[Any] = None, domainRangeAxioms: List[Any] = None, propertyChainAxioms: List[Any] = None, prefix: str | None = None, standardized: bool = False)[source]
Bases:
BaseModel
,StandardizeMixin
A graph corresponds to an ontology.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Attributes Summary
Get the version of the ontology.
Get the license of the ontology.
Get the license of the ontology.
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
Get the ontology root terms.
Get the title of the ontology.
Get the version of the ontology.
Get the version of the ontology.
Methods Summary
Get a mapping of primary identifiers to secondary identifiers.
Get a mapping from CURIEs to names.
get_edges_df
(*[, require_labels])Get all triples as a dataframe.
get_incoming_xrefs
(prefix)Get incoming xrefs.
Get a networkx multi-directional graph.
get_nodes_df
([sep])Get a nodes dataframe appropriate for serialization.
Get a SSSOM dataframe of mappings.
Get all database cross-references from the ontology.
nodes_from
(prefix)Iterate non-deprecated nodes whose identifiers start with the given prefix.
standardize
([keep_invalid, use_tqdm, nodes, ...])Standardize the OBO graph.
Attributes Documentation
- default_namespace
Get the version of the ontology.
- description
Get the license of the ontology.
- license
Get the license of the ontology.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'domainRangeAxioms': FieldInfo(annotation=List[Any], required=False, default_factory=list), 'edges': FieldInfo(annotation=List[bioontologies.obograph.Edge], required=False, default_factory=list), 'equivalentNodesSets': FieldInfo(annotation=List[Any], required=False, default_factory=list), 'id': FieldInfo(annotation=Union[str, NoneType], required=False), 'logicalDefinitionAxioms': FieldInfo(annotation=List[Any], required=False, default_factory=list), 'meta': FieldInfo(annotation=Union[Meta, NoneType], required=False), 'nodes': FieldInfo(annotation=List[bioontologies.obograph.Node], required=False, default_factory=list), 'prefix': FieldInfo(annotation=Union[str, NoneType], required=False), 'propertyChainAxioms': FieldInfo(annotation=List[Any], required=False, default_factory=list), 'standardized': FieldInfo(annotation=bool, required=False, default=False, exclude=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- roots
Get the ontology root terms.
- title
Get the title of the ontology.
- version
Get the version of the ontology.
- version_iri
Get the version of the ontology.
Methods Documentation
- get_alternative_ids() Mapping[str, List[str]] [source]
Get a mapping of primary identifiers to secondary identifiers.
- get_incoming_xrefs(prefix: str) Mapping[str, str] [source]
Get incoming xrefs.
- Parameters:
prefix – An external prefix.
- Returns:
A dictionary of external local unique identifiers to local unique identifiers in this ontology
- get_nodes_df(sep: str = ';') DataFrame [source]
Get a nodes dataframe appropriate for serialization.
- get_xrefs() List[Tuple[Reference, Reference, Reference]] [source]
Get all database cross-references from the ontology.
- nodes_from(prefix: str) Iterable[Node] [source]
Iterate non-deprecated nodes whose identifiers start with the given prefix.
- standardize(keep_invalid: bool = False, use_tqdm: bool = True, nodes: bool = True, edges: bool = True, tqdm_kwargs: Mapping[str, Any] | None = None, prefix: str | None = None) Self [source]
Standardize the OBO graph.
- Parameters:
keep_invalid – Should CURIEs/IRIs that aren’t handled by the Bioregistry be kept? Defaults to false.
use_tqdm – Should a progress bar be used?
tqdm_kwargs – Arguments to pass to tqdm if used
prefix – The prefix this graph came from (used for logging purposes)
nodes – Should nodes be standardized?
edges – Should edges be standardized?
- Returns:
This OBO graph, modified in place as follows:
Convert IRIs to CURIEs (in many places) using
bioregistry
Add alternative identifiers to
Node
objects