Skip to content

Commit

Permalink
Adding ability to specify obographviz config inside a crawl config (#829
Browse files Browse the repository at this point in the history
)

* Adding ability to specify obographviz config inside a crawl config

* format
  • Loading branch information
cmungall authored Feb 21, 2025
1 parent f9651e9 commit 46be54e
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 260 deletions.
509 changes: 255 additions & 254 deletions docs/examples/AdHoc/Summarizing-with-LLMs.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/packages/implementations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Implementations (also known as *adapters*) implement one or more :ref:`interface
aggregator
pantherdb
robot-template
translator
llm
25 changes: 25 additions & 0 deletions docs/packages/implementations/translator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _translator_implementation:

Translator Adapter
=================

About
-----


Command Line
^^^^^^^^^^^^

.. code::
runoak -i translator: mappings UniProtKB:P0DPQ9
Code
----

.. currentmodule:: oaklib.implementations.translator.translator_implementation

.. autoclass:: TranslatorImplementation



22 changes: 16 additions & 6 deletions src/oaklib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def clear_cli_settings():
default="",
help="A comma-separated list of display options. Use 'all' for all",
)
stylemap_otion = click.option(
stylemap_option = click.option(
"-S",
"--stylemap",
help="a json file to configure visualization. See https://berkeleybop.github.io/kgviz-model/",
Expand Down Expand Up @@ -1440,7 +1440,7 @@ def annotate(
show_default=True,
help="If set then extend input seed list to include all pairwise MRCAs",
)
@stylemap_otion
@stylemap_option
@stylemap_configure_option
@click.option(
"--max-hops",
Expand Down Expand Up @@ -1884,7 +1884,7 @@ def ancestors(
"--predicate-weights",
help="key-value pairs specified in YAML where keys are predicates or shorthands and values are weights",
)
@stylemap_otion
@stylemap_option
@stylemap_configure_option
@click.option("-o", "--output", help="Path to output file")
def paths(
Expand Down Expand Up @@ -3808,6 +3808,8 @@ def singletons(output: str, predicates: str, filter_obsoletes: bool):
show_default=True,
help="If true then draw a graph",
)
@stylemap_option
@stylemap_configure_option
@click.option("-d", "--directory", help="Directory to write output files")
@click.option(
"--whole-ontology/--no-whole-ontology",
Expand All @@ -3827,6 +3829,8 @@ def crawl(
allowed_prefixes,
mapping_predicates,
viz,
stylemap,
configure,
config_yaml,
whole_ontology,
directory,
Expand All @@ -3844,6 +3848,8 @@ def crawl(
Documentation for this command will be provided in a separate notebook.
"""
# TODO: normalize this option; avoid confusing with 'config'
stylemap_configure = configure
impl = settings.impl
if viz:
writer = None
Expand Down Expand Up @@ -3887,15 +3893,19 @@ def crawl(
if output_type and output_type not in ["png", "svg", "dot", "jpeg"]:
write_graph(graph, format=output_type, output=output)
else:
stylemap = None
if stylemap is None:
stylemap = default_stylemap_path()
if config.stylemap_overrides:
stylemap_configure = config.stylemap_overrides
if stylemap_configure:
# TODO: this is a bit backwards
stylemap_configure = yaml.dump(stylemap_configure)
graph_to_image(
graph,
seeds=terms,
imgfile=output,
stylemap=stylemap,
# configure=configure,
configure=stylemap_configure,
format=output_type,
view=True,
)
Expand Down Expand Up @@ -4755,7 +4765,7 @@ def associations(
show_default=True,
help="if view is set then open the image after rendering",
)
@stylemap_otion
@stylemap_option
@stylemap_configure_option
@click.argument("terms", nargs=-1)
def associations_graph(
Expand Down
2 changes: 2 additions & 0 deletions src/oaklib/implementations/monarch/monarch_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def associations(
predicate_closure_predicates: Optional[List[PRED_CURIE]] = None,
object_closure_predicates: Optional[List[PRED_CURIE]] = None,
include_modified: bool = False,
**kwargs,
) -> Iterator[Association]:
if subjects and not isinstance(subjects, list):
subjects = list(subjects)
Expand Down Expand Up @@ -140,6 +141,7 @@ def relationships(
include_abox: bool = True,
include_entailed: bool = False,
exclude_blank: bool = True,
**kwargs,
) -> Iterator[RELATIONSHIP]:
for a in self.associations(subjects=subjects, predicates=predicates, objects=objects):
yield a.subject, a.predicate, a.object
Expand Down
1 change: 1 addition & 0 deletions src/oaklib/utilities/mapping/mapping_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Config:
max_visits: Optional[int] = 10000
gap_fill: bool = True
clique_directory: Optional[str] = None
stylemap_overrides: Optional[Dict[str, Any]] = None


class MappingClique(BaseModel):
Expand Down
6 changes: 6 additions & 0 deletions src/oaklib/utilities/mapping/mapping_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ def validate_mappings(
m.predicate_id == HAS_DBXREF and xref_is_bijective
):
comments.append(f"cardinality is {m.mapping_cardinality}")
if object_adapter:
object_label = object_adapter.label(m.object_id)
if not object_label:
comments.append("no label for object")
elif m.object_label and m.object_label != object_label:
comments.append("object label mismatch")
if comments:
if autolabel:
if not m.subject_label and subject_adapter:
Expand Down

0 comments on commit 46be54e

Please sign in to comment.