diff --git a/src/oaklib/implementations/amigo/amigo_implementation.py b/src/oaklib/implementations/amigo/amigo_implementation.py index 80b76cf0b..c638213cc 100644 --- a/src/oaklib/implementations/amigo/amigo_implementation.py +++ b/src/oaklib/implementations/amigo/amigo_implementation.py @@ -211,7 +211,6 @@ def subset_members(self, subset: SUBSET_CURIE, **kwargs) -> Iterable[CURIE]: for doc in results: yield doc[ANNOTATION_CLASS] - def associations( self, subjects: Iterable[CURIE] = None, @@ -348,7 +347,6 @@ def association_counts( solr, fq, facet_field=ff, rows=0, facet_limit=limit, min_facet_count=min_facet_count ) - # def association_pairwise_coassociations( # self, # curies1: Iterable[CURIE], @@ -389,8 +387,6 @@ def association_counts( # yield ff[i], ff[i + 1] # - - def association_subject_counts( self, subjects: Iterable[CURIE] = None, @@ -446,10 +442,6 @@ def relationships( self._cache_nodes(nodes, [s, p, o]) yield s, p, o - - - - def basic_search( self, search_term: str, config: Optional[SearchConfiguration] = None ) -> Iterable[CURIE]: diff --git a/src/oaklib/interfaces/association_provider_interface.py b/src/oaklib/interfaces/association_provider_interface.py index e87445235..7d2050058 100644 --- a/src/oaklib/interfaces/association_provider_interface.py +++ b/src/oaklib/interfaces/association_provider_interface.py @@ -365,7 +365,9 @@ def association_pairwise_coassociations( curies1 = list(curies1) curies2 = list(curies2) logging.info(f"Finding co-associations between {curies1} and {curies2}") - assocmap = {c: list(self.associations(objects=[c], **kwargs)) for c in set(curies1+curies2)} + assocmap = { + c: list(self.associations(objects=[c], **kwargs)) for c in set(curies1 + curies2) + } assocmap1 = {c: assocmap[c] for c in curies1} assocmap2 = {c: assocmap[c] for c in curies2} for c1 in curies1: @@ -389,8 +391,9 @@ def association_pairwise_coassociations( number_subject_unique_to_entity2=len(elements2.difference(elements1)), ) if coassoc.number_subjects_in_union: - coassoc.proportion_subjects_in_common = (coassoc.number_subjects_in_common / - coassoc.number_subjects_in_union) + coassoc.proportion_subjects_in_common = ( + coassoc.number_subjects_in_common / coassoc.number_subjects_in_union + ) if include_entities: coassoc.subjects_in_common = list(common) coassoc.associations_for_subjects_in_common = assocs_to_common diff --git a/src/oaklib/utilities/lexical/synonymizer.py b/src/oaklib/utilities/lexical/synonymizer.py index 0d3bfecd6..743737908 100644 --- a/src/oaklib/utilities/lexical/synonymizer.py +++ b/src/oaklib/utilities/lexical/synonymizer.py @@ -85,7 +85,9 @@ def apply_synonymizer_to_terms( if qualifier is None or qualifier == "": if rule.in_place or scope_pred == "definition": # preserves the original synonym type - qualifier = pred_to_qual.get(scope_pred, scope_pred).lower() + qualifier = pred_to_qual.get( + scope_pred, scope_pred + ).lower() else: qualifier = "exact" n += 1 diff --git a/src/oaklib/utilities/writers/change_handler.py b/src/oaklib/utilities/writers/change_handler.py index 0c3b16e04..c67b19e44 100644 --- a/src/oaklib/utilities/writers/change_handler.py +++ b/src/oaklib/utilities/writers/change_handler.py @@ -1,7 +1,7 @@ """Change Handler Class.""" from dataclasses import dataclass -from typing import Dict +from typing import Dict, List from kgcl_schema.datamodel.kgcl import Change @@ -12,30 +12,22 @@ def __init__(self, oi, file): self.file = file self.oi = oi - def write_markdown_collapsible(self, title, content_lines): - # Start with the details tag for a collapsible section + def write_markdown_collapsible(self, title: str, content_lines: List[str]) -> None: self.file.write(f"
\n{title}\n\n") - - # Write the content lines within the collapsible section - content = "\n".join(content_lines) - self.file.write(content + "\n\n") - - # Close the details tag + self.file.write("\n".join(content_lines) + "\n\n") self.file.write("
\n\n") - def write_markdown_table(self, title, header, rows): - # Create the table header and separator lines - markdown_rows = [ - header, - "|".join(["----"] * len(header.split("|")[1:-1])) + "|", - ] - - # Add the table rows - markdown_rows.extend(rows) - - # Write the table as a collapsible section + def write_markdown_table(self, title: str, header: str, rows: List[str]) -> None: + separator = "|".join(["----"] * len(header.split("|")[1:-1])) + "|" + markdown_rows = [header, separator] + rows self.write_markdown_collapsible(title, markdown_rows) + def handle_generic_change( + self, value: List[object], title: str, header: str, row_format: str + ) -> None: + rows = [row_format.format(change=change) for change in value] + self.write_markdown_table(f"{title}: {len(rows)}", header, rows) + def handle_new_synonym(self, value): # Create rows for the table rows = [ diff --git a/tests/test_utilities/test_synonymizer.py b/tests/test_utilities/test_synonymizer.py index 1fa29bd11..3dfb37807 100644 --- a/tests/test_utilities/test_synonymizer.py +++ b/tests/test_utilities/test_synonymizer.py @@ -81,7 +81,6 @@ def test_synonymizer(rule, input, expected): "the plasma membrane and nucleus, but including other subcellular structures.' " "to 'All of the contents of a cell excluding the plasma membrane and " "NUCLEUS, but including other subcellular structures.'" - ) ], ), @@ -105,7 +104,7 @@ def test_synonymizer(rule, input, expected): ], ) def test_syonymizer_on_terms(ruleset, include_all, terms, expected): - #adapter = get_adapter(f"simpleobo:{TEST_SIMPLE_ONT}") + # adapter = get_adapter(f"simpleobo:{TEST_SIMPLE_ONT}") adapter = get_adapter(f"{TEST_SIMPLE_ONT}") if isinstance(ruleset, Synonymizer): ruleset = RuleSet(rules=[ruleset]) diff --git a/tox.ini b/tox.ini index aed69286d..2a2283f7e 100644 --- a/tox.ini +++ b/tox.ini @@ -41,7 +41,7 @@ deps = ruff skip_install = true commands = - black src/ tests/ + black src/ tests/ --exclude src\/oaklib\/datamodels\/.*\.py ruff --fix src/ tests/ description = Run linters.