Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Aug 17, 2024
1 parent fdaa368 commit a1ff177
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/oaklib/implementations/amigo/amigo_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def __post_init__(self):
def go_adapter(self) -> OboGraphInterface:
if not self._go_adapter:
from oaklib import get_adapter

self._go_adapter = get_adapter("sqlite:obo:go")
return self._go_adapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,13 @@ def relationships(
_sparql_values("s", s_uris),
_sparql_values("p", [self.curie_to_sparql(IS_A)]),
_sparql_values("o", o_uris),
]
],
)
bindings = self._sparql_query(q)
for row in bindings:
yield self.uri_to_curie(row["s"]["value"]), IS_A, self.uri_to_curie(row["o"]["value"])
yield self.uri_to_curie(row["s"]["value"]), IS_A, self.uri_to_curie(
row["o"]["value"]
)
if predicates != [IS_A]:
# existentials
q = SparqlQuery(
Expand All @@ -538,7 +540,7 @@ def relationships(
_sparql_values("s", s_uris),
_sparql_values("p", p_uris),
_sparql_values("o", o_uris),
]
],
)
bindings = self._sparql_query(q)
for row in bindings:
Expand All @@ -548,8 +550,6 @@ def relationships(
self.uri_to_curie(row["o"]["value"]),
)



def outgoing_relationship_map(self, *args, **kwargs) -> RELATIONSHIP_MAP:
return pairs_as_dict(self.outgoing_relationships(*args, **kwargs))

Expand Down
8 changes: 4 additions & 4 deletions src/oaklib/implementations/sqldb/sql_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ def __post_init__(self):
logging.info(f"Locator, post-processed: {locator}")
self.engine = create_engine(locator)

if(logging.root.level <= logging.DEBUG):
#If oaklib is running at DEBUG level logging; record all queries from sqlachemy on execution.
#This line is equivalent to create_engine(locator,echo=True)
logging.getLogger('sqlalchemy.engine.Engine').setLevel(logging.INFO)
if logging.root.level <= logging.DEBUG:
# If oaklib is running at DEBUG level logging; record all queries from sqlachemy on execution.
# This line is equivalent to create_engine(locator,echo=True)
logging.getLogger("sqlalchemy.engine.Engine").setLevel(logging.INFO)

@property
def session(self):
Expand Down
7 changes: 5 additions & 2 deletions src/oaklib/interfaces/association_provider_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ def association_pairwise_coassociations(
symmetric = curies1 == curies2
logging.info(f"Finding co-associations between {curies1} and {curies2}")
assocmap = {
c: list(self.associations(objects=[c], limit=-1, **kwargs)) for c in curies1.union(curies2)
c: list(self.associations(objects=[c], limit=-1, **kwargs))
for c in curies1.union(curies2)
}
assocmap1 = {c: assocmap[c] for c in curies1}
assocmap2 = {c: assocmap[c] for c in curies2}
Expand All @@ -382,7 +383,9 @@ def association_pairwise_coassociations(
elements1 = {a.subject for a in assocs1}
elements2 = {a.subject for a in assocs2}
if not elements1 or not elements2:
logging.debug(f"No associations for {c1} or {c2}, so a coassociation is not meaningful")
logging.debug(
f"No associations for {c1} or {c2}, so a coassociation is not meaningful"
)
continue
common = elements1.intersection(elements2)
assocs_to_common = [a for a in assocs1 + assocs2 if a.subject in common]
Expand Down
8 changes: 6 additions & 2 deletions src/oaklib/interfaces/usages_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,9 @@ def _source_id():
if include_unused:
for c in curies:
if c not in used_curies:
yield Usage(used_id=c, used_by_id="None", source=_source_id(), context=UsageContext.MULTIPLE)

yield Usage(
used_id=c,
used_by_id="None",
source=_source_id(),
context=UsageContext.MULTIPLE,
)
6 changes: 3 additions & 3 deletions src/oaklib/io/heatmap_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def finish(self):
# ax = sns.heatmap(df, annot=mask, fmt=".2f", mask=~mask) # Annotates only non-zero cells
ax = sns.heatmap(df, annot=True, fmt=".2f")
# Rotate x and y labels if necessary
plt.xticks(rotation=45, ha='right') # Rotate term2 labels for better fit
plt.xticks(rotation=45, ha="right") # Rotate term2 labels for better fit
plt.yticks(rotation=0) # Keep term1 labels horizontal
# Adjust font size of the labels
ax.tick_params(axis='both', which='major', labelsize=24)
ax.tick_params(axis="both", which="major", labelsize=24)

# Manually set x-axis labels to ensure correct alignment
ax.set_xticklabels(ax.get_xticklabels(), rotation=45, horizontalalignment='right')
ax.set_xticklabels(ax.get_xticklabels(), rotation=45, horizontalalignment="right")

ax.get_figure().savefig(self.output, bbox_inches="tight")
# plt.savefig(self.output, bbox_inches="tight")
1 change: 0 additions & 1 deletion src/oaklib/utilities/lexical/lexical_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def add_labels_from_uris(oi: BasicOntologyInterface):
oi.set_label(curie, label)



def create_lexical_index(
oi: BasicOntologyInterface,
pipelines: Optional[List[LexicalTransformationPipeline]] = None,
Expand Down

0 comments on commit a1ff177

Please sign in to comment.