curategpt.wrappers.ontology package

Submodules

curategpt.wrappers.ontology.bioportal_wrapper module

class curategpt.wrappers.ontology.bioportal_wrapper.BioportalWrapper(source_locator=None, local_store=None, extractor=None, oak_adapter=None, id_to_shorthand=None, shorthand_to_id=None, _objects_by_curie=None, _objects_by_shorthand=None, default_max_search_results=500, fetch_definitions=False, fetch_relationships=False, relationships_as_fields=False, branches=None, **_kwargs)

Bases: OntologyWrapper

A wrapper over the Bioportal API.

This makes use of OAK.

fetch_definitions: bool = False
fetch_relationships: bool = False

curategpt.wrappers.ontology.oboformat_wrapper module

Chat with a KB.

class curategpt.wrappers.ontology.oboformat_wrapper.OBOFormatWrapper(source_locator=None, local_store=None, extractor=None)

Bases: BaseWrapper

A wrapper to index ontologies in OBO Format.

Note that in contrast to the OntologyWrapper, this preserves OBO syntax stanzas, e.g.

```json {“term”: “[Term]

id: … name: … …”}

name: ClassVar[str] = 'oboformat'
objects(collection=None, object_ids=None, **kwargs)

Yield all objects in the view.

Return type:

Iterator[Dict]

Returns:

wrap_object(obj)

Convert an object from the source representation to the store representation.

Parameters:

obj (Optional[str])

Return type:

Dict

Returns:

curategpt.wrappers.ontology.ontology module

class curategpt.wrappers.ontology.ontology.Ontology(**data)

Bases: BaseModel

An ontology.

Corresponds to an OBO graph.

elements: List[OntologyClass]
model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class curategpt.wrappers.ontology.ontology.OntologyClass(**data)

Bases: BaseModel

An ontology class.

Corresponds to a node in an OBO graph.

aliases: List[str]
definition: str
id: str
label: str
logical_definition: List[Relationship]
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

original_id: str
relationships: List[Relationship]
class curategpt.wrappers.ontology.ontology.Relationship(**data)

Bases: BaseModel

A relationship to another node.

Corresponds to an edge in an OBO graph.

model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

predicate: str
target: str

curategpt.wrappers.ontology.ontology_wrapper module

Chat with a KB.

class curategpt.wrappers.ontology.ontology_wrapper.OntologyWrapper(source_locator=None, local_store=None, extractor=None, oak_adapter=None, id_to_shorthand=None, shorthand_to_id=None, _objects_by_curie=None, _objects_by_shorthand=None, default_max_search_results=500, fetch_definitions=True, fetch_relationships=True, relationships_as_fields=False, branches=None, **_kwargs)

Bases: BaseWrapper

A wrapper to pull from ontologies using OAK.

This wrapper can be used either with static sources (e.g. an ontology file) or dynamic (pubmed).

The data model is a simple JSON/Dict structure

as_object(curie)
Return type:

Optional[OntologyClass]

branches: List[str] = None
default_max_search_results: int = 500

Search an external source and return the results.

Parameters:
  • text (str)

  • kwargs

Return type:

List

Returns:

fetch_definitions: bool = True
fetch_relationships: bool = True
id_to_shorthand: Mapping[str, str] = None
name: ClassVar[str] = 'oaklib'
oak_adapter: BasicOntologyInterface = None
objects(collection=None, object_ids=None, **kwargs)

Yield all objects in the view.

Return type:

Iterator[Dict]

Returns:

relationships_as_fields: bool = False
retrieve_shorthand_to_id_from_store(store)
Return type:

Mapping[str, str]

shorthand_to_id: Mapping[str, str] = None
property text_field: Callable

Returns a function that returns the embeddable text field for an object.

Returns:

unwrap_object(obj, store, **kwargs)

Convert an object from the store to the source representation.

reverse transform of as_object

Parameters:
  • obj (Dict[str, Any])

  • store (DBAdapter)

  • kwargs

Return type:

GraphDocument

Returns:

unwrap_objects(objs, store, drop_dangling=False, **kwargs)

Convert an object from the store to the view representation.

reverse transform of as_object

Parameters:
  • object

  • kwargs

Return type:

GraphDocument

Returns:

Module contents

class curategpt.wrappers.ontology.OntologyWrapper(source_locator=None, local_store=None, extractor=None, oak_adapter=None, id_to_shorthand=None, shorthand_to_id=None, _objects_by_curie=None, _objects_by_shorthand=None, default_max_search_results=500, fetch_definitions=True, fetch_relationships=True, relationships_as_fields=False, branches=None, **_kwargs)

Bases: BaseWrapper

A wrapper to pull from ontologies using OAK.

This wrapper can be used either with static sources (e.g. an ontology file) or dynamic (pubmed).

The data model is a simple JSON/Dict structure

as_object(curie)
Return type:

Optional[OntologyClass]

branches: List[str] = None
default_max_search_results: int = 500

Search an external source and return the results.

Parameters:
  • text (str)

  • kwargs

Return type:

List

Returns:

fetch_definitions: bool = True
fetch_relationships: bool = True
id_to_shorthand: Mapping[str, str] = None
name: ClassVar[str] = 'oaklib'
oak_adapter: BasicOntologyInterface = None
objects(collection=None, object_ids=None, **kwargs)

Yield all objects in the view.

Return type:

Iterator[Dict]

Returns:

relationships_as_fields: bool = False
retrieve_shorthand_to_id_from_store(store)
Return type:

Mapping[str, str]

shorthand_to_id: Mapping[str, str] = None
property text_field: Callable

Returns a function that returns the embeddable text field for an object.

Returns:

unwrap_object(obj, store, **kwargs)

Convert an object from the store to the source representation.

reverse transform of as_object

Parameters:
  • obj (Dict[str, Any])

  • store (DBAdapter)

  • kwargs

Return type:

GraphDocument

Returns:

unwrap_objects(objs, store, drop_dangling=False, **kwargs)

Convert an object from the store to the view representation.

reverse transform of as_object

Parameters:
  • object

  • kwargs

Return type:

GraphDocument

Returns: