pychemstation 0.7.0.dev1__py3-none-any.whl → 0.8.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.
Files changed (49) hide show
  1. pychemstation/analysis/base_spectrum.py +3 -6
  2. pychemstation/analysis/process_report.py +248 -225
  3. pychemstation/analysis/utils.py +3 -1
  4. pychemstation/control/README.md +124 -0
  5. pychemstation/control/controllers/README.md +1 -0
  6. pychemstation/control/controllers/__init__.py +0 -2
  7. pychemstation/control/controllers/comm.py +27 -20
  8. pychemstation/control/controllers/devices/device.py +17 -4
  9. pychemstation/control/controllers/tables/method.py +57 -39
  10. pychemstation/control/controllers/tables/sequence.py +98 -31
  11. pychemstation/control/controllers/tables/table.py +121 -126
  12. pychemstation/control/hplc.py +82 -37
  13. pychemstation/generated/dad_method.py +3 -3
  14. pychemstation/generated/pump_method.py +7 -7
  15. pychemstation/out.txt +145 -0
  16. pychemstation/tests.ipynb +310 -0
  17. pychemstation/utils/chromatogram.py +5 -1
  18. pychemstation/utils/injector_types.py +2 -2
  19. pychemstation/utils/macro.py +1 -1
  20. pychemstation/utils/table_types.py +3 -0
  21. pychemstation/utils/tray_types.py +59 -39
  22. {pychemstation-0.7.0.dev1.dist-info → pychemstation-0.8.0.dist-info}/METADATA +25 -21
  23. pychemstation-0.8.0.dist-info/RECORD +39 -0
  24. {pychemstation-0.7.0.dev1.dist-info → pychemstation-0.8.0.dist-info}/WHEEL +1 -2
  25. pychemstation/control/comm.py +0 -206
  26. pychemstation/control/controllers/devices/column.py +0 -12
  27. pychemstation/control/controllers/devices/dad.py +0 -0
  28. pychemstation/control/controllers/devices/pump.py +0 -43
  29. pychemstation/control/controllers/method.py +0 -338
  30. pychemstation/control/controllers/sequence.py +0 -190
  31. pychemstation/control/controllers/table_controller.py +0 -266
  32. pychemstation/control/table/__init__.py +0 -3
  33. pychemstation/control/table/method.py +0 -274
  34. pychemstation/control/table/sequence.py +0 -210
  35. pychemstation/control/table/table_controller.py +0 -201
  36. pychemstation-0.7.0.dev1.dist-info/RECORD +0 -58
  37. pychemstation-0.7.0.dev1.dist-info/top_level.txt +0 -2
  38. tests/__init__.py +0 -0
  39. tests/constants.py +0 -88
  40. tests/test_comb.py +0 -136
  41. tests/test_comm.py +0 -65
  42. tests/test_inj.py +0 -39
  43. tests/test_method.py +0 -99
  44. tests/test_nightly.py +0 -80
  45. tests/test_proc_rep.py +0 -52
  46. tests/test_runs_stable.py +0 -125
  47. tests/test_sequence.py +0 -125
  48. tests/test_stable.py +0 -283
  49. {pychemstation-0.7.0.dev1.dist-info → pychemstation-0.8.0.dist-info/licenses}/LICENSE +0 -0
