fadliaulawi commited on
Commit
2b126e8
1 Parent(s): 5dd932f

Move validation function

Browse files
Files changed (1) hide show
  1. validate.py +1 -31
validate.py CHANGED
@@ -3,43 +3,13 @@ from dotenv import load_dotenv
3
  from langchain_google_genai import ChatGoogleGenerativeAI
4
  from langchain_openai import ChatOpenAI
5
  from prompt import *
6
- from utils import call, permutate
7
- from io import StringIO
8
 
9
  import os
10
- import pandas as pd
11
  import re
12
- import requests
13
 
14
  load_dotenv()
15
 
16
- raw_url = "https://www.ebi.ac.uk/gwas/api/search/downloads/alternative"
17
- gwas_path = "resources/gwas_catalog.tsv"
18
-
19
- # Load Raw GWAS files
20
- if os.path.exists(gwas_path):
21
- gwas = pd.read_csv(gwas_path, delimiter='\t')[['DISEASE/TRAIT', 'CHR_ID', 'MAPPED_GENE', 'SNPS', 'P-VALUE', 'OR or BETA']]
22
- else:
23
- data = requests.get(raw_url).content.decode('utf-8')
24
- gwas = pd.read_csv(StringIO(data), delimiter='\t')[['DISEASE/TRAIT', 'CHR_ID', 'MAPPED_GENE', 'SNPS', 'P-VALUE', 'OR or BETA']]
25
-
26
- # Load Genes and SNPs from GWAS
27
- gwas_gene_rsid = gwas[['MAPPED_GENE', 'SNPS']]
28
- gwas_gene_rsid.dropna(inplace=True, ignore_index=True)
29
- gwas_gene_rsid['MAPPED_GENE'] = gwas_gene_rsid['MAPPED_GENE'].apply(lambda x: x.replace(' ', '').upper())
30
-
31
- # Generate Genes and SNPs mapping
32
- ground_truth = defaultdict(list)
33
- for i in gwas_gene_rsid.index:
34
- gene = gwas_gene_rsid.loc[i, 'MAPPED_GENE']
35
- snp = gwas_gene_rsid.loc[i, 'SNPS']
36
-
37
- pattern = r"[,\-]"
38
- genes = re.split(pattern, gene)
39
- for gene in genes:
40
- ground_truth[gene].append(snp)
41
- ground_truth[snp].append(gene)
42
-
43
  class Validation():
44
 
45
  def __init__(self, llm):
 
3
  from langchain_google_genai import ChatGoogleGenerativeAI
4
  from langchain_openai import ChatOpenAI
5
  from prompt import *
6
+ from utils import *
 
7
 
8
  import os
 
9
  import re
 
10
 
11
  load_dotenv()
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  class Validation():
14
 
15
  def __init__(self, llm):