-
Notifications
You must be signed in to change notification settings - Fork 0
/
peaks_main.py
212 lines (188 loc) · 7.56 KB
/
peaks_main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
from ctypes import c_long
import apvalidation.peak_validator as peaks
unicode_dashes = " - ־ ᠆ ‐ ‑ ‒ - – — ― ⁻ ₋ − ﹘ ﹣ -"
def test_validate():
smiles_string = "O=C1CCC[C@@]2([H])C(CCC[C@@]21[H])=O"
H_valid = "13.0, (13.5-13.9), 15.5, 15.3, 12.4 ₋ 14.6"
H_bug = "10, (10-11), 10"
H_invalid_characters = "1H NMR (CD3OD, 500 MHz) δ 1.03 (d, J = 7.0 Hz, 3H, H-8)"
H_invalid_list_format = "13 (13.5-14.2) 34.5 67.3 12.4 ₋ 14.6"
H_warning_range = "19, (13.5-13.9), 15.5, 15.3, 12.4 ₋ 14.6"
H_invalid_range = "13, (13.5 14.2), 34.5, 67.3, (12.4, 14.6)"
H_invalid_number = "10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10"
temp_warning = 360
freq_warning = 1500
temp_error = -20
freq_error = -20
C_valid = "20, (20.5-25.2), 64.7, 76.3, 21.4 ₋ 22.6"
C_invalid_characters = "1H NMR (CD3OD, 500 MHz) δ 1.03 (d, J = 7.0 Hz, 3H, H-8)"
C_invalid_list_format = "11 (11.5-15.2) 64.7 76.3 1.4 ₋ 19.6"
C_warning_range = "250, (20.5-25.2), 64.7, 76.3, 21.4 ₋ 22.6"
C_invalid_range = "11, (11.5,15.2), 64.7, 76.3, 1.4 ₋ 19.6"
temp_valid = 300
freq_valid = 800
output_valid = peaks.Validate.validate(
H_text_block = H_valid,
C_text_block = C_valid,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_valid,
h_temperature = temp_valid,
c_frequency = freq_valid,
c_temperature = temp_valid,
reference = "test_reference"
)
print(f"Valid: {output_valid}")
invalid_number = peaks.Validate.validate(
H_text_block = H_invalid_number,
C_text_block = C_valid,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_valid,
h_temperature = temp_valid,
c_frequency = freq_valid,
c_temperature = temp_valid,
reference = "test_reference"
)
print(f"Invalid Number of H atoms: {invalid_number}")
output_warning_ranges = peaks.Validate.validate(
H_text_block = H_warning_range,
C_text_block = C_warning_range,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_warning,
h_temperature = temp_warning,
c_frequency = freq_warning,
c_temperature = temp_warning,
reference = "test_reference",
)
print(f"Warning Ranges: {output_warning_ranges}")
invalid_temp_freq = peaks.Validate.validate(
H_text_block = H_valid,
C_text_block = C_valid,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_valid,
h_temperature = temp_error,
c_frequency = freq_valid,
c_temperature = temp_error,
reference = "test_reference"
)
print(f"Invalid Temp Freq: {invalid_temp_freq}")
output_invalid_characters = peaks.Validate.validate(
H_text_block = H_invalid_range,
C_text_block = C_invalid_range,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_warning,
h_temperature = temp_warning,
c_frequency = freq_warning,
c_temperature = temp_warning,
reference = "test_reference",
)
print(f"Invalid Characters: {output_invalid_characters}")
output_invalid_list_format = peaks.Validate.validate(
H_text_block = H_invalid_list_format,
C_text_block = C_invalid_list_format,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = temp_valid,
h_temperature = freq_valid,
c_frequency = temp_valid,
c_temperature = freq_valid,
reference = "test_reference",
)
print(f"Invalid List: {output_invalid_list_format}")
output_invalid_range = peaks.Validate.validate(
H_text_block = H_invalid_range,
C_text_block = C_invalid_range,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = temp_valid,
h_temperature = freq_valid,
c_frequency = temp_valid,
c_temperature = freq_valid,
reference = "test_reference",
)
print(f"Invalid Range: {output_invalid_range}")
output_no_temp = peaks.Validate.validate(
H_text_block = H_valid,
C_text_block = C_valid,
smiles = smiles_string,
solvent = "test_solvent",
h_frequency = freq_valid,
h_temperature = None,
c_frequency = freq_valid,
c_temperature = None,
reference = "test_reference"
)
print(f"No Temperature: {output_no_temp}")
test_parse = peaks.Convert.convert_to_float_list(H_valid)
test_parse_sort = peaks.Convert.sort_list_desc(test_parse)
print(f"TEST CONVERT VALID: {test_parse_sort}")
test_parse_bug = peaks.Convert.convert_to_float_list(H_bug)
print(f"TEST CONVERT BUG: {test_parse_bug}")
test_parse_bug_sort = peaks.Convert.sort_list_desc(test_parse_bug)
print(f"TEST CONVERT BUG ORDER: {test_parse_bug_sort}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = H_valid,
C_text_block = C_valid,
smiles = smiles_string,
)
print(f"Lecay Validate: {legacy_ver_test}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = "",
C_text_block = C_valid,
smiles = smiles_string,
)
print(f"Legacy H 空っぽ: {legacy_ver_test}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = H_valid,
C_text_block = "",
smiles = smiles_string,
)
print(f"Legacy C 空っぽ: {legacy_ver_test}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = "",
C_text_block = "",
smiles = smiles_string,
)
print(f"Legacy 二つ空っぽ: {legacy_ver_test}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = "sdf",
C_text_block = "dsf",
smiles = smiles_string,
)
print(f"Legacy invalid char: {legacy_ver_test}")
legacy_ver_test = peaks.Validate.legacy_validate(
H_text_block = H_warning_range,
C_text_block = C_warning_range,
smiles = smiles_string,
)
print(f"Legacy warning: {legacy_ver_test}")
# def test_sanghoon():
# H_test1 = "11.87, 8.85, 8.83, 8.83, 8.52, 8.50, 8.14, 8.10, 8.09, 8.08, 8.08, 8.07, 8.07, 7.62, 7.62, 7.61, 7.61, 7.61, 7.61, 7.60, 7.60, 4.18, 2.46"
# C_test1 = "166.83, 155.98, 154.49, 152.69, 149.21, 146.77, 137.35, 124.64, 121.07, 120.78, 102.91, 56.34, 17.82"
# smiles_test1 = "COC1=CC(C2=CC=CC=N2)=NC(/C=N/O)=C1SC"
# output_test1 = peaks.Validate.validate(H_test1, C_test1, smiles_test1, )
# print(f"Test1: {output_test1}")
# if output_test1 == "Both lists are valid":
# converted_H_list1 = peaks.Convert.convert(H_test1)
# converted_C_list1 = peaks.Convert.convert(C_test1)
# print(f"Converted H test1: {converted_H_list1}")
# print(f"Converted C test1: {converted_C_list1}")
# def test_convert():
# H_invalid = "13.0, (13.5-13.9), 34.5, 67.3, 12.4 ₋ 14.6"
# C_valid = "140, 25, 75, 100, 54"
# smiles_test = "COC1=CC(C2=CC=CC=N2)=NC(/C=N/O)=C1SC"
# validation_test = peaks.Validate.validate(H_invalid, C_valid, smiles_test)
# print(validation_test)
# if validation_test == "Both lists are valid":
# converted_list = peaks.Convert.convert(H_invalid)
# original_list = H_invalid
# print(f'Converted: {converted_list}')
# print(f'Original {original_list}')
# Test Validate
test_validate()
# test_convert()
# test_sanghoon()