@@ -257,27 +257,28 @@ def search(raw_req):
257257 headers = {
258258 "X-Service-Token" : create_service_token ()
259259 }
260- resp = requests .get (url = f"{ os .getenv ("DRS_URL" )} /ga4gh/drs/v1/objects" , headers = headers )
261- drs_obj_dict = {}
260+ resp = requests .post (url = f"{ os .getenv ("DRS_URL" )} /ga4gh/drs/v1/experiments" , headers = headers , json = {})
261+
262+ exp_lookup = {}
262263 if resp .status_code == 200 :
263- drs_objects = resp .json ()
264- for obj in drs_objects :
265- drs_obj_dict [obj ["id" ]] = obj
264+ for exp in resp .json ():
265+ for v in exp ["variants" ]:
266+ if v not in exp_lookup :
267+ exp_lookup [v ] = []
268+ exp_lookup [v ].append (exp )
269+ else :
270+ raise Exception (f"couldn't get experiments: { resp .text } { resp .status_code } " )
266271
267272 hits_to_search = []
268273 for i in range (len (potential_hits )):
269274 drs_obj_id = potential_hits [i ]['drs_object_id' ]
270-
271- drs_obj = drs_obj_dict [drs_obj_id ]
272- if "program" in drs_obj :
273- if drs_obj ["program" ] not in results :
274- results [drs_obj ["program" ]] = []
275- for c in drs_obj ["contents" ]:
276- if c ["id" ] not in ["analysis" , "index" ]:
277- # this is a ExperimentContentObject
278- res = {"submitter_sample_id" : c ["name" ], "variant_count" : potential_hits [i ]["variantcount" ]}
279- results [drs_obj ["program" ]].append (res )
280- hits_to_search .append (potential_hits [i ])
275+ experiments = exp_lookup [drs_obj_id ]
276+ for experiment in experiments :
277+ if experiment ["program" ] not in results :
278+ results [experiment ["program" ]] = []
279+ res = {"submitter_sample_id" : experiment ["experiment_id" ], "variant_count" : potential_hits [i ]["variantcount" ]}
280+ results [experiment ["program" ]].append (res )
281+ hits_to_search .append (potential_hits [i ])
281282
282283 search_json = {
283284 "potential_hits" : hits_to_search ,
0 commit comments