kg_microbe.transform_utils.ontologies package
Submodules
kg_microbe.transform_utils.ontologies.ontologies_transform module
Ontology transform module.
- kg_microbe.transform_utils.ontologies.ontologies_transform.METAMODEL_NODE_PREFIXES = frozenset({'dc', 'dct', 'dcterms', 'doap', 'foaf', 'oio', 'owl', 'pav', 'rdf', 'rdfs', 'skos', 'terms'})
Prefixes of the annotation and metadata vocabulary an OWL file annotates with – never anything it defines. KGX’s OBO-JSON loader emits a node for each one it encounters, so rdfs:label, owl:deprecated, dc:title and dcterms:license arrived as biolink:OntologyClass nodes connected to nothing: 55 distinct ids, 172 rows across ten ontologies, 0 edges, 36 of them in the shipped graph (#1023). Matching on the id column of a nodes file only – skos:closeMatch as a relation value is legitimate and lives in a different column of a different file.
- class kg_microbe.transform_utils.ontologies.ontologies_transform.OntologiesTransform(input_dir=None, output_dir=None)
Bases:
TransformOntologyTransform parses an Obograph JSON form of an Ontology into nodes nad edges.
-
DATA_INPUTS:
tuple= ('mappings/foodon_model_dispositions.tsv', 'mappings/ontology_self_loop_exclusions.tsv') Repo-relative curation files this transform reads, beyond its own
data/raw/download.Declared so freshness tooling can tell that an output is stale against its data rather than only its code. Without it a mapping correction lands, every consumer keeps reporting FRESH, and a re-merge silently ships the old groundings: #778 corrected 16 isolation-source ids and #786 rewrote the unified chemical SSSOM, and the merged KG built afterwards still asserted 75 organisms isolated from a “Cell Line”, because nothing re-ran the transforms that read those files (#812).
Paths are relative to the repo root. Keep them tracked in git — the freshness check uses commit time, not mtime, because git checkout rewrites mtimes without changing content (#797).
List every curation file read, not a representative one. A partial declaration fails silently and looks identical to a complete one: ontologies_stubs declared 1 of the 11 files it read and was reported fresh after changes to the other ten (#839). Where the set comes from a constant, derive this from it rather than restating it.
- ONTOLOGY_KNOWLEDGE_SOURCES = {'chebi': 'infores:chebi', 'ec': 'infores:ec', 'envo': 'infores:envo', 'foodon': 'infores:foodon', 'go': 'infores:go', 'hp': 'infores:hp', 'metpo': 'infores:metpo', 'mondo': 'infores:mondo', 'ncbitaxon': 'infores:ncbitaxon', 'pato': 'infores:pato', 'ro': 'infores:ro', 'taxrank': 'infores:taxrank', 'uberon': 'infores:uberon', 'upa': 'infores:upa'}
- decompress(data_file)
Unzip file.
- parse(name, data_file, source)
Process the data_file.
- Parameters:
name (
str) – Name of the ontology.data_file (
Optional[Path]) – data file to parse.source (
str) – Source name.
- Return type:
None- Returns:
None.
- post_process(name)
Post process specific nodes and edges files.
- run(data_file=None, show_status=True)
Transform an ontology.
- Parameters:
data_file (
Union[Path,None,str]) – data file to parse- Return type:
None- Returns:
None.
-
DATA_INPUTS:
Module contents
Ontologies transform module.
- class kg_microbe.transform_utils.ontologies.OntologiesTransform(input_dir=None, output_dir=None)
Bases:
TransformOntologyTransform parses an Obograph JSON form of an Ontology into nodes nad edges.
-
DATA_INPUTS:
tuple= ('mappings/foodon_model_dispositions.tsv', 'mappings/ontology_self_loop_exclusions.tsv') Repo-relative curation files this transform reads, beyond its own
data/raw/download.Declared so freshness tooling can tell that an output is stale against its data rather than only its code. Without it a mapping correction lands, every consumer keeps reporting FRESH, and a re-merge silently ships the old groundings: #778 corrected 16 isolation-source ids and #786 rewrote the unified chemical SSSOM, and the merged KG built afterwards still asserted 75 organisms isolated from a “Cell Line”, because nothing re-ran the transforms that read those files (#812).
Paths are relative to the repo root. Keep them tracked in git — the freshness check uses commit time, not mtime, because git checkout rewrites mtimes without changing content (#797).
List every curation file read, not a representative one. A partial declaration fails silently and looks identical to a complete one: ontologies_stubs declared 1 of the 11 files it read and was reported fresh after changes to the other ten (#839). Where the set comes from a constant, derive this from it rather than restating it.
- ONTOLOGY_KNOWLEDGE_SOURCES = {'chebi': 'infores:chebi', 'ec': 'infores:ec', 'envo': 'infores:envo', 'foodon': 'infores:foodon', 'go': 'infores:go', 'hp': 'infores:hp', 'metpo': 'infores:metpo', 'mondo': 'infores:mondo', 'ncbitaxon': 'infores:ncbitaxon', 'pato': 'infores:pato', 'ro': 'infores:ro', 'taxrank': 'infores:taxrank', 'uberon': 'infores:uberon', 'upa': 'infores:upa'}
- decompress(data_file)
Unzip file.
- parse(name, data_file, source)
Process the data_file.
- Parameters:
name (
str) – Name of the ontology.data_file (
Optional[Path]) – data file to parse.source (
str) – Source name.
- Return type:
None- Returns:
None.
- post_process(name)
Post process specific nodes and edges files.
- run(data_file=None, show_status=True)
Transform an ontology.
- Parameters:
data_file (
Union[Path,None,str]) – data file to parse- Return type:
None- Returns:
None.
-
DATA_INPUTS: