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
-
fetch_definitions:
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
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:
-
name:
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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'elements': FieldInfo(annotation=List[curategpt.wrappers.ontology.ontology.OntologyClass], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
elements:
- 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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'aliases': FieldInfo(annotation=List[str], required=False, default=None), 'definition': FieldInfo(annotation=str, required=False, default=None), 'id': FieldInfo(annotation=str, required=True), 'label': FieldInfo(annotation=str, required=False, default=None), 'logical_definition': FieldInfo(annotation=List[curategpt.wrappers.ontology.ontology.Relationship], required=False, default=None), 'original_id': FieldInfo(annotation=str, required=False, default=None), 'relationships': FieldInfo(annotation=List[curategpt.wrappers.ontology.ontology.Relationship], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
original_id:
str
-
relationships:
List
[Relationship
]
-
aliases:
- class curategpt.wrappers.ontology.ontology.Relationship(**data)
Bases:
BaseModel
A relationship to another node.
Corresponds to an edge in an OBO graph.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'predicate': FieldInfo(annotation=str, required=True), 'target': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
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
- external_search(text, expand=True, limit=None, **kwargs)
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
- external_search(text, expand=True, limit=None, **kwargs)
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: