Skip to content

Commit

Permalink
#1818, added bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
finnagin committed Jun 5, 2022
1 parent e4083bf commit c456de8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions code/ARAX/ARAXQuery/Infer/scripts/infer_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
from node_synonymizer import NodeSynonymizer




class InferUtilities:

#### Constructor
Expand All @@ -45,6 +47,12 @@ def __init__(self):
def __get_formated_edge_key(self, edge: Edge, kp: str = 'infores:rtx-kg2') -> str:
return f"{kp}:{edge.subject}-{edge.predicate}-{edge.object}"

def __none_to_zero(self, val):
if val is None:
return 0
else:
return val

def genrete_treat_subgraphs(self, response: ARAXResponse, top_drugs: pd.DataFrame, top_paths: dict, kedge_global_iter: int=0, qedge_global_iter: int=0, qnode_global_iter: int=0, option_global_iter: int=0):
self.response = response
self.kedge_global_iter = 0
Expand Down Expand Up @@ -192,8 +200,12 @@ def genrete_treat_subgraphs(self, response: ARAXResponse, top_drugs: pd.DataFram
}
self.response = resultifier.apply(self.response, resultify_params)
for result in self.response.envelope.message.results:
result.score = essence_scores[result.essence]
self.response.envelope.message.results.sort(key=lambda x: x.score, reverse=True)
if result.essence in essence_scores:
result.score = essence_scores[result.essence]
else:
result.score = None
self.response.warning(f"Error retrieving score for result essence {result.essence}. Setting result score to None.")
self.response.envelope.message.results.sort(key=lambda x: self.__none_to_zero(x.score), reverse=True)


return self.response, self.kedge_global_iter, self.qedge_global_iter, self.qnode_global_iter, self.option_global_iter
Expand Down

0 comments on commit c456de8

Please sign in to comment.