stefan-insilico commited on
Commit
6daea16
1 Parent(s): 63af785

Update handler.py

Browse files

Fixed error "setting an array element with a sequence. "

Files changed (1) hide show
  1. handler.py +17 -7
handler.py CHANGED
@@ -76,10 +76,10 @@ class EndpointHandler:
76
  if k == 'instruction':
77
  prompt += f'<{v}>' if isinstance(v, str) else "".join([f'<{v_i}>' for v_i in v])
78
  elif k == 'up':
79
- if v and len(prompt_config['drug']) != 0:
80
  prompt += f'{multi_modal_prefix}<{k}>{v} </{k}>' if isinstance(v, str) else f'{multi_modal_prefix}<{k}>{" ".join(v)} </{k}>'
81
  elif k == 'down':
82
- if v and "drug" in list(prompt_config.keys()):
83
  prompt += f'{multi_modal_prefix}<{k}>{v} </{k}>' if isinstance(v, str) else f'{multi_modal_prefix}<{k}>{" ".join(v)} </{k}>'
84
  elif k == 'age':
85
  if isinstance(v, int):
@@ -327,9 +327,13 @@ class EndpointHandler:
327
  acc_embs_up1 = []
328
  acc_embs_up2 = []
329
  if 'up' in config_data:
330
- for gs in config_data['up']:
331
- acc_embs_up1.append(self.emb_hgt_genes.get(gs))
332
- acc_embs_up2.append(self.emb_gpt_genes.get(gs))
 
 
 
 
333
 
334
  acc_embs_up1_mean = np.array(acc_embs_up1).mean(0) if acc_embs_up1 else None
335
  acc_embs_up2_mean = np.array(acc_embs_up2).mean(0) if acc_embs_up2 else None
@@ -338,8 +342,14 @@ class EndpointHandler:
338
  acc_embs_down2 = []
339
  if 'down' in config_data:
340
  for gs in config_data['down']:
341
- acc_embs_down1.append(self.emb_hgt_genes.get(gs))
342
- acc_embs_down2.append(self.emb_gpt_genes.get(gs))
 
 
 
 
 
 
343
 
344
  acc_embs_down1_mean = np.array(acc_embs_down1).mean(0) if acc_embs_down1 else None
345
  acc_embs_down2_mean = np.array(acc_embs_down2).mean(0) if acc_embs_down2 else None
 
76
  if k == 'instruction':
77
  prompt += f'<{v}>' if isinstance(v, str) else "".join([f'<{v_i}>' for v_i in v])
78
  elif k == 'up':
79
+ if v:
80
  prompt += f'{multi_modal_prefix}<{k}>{v} </{k}>' if isinstance(v, str) else f'{multi_modal_prefix}<{k}>{" ".join(v)} </{k}>'
81
  elif k == 'down':
82
+ if v:
83
  prompt += f'{multi_modal_prefix}<{k}>{v} </{k}>' if isinstance(v, str) else f'{multi_modal_prefix}<{k}>{" ".join(v)} </{k}>'
84
  elif k == 'age':
85
  if isinstance(v, int):
 
327
  acc_embs_up1 = []
328
  acc_embs_up2 = []
329
  if 'up' in config_data:
330
+ for gs in config_data['up']:
331
+ try:
332
+ acc_embs_up1.append(self.emb_hgt_genes[gs])
333
+ acc_embs_up2.append(self.emb_gpt_genes[gs])
334
+ except Exception as e:
335
+ pass
336
+
337
 
338
  acc_embs_up1_mean = np.array(acc_embs_up1).mean(0) if acc_embs_up1 else None
339
  acc_embs_up2_mean = np.array(acc_embs_up2).mean(0) if acc_embs_up2 else None
 
342
  acc_embs_down2 = []
343
  if 'down' in config_data:
344
  for gs in config_data['down']:
345
+ try:
346
+ acc_embs_down1.append(self.emb_hgt_genes[gs])
347
+ acc_embs_down2.append(self.emb_gpt_genes[gs])
348
+ except Exception as e:
349
+ pass
350
+ # for gs in config_data['down']:
351
+ # acc_embs_down1.append(self.emb_hgt_genes.get(gs))
352
+ # acc_embs_down2.append(self.emb_gpt_genes.get(gs))
353
 
354
  acc_embs_down1_mean = np.array(acc_embs_down1).mean(0) if acc_embs_down1 else None
355
  acc_embs_down2_mean = np.array(acc_embs_down2).mean(0) if acc_embs_down2 else None