pychemstation 0.8.3__py3-none-any.whl → 0.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pychemstation/analysis/__init__.py +4 -0
- pychemstation/analysis/base_spectrum.py +9 -9
- pychemstation/analysis/process_report.py +13 -7
- pychemstation/analysis/utils.py +1 -3
- pychemstation/control/__init__.py +4 -0
- pychemstation/control/comm.py +206 -0
- pychemstation/control/controllers/__init__.py +6 -0
- pychemstation/control/controllers/comm.py +12 -5
- pychemstation/control/controllers/devices/column.py +12 -0
- pychemstation/control/controllers/devices/dad.py +0 -0
- pychemstation/control/controllers/devices/device.py +10 -7
- pychemstation/control/controllers/devices/injector.py +18 -84
- pychemstation/control/controllers/devices/pump.py +43 -0
- pychemstation/control/controllers/method.py +338 -0
- pychemstation/control/controllers/sequence.py +190 -0
- pychemstation/control/controllers/table_controller.py +266 -0
- pychemstation/control/controllers/tables/method.py +35 -13
- pychemstation/control/controllers/tables/sequence.py +46 -37
- pychemstation/control/controllers/tables/table.py +46 -30
- pychemstation/control/hplc.py +27 -11
- pychemstation/control/table/__init__.py +3 -0
- pychemstation/control/table/method.py +274 -0
- pychemstation/control/table/sequence.py +210 -0
- pychemstation/control/table/table_controller.py +201 -0
- pychemstation/generated/dad_method.py +1 -1
- pychemstation/generated/pump_method.py +1 -1
- pychemstation/utils/chromatogram.py +2 -5
- pychemstation/utils/injector_types.py +1 -1
- pychemstation/utils/macro.py +3 -3
- pychemstation/utils/method_types.py +2 -2
- pychemstation/utils/num_utils.py +65 -0
- pychemstation/utils/parsing.py +1 -0
- pychemstation/utils/sequence_types.py +3 -3
- pychemstation/utils/spec_utils.py +304 -0
- {pychemstation-0.8.3.dist-info → pychemstation-0.10.0.dist-info}/METADATA +19 -8
- pychemstation-0.10.0.dist-info/RECORD +62 -0
- {pychemstation-0.8.3.dist-info → pychemstation-0.10.0.dist-info}/WHEEL +2 -1
- pychemstation-0.10.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/constants.py +134 -0
- tests/test_comb.py +136 -0
- tests/test_comm.py +65 -0
- tests/test_inj.py +39 -0
- tests/test_method.py +99 -0
- tests/test_nightly.py +80 -0
- tests/test_offline_stable.py +69 -0
- tests/test_online_stable.py +275 -0
- tests/test_proc_rep.py +52 -0
- tests/test_runs_stable.py +225 -0
- tests/test_sequence.py +125 -0
- tests/test_stable.py +276 -0
- pychemstation/control/README.md +0 -124
- pychemstation/control/controllers/README.md +0 -1
- pychemstation-0.8.3.dist-info/RECORD +0 -37
- {pychemstation-0.8.3.dist-info → pychemstation-0.10.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
import os
|
2
|
+
import unittest
|
3
|
+
|
4
|
+
from pychemstation.utils.macro import Command, HPLCAvailStatus, HPLCRunningStatus
|
5
|
+
from pychemstation.utils.method_types import (
|
6
|
+
HPLCMethodParams,
|
7
|
+
MethodDetails,
|
8
|
+
TimeTableEntry,
|
9
|
+
)
|
10
|
+
from pychemstation.utils.sequence_types import (
|
11
|
+
InjectionSource,
|
12
|
+
SampleType,
|
13
|
+
SequenceEntry,
|
14
|
+
SequenceTable,
|
15
|
+
)
|
16
|
+
from pychemstation.utils.tray_types import (
|
17
|
+
FiftyFourVialPlate,
|
18
|
+
Letter,
|
19
|
+
Num,
|
20
|
+
Plate,
|
21
|
+
TenVialColumn,
|
22
|
+
)
|
23
|
+
from tests.constants import (
|
24
|
+
DEFAULT_METHOD,
|
25
|
+
DEFAULT_SEQUENCE,
|
26
|
+
VIAL_PLATES,
|
27
|
+
clean_up,
|
28
|
+
gen_rand_method,
|
29
|
+
set_up_utils,
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
class TestStable(unittest.TestCase):
|
34
|
+
"""
|
35
|
+
These tests should always work with an online controller.
|
36
|
+
"""
|
37
|
+
def setUp(self):
|
38
|
+
self.hplc_controller = set_up_utils(242, offline=False, runs=False)
|
39
|
+
|
40
|
+
def tearDown(self):
|
41
|
+
clean_up(self.hplc_controller)
|
42
|
+
|
43
|
+
def test_load_inj(self):
|
44
|
+
try:
|
45
|
+
inj_table = self.hplc_controller.load_injector_program()
|
46
|
+
self.assertTrue(len(inj_table.functions) == 2)
|
47
|
+
except Exception as e:
|
48
|
+
self.fail(f"Should have not failed, {e}")
|
49
|
+
|
50
|
+
def test_status_check_standby(self):
|
51
|
+
self.hplc_controller.standby()
|
52
|
+
self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.STANDBY, HPLCRunningStatus.NOTREADY])
|
53
|
+
|
54
|
+
def test_status_check_preprun(self):
|
55
|
+
self.hplc_controller.preprun()
|
56
|
+
self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.PRERUN, HPLCAvailStatus.STANDBY,
|
57
|
+
HPLCRunningStatus.NOTREADY])
|
58
|
+
|
59
|
+
def test_send_command(self):
|
60
|
+
try:
|
61
|
+
self.hplc_controller.send(Command.GET_METHOD_CMD)
|
62
|
+
except Exception as e:
|
63
|
+
self.fail(f"Should not throw error: {e}")
|
64
|
+
|
65
|
+
def test_send_str(self):
|
66
|
+
try:
|
67
|
+
self.hplc_controller.send("Local TestNum")
|
68
|
+
self.hplc_controller.send("TestNum = 0")
|
69
|
+
self.hplc_controller.send("Print TestNum")
|
70
|
+
self.hplc_controller.send("response_num = TestNum")
|
71
|
+
self.hplc_controller.send("Print response_num")
|
72
|
+
except Exception as e:
|
73
|
+
self.fail(f"Should not throw error: {e}")
|
74
|
+
|
75
|
+
def test_get_num(self):
|
76
|
+
try:
|
77
|
+
self.hplc_controller.send("response_num = 10")
|
78
|
+
res = self.hplc_controller.receive().num_response
|
79
|
+
self.assertEqual(res, 10)
|
80
|
+
except Exception as e:
|
81
|
+
self.fail(f"Should not throw error: {e}")
|
82
|
+
|
83
|
+
def test_get_response(self):
|
84
|
+
try:
|
85
|
+
self.hplc_controller.switch_method(method_name=DEFAULT_METHOD)
|
86
|
+
self.hplc_controller.send(Command.GET_METHOD_CMD)
|
87
|
+
res = self.hplc_controller.receive()
|
88
|
+
self.assertTrue(DEFAULT_METHOD in res.string_response)
|
89
|
+
except Exception as e:
|
90
|
+
self.fail(f"Should not throw error: {e}")
|
91
|
+
|
92
|
+
def test_edit_method(self):
|
93
|
+
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
94
|
+
new_method = MethodDetails(name=DEFAULT_METHOD + ".M",
|
95
|
+
timetable=[TimeTableEntry(start_time=1.0,
|
96
|
+
organic_modifer=20.0,
|
97
|
+
flow=0.65),
|
98
|
+
TimeTableEntry(start_time=2.0,
|
99
|
+
organic_modifer=30.0,
|
100
|
+
flow=0.65),
|
101
|
+
TimeTableEntry(start_time=2.5,
|
102
|
+
organic_modifer=60.0,
|
103
|
+
flow=0.65),
|
104
|
+
TimeTableEntry(start_time=3.0,
|
105
|
+
organic_modifer=80.0,
|
106
|
+
flow=0.65),
|
107
|
+
TimeTableEntry(start_time=3.5,
|
108
|
+
organic_modifer=100.0,
|
109
|
+
flow=0.65)],
|
110
|
+
stop_time=4.0,
|
111
|
+
post_time=1.0,
|
112
|
+
params=HPLCMethodParams(organic_modifier=5.0, flow=0.65))
|
113
|
+
try:
|
114
|
+
self.hplc_controller.edit_method(new_method)
|
115
|
+
self.assertEqual(new_method, self.hplc_controller.load_method())
|
116
|
+
except Exception as e:
|
117
|
+
self.fail(f"Should have not failed: {e}")
|
118
|
+
|
119
|
+
def test_load_method(self):
|
120
|
+
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
121
|
+
new_method = gen_rand_method()
|
122
|
+
try:
|
123
|
+
self.hplc_controller.edit_method(new_method)
|
124
|
+
loaded_method = self.hplc_controller.load_method()
|
125
|
+
self.assertEqual(new_method.params.organic_modifier,
|
126
|
+
loaded_method.params.organic_modifier)
|
127
|
+
self.assertEqual(new_method.timetable[0].organic_modifer,
|
128
|
+
loaded_method.timetable[0].organic_modifer)
|
129
|
+
self.assertEqual(round(new_method.params.flow, 2),
|
130
|
+
round(loaded_method.params.flow, 2))
|
131
|
+
except Exception as e:
|
132
|
+
self.fail(f"Should have not failed: {e}")
|
133
|
+
|
134
|
+
def test_switch_seq(self):
|
135
|
+
try:
|
136
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
137
|
+
except Exception as e:
|
138
|
+
self.fail(f"Should have not expected: {e}")
|
139
|
+
|
140
|
+
def test_read_seq(self):
|
141
|
+
try:
|
142
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
143
|
+
table = self.hplc_controller.load_sequence()
|
144
|
+
self.assertTrue(table)
|
145
|
+
except Exception as e:
|
146
|
+
self.fail(f"Should have not expected: {e}")
|
147
|
+
|
148
|
+
def test_edit_entire_seq_table(self):
|
149
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
150
|
+
seq_folder = self.hplc_controller.sequence_controller.src
|
151
|
+
meth_path = os.path.join(seq_folder, DEFAULT_METHOD)
|
152
|
+
try:
|
153
|
+
seq_table = SequenceTable(
|
154
|
+
name=DEFAULT_SEQUENCE,
|
155
|
+
rows=[
|
156
|
+
SequenceEntry(
|
157
|
+
vial_location=TenVialColumn.ONE,
|
158
|
+
method=meth_path,
|
159
|
+
num_inj=3,
|
160
|
+
inj_vol=4,
|
161
|
+
sample_name="Sampel1",
|
162
|
+
sample_type=SampleType.SAMPLE,
|
163
|
+
inj_source=InjectionSource.HIP_ALS
|
164
|
+
),
|
165
|
+
SequenceEntry(
|
166
|
+
vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.ONE),
|
167
|
+
method=meth_path,
|
168
|
+
num_inj=3,
|
169
|
+
inj_vol=4,
|
170
|
+
sample_name="Sampel2",
|
171
|
+
sample_type=SampleType.SAMPLE,
|
172
|
+
inj_source=InjectionSource.HIP_ALS
|
173
|
+
),
|
174
|
+
SequenceEntry(
|
175
|
+
vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.TWO),
|
176
|
+
method=meth_path,
|
177
|
+
num_inj=3,
|
178
|
+
inj_vol=4,
|
179
|
+
sample_name="Sampel2",
|
180
|
+
sample_type=SampleType.SAMPLE,
|
181
|
+
inj_source=InjectionSource.HIP_ALS
|
182
|
+
),
|
183
|
+
SequenceEntry(
|
184
|
+
vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.THREE),
|
185
|
+
method=meth_path,
|
186
|
+
num_inj=3,
|
187
|
+
inj_vol=4,
|
188
|
+
sample_name="Sampel2",
|
189
|
+
sample_type=SampleType.SAMPLE,
|
190
|
+
inj_source=InjectionSource.HIP_ALS
|
191
|
+
)
|
192
|
+
]
|
193
|
+
)
|
194
|
+
self.hplc_controller.edit_sequence(seq_table)
|
195
|
+
self.assertEqual(seq_table,
|
196
|
+
self.hplc_controller.load_sequence())
|
197
|
+
except Exception:
|
198
|
+
self.fail("Should have not occured")
|
199
|
+
|
200
|
+
def test_edit_entire_table_less_rows(self):
|
201
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
202
|
+
try:
|
203
|
+
seq_table = SequenceTable(
|
204
|
+
name=DEFAULT_SEQUENCE,
|
205
|
+
rows=[
|
206
|
+
SequenceEntry(
|
207
|
+
vial_location=TenVialColumn.TEN,
|
208
|
+
method=DEFAULT_METHOD,
|
209
|
+
num_inj=3,
|
210
|
+
inj_vol=4,
|
211
|
+
sample_name="Sampel2",
|
212
|
+
sample_type=SampleType.SAMPLE,
|
213
|
+
inj_source=InjectionSource.HIP_ALS
|
214
|
+
),
|
215
|
+
SequenceEntry(
|
216
|
+
vial_location=TenVialColumn.THREE,
|
217
|
+
method=DEFAULT_METHOD,
|
218
|
+
num_inj=3,
|
219
|
+
inj_vol=4,
|
220
|
+
sample_name="Sampel2",
|
221
|
+
sample_type=SampleType.SAMPLE,
|
222
|
+
inj_source=InjectionSource.HIP_ALS
|
223
|
+
)
|
224
|
+
]
|
225
|
+
)
|
226
|
+
self.hplc_controller.edit_sequence(seq_table)
|
227
|
+
except Exception:
|
228
|
+
self.fail("Should have not occured")
|
229
|
+
|
230
|
+
def test_load(self):
|
231
|
+
try:
|
232
|
+
seq = self.hplc_controller.load_sequence()
|
233
|
+
self.assertTrue(len(seq.rows) > 0)
|
234
|
+
except Exception as e:
|
235
|
+
self.fail(f"Should have not expected: {e}")
|
236
|
+
|
237
|
+
def test_tray_nums(self):
|
238
|
+
seq_table = SequenceTable(
|
239
|
+
name=DEFAULT_SEQUENCE,
|
240
|
+
rows=[
|
241
|
+
SequenceEntry(
|
242
|
+
vial_location=v,
|
243
|
+
method=DEFAULT_METHOD,
|
244
|
+
num_inj=3,
|
245
|
+
inj_vol=4,
|
246
|
+
sample_name="Sampel2",
|
247
|
+
sample_type=SampleType.SAMPLE,
|
248
|
+
inj_source=InjectionSource.HIP_ALS
|
249
|
+
) for v in VIAL_PLATES
|
250
|
+
]
|
251
|
+
)
|
252
|
+
self.hplc_controller.edit_sequence(seq_table)
|
253
|
+
loaded_table = self.hplc_controller.load_sequence()
|
254
|
+
for i in range(len(VIAL_PLATES)):
|
255
|
+
self.assertTrue(VIAL_PLATES[i].value()
|
256
|
+
== seq_table.rows[i].vial_location.value()
|
257
|
+
== loaded_table.rows[i].vial_location.value())
|
258
|
+
|
259
|
+
def test_tray_nums_only(self):
|
260
|
+
for i in range(len(VIAL_PLATES)):
|
261
|
+
self.assertEqual(VIAL_PLATES[i], FiftyFourVialPlate.from_int(VIAL_PLATES[i].value()))
|
262
|
+
|
263
|
+
def test_plate_number(self):
|
264
|
+
self.assertEqual(FiftyFourVialPlate.from_str("P1-A4").value(),
|
265
|
+
FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.FOUR).value())
|
266
|
+
|
267
|
+
def test_method_switch_load(self):
|
268
|
+
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
269
|
+
self.assertEqual(DEFAULT_METHOD, self.hplc_controller.check_loaded_method()[:-2])
|
270
|
+
self.hplc_controller.switch_method("GENERAL-POROSHELL-JD")
|
271
|
+
self.assertEqual("GENERAL-POROSHELL-JD", self.hplc_controller.check_loaded_method()[:-2])
|
272
|
+
|
273
|
+
|
274
|
+
if __name__ == '__main__':
|
275
|
+
unittest.main()
|
tests/test_proc_rep.py
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
from result import Result
|
4
|
+
|
5
|
+
from pychemstation.analysis.process_report import process_csv_report
|
6
|
+
|
7
|
+
|
8
|
+
class TestReport(unittest.TestCase):
|
9
|
+
|
10
|
+
def test_build_peak_regex(self):
|
11
|
+
try:
|
12
|
+
# TODO
|
13
|
+
print('yes')
|
14
|
+
except Exception as e:
|
15
|
+
self.fail(f"Should have not failed, {e}")
|
16
|
+
|
17
|
+
def test_parse_area_report(self):
|
18
|
+
try:
|
19
|
+
# TODO
|
20
|
+
print('yes')
|
21
|
+
except Exception as e:
|
22
|
+
self.fail(f"Should have not failed, {e}")
|
23
|
+
|
24
|
+
def test_process_export_report(self):
|
25
|
+
try:
|
26
|
+
import pandas as pd
|
27
|
+
|
28
|
+
file_path = "/Users/lucyhao/Codes/pychemstation/tests/0_2025-03-15 19-14-35.D/Report00.CSV"
|
29
|
+
df = pd.read_csv(file_path, encoding="utf-16")
|
30
|
+
|
31
|
+
# Print the first column
|
32
|
+
print(df)
|
33
|
+
except Exception as e:
|
34
|
+
self.fail(f"Should have not failed, {e}")
|
35
|
+
|
36
|
+
def test_process_folder(self):
|
37
|
+
try:
|
38
|
+
# TODO
|
39
|
+
print('yes')
|
40
|
+
except Exception as e:
|
41
|
+
self.fail(f"Should have not failed, {e}")
|
42
|
+
|
43
|
+
def test_report_csv(self):
|
44
|
+
try:
|
45
|
+
report: Result = process_csv_report(folder_path="0_2025-03-15 19-14-35.D")
|
46
|
+
print(report)
|
47
|
+
except Exception as e:
|
48
|
+
self.fail(f"Should have not failed: {e}")
|
49
|
+
|
50
|
+
|
51
|
+
if __name__ == '__main__':
|
52
|
+
unittest.main()
|
@@ -0,0 +1,225 @@
|
|
1
|
+
import time
|
2
|
+
import unittest
|
3
|
+
|
4
|
+
from pychemstation.utils.method_types import (
|
5
|
+
HPLCMethodParams,
|
6
|
+
MethodDetails,
|
7
|
+
TimeTableEntry,
|
8
|
+
)
|
9
|
+
from pychemstation.utils.sequence_types import (
|
10
|
+
InjectionSource,
|
11
|
+
SampleType,
|
12
|
+
SequenceEntry,
|
13
|
+
SequenceTable,
|
14
|
+
)
|
15
|
+
from pychemstation.utils.tray_types import FiftyFourVialPlate, Letter, Num, Plate
|
16
|
+
from tests.constants import DEFAULT_METHOD, DEFAULT_SEQUENCE, clean_up, set_up_utils
|
17
|
+
|
18
|
+
|
19
|
+
class TestRunsStable(unittest.TestCase):
|
20
|
+
def setUp(self):
|
21
|
+
self.hplc_controller = set_up_utils(242, offline=False, runs=True)
|
22
|
+
|
23
|
+
def tearDown(self):
|
24
|
+
clean_up(self.hplc_controller)
|
25
|
+
|
26
|
+
def test_run_method_many_times(self):
|
27
|
+
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
28
|
+
rand_method = MethodDetails(
|
29
|
+
name=DEFAULT_METHOD,
|
30
|
+
params=HPLCMethodParams(organic_modifier=5, flow=0.65),
|
31
|
+
timetable=[TimeTableEntry(start_time=0.5, organic_modifer=100, flow=0.65)],
|
32
|
+
stop_time=1,
|
33
|
+
post_time=0.5,
|
34
|
+
)
|
35
|
+
self.hplc_controller.edit_method(rand_method, save=True)
|
36
|
+
try:
|
37
|
+
for _ in range(5):
|
38
|
+
self.hplc_controller.run_method(experiment_name="test_experiment")
|
39
|
+
chrom = self.hplc_controller.get_last_run_method_data()
|
40
|
+
uv = self.hplc_controller.get_last_run_method_data(read_uv=True)
|
41
|
+
repos = self.hplc_controller.get_last_run_method_report()
|
42
|
+
self.assertEqual(repos.vial_location, FiftyFourVialPlate.from_str("P1-A3"))
|
43
|
+
self.assertEqual(repos.signals[0].wavelength, '210')
|
44
|
+
self.assertIsNotNone(repos.signals[0].data, )
|
45
|
+
self.assertTrue(210 in uv.keys())
|
46
|
+
self.assertTrue(len(chrom.A.x) > 0)
|
47
|
+
self.assertIsNone(chrom.F.x)
|
48
|
+
except Exception as e:
|
49
|
+
self.fail(f"Should have not failed: {e}")
|
50
|
+
|
51
|
+
def test_update_method_update_seq_table_run(self):
|
52
|
+
try:
|
53
|
+
loc = FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.TWO)
|
54
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
55
|
+
seq_table = SequenceTable(
|
56
|
+
name=DEFAULT_SEQUENCE,
|
57
|
+
rows=[SequenceEntry(
|
58
|
+
vial_location=loc,
|
59
|
+
sample_name="run seq with new method",
|
60
|
+
method="GENERAL-POROSHELL-JD",
|
61
|
+
inj_source=InjectionSource.HIP_ALS,
|
62
|
+
inj_vol=0.5,
|
63
|
+
num_inj=1,
|
64
|
+
sample_type=SampleType.SAMPLE
|
65
|
+
)])
|
66
|
+
self.hplc_controller.edit_sequence(seq_table)
|
67
|
+
|
68
|
+
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
69
|
+
rand_method = MethodDetails(
|
70
|
+
name=DEFAULT_METHOD,
|
71
|
+
params=HPLCMethodParams(
|
72
|
+
organic_modifier=5,
|
73
|
+
flow=0.65),
|
74
|
+
timetable=[TimeTableEntry(
|
75
|
+
start_time=1,
|
76
|
+
organic_modifer=100,
|
77
|
+
flow=0.65)],
|
78
|
+
stop_time=2,
|
79
|
+
post_time=1)
|
80
|
+
self.hplc_controller.edit_method(rand_method, save=True)
|
81
|
+
self.hplc_controller.preprun()
|
82
|
+
self.hplc_controller.run_sequence()
|
83
|
+
chrom = self.hplc_controller.get_last_run_sequence_data()
|
84
|
+
uv = self.hplc_controller.get_last_run_sequence_data(read_uv=True)
|
85
|
+
self.assertEqual(len(chrom), 1)
|
86
|
+
self.assertEqual(len(uv), 1)
|
87
|
+
except Exception:
|
88
|
+
self.fail("Failed")
|
89
|
+
|
90
|
+
def test_run_sequence(self):
|
91
|
+
try:
|
92
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
93
|
+
seq_table = SequenceTable(
|
94
|
+
name=DEFAULT_SEQUENCE,
|
95
|
+
rows=[SequenceEntry(vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.ONE),
|
96
|
+
sample_name="P1-A1",
|
97
|
+
method=DEFAULT_METHOD,
|
98
|
+
inj_source=InjectionSource.HIP_ALS,
|
99
|
+
inj_vol=0.5,
|
100
|
+
num_inj=1,
|
101
|
+
sample_type=SampleType.SAMPLE),
|
102
|
+
SequenceEntry(vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.TWO),
|
103
|
+
sample_name="P1-A2",
|
104
|
+
method=DEFAULT_METHOD,
|
105
|
+
inj_source=InjectionSource.HIP_ALS,
|
106
|
+
inj_vol=0.5,
|
107
|
+
num_inj=1,
|
108
|
+
sample_type=SampleType.SAMPLE),
|
109
|
+
SequenceEntry(vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.THREE),
|
110
|
+
sample_name="P1-A3",
|
111
|
+
method="GENERAL-POROSHELL-JD",
|
112
|
+
inj_source=InjectionSource.HIP_ALS,
|
113
|
+
inj_vol=0.5,
|
114
|
+
num_inj=1,
|
115
|
+
sample_type=SampleType.SAMPLE)])
|
116
|
+
self.hplc_controller.edit_sequence(seq_table)
|
117
|
+
self.hplc_controller.switch_method(method_name=DEFAULT_METHOD)
|
118
|
+
method = MethodDetails(
|
119
|
+
name=DEFAULT_METHOD,
|
120
|
+
params=HPLCMethodParams(
|
121
|
+
organic_modifier=5,
|
122
|
+
flow=0.65),
|
123
|
+
timetable=[TimeTableEntry(
|
124
|
+
start_time=0.50,
|
125
|
+
organic_modifer=100,
|
126
|
+
flow=0.65)],
|
127
|
+
stop_time=1,
|
128
|
+
post_time=1)
|
129
|
+
self.hplc_controller.edit_method(method)
|
130
|
+
self.hplc_controller.preprun()
|
131
|
+
self.hplc_controller.run_sequence()
|
132
|
+
chroms = self.hplc_controller.get_last_run_sequence_data()
|
133
|
+
repo = self.hplc_controller.get_last_run_sequence_reports()
|
134
|
+
self.assertEqual(len(repo) , 3)
|
135
|
+
self.assertTrue(len(chroms) == 3)
|
136
|
+
except Exception:
|
137
|
+
self.fail("Failed")
|
138
|
+
|
139
|
+
def test_run_method_immidiate_return(self):
|
140
|
+
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
141
|
+
rand_method = MethodDetails(
|
142
|
+
name=DEFAULT_METHOD,
|
143
|
+
params=HPLCMethodParams(organic_modifier=5, flow=0.65),
|
144
|
+
timetable=[TimeTableEntry(start_time=0.5, organic_modifer=100, flow=0.65)],
|
145
|
+
stop_time=1,
|
146
|
+
post_time=0.5,
|
147
|
+
)
|
148
|
+
self.hplc_controller.edit_method(rand_method, save=True)
|
149
|
+
try:
|
150
|
+
for _ in range(5):
|
151
|
+
self.hplc_controller.run_method(experiment_name="test_experiment", stall_while_running=False)
|
152
|
+
time_left, done = self.hplc_controller.check_method_complete()
|
153
|
+
while not done:
|
154
|
+
time.sleep(abs(time_left/2))
|
155
|
+
print(time_left)
|
156
|
+
time_left, done = self.hplc_controller.check_method_complete()
|
157
|
+
chrom = self.hplc_controller.get_last_run_method_data()
|
158
|
+
uv = self.hplc_controller.get_last_run_method_data(read_uv=True)
|
159
|
+
repos = self.hplc_controller.get_last_run_method_report()
|
160
|
+
self.assertEqual(repos.vial_location, FiftyFourVialPlate.from_str("P1-A3"))
|
161
|
+
self.assertEqual(repos.signals[0].wavelength, '210')
|
162
|
+
self.assertTrue(210 in uv.keys())
|
163
|
+
self.assertTrue(len(chrom.A.x) > 0)
|
164
|
+
except Exception as e:
|
165
|
+
self.fail(f"Should have not failed: {e}")
|
166
|
+
|
167
|
+
def test_update_method_update_seq_table_run_immidiate_return(self):
|
168
|
+
try:
|
169
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
170
|
+
seq_table = SequenceTable(
|
171
|
+
name=DEFAULT_SEQUENCE,
|
172
|
+
rows=[
|
173
|
+
SequenceEntry(
|
174
|
+
vial_location=FiftyFourVialPlate(
|
175
|
+
plate=Plate.ONE, letter=Letter.A, num=Num.TWO
|
176
|
+
),
|
177
|
+
sample_name="run seq with new method",
|
178
|
+
method=DEFAULT_METHOD,
|
179
|
+
inj_source=InjectionSource.HIP_ALS,
|
180
|
+
inj_vol=0.5,
|
181
|
+
num_inj=1,
|
182
|
+
sample_type=SampleType.SAMPLE,
|
183
|
+
),
|
184
|
+
SequenceEntry(
|
185
|
+
vial_location=FiftyFourVialPlate(
|
186
|
+
plate=Plate.ONE, letter=Letter.A, num=Num.THREE
|
187
|
+
),
|
188
|
+
sample_name="P1-A3",
|
189
|
+
method="GENERAL-POROSHELL-JD",
|
190
|
+
inj_source=InjectionSource.HIP_ALS,
|
191
|
+
inj_vol=0.5,
|
192
|
+
num_inj=1,
|
193
|
+
sample_type=SampleType.SAMPLE,
|
194
|
+
),
|
195
|
+
],
|
196
|
+
)
|
197
|
+
self.hplc_controller.edit_sequence(seq_table)
|
198
|
+
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
199
|
+
rand_method = MethodDetails(
|
200
|
+
name=DEFAULT_METHOD,
|
201
|
+
params=HPLCMethodParams(
|
202
|
+
organic_modifier=5,
|
203
|
+
flow=0.65),
|
204
|
+
timetable=[TimeTableEntry(
|
205
|
+
start_time=1,
|
206
|
+
organic_modifer=100,
|
207
|
+
flow=0.65)],
|
208
|
+
stop_time=2,
|
209
|
+
post_time=1)
|
210
|
+
self.hplc_controller.edit_method(rand_method, save=True)
|
211
|
+
self.hplc_controller.preprun()
|
212
|
+
self.hplc_controller.run_sequence(stall_while_running=False)
|
213
|
+
time_left, done = self.hplc_controller.check_sequence_complete()
|
214
|
+
while not done:
|
215
|
+
time.sleep(time_left/2)
|
216
|
+
time_left, done = self.hplc_controller.check_sequence_complete()
|
217
|
+
chrom = self.hplc_controller.get_last_run_sequence_data()
|
218
|
+
uv = self.hplc_controller.get_last_run_sequence_data(read_uv=True)
|
219
|
+
self.assertEqual(len(chrom), 2)
|
220
|
+
self.assertEqual(len(uv), 2)
|
221
|
+
except Exception:
|
222
|
+
self.fail("Failed")
|
223
|
+
|
224
|
+
if __name__ == '__main__':
|
225
|
+
unittest.main()
|
tests/test_sequence.py
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
import os
|
2
|
+
import unittest
|
3
|
+
|
4
|
+
from pychemstation.control import HPLCController
|
5
|
+
from tests.constants import *
|
6
|
+
|
7
|
+
|
8
|
+
class TestSequence(unittest.TestCase):
|
9
|
+
def setUp(self):
|
10
|
+
path_constants = room(242)
|
11
|
+
for path in path_constants:
|
12
|
+
if not os.path.exists(path):
|
13
|
+
self.fail(
|
14
|
+
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
15
|
+
|
16
|
+
self.hplc_controller = HPLCController(comm_dir=path_constants[0],
|
17
|
+
method_dir=path_constants[1],
|
18
|
+
data_dir=path_constants[2],
|
19
|
+
sequence_dir=path_constants[3])
|
20
|
+
|
21
|
+
def test_switch(self):
|
22
|
+
try:
|
23
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
24
|
+
except Exception as e:
|
25
|
+
self.fail(f"Should have not expected: {e}")
|
26
|
+
|
27
|
+
def test_edit_row(self):
|
28
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
29
|
+
try:
|
30
|
+
self.hplc_controller.edit_sequence_row(SequenceEntry(
|
31
|
+
vial_location=TenVialColumn.TEN,
|
32
|
+
method=DEFAULT_METHOD,
|
33
|
+
num_inj=3,
|
34
|
+
inj_vol=4,
|
35
|
+
sample_name="Blank",
|
36
|
+
sample_type=SampleType.BLANK,
|
37
|
+
inj_source=InjectionSource.HIP_ALS
|
38
|
+
), 1)
|
39
|
+
except Exception:
|
40
|
+
self.fail("Should have not failed")
|
41
|
+
|
42
|
+
def test_edit_entire_table(self):
|
43
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
44
|
+
try:
|
45
|
+
seq_table = SequenceTable(
|
46
|
+
name=DEFAULT_SEQUENCE,
|
47
|
+
rows=[
|
48
|
+
SequenceEntry(
|
49
|
+
vial_location=TenVialColumn.ONE,
|
50
|
+
method=DEFAULT_METHOD,
|
51
|
+
num_inj=3,
|
52
|
+
inj_vol=4,
|
53
|
+
sample_name="Sampel1",
|
54
|
+
sample_type=SampleType.SAMPLE,
|
55
|
+
inj_source=InjectionSource.HIP_ALS
|
56
|
+
),
|
57
|
+
SequenceEntry(
|
58
|
+
vial_location=TenVialColumn.TWO,
|
59
|
+
method=DEFAULT_METHOD,
|
60
|
+
num_inj=3,
|
61
|
+
inj_vol=4,
|
62
|
+
sample_name="Sampel2",
|
63
|
+
sample_type=SampleType.SAMPLE,
|
64
|
+
inj_source=InjectionSource.HIP_ALS
|
65
|
+
),
|
66
|
+
SequenceEntry(
|
67
|
+
vial_location=TenVialColumn.TEN,
|
68
|
+
method=DEFAULT_METHOD,
|
69
|
+
num_inj=3,
|
70
|
+
inj_vol=4,
|
71
|
+
sample_name="Sampel2",
|
72
|
+
sample_type=SampleType.SAMPLE,
|
73
|
+
inj_source=InjectionSource.HIP_ALS
|
74
|
+
),
|
75
|
+
SequenceEntry(
|
76
|
+
vial_location=TenVialColumn.THREE,
|
77
|
+
method=DEFAULT_METHOD,
|
78
|
+
num_inj=3,
|
79
|
+
inj_vol=4,
|
80
|
+
sample_name="Sampel2",
|
81
|
+
sample_type=SampleType.SAMPLE,
|
82
|
+
inj_source=InjectionSource.HIP_ALS
|
83
|
+
)
|
84
|
+
]
|
85
|
+
)
|
86
|
+
self.hplc_controller.edit_sequence(seq_table)
|
87
|
+
except Exception:
|
88
|
+
self.fail("Should have not occured")
|
89
|
+
|
90
|
+
def test_edit_entire_table_less_rows(self):
|
91
|
+
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
92
|
+
try:
|
93
|
+
seq_table = SequenceTable(
|
94
|
+
name=DEFAULT_SEQUENCE,
|
95
|
+
rows=[
|
96
|
+
SequenceEntry(
|
97
|
+
vial_location=TenVialColumn.TEN,
|
98
|
+
method=DEFAULT_METHOD,
|
99
|
+
num_inj=3,
|
100
|
+
inj_vol=4,
|
101
|
+
sample_name="Sampel2",
|
102
|
+
sample_type=SampleType.SAMPLE,
|
103
|
+
inj_source=InjectionSource.HIP_ALS
|
104
|
+
),
|
105
|
+
SequenceEntry(
|
106
|
+
vial_location=TenVialColumn.THREE,
|
107
|
+
method=DEFAULT_METHOD,
|
108
|
+
num_inj=3,
|
109
|
+
inj_vol=4,
|
110
|
+
sample_name="Sampel2",
|
111
|
+
sample_type=SampleType.SAMPLE,
|
112
|
+
inj_source=InjectionSource.HIP_ALS
|
113
|
+
)
|
114
|
+
]
|
115
|
+
)
|
116
|
+
self.hplc_controller.edit_sequence(seq_table)
|
117
|
+
except Exception:
|
118
|
+
self.fail("Should have not occured")
|
119
|
+
|
120
|
+
def test_load(self):
|
121
|
+
try:
|
122
|
+
seq = self.hplc_controller.load_sequence()
|
123
|
+
self.assertTrue(len(seq.rows) > 0)
|
124
|
+
except Exception as e:
|
125
|
+
self.fail(f"Should have not expected: {e}")
|