Data Structure
SeMRA implements a data structure as an extension to a simple curies.Triple that contains a list of EvidenceMixin objects, that are come as of the the following two flavors:
semra.struct.SimpleEvidence- simple evidence objects correspond to rows in a SSSOM file. These contain a mapping justification, optional confidence, and optional provenance for the mapping tool and/or curator that produced the mappingsemra.struct.ReasonedEvidence- complex evidence objects that are based on other mappings. These contain a mapping justification (typicallysemra.vocabulary.INVERSION_MAPPINGfor inversions orsemra.vocabulary.CHAIN_MAPPINGfor graph-based inference) and a list of full mapping objects.
Here’s an example of how a mapping might look:
Note
This data structure is based on SSSOM, but is implemented such that each mapping has a full reference to the mapping set that it’s part of (while SSSOM’s data model makes the mapping set the primary object, which contains a list of mappings).
A simple evidence can be used to justify a mapping:
from semra import (
Reference,
Mapping,
EXACT_MATCH,
SimpleEvidence,
MappingSet,
MANUAL_MAPPING,
)
r1 = Reference(prefix="chebi", identifier="107635", name="2,3-diacetyloxybenzoic")
r2 = Reference(prefix="mesh", identifier="C011748", name="tosiben")
mapping = Mapping(
subject=r1,
predicate=EXACT_MATCH,
object=r2,
evidence=[
SimpleEvidence(
justification=MANUAL_MAPPING,
confidence=0.99,
author=Reference(
prefix="orcid",
identifier="0000-0003-4423-4370",
name="Charles Tapley Hoyt",
),
mapping_set=MappingSet(
name="biomappings",
license="CC0",
confidence=0.90,
),
)
],
)
A mapping that relies on another mapping can use a reasoned evidence. In the following example, we justify the inverse mapping from the first one:
from semra import ReasonedEvidence, INVERSION_MAPPING
mapping_inv = Mapping(
subject=r2,
predicate=EXACT_MATCH,
object=r1,
evidence=[
ReasonedEvidence(
justification=INVERSION_MAPPING,
mappings=[mapping],
)
],
)
Note
These mappings can be produced with semra.api.flip() for a single mapping or
with semra.inference.infer_reversible() for a mapping set.
Classes
A mixin for classes that have confidence information. |
|
A class that represents evidences. |
|
A mixin for a class that can be hashed and CURIE-encoded. |
|
|
A semantic mapping. |
|
Represents a set of semantic mappings. |
|
The key used for a mapping set. |
|
A complex evidence based on multiple mappings. |
|
The key used for a reasoned evidence. |
|
Evidence for a mapping. |