obographs 0.0.6__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {obographs-0.0.6 → obographs-0.0.7}/PKG-INFO +1 -1
- {obographs-0.0.6 → obographs-0.0.7}/pyproject.toml +2 -2
- {obographs-0.0.6 → obographs-0.0.7}/src/obographs/__init__.py +2 -0
- obographs-0.0.7/src/obographs/contrib.py +71 -0
- {obographs-0.0.6 → obographs-0.0.7}/src/obographs/model.py +4 -2
- {obographs-0.0.6 → obographs-0.0.7}/src/obographs/version.py +1 -1
- {obographs-0.0.6 → obographs-0.0.7}/LICENSE +0 -0
- {obographs-0.0.6 → obographs-0.0.7}/README.md +0 -0
- {obographs-0.0.6 → obographs-0.0.7}/src/obographs/py.typed +0 -0
- {obographs-0.0.6 → obographs-0.0.7}/src/obographs/standardized.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "obographs"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.7"
|
|
8
8
|
description = "A python data model for OBO Graphs"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -232,7 +232,7 @@ known-first-party = [
|
|
|
232
232
|
docstring-code-format = true
|
|
233
233
|
|
|
234
234
|
[tool.bumpversion]
|
|
235
|
-
current_version = "0.0.
|
|
235
|
+
current_version = "0.0.7"
|
|
236
236
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+(?P<build>[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?"
|
|
237
237
|
serialize = [
|
|
238
238
|
"{major}.{minor}.{patch}-{release}+{build}",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""A python data model for OBO Graphs."""
|
|
2
2
|
|
|
3
|
+
from .contrib import guess_primary_graph
|
|
3
4
|
from .model import (
|
|
4
5
|
Definition,
|
|
5
6
|
DomainRangeAxiom,
|
|
@@ -69,5 +70,6 @@ __all__ = [
|
|
|
69
70
|
"StandardizedXref",
|
|
70
71
|
"Synonym",
|
|
71
72
|
"Xref",
|
|
73
|
+
"guess_primary_graph",
|
|
72
74
|
"read",
|
|
73
75
|
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Extra functionality that isn't part of the core obographs package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import overload
|
|
6
|
+
|
|
7
|
+
from .model import Graph, GraphDocument
|
|
8
|
+
from .standardized import StandardizedGraph, StandardizedGraphDocument
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"guess_primary_graph",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
CANONICAL = {
|
|
15
|
+
"mamo": "http://identifiers.org/mamo",
|
|
16
|
+
"swo": "http://www.ebi.ac.uk/swo/swo.json",
|
|
17
|
+
"ito": "https://identifiers.org/ito:ontology",
|
|
18
|
+
"apollosv": "http://purl.obolibrary.org/obo/apollo_sv.owl",
|
|
19
|
+
"cheminf": "http://semanticchemistry.github.io/semanticchemistry/ontology/cheminf.owl",
|
|
20
|
+
"dideo": "http://purl.obolibrary.org/obo/dideo/release/2022-06-14/dideo.owl",
|
|
21
|
+
"micro": "http://purl.obolibrary.org/obo/MicrO.owl",
|
|
22
|
+
"ogsf": "http://purl.obolibrary.org/obo/ogsf-merged.owl",
|
|
23
|
+
"mfomd": "http://purl.obolibrary.org/obo/MF.owl",
|
|
24
|
+
"one": "http://purl.obolibrary.org/obo/ONE",
|
|
25
|
+
"ons": "https://raw.githubusercontent.com/enpadasi/Ontology-for-Nutritional-Studies/master/ons.owl",
|
|
26
|
+
"ontie": "https://ontology.iedb.org/ontology/ontie.owl",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# docstr-coverage:excused `overload`
|
|
31
|
+
@overload
|
|
32
|
+
def guess_primary_graph(
|
|
33
|
+
graph_document: GraphDocument,
|
|
34
|
+
prefix: str,
|
|
35
|
+
) -> Graph: ...
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# docstr-coverage:excused `overload`
|
|
39
|
+
@overload
|
|
40
|
+
def guess_primary_graph(
|
|
41
|
+
graph_document: StandardizedGraphDocument,
|
|
42
|
+
prefix: str,
|
|
43
|
+
) -> StandardizedGraph: ...
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def guess_primary_graph(
|
|
47
|
+
graph_document: GraphDocument | StandardizedGraphDocument,
|
|
48
|
+
prefix: str,
|
|
49
|
+
) -> Graph | StandardizedGraph:
|
|
50
|
+
"""Guess the primary graph from a graph document."""
|
|
51
|
+
if 0 == len(graph_document.graphs):
|
|
52
|
+
raise ValueError("Could not automatically identify the primary graph from empty list")
|
|
53
|
+
elif 1 == len(graph_document.graphs):
|
|
54
|
+
return graph_document.graphs[0]
|
|
55
|
+
|
|
56
|
+
id_to_graph = {graph.id: graph for graph in graph_document.graphs if graph.id}
|
|
57
|
+
|
|
58
|
+
# Check for standard construction of OBO PURLs
|
|
59
|
+
for suffix in ["owl", "obo", "json"]:
|
|
60
|
+
standard_id = f"http://purl.obolibrary.org/obo/{prefix.lower()}.{suffix}"
|
|
61
|
+
if standard_id in id_to_graph:
|
|
62
|
+
return id_to_graph[standard_id]
|
|
63
|
+
|
|
64
|
+
# Check if we've manually curated a mapping
|
|
65
|
+
if prefix in CANONICAL and CANONICAL[prefix] in id_to_graph:
|
|
66
|
+
return id_to_graph[CANONICAL[prefix]]
|
|
67
|
+
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"Could not automatically identify the primary graph for {prefix=} from "
|
|
70
|
+
f"{len(id_to_graph):,} graphs:\n\n{sorted(id_to_graph)}"
|
|
71
|
+
)
|
|
@@ -184,11 +184,13 @@ class Graph(BaseModel):
|
|
|
184
184
|
domainRangeAxioms: list[DomainRangeAxiom] = Field(default_factory=list) # noqa:N815
|
|
185
185
|
propertyChainAxioms: list[PropertyChainAxiom] = Field(default_factory=list) # noqa:N815
|
|
186
186
|
|
|
187
|
-
def standardize(
|
|
187
|
+
def standardize(
|
|
188
|
+
self, converter: curies.Converter, *, strict: bool = False
|
|
189
|
+
) -> StandardizedGraph:
|
|
188
190
|
"""Standardize the graph."""
|
|
189
191
|
from .standardized import StandardizedGraph
|
|
190
192
|
|
|
191
|
-
return StandardizedGraph.from_obograph_raw(self, converter)
|
|
193
|
+
return StandardizedGraph.from_obograph_raw(self, converter, strict=strict)
|
|
192
194
|
|
|
193
195
|
|
|
194
196
|
class GraphDocument(BaseModel):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|