tests/test_sequence.py DELETED
@@ -1,125 +0,0 @@
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}")
tests/test_stable.py DELETED
@@ -1,283 +0,0 @@
1
- import unittest
2
-
3
- from pychemstation.utils.macro import *
4
- from pychemstation.utils.tray_types import *
5
- from tests.constants import *
6
-
7
-
8
- class TestStable(unittest.TestCase):
9
-
10
- def setUp(self):
11
- self.hplc_controller = set_up_utils(242)
12
-
13
- def test_status_check_standby(self):
14
- self.hplc_controller.standby()
15
- self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.STANDBY, HPLCRunningStatus.NOTREADY])
16
-
17
- def test_status_check_preprun(self):
18
- self.hplc_controller.preprun()
19
- self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.PRERUN, HPLCAvailStatus.STANDBY,
20
- HPLCRunningStatus.NOTREADY])
21
-
22
- def test_send_command(self):
23
- try:
24
- self.hplc_controller.send(Command.GET_METHOD_CMD)
25
- except Exception as e:
26
- self.fail(f"Should not throw error: {e}")
27
-
28
- def test_send_str(self):
29
- try:
30
- self.hplc_controller.send("Local TestNum")
31
- self.hplc_controller.send("TestNum = 0")
32
- self.hplc_controller.send("Print TestNum")
33
- self.hplc_controller.send("response_num = TestNum")
34
- self.hplc_controller.send("Print response_num")
35
- except Exception as e:
36
- self.fail(f"Should not throw error: {e}")
37
-
38
- def test_get_num(self):
39
- try:
40
- self.hplc_controller.send("response_num = 10")
41
- res = self.hplc_controller.receive().num_response
42
- self.assertEqual(res, 10)
43
- except Exception as e:
44
- self.fail(f"Should not throw error: {e}")
45
-
46
- def test_get_response(self):
47
- try:
48
- self.hplc_controller.switch_method(method_name=DEFAULT_METHOD)
49
- self.hplc_controller.send(Command.GET_METHOD_CMD)
50
- res = self.hplc_controller.receive()
51
- self.assertTrue(DEFAULT_METHOD in res.string_response)
52
- except Exception as e:
53
- self.fail(f"Should not throw error: {e}")
54
-
55
- def test_load_method_from_disk(self):
56
- self.hplc_controller.switch_method(DEFAULT_METHOD)
57
- try:
58
- gp_mtd = self.hplc_controller.method_controller.load_from_disk(DEFAULT_METHOD)
59
- self.assertTrue(gp_mtd.params.organic_modifier == 5)
60
- except Exception as e:
61
- self.fail(f"Should have not failed, {e}")
62
-
63
- def test_edit_method(self):
64
- self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
65
- new_method = MethodDetails(name=DEFAULT_METHOD + ".M",
66
- timetable=[TimeTableEntry(start_time=1.0,
67
- organic_modifer=20.0,
68
- flow=0.65),
69
- TimeTableEntry(start_time=2.0,
70
- organic_modifer=30.0,
71
- flow=0.65),
72
- TimeTableEntry(start_time=2.5,
73
- organic_modifer=60.0,
74
- flow=0.65),
75
- TimeTableEntry(start_time=3.0,
76
- organic_modifer=80.0,
77
- flow=0.65),
78
- TimeTableEntry(start_time=3.5,
79
- organic_modifer=100.0,
80
- flow=0.65)],
81
- stop_time=4.0,
82
- post_time=1.0,
83
- params=HPLCMethodParams(organic_modifier=5.0, flow=0.65))
84
- try:
85
- self.hplc_controller.edit_method(new_method)
86
- self.assertEqual(new_method, self.hplc_controller.load_method())
87
- except Exception as e:
88
- self.fail(f"Should have not failed: {e}")
89
-
90
- def test_load_method(self):
91
- self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
92
- new_method = gen_rand_method()
93
- try:
94
- self.hplc_controller.edit_method(new_method)
95
- loaded_method = self.hplc_controller.load_method()
96
- self.assertEqual(new_method.params.organic_modifier,
97
- loaded_method.params.organic_modifier)
98
- self.assertEqual(new_method.timetable[0].organic_modifer,
99
- loaded_method.timetable[0].organic_modifer)
100
- self.assertEqual(round(new_method.params.flow, 2),
101
- round(loaded_method.params.flow, 2))
102
- except Exception as e:
103
- self.fail(f"Should have not failed: {e}")
104
-
105
- def test_switch(self):
106
- try:
107
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
108
- except Exception as e:
109
- self.fail(f"Should have not expected: {e}")
110
-
111
- def test_read(self):
112
- try:
113
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
114
- table = self.hplc_controller.load_sequence()
115
- self.assertTrue(table)
116
- except Exception as e:
117
- self.fail(f"Should have not expected: {e}")
118
-
119
- def test_edit_entire_table(self):
120
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
121
- seq_folder = self.hplc_controller.sequence_controller.src
122
- meth_path = os.path.join(seq_folder, DEFAULT_METHOD)
123
- try:
124
- seq_table = SequenceTable(
125
- name=DEFAULT_SEQUENCE,
126
- rows=[
127
- SequenceEntry(
128
- vial_location=TenVialColumn.ONE,
129
- method=meth_path,
130
- num_inj=3,
131
- inj_vol=4,
132
- sample_name="Sampel1",
133
- sample_type=SampleType.SAMPLE,
134
- inj_source=InjectionSource.HIP_ALS
135
- ),
136
- SequenceEntry(
137
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.ONE),
138
- method=meth_path,
139
- num_inj=3,
140
- inj_vol=4,
141
- sample_name="Sampel2",
142
- sample_type=SampleType.SAMPLE,
143
- inj_source=InjectionSource.HIP_ALS
144
- ),
145
- SequenceEntry(
146
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.TWO),
147
- method=meth_path,
148
- num_inj=3,
149
- inj_vol=4,
150
- sample_name="Sampel2",
151
- sample_type=SampleType.SAMPLE,
152
- inj_source=InjectionSource.HIP_ALS
153
- ),
154
- SequenceEntry(
155
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.THREE),
156
- method=meth_path,
157
- num_inj=3,
158
- inj_vol=4,
159
- sample_name="Sampel2",
160
- sample_type=SampleType.SAMPLE,
161
- inj_source=InjectionSource.HIP_ALS
162
- )
163
- ]
164
- )
165
- self.hplc_controller.edit_sequence(seq_table)
166
- self.assertEqual(seq_table,
167
- self.hplc_controller.load_sequence())
168
- except Exception:
169
- self.fail("Should have not occured")
170
-
171
- def test_edit_entire_table_less_rows(self):
172
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
173
- try:
174
- seq_table = SequenceTable(
175
- name=DEFAULT_SEQUENCE,
176
- rows=[
177
- SequenceEntry(
178
- vial_location=TenVialColumn.TEN,
179
- method=DEFAULT_METHOD,
180
- num_inj=3,
181
- inj_vol=4,
182
- sample_name="Sampel2",
183
- sample_type=SampleType.SAMPLE,
184
- inj_source=InjectionSource.HIP_ALS
185
- ),
186
- SequenceEntry(
187
- vial_location=TenVialColumn.THREE,
188
- method=DEFAULT_METHOD,
189
- num_inj=3,
190
- inj_vol=4,
191
- sample_name="Sampel2",
192
- sample_type=SampleType.SAMPLE,
193
- inj_source=InjectionSource.HIP_ALS
194
- )
195
- ]
196
- )
197
- self.hplc_controller.edit_sequence(seq_table)
198
- except Exception:
199
- self.fail("Should have not occured")
200
-
201
- def test_load(self):
202
- try:
203
- seq = self.hplc_controller.load_sequence()
204
- self.assertTrue(len(seq.rows) > 0)
205
- except Exception as e:
206
- self.fail(f"Should have not expected: {e}")
207
-
208
- def test_tray_nums(self):
209
- vial_locations = [
210
- FiftyFourVialPlate.from_str('P1-A7'),
211
- FiftyFourVialPlate.from_str('P1-B4'),
212
- FiftyFourVialPlate.from_str('P1-C2'),
213
- FiftyFourVialPlate.from_str('P1-D8'),
214
- FiftyFourVialPlate.from_str('P1-E3'),
215
- FiftyFourVialPlate.from_str('P1-F5'),
216
- # plate 2
217
- FiftyFourVialPlate.from_str('P2-A7'),
218
- FiftyFourVialPlate.from_str('P2-B2'),
219
- FiftyFourVialPlate.from_str('P2-C1'),
220
- FiftyFourVialPlate.from_str('P2-D8'),
221
- FiftyFourVialPlate.from_str('P2-E3'),
222
- FiftyFourVialPlate.from_str('P2-F6'),
223
- ]
224
- seq_table = SequenceTable(
225
- name=DEFAULT_SEQUENCE,
226
- rows=[
227
- SequenceEntry(
228
- vial_location=v,
229
- method=DEFAULT_METHOD,
230
- num_inj=3,
231
- inj_vol=4,
232
- sample_name="Sampel2",
233
- sample_type=SampleType.SAMPLE,
234
- inj_source=InjectionSource.HIP_ALS
235
- ) for v in vial_locations
236
- ]
237
- )
238
- self.hplc_controller.edit_sequence(seq_table)
239
- loaded_table = self.hplc_controller.load_sequence()
240
- for i in range(len(vial_locations)):
241
- self.assertTrue(vial_locations[i].value()
242
- == seq_table.rows[i].vial_location.value()
243
- == loaded_table.rows[i].vial_location.value())
244
-
245
- def test_tray_nums_only(self):
246
- vial_locations = [
247
- # plate 2
248
- FiftyFourVialPlate.from_str('P2-A7'),
249
- FiftyFourVialPlate.from_str('P2-B2'),
250
- FiftyFourVialPlate.from_str('P2-C1'),
251
- FiftyFourVialPlate.from_str('P2-D8'),
252
- FiftyFourVialPlate.from_str('P2-E3'),
253
- FiftyFourVialPlate.from_str('P2-F6'),
254
- # plate 1
255
- FiftyFourVialPlate.from_str('P1-A7'),
256
- FiftyFourVialPlate.from_str('P1-B4'),
257
- FiftyFourVialPlate.from_str('P1-C2'),
258
- FiftyFourVialPlate.from_str('P1-D8'),
259
- FiftyFourVialPlate.from_str('P1-E3'),
260
- FiftyFourVialPlate.from_str('P1-F5'),
261
- ]
262
-
263
- for i in range(len(vial_locations)):
264
- self.assertEqual(vial_locations[i], FiftyFourVialPlate.from_int(vial_locations[i].value()))
265
-
266
- def test_get_last_run_sequence(self):
267
- path = "C:\\Users\\Public\\Documents\\ChemStation\\3\\Data\\hplc_testing 2025-03-24 16-28-16"
268
- folder_name = "hplc_testing 2025-03-24 16-28"
269
- self.hplc_controller.sequence_controller.data_files.append(SequenceDataFiles(dir=folder_name,
270
- sequence_name=DEFAULT_SEQUENCE))
271
- try:
272
- most_recent_folder = self.hplc_controller.sequence_controller.retrieve_recent_data_files()
273
- check_folder = self.hplc_controller.sequence_controller.fuzzy_match_most_recent_folder(
274
- most_recent_folder=most_recent_folder)
275
- self.assertEqual(check_folder.ok_value, path)
276
- chrom = self.hplc_controller.get_last_run_sequence_data()
277
- self.assertTrue(chrom)
278
- except Exception:
279
- self.fail()
280
-
281
-
282
- if __name__ == '__main__':
283
- unittest.main()