Skip to content

Commit 46be54e

Browse files
authored
Adding ability to specify obographviz config inside a crawl config (#829)
* Adding ability to specify obographviz config inside a crawl config * format
1 parent f9651e9 commit 46be54e

File tree

7 files changed

+306
-260
lines changed

7 files changed

+306
-260
lines changed

docs/examples/AdHoc/Summarizing-with-LLMs.ipynb

+255-254
Large diffs are not rendered by default.

docs/packages/implementations/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ Implementations (also known as *adapters*) implement one or more :ref:`interface
2424
aggregator
2525
pantherdb
2626
robot-template
27+
translator
2728
llm
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.. _translator_implementation:
2+
3+
Translator Adapter
4+
=================
5+
6+
About
7+
-----
8+
9+
10+
Command Line
11+
^^^^^^^^^^^^
12+
13+
.. code::
14+
15+
runoak -i translator: mappings UniProtKB:P0DPQ9
16+
17+
Code
18+
----
19+
20+
.. currentmodule:: oaklib.implementations.translator.translator_implementation
21+
22+
.. autoclass:: TranslatorImplementation
23+
24+
25+

src/oaklib/cli.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def clear_cli_settings():
401401
default="",
402402
help="A comma-separated list of display options. Use 'all' for all",
403403
)
404-
stylemap_otion = click.option(
404+
stylemap_option = click.option(
405405
"-S",
406406
"--stylemap",
407407
help="a json file to configure visualization. See https://berkeleybop.github.io/kgviz-model/",
@@ -1440,7 +1440,7 @@ def annotate(
14401440
show_default=True,
14411441
help="If set then extend input seed list to include all pairwise MRCAs",
14421442
)
1443-
@stylemap_otion
1443+
@stylemap_option
14441444
@stylemap_configure_option
14451445
@click.option(
14461446
"--max-hops",
@@ -1884,7 +1884,7 @@ def ancestors(
18841884
"--predicate-weights",
18851885
help="key-value pairs specified in YAML where keys are predicates or shorthands and values are weights",
18861886
)
1887-
@stylemap_otion
1887+
@stylemap_option
18881888
@stylemap_configure_option
18891889
@click.option("-o", "--output", help="Path to output file")
18901890
def paths(
@@ -3808,6 +3808,8 @@ def singletons(output: str, predicates: str, filter_obsoletes: bool):
38083808
show_default=True,
38093809
help="If true then draw a graph",
38103810
)
3811+
@stylemap_option
3812+
@stylemap_configure_option
38113813
@click.option("-d", "--directory", help="Directory to write output files")
38123814
@click.option(
38133815
"--whole-ontology/--no-whole-ontology",
@@ -3827,6 +3829,8 @@ def crawl(
38273829
allowed_prefixes,
38283830
mapping_predicates,
38293831
viz,
3832+
stylemap,
3833+
configure,
38303834
config_yaml,
38313835
whole_ontology,
38323836
directory,
@@ -3844,6 +3848,8 @@ def crawl(
38443848
38453849
Documentation for this command will be provided in a separate notebook.
38463850
"""
3851+
# TODO: normalize this option; avoid confusing with 'config'
3852+
stylemap_configure = configure
38473853
impl = settings.impl
38483854
if viz:
38493855
writer = None
@@ -3887,15 +3893,19 @@ def crawl(
38873893
if output_type and output_type not in ["png", "svg", "dot", "jpeg"]:
38883894
write_graph(graph, format=output_type, output=output)
38893895
else:
3890-
stylemap = None
38913896
if stylemap is None:
38923897
stylemap = default_stylemap_path()
3898+
if config.stylemap_overrides:
3899+
stylemap_configure = config.stylemap_overrides
3900+
if stylemap_configure:
3901+
# TODO: this is a bit backwards
3902+
stylemap_configure = yaml.dump(stylemap_configure)
38933903
graph_to_image(
38943904
graph,
38953905
seeds=terms,
38963906
imgfile=output,
38973907
stylemap=stylemap,
3898-
# configure=configure,
3908+
configure=stylemap_configure,
38993909
format=output_type,
39003910
view=True,
39013911
)
@@ -4755,7 +4765,7 @@ def associations(
47554765
show_default=True,
47564766
help="if view is set then open the image after rendering",
47574767
)
4758-
@stylemap_otion
4768+
@stylemap_option
47594769
@stylemap_configure_option
47604770
@click.argument("terms", nargs=-1)
47614771
def associations_graph(

src/oaklib/implementations/monarch/monarch_implementation.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def associations(
4848
predicate_closure_predicates: Optional[List[PRED_CURIE]] = None,
4949
object_closure_predicates: Optional[List[PRED_CURIE]] = None,
5050
include_modified: bool = False,
51+
**kwargs,
5152
) -> Iterator[Association]:
5253
if subjects and not isinstance(subjects, list):
5354
subjects = list(subjects)
@@ -140,6 +141,7 @@ def relationships(
140141
include_abox: bool = True,
141142
include_entailed: bool = False,
142143
exclude_blank: bool = True,
144+
**kwargs,
143145
) -> Iterator[RELATIONSHIP]:
144146
for a in self.associations(subjects=subjects, predicates=predicates, objects=objects):
145147
yield a.subject, a.predicate, a.object

src/oaklib/utilities/mapping/mapping_crawler.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Config:
3838
max_visits: Optional[int] = 10000
3939
gap_fill: bool = True
4040
clique_directory: Optional[str] = None
41+
stylemap_overrides: Optional[Dict[str, Any]] = None
4142

4243

4344
class MappingClique(BaseModel):

src/oaklib/utilities/mapping/mapping_validation.py

+6
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ def validate_mappings(
276276
m.predicate_id == HAS_DBXREF and xref_is_bijective
277277
):
278278
comments.append(f"cardinality is {m.mapping_cardinality}")
279+
if object_adapter:
280+
object_label = object_adapter.label(m.object_id)
281+
if not object_label:
282+
comments.append("no label for object")
283+
elif m.object_label and m.object_label != object_label:
284+
comments.append("object label mismatch")
279285
if comments:
280286
if autolabel:
281287
if not m.subject_label and subject_adapter:

0 commit comments

Comments
 (0)