@@ -169,7 +169,7 @@ def get_ora_statements(
169
169
is_downstream : bool = False ,
170
170
* ,
171
171
client : Neo4jClient ,
172
- ) -> Tuple [List [Statement ], Mapping [int , int ]]:
172
+ ) -> Tuple [List [Statement ], Mapping [int , Mapping [ str , int ] ]]:
173
173
"""Get statements connecting input genes to target entity for ORA analysis.
174
174
175
175
Parameters
@@ -192,7 +192,7 @@ def get_ora_statements(
192
192
:
193
193
A tuple containing:
194
194
- List of INDRA statements representing the relationships
195
- - Dictionary mapping statement hashes to their evidence counts
195
+ - Dictionary mapping statement hashes to their source counts
196
196
"""
197
197
# Normalize gene IDs
198
198
normalized_genes = [norm_id ('HGNC' , gene .split (':' )[1 ]) for gene in genes ]
@@ -255,18 +255,15 @@ def get_ora_statements(
255
255
stmts = indra_stmts_from_relations (flattened_rels , deduplicate = True )
256
256
257
257
# Enrich statements with complete evidence (no limit)
258
- stmts = enrich_statements (
259
- stmts ,
260
- client = client
261
- )
258
+ stmts = enrich_statements (stmts , client = client )
262
259
263
- # Create evidence count mapping
264
- evidence_counts = {
265
- stmt . get_hash (): rel .data . get ( "evidence_count" , 0 )
266
- for rel , stmt in zip ( flattened_rels , stmts )
260
+ # Create source count mapping
261
+ source_counts = {
262
+ rel . data [ "stmt_hash" ]: json . loads ( rel .data [ "source_counts" ] )
263
+ for rel in flattened_rels
267
264
}
268
265
269
- return stmts , evidence_counts
266
+ return stmts , source_counts
270
267
271
268
272
269
@search_blueprint .route ("/ora_statements/" , methods = ['GET' ])
@@ -287,17 +284,21 @@ def search_ora_statements():
287
284
return jsonify ({"error" : "target_id and genes are required" }), 400
288
285
289
286
try :
290
- statements , evidence_counts = get_ora_statements (
287
+ statements , source_counts = get_ora_statements (
291
288
target_id = target_id ,
292
289
genes = genes ,
293
290
minimum_belief = minimum_belief ,
294
291
minimum_evidence = minimum_evidence ,
295
292
is_downstream = is_downstream
296
293
)
294
+ evidence_counts = {
295
+ k : sum (v .values ()) for k , v in source_counts .items ()
296
+ }
297
297
298
298
return render_statements (
299
299
stmts = statements ,
300
- evidence_count = evidence_counts
300
+ evidence_count = evidence_counts ,
301
+ source_counts_dict = source_counts
301
302
)
302
303
303
304
except Exception as e :
0 commit comments