pychemstation 0.10.0__py3-none-any.whl → 0.10.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.
- pychemstation/control/README.md +132 -0
- pychemstation/control/controllers/README.md +1 -0
- {pychemstation-0.10.0.dist-info → pychemstation-0.10.1.dist-info}/METADATA +11 -9
- {pychemstation-0.10.0.dist-info → pychemstation-0.10.1.dist-info}/RECORD +6 -31
- {pychemstation-0.10.0.dist-info → pychemstation-0.10.1.dist-info}/WHEEL +1 -2
- pychemstation/analysis/spec_utils.py +0 -304
- pychemstation/analysis/utils.py +0 -63
- pychemstation/control/comm.py +0 -206
- pychemstation/control/controllers/devices/column.py +0 -12
- pychemstation/control/controllers/devices/dad.py +0 -0
- pychemstation/control/controllers/devices/pump.py +0 -43
- pychemstation/control/controllers/method.py +0 -338
- pychemstation/control/controllers/sequence.py +0 -190
- pychemstation/control/controllers/table_controller.py +0 -266
- pychemstation/control/table/__init__.py +0 -3
- pychemstation/control/table/method.py +0 -274
- pychemstation/control/table/sequence.py +0 -210
- pychemstation/control/table/table_controller.py +0 -201
- pychemstation-0.10.0.dist-info/top_level.txt +0 -2
- tests/__init__.py +0 -0
- tests/constants.py +0 -134
- tests/test_comb.py +0 -136
- tests/test_comm.py +0 -65
- tests/test_inj.py +0 -39
- tests/test_method.py +0 -99
- tests/test_nightly.py +0 -80
- tests/test_offline_stable.py +0 -69
- tests/test_online_stable.py +0 -275
- tests/test_proc_rep.py +0 -52
- tests/test_runs_stable.py +0 -225
- tests/test_sequence.py +0 -125
- tests/test_stable.py +0 -276
- {pychemstation-0.10.0.dist-info → pychemstation-0.10.1.dist-info}/licenses/LICENSE +0 -0
tests/__init__.py
DELETED
File without changes
|
tests/constants.py
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import random
|
3
|
-
import shutil
|
4
|
-
|
5
|
-
from pychemstation.control import HPLCController
|
6
|
-
from pychemstation.utils.macro import Command
|
7
|
-
from pychemstation.utils.method_types import (
|
8
|
-
HPLCMethodParams,
|
9
|
-
MethodDetails,
|
10
|
-
TimeTableEntry,
|
11
|
-
)
|
12
|
-
from pychemstation.utils.sequence_types import SampleType, SequenceEntry
|
13
|
-
from pychemstation.utils.tray_types import FiftyFourVialPlate, TenVialColumn
|
14
|
-
|
15
|
-
VIAL_PLATES = [
|
16
|
-
FiftyFourVialPlate.from_str('P1-A7'),
|
17
|
-
FiftyFourVialPlate.from_str('P1-B4'),
|
18
|
-
FiftyFourVialPlate.from_str('P1-C2'),
|
19
|
-
FiftyFourVialPlate.from_str('P1-D8'),
|
20
|
-
FiftyFourVialPlate.from_str('P1-E3'),
|
21
|
-
FiftyFourVialPlate.from_str('P1-F5'),
|
22
|
-
# plate 2
|
23
|
-
FiftyFourVialPlate.from_str('P2-A7'),
|
24
|
-
FiftyFourVialPlate.from_str('P2-B2'),
|
25
|
-
FiftyFourVialPlate.from_str('P2-C1'),
|
26
|
-
FiftyFourVialPlate.from_str('P2-D8'),
|
27
|
-
FiftyFourVialPlate.from_str('P2-E3'),
|
28
|
-
FiftyFourVialPlate.from_str('P2-F6'),
|
29
|
-
]
|
30
|
-
|
31
|
-
DEFAULT_METHOD = "GENERAL-POROSHELL-OPT"
|
32
|
-
DEFAULT_SEQUENCE = "hplc_testing"
|
33
|
-
|
34
|
-
# CONSTANTS: paths only work in Hein group HPLC machine in room 242
|
35
|
-
DEFAULT_COMMAND_PATH = "C:\\Users\\User\\Desktop\\Lucy\\hplc-method-optimization\\tests\\"
|
36
|
-
DEFAULT_METHOD_DIR = "C:\\ChemStation\\1\\Methods\\"
|
37
|
-
DATA_DIR = "C:\\Users\\Public\\Documents\\ChemStation\\2\\Data\\LC-BO\\"
|
38
|
-
SEQUENCE_DIR = "C:\\USERS\\PUBLIC\\DOCUMENTS\\CHEMSTATION\\3\\Sequence"
|
39
|
-
SEQUENCE_DATA_DIR_2 = "C:\\Users\\Public\\Documents\\ChemStation\\2\\Data"
|
40
|
-
SEQUENCE_DATA_DIR = "C:\\Users\\Public\\Documents\\ChemStation\\3\\Data\\"
|
41
|
-
|
42
|
-
HEIN_LAB_CONSTANTS_242 = [DEFAULT_COMMAND_PATH,
|
43
|
-
DEFAULT_METHOD_DIR,
|
44
|
-
DATA_DIR,
|
45
|
-
SEQUENCE_DIR,
|
46
|
-
SEQUENCE_DATA_DIR_2,
|
47
|
-
SEQUENCE_DATA_DIR]
|
48
|
-
|
49
|
-
# these CONSTANTS work in rm 254
|
50
|
-
DEFAULT_COMMAND_PATH_254 = "D:\\\git_repositories\\\hplc_comm\\"
|
51
|
-
DEFAULT_METHOD_DIR_254 = "D:\\Chemstation\\1\\Methods\\"
|
52
|
-
DATA_DIR_254 = "D:\\Chemstation\\1\\Data\\LC BO\\"
|
53
|
-
SEQUENCE_DIR_254 = "C:\\1\\Sequence\\"
|
54
|
-
SEQUENCE_DATA_DIR_254 = "D:\\Chemstation\\1\\Data\\"
|
55
|
-
|
56
|
-
HEIN_LAB_CONSTANTS_254 = [DEFAULT_COMMAND_PATH_254,
|
57
|
-
DEFAULT_METHOD_DIR_254,
|
58
|
-
DATA_DIR_254,
|
59
|
-
SEQUENCE_DIR_254,
|
60
|
-
SEQUENCE_DATA_DIR_254]
|
61
|
-
|
62
|
-
|
63
|
-
def room(num: int):
|
64
|
-
if num == 242:
|
65
|
-
return HEIN_LAB_CONSTANTS_242
|
66
|
-
elif num == 254:
|
67
|
-
return HEIN_LAB_CONSTANTS_254
|
68
|
-
|
69
|
-
|
70
|
-
def gen_rand_method():
|
71
|
-
org_modifier = int(random.random() * 10)
|
72
|
-
max_run_time = int(random.random() * 10)
|
73
|
-
post_run_time = int(random.random() * 10)
|
74
|
-
flow = float(random.random() * 10) / 10
|
75
|
-
flow_1 = float(random.random() * 10) / 10
|
76
|
-
flow_2 = float(random.random() * 10) / 10
|
77
|
-
return MethodDetails(name=DEFAULT_METHOD,
|
78
|
-
timetable=[TimeTableEntry(start_time=0.10,
|
79
|
-
organic_modifer=org_modifier,
|
80
|
-
flow=flow_1),
|
81
|
-
TimeTableEntry(start_time=1,
|
82
|
-
organic_modifer=100 - int(random.random() * 10),
|
83
|
-
flow=flow_2)],
|
84
|
-
stop_time=max_run_time,
|
85
|
-
post_time=post_run_time,
|
86
|
-
params=HPLCMethodParams(organic_modifier=org_modifier, flow=flow))
|
87
|
-
|
88
|
-
|
89
|
-
seq_entry = SequenceEntry(
|
90
|
-
vial_location=TenVialColumn.ONE,
|
91
|
-
method=DEFAULT_METHOD,
|
92
|
-
num_inj=int(random.random() * 10),
|
93
|
-
inj_vol=int(random.random() * 10),
|
94
|
-
sample_name="Test",
|
95
|
-
sample_type=SampleType(int(random.random() * 3)),
|
96
|
-
)
|
97
|
-
|
98
|
-
|
99
|
-
def set_up_utils(num: int, offline: bool = False, runs: bool = False) -> HPLCController:
|
100
|
-
path_constants = room(num)
|
101
|
-
if not offline:
|
102
|
-
for path in path_constants:
|
103
|
-
if not os.path.exists(path):
|
104
|
-
raise FileNotFoundError(
|
105
|
-
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
106
|
-
|
107
|
-
controller = HPLCController(offline=offline,
|
108
|
-
comm_dir=path_constants[0],
|
109
|
-
method_dir=path_constants[1],
|
110
|
-
data_dirs=[path_constants[2], path_constants[4], path_constants[5]],
|
111
|
-
sequence_dir=path_constants[3],
|
112
|
-
debug=True)
|
113
|
-
if not offline:
|
114
|
-
controller.send(Command.SAVE_METHOD_CMD.value.format(commit_msg="method saved by pychemstation"))
|
115
|
-
controller.send(Command.SAVE_SEQUENCE_CMD)
|
116
|
-
if runs:
|
117
|
-
controller.instrument_on()
|
118
|
-
controller.preprun()
|
119
|
-
return controller
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
def clean_up(hplc_controller: HPLCController):
|
124
|
-
if hasattr(hplc_controller.method_controller, "data_dirs") and hasattr(hplc_controller.sequence_controller, "data_dirs"):
|
125
|
-
files = hplc_controller.method_controller.data_files + [d.dir for d in hplc_controller.sequence_controller.data_files]
|
126
|
-
data_dirs = hplc_controller.method_controller.data_dirs
|
127
|
-
for folder in files:
|
128
|
-
if os.path.isdir(folder):
|
129
|
-
shutil.rmtree(folder)
|
130
|
-
else:
|
131
|
-
for data_dir in data_dirs:
|
132
|
-
possible_path = os.path.join(data_dir, folder)
|
133
|
-
if os.path.isdir(possible_path):
|
134
|
-
shutil.rmtree(possible_path)
|
tests/test_comb.py
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
|
5
|
-
from pychemstation.control import HPLCController
|
6
|
-
from tests.constants import *
|
7
|
-
|
8
|
-
run_too = True
|
9
|
-
|
10
|
-
|
11
|
-
class TestCombinations(unittest.TestCase):
|
12
|
-
def setUp(self):
|
13
|
-
path_constants = room(242)
|
14
|
-
for path in path_constants:
|
15
|
-
if not os.path.exists(path):
|
16
|
-
self.fail(
|
17
|
-
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
18
|
-
|
19
|
-
self.hplc_controller = HPLCController(comm_dir=path_constants[0],
|
20
|
-
method_dir=path_constants[1],
|
21
|
-
data_dir=path_constants[2],
|
22
|
-
sequence_dir=path_constants[3])
|
23
|
-
|
24
|
-
def test_run_method_after_update(self):
|
25
|
-
try:
|
26
|
-
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
27
|
-
rand_method = MethodDetails(
|
28
|
-
params=HPLCMethodParams(organic_modifier=5,
|
29
|
-
flow=0.65),
|
30
|
-
timetable=[TimeTableEntry(start_time=3.5,
|
31
|
-
organic_modifer=100,
|
32
|
-
flow=0.65)],
|
33
|
-
name=DEFAULT_METHOD,
|
34
|
-
stop_time=10,
|
35
|
-
post_time=9)
|
36
|
-
self.hplc_controller.edit_method(rand_method, save=True)
|
37
|
-
if run_too:
|
38
|
-
self.hplc_controller.run_method(experiment_name="changed_method")
|
39
|
-
chrom = self.hplc_controller.get_last_run_method_data()
|
40
|
-
self.assertEqual(len(chrom.__dict__), 8)
|
41
|
-
except Exception as e:
|
42
|
-
self.fail(f"Should have not failed: {e}")
|
43
|
-
|
44
|
-
def test_run_after_table_edit(self):
|
45
|
-
try:
|
46
|
-
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
47
|
-
seq_table = self.hplc_controller.load_sequence()
|
48
|
-
seq_table.rows.append(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
|
-
))
|
56
|
-
seq_table.rows[0] = SequenceEntry(
|
57
|
-
vial_location=TenVialColumn.ONE,
|
58
|
-
method=DEFAULT_METHOD,
|
59
|
-
num_inj=3,
|
60
|
-
inj_vol=4,
|
61
|
-
sample_name="Sampel2",
|
62
|
-
sample_type=SampleType.SAMPLE)
|
63
|
-
self.hplc_controller.edit_sequence(seq_table)
|
64
|
-
if run_too:
|
65
|
-
self.hplc_controller.run_sequence()
|
66
|
-
chrom = self.hplc_controller.get_last_run_sequence_data()
|
67
|
-
self.assertTrue(len(chrom) == 2)
|
68
|
-
except Exception as e:
|
69
|
-
self.fail("Failed")
|
70
|
-
|
71
|
-
def test_run_after_existing_row_edit(self):
|
72
|
-
try:
|
73
|
-
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
74
|
-
seq_table = self.hplc_controller.load_sequence()
|
75
|
-
self.hplc_controller.edit_sequence_row(seq_entry, 1)
|
76
|
-
if run_too:
|
77
|
-
self.hplc_controller.run_sequence()
|
78
|
-
chrom = self.hplc_controller.get_last_run_sequence_data()
|
79
|
-
self.assertTrue(len(chrom) == 2)
|
80
|
-
except Exception:
|
81
|
-
self.fail("Failed")
|
82
|
-
|
83
|
-
def test_update_method_update_seq_table_run(self):
|
84
|
-
try:
|
85
|
-
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
86
|
-
rand_method = MethodDetails(
|
87
|
-
name=DEFAULT_METHOD,
|
88
|
-
params=HPLCMethodParams(
|
89
|
-
organic_modifier=5,
|
90
|
-
flow=0.65),
|
91
|
-
timetable=[TimeTableEntry(
|
92
|
-
start_time=0.50,
|
93
|
-
organic_modifer=99,
|
94
|
-
flow=0.34)],
|
95
|
-
stop_time=10,
|
96
|
-
post_time=5)
|
97
|
-
self.hplc_controller.edit_method(rand_method, save=True)
|
98
|
-
|
99
|
-
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
100
|
-
seq_table = SequenceTable(
|
101
|
-
name=DEFAULT_SEQUENCE,
|
102
|
-
rows=[SequenceEntry(
|
103
|
-
vial_location=8320,
|
104
|
-
sample_name="WM-01-001_Cr-Org",
|
105
|
-
method=DEFAULT_METHOD,
|
106
|
-
inj_source=InjectionSource.HIP_ALS,
|
107
|
-
inj_vol=2,
|
108
|
-
num_inj=1,
|
109
|
-
sample_type=SampleType.SAMPLE
|
110
|
-
), SequenceEntry(
|
111
|
-
vial_location=8448,
|
112
|
-
sample_name="WM-01-001_Cr-Aq",
|
113
|
-
method=DEFAULT_METHOD,
|
114
|
-
inj_source=InjectionSource.HIP_ALS,
|
115
|
-
inj_vol=2,
|
116
|
-
num_inj=1,
|
117
|
-
sample_type=SampleType.SAMPLE)])
|
118
|
-
|
119
|
-
self.hplc_controller.edit_sequence(seq_table)
|
120
|
-
if run_too:
|
121
|
-
self.hplc_controller.preprun()
|
122
|
-
self.hplc_controller.run_sequence()
|
123
|
-
chrom = self.hplc_controller.get_last_run_sequence_data()
|
124
|
-
self.assertTrue(len(chrom) == 2)
|
125
|
-
except Exception:
|
126
|
-
self.fail("Failed")
|
127
|
-
|
128
|
-
def test_run_sequence(self):
|
129
|
-
try:
|
130
|
-
self.hplc_controller.switch_sequence(sequence_name=DEFAULT_SEQUENCE)
|
131
|
-
self.hplc_controller.preprun()
|
132
|
-
self.hplc_controller.run_sequence()
|
133
|
-
chrom = self.hplc_controller.get_last_run_sequence_data()
|
134
|
-
self.assertTrue(len(chrom) == 1)
|
135
|
-
except Exception:
|
136
|
-
self.fail("Failed")
|
tests/test_comm.py
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
|
5
|
-
from pychemstation.control import HPLCController
|
6
|
-
from pychemstation.utils.macro import *
|
7
|
-
from tests.constants import *
|
8
|
-
|
9
|
-
|
10
|
-
class TestComm(unittest.TestCase):
|
11
|
-
|
12
|
-
def setUp(self):
|
13
|
-
path_constants = room(242)
|
14
|
-
for path in path_constants:
|
15
|
-
if not os.path.exists(path):
|
16
|
-
self.fail(
|
17
|
-
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
18
|
-
|
19
|
-
self.hplc_controller = HPLCController(comm_dir=path_constants[0],
|
20
|
-
method_dir=path_constants[1],
|
21
|
-
data_dir=path_constants[2],
|
22
|
-
sequence_dir=path_constants[3])
|
23
|
-
|
24
|
-
def test_status_check_standby(self):
|
25
|
-
self.hplc_controller.standby()
|
26
|
-
self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.STANDBY, HPLCRunningStatus.NOTREADY])
|
27
|
-
|
28
|
-
def test_status_check_preprun(self):
|
29
|
-
self.hplc_controller.preprun()
|
30
|
-
self.assertTrue(self.hplc_controller.status() in [HPLCAvailStatus.PRERUN, HPLCAvailStatus.STANDBY,
|
31
|
-
HPLCRunningStatus.NOTREADY])
|
32
|
-
|
33
|
-
def test_send_command(self):
|
34
|
-
try:
|
35
|
-
self.hplc_controller.send(Command.GET_METHOD_CMD)
|
36
|
-
except Exception as e:
|
37
|
-
self.fail(f"Should not throw error: {e}")
|
38
|
-
|
39
|
-
def test_send_str(self):
|
40
|
-
try:
|
41
|
-
self.hplc_controller.send("Local TestNum")
|
42
|
-
self.hplc_controller.send("TestNum = 0")
|
43
|
-
self.hplc_controller.send("Print TestNum")
|
44
|
-
self.hplc_controller.send("response_num = TestNum")
|
45
|
-
self.hplc_controller.send("Print response_num")
|
46
|
-
except Exception as e:
|
47
|
-
self.fail(f"Should not throw error: {e}")
|
48
|
-
|
49
|
-
def test_get_num(self):
|
50
|
-
try:
|
51
|
-
self.hplc_controller.send("response_num = 10")
|
52
|
-
res = self.hplc_controller.receive().num_response
|
53
|
-
self.assertEqual(res, 10)
|
54
|
-
except Exception as e:
|
55
|
-
self.fail(f"Should not throw error: {e}")
|
56
|
-
|
57
|
-
def test_get_response(self):
|
58
|
-
try:
|
59
|
-
self.hplc_controller.switch_method(method_name=DEFAULT_METHOD)
|
60
|
-
self.hplc_controller.send(Command.GET_METHOD_CMD)
|
61
|
-
res = self.hplc_controller.receive()
|
62
|
-
self.assertTrue(DEFAULT_METHOD in res.string_response)
|
63
|
-
except Exception as e:
|
64
|
-
self.fail(f"Should not throw error: {e}")
|
65
|
-
|
tests/test_inj.py
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import unittest
|
3
|
-
|
4
|
-
from pychemstation.control import HPLCController
|
5
|
-
from pychemstation.utils.tray_types import FiftyFourVialPlate, Letter, Plate, Num
|
6
|
-
from tests.constants import *
|
7
|
-
|
8
|
-
offline = True
|
9
|
-
|
10
|
-
|
11
|
-
class TestInj(unittest.TestCase):
|
12
|
-
def setUp(self):
|
13
|
-
path_constants = room(254)
|
14
|
-
for path in path_constants:
|
15
|
-
if not offline and not os.path.exists(path):
|
16
|
-
self.fail(
|
17
|
-
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
18
|
-
|
19
|
-
self.hplc_controller = HPLCController(offline=offline,
|
20
|
-
comm_dir=path_constants[0],
|
21
|
-
method_dir=path_constants[1],
|
22
|
-
data_dir=path_constants[2],
|
23
|
-
sequence_dir=path_constants[3])
|
24
|
-
if not offline:
|
25
|
-
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
26
|
-
|
27
|
-
def test_load_inj(self):
|
28
|
-
try:
|
29
|
-
inj_table = self.hplc_controller.load_injector_program()
|
30
|
-
self.assertTrue(len(inj_table.functions) == 2)
|
31
|
-
except Exception as e:
|
32
|
-
self.fail(f"Should have not failed, {e}")
|
33
|
-
|
34
|
-
def test_plate_number(self):
|
35
|
-
self.assertEqual(4096, FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.FOUR).value())
|
36
|
-
|
37
|
-
|
38
|
-
if __name__ == '__main__':
|
39
|
-
unittest.main()
|
tests/test_method.py
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import unittest
|
3
|
-
|
4
|
-
from pychemstation.control import HPLCController
|
5
|
-
from tests.constants import *
|
6
|
-
|
7
|
-
|
8
|
-
class TestMethod(unittest.TestCase):
|
9
|
-
def setUp(self):
|
10
|
-
path_constants = room(254)
|
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_load_method_from_disk(self):
|
22
|
-
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
23
|
-
try:
|
24
|
-
gp_mtd = self.hplc_controller.method_controller.load_from_disk(DEFAULT_METHOD)
|
25
|
-
self.assertTrue(gp_mtd.first_row.organic_modifier == 5)
|
26
|
-
except Exception as e:
|
27
|
-
self.fail(f"Should have not failed, {e}")
|
28
|
-
|
29
|
-
def test_edit_method(self):
|
30
|
-
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
31
|
-
new_method = MethodDetails(name=DEFAULT_METHOD,
|
32
|
-
timetable=[TimeTableEntry(start_time=1,
|
33
|
-
organic_modifer=20,
|
34
|
-
flow=0.65),
|
35
|
-
TimeTableEntry(start_time=2,
|
36
|
-
organic_modifer=30,
|
37
|
-
flow=0.65),
|
38
|
-
TimeTableEntry(start_time=2.5,
|
39
|
-
organic_modifer=60,
|
40
|
-
flow=0.65),
|
41
|
-
TimeTableEntry(start_time=3,
|
42
|
-
organic_modifer=80,
|
43
|
-
flow=0.65),
|
44
|
-
TimeTableEntry(start_time=3.5,
|
45
|
-
organic_modifer=100,
|
46
|
-
flow=0.65)],
|
47
|
-
stop_time=4,
|
48
|
-
post_time=1,
|
49
|
-
params=HPLCMethodParams(organic_modifier=5, flow=0.65))
|
50
|
-
try:
|
51
|
-
self.hplc_controller.edit_method(new_method)
|
52
|
-
except Exception as e:
|
53
|
-
self.fail(f"Should have not failed: {e}")
|
54
|
-
|
55
|
-
def test_load_method(self):
|
56
|
-
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
57
|
-
new_method = gen_rand_method()
|
58
|
-
try:
|
59
|
-
self.hplc_controller.edit_method(new_method)
|
60
|
-
loaded_method = self.hplc_controller.load_method()
|
61
|
-
self.assertEqual(new_method.params.organic_modifier,
|
62
|
-
loaded_method.params.organic_modifier)
|
63
|
-
self.assertEqual(new_method.timetable[0].organic_modifer,
|
64
|
-
loaded_method.timetable[0].organic_modifer)
|
65
|
-
self.assertEqual(round(new_method.params.flow, 2),
|
66
|
-
round(loaded_method.params.flow, 2))
|
67
|
-
except Exception as e:
|
68
|
-
self.fail(f"Should have not failed: {e}")
|
69
|
-
|
70
|
-
def test_run_method(self):
|
71
|
-
try:
|
72
|
-
self.hplc_controller.run_method(experiment_name="test_experiment")
|
73
|
-
chrom = self.hplc_controller.get_last_run_method_data()
|
74
|
-
except Exception as e:
|
75
|
-
self.fail(f"Should have not failed: {e}")
|
76
|
-
|
77
|
-
def test_run_10_times(self):
|
78
|
-
self.hplc_controller.method_controller.switch(DEFAULT_METHOD)
|
79
|
-
rand_method = MethodDetails(
|
80
|
-
name=DEFAULT_METHOD,
|
81
|
-
params=HPLCMethodParams(
|
82
|
-
organic_modifier=5,
|
83
|
-
flow=0.65),
|
84
|
-
timetable=[TimeTableEntry(
|
85
|
-
start_time=0.50,
|
86
|
-
organic_modifer=99,
|
87
|
-
flow=0.65)],
|
88
|
-
stop_time=1,
|
89
|
-
post_time=0)
|
90
|
-
self.hplc_controller.edit_method(rand_method, save=True)
|
91
|
-
try:
|
92
|
-
for _ in range(10):
|
93
|
-
self.hplc_controller.run_method(experiment_name="limiting_testing")
|
94
|
-
except Exception as e:
|
95
|
-
self.fail(f"Should have not failed: {e}")
|
96
|
-
|
97
|
-
|
98
|
-
if __name__ == '__main__':
|
99
|
-
unittest.main()
|
tests/test_nightly.py
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
|
3
|
-
from pluggy import Result
|
4
|
-
|
5
|
-
from pychemstation.analysis.process_report import process_csv_report
|
6
|
-
from pychemstation.utils.tray_types import FiftyFourVialPlate, Letter, Plate, Num
|
7
|
-
from tests.constants import *
|
8
|
-
|
9
|
-
offline = True
|
10
|
-
|
11
|
-
|
12
|
-
class TestNightly(unittest.TestCase):
|
13
|
-
def setUp(self):
|
14
|
-
path_constants = room(254)
|
15
|
-
for path in path_constants:
|
16
|
-
if not offline and not os.path.exists(path):
|
17
|
-
self.fail(
|
18
|
-
f"{path} does not exist on your system. If you would like to run tests, please change this path.")
|
19
|
-
|
20
|
-
self.hplc_controller = HPLCController(offline=offline,
|
21
|
-
comm_dir=path_constants[0],
|
22
|
-
method_dir=path_constants[1],
|
23
|
-
data_dir=path_constants[2],
|
24
|
-
sequence_dir=path_constants[3])
|
25
|
-
if not offline:
|
26
|
-
self.hplc_controller.switch_method(DEFAULT_METHOD)
|
27
|
-
|
28
|
-
def test_load_inj(self):
|
29
|
-
try:
|
30
|
-
inj_table = self.hplc_controller.load_injector_program()
|
31
|
-
self.assertTrue(len(inj_table.functions) == 2)
|
32
|
-
except Exception as e:
|
33
|
-
self.fail(f"Should have not failed, {e}")
|
34
|
-
|
35
|
-
def test_plate_number(self):
|
36
|
-
self.assertEqual(4096, FiftyFourVialPlate(plate=Plate.ONE, letter=Letter.A, num=Num.FOUR).value())
|
37
|
-
|
38
|
-
def test_build_peak_regex(self):
|
39
|
-
try:
|
40
|
-
# TODO
|
41
|
-
print('yes')
|
42
|
-
except Exception as e:
|
43
|
-
self.fail(f"Should have not failed, {e}")
|
44
|
-
|
45
|
-
def test_parse_area_report(self):
|
46
|
-
try:
|
47
|
-
# TODO
|
48
|
-
print('yes')
|
49
|
-
except Exception as e:
|
50
|
-
self.fail(f"Should have not failed, {e}")
|
51
|
-
|
52
|
-
def test_process_export_report(self):
|
53
|
-
try:
|
54
|
-
import pandas as pd
|
55
|
-
|
56
|
-
file_path = "/Users/lucyhao/Codes/pychemstation/tests/0_2025-03-15 19-14-35.D/Report00.CSV"
|
57
|
-
df = pd.read_csv(file_path, encoding="utf-16")
|
58
|
-
|
59
|
-
# Print the first column
|
60
|
-
print(df)
|
61
|
-
except Exception as e:
|
62
|
-
self.fail(f"Should have not failed, {e}")
|
63
|
-
|
64
|
-
def test_process_folder(self):
|
65
|
-
try:
|
66
|
-
# TODO
|
67
|
-
print('yes')
|
68
|
-
except Exception as e:
|
69
|
-
self.fail(f"Should have not failed, {e}")
|
70
|
-
|
71
|
-
def test_report_csv(self):
|
72
|
-
try:
|
73
|
-
report: Result = process_csv_report(folder_path="0_2025-03-15 19-14-35.D")
|
74
|
-
print(report)
|
75
|
-
except Exception as e:
|
76
|
-
self.fail(f"Should have not failed: {e}")
|
77
|
-
|
78
|
-
|
79
|
-
if __name__ == '__main__':
|
80
|
-
unittest.main()
|
tests/test_offline_stable.py
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
|
3
|
-
from pychemstation.analysis.process_report import ReportType
|
4
|
-
from pychemstation.utils.sequence_types import SequenceDataFiles
|
5
|
-
from pychemstation.utils.tray_types import FiftyFourVialPlate
|
6
|
-
from tests.constants import DEFAULT_SEQUENCE, VIAL_PLATES, clean_up, set_up_utils
|
7
|
-
|
8
|
-
|
9
|
-
class TestStable(unittest.TestCase):
|
10
|
-
"""
|
11
|
-
These tests should always work, while the controller is offline or online.
|
12
|
-
"""
|
13
|
-
|
14
|
-
def setUp(self):
|
15
|
-
self.hplc_controller = set_up_utils(242, offline=True)
|
16
|
-
|
17
|
-
def tearDown(self):
|
18
|
-
clean_up(self.hplc_controller)
|
19
|
-
|
20
|
-
def test_tray_nums_only(self):
|
21
|
-
for i in range(len(VIAL_PLATES)):
|
22
|
-
self.assertEqual(VIAL_PLATES[i], FiftyFourVialPlate.from_int(VIAL_PLATES[i].value()))
|
23
|
-
|
24
|
-
def test_get_last_run_sequence(self):
|
25
|
-
path = "hplc_testing 2025-03-27 17-13-47"
|
26
|
-
self.hplc_controller.sequence_controller.data_files.append(SequenceDataFiles(dir=path,
|
27
|
-
sequence_name=DEFAULT_SEQUENCE))
|
28
|
-
try:
|
29
|
-
most_recent_folder = self.hplc_controller.sequence_controller.data_files[-1]
|
30
|
-
check_folder = self.hplc_controller.sequence_controller.fuzzy_match_most_recent_folder(
|
31
|
-
most_recent_folder=most_recent_folder)
|
32
|
-
self.assertEqual(check_folder.ok_value.dir, path)
|
33
|
-
self.hplc_controller.sequence_controller.data_files[-1].dir = check_folder.ok_value
|
34
|
-
chrom = self.hplc_controller.get_last_run_sequence_data()
|
35
|
-
self.assertTrue(chrom)
|
36
|
-
except Exception:
|
37
|
-
self.fail()
|
38
|
-
|
39
|
-
def test_plate_number(self):
|
40
|
-
self.assertEqual(FiftyFourVialPlate.from_str("P1-A1").value(), 4096)
|
41
|
-
self.assertEqual(FiftyFourVialPlate.from_str("P1-A4").value(), 4099)
|
42
|
-
|
43
|
-
def test_get_method_report(self):
|
44
|
-
method_path = "0_2025-03-15 19-14-35.D"
|
45
|
-
report = self.hplc_controller.get_last_run_method_report(custom_path=method_path, report_type=ReportType.CSV)
|
46
|
-
self.assertEqual(report.vial_location, FiftyFourVialPlate.from_int(4096))
|
47
|
-
|
48
|
-
def test_get_seq_report(self):
|
49
|
-
seq_path = "hplc_testing 2025-03-27 17-13-47"
|
50
|
-
report = self.hplc_controller.get_last_run_sequence_reports(custom_path=seq_path, report_type=ReportType.TXT)
|
51
|
-
self.assertEqual(len(report[0].signals[0].peaks), 12)
|
52
|
-
|
53
|
-
def test_get_method_uv(self):
|
54
|
-
method_path = "0_2025-03-15 19-14-35.D"
|
55
|
-
try:
|
56
|
-
uv_data = self.hplc_controller.get_last_run_method_data(custom_path=method_path, read_uv=True)
|
57
|
-
except Exception:
|
58
|
-
pass
|
59
|
-
|
60
|
-
def test_get_seq_uv(self):
|
61
|
-
seq_path = "hplc_testing 2025-03-27 17-13-47"
|
62
|
-
try:
|
63
|
-
uv_datas = self.hplc_controller.get_last_run_sequence_data(custom_path=seq_path, read_uv=True)
|
64
|
-
except Exception:
|
65
|
-
pass
|
66
|
-
|
67
|
-
|
68
|
-
if __name__ == '__main__':
|
69
|
-
unittest.main()
|