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