|
1
|
|
|
from __future__ import annotations |
|
|
|
|
|
|
2
|
|
|
import enum |
|
3
|
|
|
from typing import Union, Set |
|
4
|
|
|
|
|
5
|
|
|
from mandos.model.utils import CleverEnum |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class ActivityRelation(CleverEnum): |
|
|
|
|
|
|
9
|
|
|
lt = enum.auto() |
|
10
|
|
|
gt = enum.auto() |
|
11
|
|
|
le = enum.auto() |
|
12
|
|
|
ge = enum.auto() |
|
13
|
|
|
eq = enum.auto() |
|
14
|
|
|
approx = enum.auto() |
|
15
|
|
|
|
|
16
|
|
|
@classmethod |
|
17
|
|
|
def of(cls, name: Union[int, str]) -> CleverEnum: |
|
|
|
|
|
|
18
|
|
|
return super().of( |
|
19
|
|
|
{ |
|
20
|
|
|
"<": "lt", |
|
21
|
|
|
">": "gt", |
|
22
|
|
|
"=": "eq", |
|
23
|
|
|
"~": "approx", |
|
24
|
|
|
"<=": "le", |
|
25
|
|
|
">=": "ge", |
|
26
|
|
|
}.get(name, name) |
|
27
|
|
|
) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
class DataValidityComment(CleverEnum): |
|
|
|
|
|
|
31
|
|
|
potential_missing_data = enum.auto() |
|
32
|
|
|
potential_transcription_error = enum.auto() |
|
33
|
|
|
potential_author_error = enum.auto() |
|
34
|
|
|
manually_validated = enum.auto() |
|
35
|
|
|
outside_typical_range = enum.auto() |
|
36
|
|
|
non_standard_unit_for_type = enum.auto() |
|
37
|
|
|
author_confirmed_error = enum.auto() |
|
38
|
|
|
|
|
39
|
|
|
@classmethod |
|
40
|
|
|
def resolve(cls, st: str) -> Set[DataValidityComment]: |
|
|
|
|
|
|
41
|
|
|
found = set() |
|
42
|
|
|
for s in st.lower().split(","): |
|
|
|
|
|
|
43
|
|
|
s = s.strip() |
|
|
|
|
|
|
44
|
|
|
if s == "@all": |
|
45
|
|
|
return set(cls) |
|
46
|
|
|
if s == "@negative": |
|
47
|
|
|
match = DataValidityComment.negative_comments() |
|
48
|
|
|
elif s == "@positive": |
|
49
|
|
|
match = DataValidityComment.positive_comments() |
|
50
|
|
|
else: |
|
51
|
|
|
match = {DataValidityComment.of(s)} |
|
52
|
|
|
for m in match: |
|
|
|
|
|
|
53
|
|
|
found.add(m) |
|
54
|
|
|
return found |
|
55
|
|
|
|
|
56
|
|
|
@property |
|
57
|
|
|
def is_positive(self) -> bool: |
|
|
|
|
|
|
58
|
|
|
return self in DataValidityComment.positive_comments() |
|
59
|
|
|
|
|
60
|
|
|
@property |
|
61
|
|
|
def is_negative(self) -> bool: |
|
|
|
|
|
|
62
|
|
|
return self in DataValidityComment.negative_comments() |
|
63
|
|
|
|
|
64
|
|
|
@classmethod |
|
65
|
|
|
def positive_comments(cls) -> Set[DataValidityComment]: |
|
|
|
|
|
|
66
|
|
|
return {DataValidityComment.manually_validated} |
|
67
|
|
|
|
|
68
|
|
|
@classmethod |
|
69
|
|
|
def negative_comments(cls) -> Set[DataValidityComment]: |
|
|
|
|
|
|
70
|
|
|
return { |
|
71
|
|
|
DataValidityComment.potential_missing_data, |
|
72
|
|
|
DataValidityComment.potential_transcription_error, |
|
73
|
|
|
DataValidityComment.potential_author_error, |
|
74
|
|
|
DataValidityComment.outside_typical_range, |
|
75
|
|
|
DataValidityComment.non_standard_unit_for_type, |
|
76
|
|
|
DataValidityComment.author_confirmed_error, |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
class AssayType(enum.Enum): |
|
|
|
|
|
|
81
|
|
|
binding = enum.auto() |
|
82
|
|
|
functional = enum.auto() |
|
83
|
|
|
adme = enum.auto() |
|
84
|
|
|
physicochemical = enum.auto() |
|
85
|
|
|
|
|
86
|
|
|
@property |
|
87
|
|
|
def character(self) -> str: |
|
|
|
|
|
|
88
|
|
|
return { |
|
89
|
|
|
AssayType.binding: "B", |
|
90
|
|
|
AssayType.functional: "F", |
|
91
|
|
|
AssayType.adme: "A", |
|
92
|
|
|
AssayType.physicochemical: "P", |
|
93
|
|
|
}[self] |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
__all__ = [ |
|
97
|
|
|
"AssayType", |
|
98
|
|
|
"DataValidityComment", |
|
99
|
|
|
"ActivityRelation", |
|
100
|
|
|
] |
|
101
|
|
|
|