def main(): #### Create a response object response = Response() ranker = ARAXRanker() #### Get a Message to work on messenger = ARAXMessenger() print("INFO: Fetching message to work on from arax.rtx.ai", flush=True) message = messenger.fetch_message( 'https://arax.rtx.ai/api/rtx/v1/message/2614') if message is None: print("ERROR: Unable to fetch message") return ranker.aggregate_scores(message, response=response) #### Show the final result print(response.show(level=Response.DEBUG)) print("Results:") for result in message.results: confidence = result.confidence if confidence is None: confidence = 0.0 print(" -" + '{:6.3f}'.format(confidence) + f"\t{result.essence}")
def main(): # For faster testing, cache the testing messages locally import requests_cache requests_cache.install_cache('ARAX_ranker_testing_cache') import argparse argparser = argparse.ArgumentParser(description='Ranker system') argparser.add_argument('--local', action='store_true', help='If set, use local RTXFeedback database to fetch messages') params = argparser.parse_args() # --- Create a response object response = ARAXResponse() ranker = ARAXRanker() # --- Get a Message to work on from ARAX_messenger import ARAXMessenger messenger = ARAXMessenger() if not params.local: print("INFO: Fetching message to work on from arax.ncats.io", flush=True) message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2614') # acetaminophen - > protein, just NGD as virtual edge # message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2687') # neutropenia -> drug, predict_drug_treats_disease and ngd # message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2701') # observed_expected_ratio and ngd # message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2703') # a huge one with jaccard # message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2706') # small one with paired concept frequency # message = messenger.fetch_message('https://arax.ncats.io/api/rtx/v1/message/2709') # bigger one with paired concept frequency # For local messages due to local changes in code not rolled out to production: if params.local: sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../UI/Feedback") from RTXFeedback import RTXFeedback araxdb = RTXFeedback() message_dict = araxdb.getMessage(294) # local version of 2709 but with updates to COHD # message_dict = araxdb.getMessage(297) # message_dict = araxdb.getMessage(298) # message_dict = araxdb.getMessage(299) # observed_expected_ratio different disease # message_dict = araxdb.getMessage(300) # chi_square # message_dict = araxdb.getMessage(302) # chi_square, different disease # message_dict = araxdb.getMessage(304) # all clinical info, osteoarthritis # message_dict = araxdb.getMessage(305) # all clinical info, neurtropenia # message_dict = araxdb.getMessage(306) # all clinical info, neurtropenia, but with virtual edges # message_dict = araxdb.getMessage(307) # all clinical info, osteoarthritis, but with virtual edges # message_dict = araxdb.getMessage(322) # Parkinsons Jaccard, top 50 # message_dict = araxdb.getMessage(324) # chi_square, KG2 # message_dict = araxdb.getMessage(325) # chi_square, ngd, KG2 # message_dict = araxdb.getMessage(326) # prob drug treats disease as attribute to all edge thrombocytopenia # message_dict = araxdb.getMessage(327) # add_qnode(name=DOID:1227, id=n00) # add_qnode(type=protein, is_set=true, id=n01) # add_qnode(type=chemical_substance, id=n02) # add_qedge(subject=n00, object=n01, id=e00) # add_qedge(subject=n01, object=n02, id=e01, type=physically_interacts_with) # expand(edge_id=[e00,e01], kp=ARAX/KG1) # overlay(action=compute_jaccard, start_node_id=n00, intermediate_node_id=n01, end_node_id=n02, virtual_relation_label=J1) # overlay(action=predict_drug_treats_disease, source_qnode_id=n02, target_qnode_id=n00, virtual_relation_label=P1) # overlay(action=overlay_clinical_info, chi_square=true, virtual_relation_label=C1, source_qnode_id=n00, target_qnode_id=n02) # overlay(action=compute_ngd, virtual_relation_label=N1, source_qnode_id=n00, target_qnode_id=n01) # overlay(action=compute_ngd, virtual_relation_label=N2, source_qnode_id=n00, target_qnode_id=n02) # overlay(action=compute_ngd, virtual_relation_label=N3, source_qnode_id=n01, target_qnode_id=n02) # resultify(ignore_edge_direction=true) # filter_results(action=limit_number_of_results, max_results=100) from ARAX_messenger import ARAXMessenger message = ARAXMessenger().from_dict(message_dict) if message is None: print("ERROR: Unable to fetch message") return # ranker.aggregate_scores(message,response=response) ranker.aggregate_scores_dmk(message, response=response) # Show the final result print(response.show(level=ARAXResponse.DEBUG)) print("Results:") for result in message.results: confidence = result.confidence if confidence is None: confidence = 0.0 print(" -" + '{:6.3f}'.format(confidence) + f"\t{result.essence}") # print(json.dumps(message.to_dict(),sort_keys=True,indent=2)) # Show the message number print(json.dumps(ast.literal_eval(repr(message.id)), sort_keys=True, indent=2))