pychemstation 0.7.0.dev2__py3-none-any.whl → 0.8.1__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 -28
  11. pychemstation/control/controllers/tables/table.py +124 -127
  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.dev2.dist-info → pychemstation-0.8.1.dist-info}/METADATA +25 -21
  23. pychemstation-0.8.1.dist-info/RECORD +39 -0
  24. {pychemstation-0.7.0.dev2.dist-info → pychemstation-0.8.1.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.dev2.dist-info/RECORD +0 -58
  37. pychemstation-0.7.0.dev2.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 -276
  49. {pychemstation-0.7.0.dev2.dist-info → pychemstation-0.8.1.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,276 +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_edit_method(self):
56
- self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
57
- new_method = MethodDetails(name=DEFAULT_METHOD + ".M",
58
- timetable=[TimeTableEntry(start_time=1.0,
59
- organic_modifer=20.0,
60
- flow=0.65),
61
- TimeTableEntry(start_time=2.0,
62
- organic_modifer=30.0,
63
- flow=0.65),
64
- TimeTableEntry(start_time=2.5,
65
- organic_modifer=60.0,
66
- flow=0.65),
67
- TimeTableEntry(start_time=3.0,
68
- organic_modifer=80.0,
69
- flow=0.65),
70
- TimeTableEntry(start_time=3.5,
71
- organic_modifer=100.0,
72
- flow=0.65)],
73
- stop_time=4.0,
74
- post_time=1.0,
75
- params=HPLCMethodParams(organic_modifier=5.0, flow=0.65))
76
- try:
77
- self.hplc_controller.edit_method(new_method)
78
- self.assertEqual(new_method, self.hplc_controller.load_method())
79
- except Exception as e:
80
- self.fail(f"Should have not failed: {e}")
81
-
82
- def test_load_method(self):
83
- self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
84
- new_method = gen_rand_method()
85
- try:
86
- self.hplc_controller.edit_method(new_method)
87
- loaded_method = self.hplc_controller.load_method()
88
- self.assertEqual(new_method.params.organic_modifier,
89
- loaded_method.params.organic_modifier)
90
- self.assertEqual(new_method.timetable[0].organic_modifer,
91
- loaded_method.timetable[0].organic_modifer)
92
- self.assertEqual(round(new_method.params.flow, 2),
93
- round(loaded_method.params.flow, 2))
94
- except Exception as e:
95
- self.fail(f"Should have not failed: {e}")
96
-
97
- def test_switch(self):
98
- try:
99
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
100
- except Exception as e:
101
- self.fail(f"Should have not expected: {e}")
102
-
103
- def test_read(self):
104
- try:
105
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
106
- table = self.hplc_controller.load_sequence()
107
- self.assertTrue(table)
108
- except Exception as e:
109
- self.fail(f"Should have not expected: {e}")
110
-
111
- def test_edit_entire_table(self):
112
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
113
- seq_folder = self.hplc_controller.sequence_controller.src
114
- meth_path = os.path.join(seq_folder, DEFAULT_METHOD)
115
- try:
116
- seq_table = SequenceTable(
117
- name=DEFAULT_SEQUENCE,
118
- rows=[
119
- SequenceEntry(
120
- vial_location=TenVialColumn.ONE,
121
- method=meth_path,
122
- num_inj=3,
123
- inj_vol=4,
124
- sample_name="Sampel1",
125
- sample_type=SampleType.SAMPLE,
126
- inj_source=InjectionSource.HIP_ALS
127
- ),
128
- SequenceEntry(
129
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.ONE),
130
- method=meth_path,
131
- num_inj=3,
132
- inj_vol=4,
133
- sample_name="Sampel2",
134
- sample_type=SampleType.SAMPLE,
135
- inj_source=InjectionSource.HIP_ALS
136
- ),
137
- SequenceEntry(
138
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.TWO),
139
- method=meth_path,
140
- num_inj=3,
141
- inj_vol=4,
142
- sample_name="Sampel2",
143
- sample_type=SampleType.SAMPLE,
144
- inj_source=InjectionSource.HIP_ALS
145
- ),
146
- SequenceEntry(
147
- vial_location=FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.THREE),
148
- method=meth_path,
149
- num_inj=3,
150
- inj_vol=4,
151
- sample_name="Sampel2",
152
- sample_type=SampleType.SAMPLE,
153
- inj_source=InjectionSource.HIP_ALS
154
- )
155
- ]
156
- )
157
- self.hplc_controller.edit_sequence(seq_table)
158
- self.assertEqual(seq_table,
159
- self.hplc_controller.load_sequence())
160
- except Exception:
161
- self.fail("Should have not occured")
162
-
163
- def test_edit_entire_table_less_rows(self):
164
- self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
165
- try:
166
- seq_table = SequenceTable(
167
- name=DEFAULT_SEQUENCE,
168
- rows=[
169
- SequenceEntry(
170
- vial_location=TenVialColumn.TEN,
171
- method=DEFAULT_METHOD,
172
- num_inj=3,
173
- inj_vol=4,
174
- sample_name="Sampel2",
175
- sample_type=SampleType.SAMPLE,
176
- inj_source=InjectionSource.HIP_ALS
177
- ),
178
- SequenceEntry(
179
- vial_location=TenVialColumn.THREE,
180
- method=DEFAULT_METHOD,
181
- num_inj=3,
182
- inj_vol=4,
183
- sample_name="Sampel2",
184
- sample_type=SampleType.SAMPLE,
185
- inj_source=InjectionSource.HIP_ALS
186
- )
187
- ]
188
- )
189
- self.hplc_controller.edit_sequence(seq_table)
190
- except Exception:
191
- self.fail("Should have not occured")
192
-
193
- def test_load(self):
194
- try:
195
- seq = self.hplc_controller.load_sequence()
196
- self.assertTrue(len(seq.rows) > 0)
197
- except Exception as e:
198
- self.fail(f"Should have not expected: {e}")
199
-
200
- def test_tray_nums(self):
201
- vial_locations = [
202
- FiftyFourVialPlate.from_str('P1-A7'),
203
- FiftyFourVialPlate.from_str('P1-B4'),
204
- FiftyFourVialPlate.from_str('P1-C2'),
205
- FiftyFourVialPlate.from_str('P1-D8'),
206
- FiftyFourVialPlate.from_str('P1-E3'),
207
- FiftyFourVialPlate.from_str('P1-F5'),
208
- # plate 2
209
- FiftyFourVialPlate.from_str('P2-A7'),
210
- FiftyFourVialPlate.from_str('P2-B2'),
211
- FiftyFourVialPlate.from_str('P2-C1'),
212
- FiftyFourVialPlate.from_str('P2-D8'),
213
- FiftyFourVialPlate.from_str('P2-E3'),
214
- FiftyFourVialPlate.from_str('P2-F6'),
215
- ]
216
- seq_table = SequenceTable(
217
- name=DEFAULT_SEQUENCE,
218
- rows=[
219
- SequenceEntry(
220
- vial_location=v,
221
- method=DEFAULT_METHOD,
222
- num_inj=3,
223
- inj_vol=4,
224
- sample_name="Sampel2",
225
- sample_type=SampleType.SAMPLE,
226
- inj_source=InjectionSource.HIP_ALS
227
- ) for v in vial_locations
228
- ]
229
- )
230
- self.hplc_controller.edit_sequence(seq_table)
231
- loaded_table = self.hplc_controller.load_sequence()
232
- for i in range(len(vial_locations)):
233
- self.assertTrue(vial_locations[i].value()
234
- == seq_table.rows[i].vial_location.value()
235
- == loaded_table.rows[i].vial_location.value())
236
-
237
- def test_tray_nums_only(self):
238
- vial_locations = [
239
- # plate 2
240
- FiftyFourVialPlate.from_str('P2-A7'),
241
- FiftyFourVialPlate.from_str('P2-B2'),
242
- FiftyFourVialPlate.from_str('P2-C1'),
243
- FiftyFourVialPlate.from_str('P2-D8'),
244
- FiftyFourVialPlate.from_str('P2-E3'),
245
- FiftyFourVialPlate.from_str('P2-F6'),
246
- # plate 1
247
- FiftyFourVialPlate.from_str('P1-A7'),
248
- FiftyFourVialPlate.from_str('P1-B4'),
249
- FiftyFourVialPlate.from_str('P1-C2'),
250
- FiftyFourVialPlate.from_str('P1-D8'),
251
- FiftyFourVialPlate.from_str('P1-E3'),
252
- FiftyFourVialPlate.from_str('P1-F5'),
253
- ]
254
-
255
- for i in range(len(vial_locations)):
256
- self.assertEqual(vial_locations[i], FiftyFourVialPlate.from_int(vial_locations[i].value()))
257
-
258
- def test_get_last_run_sequence(self):
259
- path = "C:\\Users\\Public\\Documents\\ChemStation\\3\\Data\\hplc_testing 2025-03-24 16-28-16"
260
- folder_name = "hplc_testing 2025-03-24 16-28"
261
- self.hplc_controller.sequence_controller.data_files.append(SequenceDataFiles(dir=folder_name,
262
- sequence_name=DEFAULT_SEQUENCE))
263
- try:
264
- most_recent_folder = self.hplc_controller.sequence_controller.retrieve_recent_data_files()
265
- check_folder = self.hplc_controller.sequence_controller.fuzzy_match_most_recent_folder(
266
- most_recent_folder=most_recent_folder)
267
- self.assertEqual(check_folder.ok_value, path)
268
- self.hplc_controller.sequence_controller.data_files[-1].dir = check_folder.ok_value
269
- chrom = self.hplc_controller.get_last_run_sequence_data()
270
- self.assertTrue(chrom)
271
- except Exception:
272
- self.fail()
273
-
274
-
275
- if __name__ == '__main__':
276
- unittest.main()