hash_mapping
- hash_mapping(mapping: SemanticMapping, converter: Converter) str[source]
Hash the entire SSSOM semantic mapping record.
- Parameters:
mapping – A semantic mapping
converter – A converter
- Returns:
A hexadecimal representation of the FNV64 hash of the canonical S-expression for the mapping, proposed in https://github.com/mapping-commons/sssom/pull/534.
>>> from curies import NamedReference, Converter >>> from sssom_pydantic import SemanticMapping, hash_mapping >>> converter = Converter.from_prefix_map( ... { ... "cas": "https://commonchemistry.cas.org/detail?cas_rn=", ... "CHEBI": "http://purl.obolibrary.org/obo/CHEBI_", ... "mesh": "http://id.nlm.nih.gov/mesh/", ... "skos": "http://www.w3.org/2004/02/skos/core#", ... "semapv": "https://w3id.org/semapv/vocab/", ... } ... ) >>> mapping = SemanticMapping.exact( ... subject=NamedReference(prefix="mesh", identifier="C000089", name="ammeline"), ... object=NamedReference(prefix="CHEBI", identifier="28646", name="ammeline"), ... ) >>> hash_mapping(mapping, converter) '9D59EF306286DC1A' >>> mapping = SemanticMapping.exact( ... subject=NamedReference(prefix="CHEBI", identifier="28646", name="ammeline"), ... object=NamedReference(prefix="cas", identifier="645-92-1", name="Ammeline"), ... ) >>> hash_mapping(mapping, converter) '63C5D4FA232E1188'
Note
This creates a hash over the entire SSSOM semantic mapping record. If you just want to hash the core triple (i.e., subject, predicate, predicate modifier, and object), then use
hash_triple()