-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.py
57 lines (43 loc) · 1.05 KB
/
validate.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
46
47
48
49
50
51
52
53
54
55
56
57
from enum import IntEnum, Enum
import pandas as pd
from pydantic import BaseModel
class Ternary(IntEnum):
false = -1
unknown = 0
true = 1
class SourceType(Enum):
prediction = "prediction"
unknown = "unknown"
easi_fish = "easi_fish"
immunohistochemistry = "immunohistochemistry"
other = "other"
class Evidence(IntEnum):
"""
How strong the evidence is for the presence of a neurotransmitter in a cell type.
"""
limited = 1
moderate = 2"
strong = 3
class Row(BaseModel):
cell_type: str
acetylcholine: Ternary
glutamate: Ternary
gaba: Ternary
dopamine: Ternary
serotonin: Ternary
octopamine: Ternary
tyramine: Ternary
glycine: Ternary
histamine: Ternary
nitric_oxide: Ternary
source: str
source_type: SourceType
evidence: Evidence
def validate_row(row: dict) -> Row:
return Row(**row)
def validate_df(df):
return df.apply(validate_row, axis=1)
def test_example():
filename = "data.csv"
df = pd.read_csv(filename)
validate_df(df)