@@ -42,7 +42,7 @@ class CohdTrapi150(CohdTrapi):
4242 edge_types_negative = ['biolink:negatively_correlated_with' ]
4343 default_negative_predicate = edge_types_negative [0 ]
4444
45- tool_version = f'{ CohdTrapi ._SERVICE_NAME } 6.5.3 '
45+ tool_version = f'{ CohdTrapi ._SERVICE_NAME } 6.5.4 '
4646 schema_version = '1.5.0'
4747 biolink_version = bm_version
4848
@@ -600,15 +600,15 @@ def _interpret_query(self):
600600 if self ._concept_1_set_interpretation == 'BATCH' :
601601 ids = list (set (concept_1_qnode ['ids' ])) # remove duplicate CURIEs
602602 elif self ._concept_1_set_interpretation == 'MANY' :
603- member_ids = concept_1_qnode .get ('member_ids' )
604- if not member_ids :
603+ self . _mcq_member_ids = concept_1_qnode .get ('member_ids' )
604+ if not self . _mcq_member_ids :
605605 # Missing required member_ids for MCQ
606606 self ._valid_query = False
607607 description = 'set_interpretation: MANY but no member_ids'
608608 response = self ._trapi_mini_response (TrapiStatusCode .MISSING_MEMBER_IDS , description )
609609 self ._invalid_query_response = response , 200
610610 return self ._valid_query , self ._invalid_query_response
611- ids = list (set ( concept_1_qnode [ 'member_ids' ]) ) # remove duplicate CURIEs
611+ ids = list (self . _mcq_member_ids ) # remove duplicate CURIEs
612612
613613 # Get the MCQ set ID
614614 self ._mcq_set_id = concept_1_qnode ['ids' ][0 ]
@@ -999,31 +999,36 @@ def operate_mcq(self):
999999 # categories (domains)
10001000 for domain_id , concept_class_id in self ._domain_class_pairs :
10011001 new_results = query_cohd_mysql .query_trapi_mcq (concept_ids = self ._concept_1_omop_ids ,
1002- dataset_id = self ._dataset_id ,
1003- domain_id = domain_id ,
1004- concept_class_id = concept_class_id ,
1005- ln_ratio_sign = self ._association_direction ,
1006- confidence = self ._confidence_interval ,
1007- bypass = self ._bypass_cache )
1002+ n_member_ids = len (self ._mcq_member_ids ),
1003+ score_scaling = CohdTrapi .mcq_score_scaling ,
1004+ dataset_id = self ._dataset_id ,
1005+ domain_id = domain_id ,
1006+ concept_class_id = concept_class_id ,
1007+ ln_ratio_sign = self ._association_direction ,
1008+ confidence = self ._confidence_interval ,
1009+ bypass = self ._bypass_cache )
10081010 new_set_results , new_single_results = new_results
10091011 if new_set_results :
10101012 set_results .extend (new_set_results )
10111013 single_results .update (new_single_results )
10121014 else :
10131015 # No category (domain) was specified for Node 2. Query the associations between Node 1 and all
10141016 # domains
1015- new_results = query_cohd_mysql .query_trapi_mcq (concept_id_1 = self ._concept_1_omop_ids ,
1016- dataset_id = self ._dataset_id , domain_id = None ,
1017- ln_ratio_sign = self ._association_direction ,
1018- confidence = self ._confidence_interval ,
1019- bypass = self ._bypass_cache )
1017+ new_results = query_cohd_mysql .query_trapi_mcq (concept_ids = self ._concept_1_omop_ids ,
1018+ n_member_ids = len (self ._mcq_member_ids ),
1019+ score_scaling = CohdTrapi .mcq_score_scaling ,
1020+ dataset_id = self ._dataset_id ,
1021+ domain_id = None ,
1022+ ln_ratio_sign = self ._association_direction ,
1023+ confidence = self ._confidence_interval ,
1024+ bypass = self ._bypass_cache )
10201025 new_set_results , new_single_results = new_results
10211026 if new_set_results :
10221027 set_results .extend (new_set_results )
10231028 single_results .update (new_single_results )
10241029
10251030 # Results within each query call should be sorted, but still need to be sorted across query calls
1026- new_set_results = sort_cohd_results (new_set_results , sort_field = 'ln_ratio_score ' )
1031+ new_set_results = sort_cohd_results (new_set_results , sort_field = 'mcq_score ' )
10271032
10281033 # Convert results from COHD format to Translator Reasoner standard
10291034 self ._add_mcq_results_to_trapi (set_results , single_results )
@@ -1169,8 +1174,8 @@ def _add_mcq_result(self, set_result, single_results, criteria):
11691174 kg_node_2 , kg_set_edge , kg_set_edge_id = self ._add_kg_set_edge (node_2 , is_subject , set_result )
11701175
11711176 # Add to results
1172- score = set_result ['ln_ratio_score ' ]
1173- self ._add_result (self ._mcq_set_id , concept_2_curie , kg_set_edge_id , score )
1177+ score = set_result ['mcq_score ' ]
1178+ self ._add_result (self ._mcq_set_id , concept_2_curie , kg_set_edge_id , score , mcq = True )
11741179
11751180 # Add single result edges and auxiliary graphs
11761181 support_graphs = list ()
@@ -1196,7 +1201,7 @@ def _add_mcq_result(self, set_result, single_results, criteria):
11961201 "value" : support_graphs
11971202 })
11981203
1199- def _add_result (self , kg_node_1_id , kg_node_2_id , kg_edge_id , score ):
1204+ def _add_result (self , kg_node_1_id , kg_node_2_id , kg_edge_id , score , mcq = False ):
12001205 """ Adds a knowledge graph edge to the results list
12011206
12021207 Parameters
@@ -1205,6 +1210,7 @@ def _add_result(self, kg_node_1_id, kg_node_2_id, kg_edge_id, score):
12051210 kg_node_2_id: Object node ID
12061211 kg_edge_id: edge ID
12071212 score: result score
1213+ mcq: True/False if MCQ analysis
12081214
12091215 Returns
12101216 -------
@@ -1231,7 +1237,7 @@ def _add_result(self, kg_node_1_id, kg_node_2_id, kg_edge_id, score):
12311237 }]
12321238 },
12331239 'score' : score ,
1234- 'scoring_method' : 'Lower bound of biolink:ln_ratio_confidence_interval' ,
1240+ 'scoring_method' : 'COHD set-input query scoring, range: [0,1]' if mcq else ' Lower bound of biolink:ln_ratio_confidence_interval' ,
12351241 }
12361242 ]
12371243 }
@@ -1913,7 +1919,7 @@ def _add_kg_set_edge(self, node_2, is_subject, set_result):
19131919 'value_type_id' : 'EDAM:data_1772' , # Score
19141920 'attribute_source' : CohdTrapi ._INFORES_ID ,
19151921 'description' : 'Observed-expected frequency ratio.'
1916- },
1922+ },
19171923 {
19181924 'attribute_type_id' : 'biolink:supporting_data_set' , # Database ID
19191925 'original_attribute_name' : 'dataset_id' ,
0 commit comments