-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_data.py
45 lines (34 loc) · 1.7 KB
/
load_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
from annotator.models import Annotation, Drug, Person
Ani = Person.objects.get(last_name='Nguyen', first_name='Ani')
Luke = Person.objects.get(last_name='Ward', first_name='Luke')
Aimee = Person.objects.get(last_name='Deaton', first_name='Aimee')
def load_drugs(annotator):
drug_df = pd.read_excel('data/ceased_drugs_human_targets_' + annotator.first_name + '.xlsx')
column_to_index = dict([(c, i + 1) for i, c in enumerate(drug_df.columns)])
for record in drug_df.itertuples():
drug = Drug(
key=record[column_to_index['Drug Key (Unique ID)']],
name=record[column_to_index['Drug URL']],
overview=record[column_to_index['Overview']],
cl_phase_1=record[column_to_index['Key Clinical - Phase I']],
cl_phase_2=record[column_to_index['Key Clinical - Phase II']],
cl_phase_3=record[column_to_index['Key Clinical - Phase III']],
annotator=annotator,
)
drug.save()
print("Loaded {} drugs".format(len(drug_df)))
def load_annotations(annotator):
annotation_df = pd.read_excel('data/all_clinical_human_target_' + annotator.first_name + '.xlsx')
column_to_index = dict([(c, i + 1) for i, c in enumerate(annotation_df.columns)])
for record in annotation_df.itertuples():
mdr = record[column_to_index['mdr1']]
if mdr == '<none>':
mdr = record[column_to_index['mdr2']]
annotation = Annotation(
key=Drug.objects.get(key=record[column_to_index['Drug.Key..Unique.ID.']]),
cui=record[column_to_index['cui']],
mdr1=mdr,
)
annotation.save()
print("Loaded {} annotations".format(len(annotation_df)))