pychemstation 0.5.4__tar.gz → 0.5.5__tar.gz

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 (40) hide show
  1. {pychemstation-0.5.4 → pychemstation-0.5.5}/PKG-INFO +10 -8
  2. {pychemstation-0.5.4 → pychemstation-0.5.5}/README.md +10 -8
  3. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/control/__init__.py +0 -1
  4. {pychemstation-0.5.4/pychemstation/control/table → pychemstation-0.5.5/pychemstation/control/controllers}/__init__.py +1 -0
  5. {pychemstation-0.5.4/pychemstation/control → pychemstation-0.5.5/pychemstation/control/controllers}/comm.py +2 -2
  6. {pychemstation-0.5.4/pychemstation/control/table → pychemstation-0.5.5/pychemstation/control/controllers}/method.py +6 -6
  7. {pychemstation-0.5.4/pychemstation/control/table → pychemstation-0.5.5/pychemstation/control/controllers}/sequence.py +13 -12
  8. {pychemstation-0.5.4/pychemstation/control/table → pychemstation-0.5.5/pychemstation/control/controllers}/table_controller.py +3 -3
  9. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/control/hplc.py +6 -7
  10. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/chromatogram.py +7 -26
  11. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation.egg-info/PKG-INFO +10 -8
  12. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation.egg-info/SOURCES.txt +5 -5
  13. {pychemstation-0.5.4 → pychemstation-0.5.5}/setup.py +1 -1
  14. {pychemstation-0.5.4 → pychemstation-0.5.5}/LICENSE +0 -0
  15. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/__init__.py +0 -0
  16. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/analysis/__init__.py +0 -0
  17. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/analysis/base_spectrum.py +0 -0
  18. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/analysis/spec_utils.py +0 -0
  19. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/analysis/utils.py +0 -0
  20. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/generated/__init__.py +0 -0
  21. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/generated/dad_method.py +0 -0
  22. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/generated/pump_method.py +0 -0
  23. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/__init__.py +0 -0
  24. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/macro.py +0 -0
  25. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/method_types.py +0 -0
  26. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/parsing.py +0 -0
  27. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/sequence_types.py +0 -0
  28. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/table_types.py +0 -0
  29. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation/utils/tray_types.py +0 -0
  30. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation.egg-info/dependency_links.txt +0 -0
  31. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation.egg-info/requires.txt +0 -0
  32. {pychemstation-0.5.4 → pychemstation-0.5.5}/pychemstation.egg-info/top_level.txt +0 -0
  33. {pychemstation-0.5.4 → pychemstation-0.5.5}/pyproject.toml +0 -0
  34. {pychemstation-0.5.4 → pychemstation-0.5.5}/setup.cfg +0 -0
  35. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/__init__.py +0 -0
  36. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/constants.py +0 -0
  37. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/test_comb.py +0 -0
  38. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/test_comm.py +0 -0
  39. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/test_method.py +0 -0
  40. {pychemstation-0.5.4 → pychemstation-0.5.5}/tests/test_sequence.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pychemstation
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Library to interact with Chemstation software, primarily used in Hein lab
5
5
  Home-page: https://gitlab.com/heingroup/device-api/pychemstation
6
6
  Author: Lucy Hao
@@ -41,7 +41,7 @@ pip install pychemstation
41
41
  where you will put your
42
42
  MACRO file(s).
43
43
  3. Download the [
44
- `hplc_talk.mac`](https://github.com/croningp/analyticallabware/blob/master/AnalyticalLabware/devices/Agilent/hplctalk.mac).
44
+ `hplc_talk.mac`](https://gitlab.com/heingroup/device-api/pychemstation/-/blob/main/tests/hplc_talk.mac).
45
45
  - On line 69, change the path name up to `\cmd` and `\reply`. For instance, you should have:
46
46
  `MonitorFile "[my path]\cmd", "[my path]\reply"`
47
47
  - and then add this file to the folder from the previous step.
@@ -78,13 +78,12 @@ hplc_controller = HPLCController(data_dir=DATA_DIR,
78
78
  hplc_controller.preprun()
79
79
  hplc_controller.switch_method(method_name=DEFAULT_METHOD)
80
80
  hplc_controller.run_method(experiment_name="Run 10")
81
- data_status_valid, chrom = hplc_controller.get_last_run_method_data()
81
+ chrom = hplc_controller.get_last_run_method_data()
82
82
 
83
- if data_status_valid:
84
- # afterwards, save, analyze or plot the data!
85
- values = {"x": chrom.x, "y": chrom.y}
86
- chromatogram_data = pd.DataFrame.from_dict(values)
87
- chromatogram_data.to_csv("Run 10.csv", index=False)
83
+ # afterwards, save, analyze or plot the data!
84
+ values = {"x": chrom.A.x, "y": chrom.A.y}
85
+ chromatogram_data = pd.DataFrame.from_dict(values)
86
+ chromatogram_data.to_csv("Run 10.csv", index=False)
88
87
  ```
89
88
 
90
89
  ## Adding your own MACROs
@@ -103,3 +102,6 @@ Lucy Hao
103
102
 
104
103
  - Adapted from [**AnalyticalLabware**](https://github.com/croningp/analyticallabware), created by members in the Cronin
105
104
  Group. Copyright © Cronin Group, used under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license.
105
+ - Adapted from the [MACROS](https://github.com/Bourne-Group/HPLCMethodOptimisationGUI)
106
+ used in [**Operator-free HPLC automated method development guided by Bayesian optimization**](https://pubs.rsc.org/en/content/articlelanding/2024/dd/d4dd00062e),
107
+ created by members in the Bourne Group. Copyright © Bourne Group, used under the [MIT](https://opensource.org/license/mit) license.
@@ -25,7 +25,7 @@ pip install pychemstation
25
25
  where you will put your
26
26
  MACRO file(s).
27
27
  3. Download the [
28
- `hplc_talk.mac`](https://github.com/croningp/analyticallabware/blob/master/AnalyticalLabware/devices/Agilent/hplctalk.mac).
28
+ `hplc_talk.mac`](https://gitlab.com/heingroup/device-api/pychemstation/-/blob/main/tests/hplc_talk.mac).
29
29
  - On line 69, change the path name up to `\cmd` and `\reply`. For instance, you should have:
30
30
  `MonitorFile "[my path]\cmd", "[my path]\reply"`
31
31
  - and then add this file to the folder from the previous step.
@@ -62,13 +62,12 @@ hplc_controller = HPLCController(data_dir=DATA_DIR,
62
62
  hplc_controller.preprun()
63
63
  hplc_controller.switch_method(method_name=DEFAULT_METHOD)
64
64
  hplc_controller.run_method(experiment_name="Run 10")
65
- data_status_valid, chrom = hplc_controller.get_last_run_method_data()
65
+ chrom = hplc_controller.get_last_run_method_data()
66
66
 
67
- if data_status_valid:
68
- # afterwards, save, analyze or plot the data!
69
- values = {"x": chrom.x, "y": chrom.y}
70
- chromatogram_data = pd.DataFrame.from_dict(values)
71
- chromatogram_data.to_csv("Run 10.csv", index=False)
67
+ # afterwards, save, analyze or plot the data!
68
+ values = {"x": chrom.A.x, "y": chrom.A.y}
69
+ chromatogram_data = pd.DataFrame.from_dict(values)
70
+ chromatogram_data.to_csv("Run 10.csv", index=False)
72
71
  ```
73
72
 
74
73
  ## Adding your own MACROs
@@ -86,4 +85,7 @@ our [GitLab](https://gitlab.com/heingroup/device-api/pychemstation)!
86
85
  Lucy Hao
87
86
 
88
87
  - Adapted from [**AnalyticalLabware**](https://github.com/croningp/analyticallabware), created by members in the Cronin
89
- Group. Copyright © Cronin Group, used under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license.
88
+ Group. Copyright © Cronin Group, used under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license.
89
+ - Adapted from the [MACROS](https://github.com/Bourne-Group/HPLCMethodOptimisationGUI)
90
+ used in [**Operator-free HPLC automated method development guided by Bayesian optimization**](https://pubs.rsc.org/en/content/articlelanding/2024/dd/d4dd00062e),
91
+ created by members in the Bourne Group. Copyright © Bourne Group, used under the [MIT](https://opensource.org/license/mit) license.
@@ -1,5 +1,4 @@
1
1
  """
2
2
  .. include:: README.md
3
3
  """
4
- from .comm import CommunicationController
5
4
  from .hplc import HPLCController
@@ -1,3 +1,4 @@
1
1
  from .method import MethodController
2
2
  from .sequence import SequenceController
3
3
  from .table_controller import TableController
4
+ from .comm import CommunicationController
@@ -14,8 +14,8 @@ import os
14
14
  import time
15
15
 
16
16
  from result import Result, Ok, Err
17
- from ..utils.macro import *
18
- from ..utils.method_types import *
17
+
18
+ from ...utils.macro import *
19
19
 
20
20
 
21
21
  class CommunicationController:
@@ -1,13 +1,13 @@
1
1
  import os
2
2
  import time
3
- from typing import Optional, Any
3
+ from typing import Optional
4
4
 
5
5
  from xsdata.formats.dataclass.parsers import XmlParser
6
6
 
7
- from .. import CommunicationController
8
- from ...control.table.table_controller import TableController
7
+ from ...control.controllers.table_controller import TableController
8
+ from ...control.controllers.comm import CommunicationController
9
9
  from ...generated import PumpMethod, DadMethod, SolventElement
10
- from ...utils.chromatogram import TIME_FORMAT, AgilentHPLCChromatogram
10
+ from ...utils.chromatogram import TIME_FORMAT, AgilentChannelChromatogramData
11
11
  from ...utils.macro import Command
12
12
  from ...utils.method_types import PType, TimeTableEntry, Param, MethodTimetable, HPLCMethodParams
13
13
  from ...utils.table_types import RegisterFlag, TableOperation, Table
@@ -269,6 +269,6 @@ class MethodController(TableController):
269
269
  def retrieve_recent_data_files(self) -> str:
270
270
  return self.data_files[-1]
271
271
 
272
- def get_data(self) -> dict[str, AgilentHPLCChromatogram]:
272
+ def get_data(self) -> AgilentChannelChromatogramData:
273
273
  self.get_spectrum(self.data_files[-1])
274
- return self.spectra
274
+ return AgilentChannelChromatogramData(**self.spectra)
@@ -1,17 +1,12 @@
1
- from typing import Any
2
-
3
- from copy import deepcopy
4
-
5
1
  import os
6
2
  import time
7
3
 
8
- from .table_controller import TableController
9
- from ...control import CommunicationController
10
- from ...utils.chromatogram import SEQUENCE_TIME_FORMAT, AgilentHPLCChromatogram
4
+ from ...control.controllers.table_controller import TableController
5
+ from ...control.controllers.comm import CommunicationController
6
+ from ...utils.chromatogram import SEQUENCE_TIME_FORMAT, AgilentChannelChromatogramData
11
7
  from ...utils.macro import Command
12
8
  from ...utils.sequence_types import SequenceTable, SequenceEntry, SequenceDataFiles, InjectionSource, SampleType
13
9
  from ...utils.table_types import TableOperation, RegisterFlag, Table
14
- from ...utils.tray_types import TenColumn
15
10
 
16
11
 
17
12
  class SequenceController(TableController):
@@ -197,14 +192,20 @@ class SequenceController(TableController):
197
192
  sequence_data_files: SequenceDataFiles = self.data_files[-1]
198
193
  return sequence_data_files.dir
199
194
 
200
- def get_data(self) -> list[dict[str, AgilentHPLCChromatogram]]:
195
+ def get_data(self) -> list[AgilentChannelChromatogramData]:
201
196
  parent_dir = self.data_files[-1].dir
202
197
  subdirs = [x[0] for x in os.walk(self.data_dir)]
203
198
  potential_folders = sorted(list(filter(lambda d: parent_dir in d, subdirs)))
204
- self.data_files[-1].child_dirs = [f for f in potential_folders if parent_dir in f and ".M" not in f and ".D" in f]
199
+ self.data_files[-1].child_dirs = [f for f in potential_folders if
200
+ parent_dir in f and ".M" not in f and ".D" in f]
205
201
 
206
- spectra: list[dict[str, AgilentHPLCChromatogram]] = []
202
+ spectra: list[AgilentChannelChromatogramData] = []
207
203
  for row in self.data_files[-1].child_dirs:
208
204
  self.get_spectrum(row)
209
- spectra.append(deepcopy(self.spectra))
205
+ spectra.append(
206
+ AgilentChannelChromatogramData(
207
+ A=self.spectra["A"],
208
+ B=self.spectra["B"],
209
+ C=self.spectra["C"],
210
+ D=self.spectra["D"]))
210
211
  return spectra
@@ -12,8 +12,8 @@ from typing import Union, Optional
12
12
  import polling
13
13
  from result import Result, Ok, Err
14
14
 
15
- from ...control import CommunicationController
16
- from ...utils.chromatogram import AgilentHPLCChromatogram
15
+ from ...control.controllers.comm import CommunicationController
16
+ from ...utils.chromatogram import AgilentHPLCChromatogram, AgilentChannelChromatogramData
17
17
  from ...utils.macro import Command, HPLCRunningStatus, Response
18
18
  from ...utils.method_types import MethodTimetable
19
19
  from ...utils.sequence_types import SequenceDataFiles, SequenceTable
@@ -187,7 +187,7 @@ class TableController(abc.ABC):
187
187
  pass
188
188
 
189
189
  @abc.abstractmethod
190
- def get_data(self) -> tuple[bool,]:
190
+ def get_data(self) -> Union[list[AgilentChannelChromatogramData], AgilentChannelChromatogramData]:
191
191
  pass
192
192
 
193
193
  def get_spectrum(self, data_file: str):
@@ -6,9 +6,8 @@ Authors: Lucy Hao
6
6
 
7
7
  from typing import Union, Optional
8
8
 
9
- from ..control import CommunicationController
10
- from ..control.table import MethodController, SequenceController
11
- from ..utils.chromatogram import AgilentHPLCChromatogram
9
+ from ..control.controllers import MethodController, SequenceController, CommunicationController
10
+ from ..utils.chromatogram import AgilentHPLCChromatogram, AgilentChannelChromatogramData
12
11
  from ..utils.macro import Command, HPLCRunningStatus, HPLCAvailStatus, HPLCErrorStatus, Response
13
12
  from ..utils.method_types import MethodTimetable
14
13
  from ..utils.sequence_types import SequenceTable, SequenceEntry
@@ -65,8 +64,8 @@ class HPLCController:
65
64
  only 'General-Poroshell' is needed.
66
65
 
67
66
  :param method_name: any available method in Chemstation method directory
68
- :raise IndexError: Response did not have expected format. Try again.
69
- :raise AssertionError: The desired method is not selected. Try again.
67
+ :raises IndexError: Response did not have expected format. Try again.
68
+ :raises AssertionError: The desired method is not selected. Try again.
70
69
  """
71
70
  self.method_controller.switch(method_name)
72
71
 
@@ -127,13 +126,13 @@ class HPLCController:
127
126
  """
128
127
  self.sequence_controller.edit_row(row, num)
129
128
 
130
- def get_last_run_method_data(self) -> dict[str, AgilentHPLCChromatogram]:
129
+ def get_last_run_method_data(self) -> AgilentChannelChromatogramData:
131
130
  """
132
131
  Returns the last run method data.
133
132
  """
134
133
  return self.method_controller.get_data()
135
134
 
136
- def get_last_run_sequence_data(self) -> list[dict[str, AgilentHPLCChromatogram]]:
135
+ def get_last_run_sequence_data(self) -> list[AgilentChannelChromatogramData]:
137
136
  """
138
137
  Returns data for all rows in the last run sequence data.
139
138
  """
@@ -1,17 +1,14 @@
1
1
  """Module for HPLC chromatogram data loading and manipulating"""
2
2
 
3
3
  import os
4
- import logging
5
4
  import time
5
+ from dataclasses import dataclass
6
6
 
7
7
  import numpy as np
8
8
 
9
9
  from .parsing import CHFile
10
10
  from ..analysis import AbstractSpectrum
11
11
 
12
- # Chemstation data path
13
- DATA_DIR = r"C:\Chem32\1\Data"
14
-
15
12
  # standard filenames for spectral data
16
13
  CHANNELS = {"A": "01", "B": "02", "C": "03", "D": "04"}
17
14
 
@@ -105,26 +102,10 @@ class AgilentHPLCChromatogram(AbstractSpectrum):
105
102
  np.savez_compressed(npz_file, times=data.times, values=data.values)
106
103
  return np.array(data.times), np.array(data.values)
107
104
 
108
- def extract_peakarea(self, experiment_dir: str):
109
- """
110
- Reads processed data from Chemstation report files.
111
105
 
112
- Args:
113
- experiment_dir: .D directory with the report files
114
- """
115
- # filename = os.path.join(experiment_dir, f"REPORT{CHANNELS[channel]}.csv")
116
- # TODO parse file properly
117
- # data = np.genfromtxt(filename, delimiter=',')
118
- # return data
119
- pass
120
-
121
- def default_processing(self):
122
- """
123
- Processes the chromatogram in place.
124
- """
125
- # trim first 5 min and last 3 min of run
126
- self.trim(5, 25)
127
- # parameters found to work best for chromatogram data
128
- self.correct_baseline(lmbd=1e5, p=0.0001, n_iter=10)
129
- # get all peaks in processed chromatogram
130
- self.find_peaks()
106
+ @dataclass
107
+ class AgilentChannelChromatogramData:
108
+ A: AgilentHPLCChromatogram
109
+ B: AgilentHPLCChromatogram
110
+ C: AgilentHPLCChromatogram
111
+ D: AgilentHPLCChromatogram
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pychemstation
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Library to interact with Chemstation software, primarily used in Hein lab
5
5
  Home-page: https://gitlab.com/heingroup/device-api/pychemstation
6
6
  Author: Lucy Hao
@@ -41,7 +41,7 @@ pip install pychemstation
41
41
  where you will put your
42
42
  MACRO file(s).
43
43
  3. Download the [
44
- `hplc_talk.mac`](https://github.com/croningp/analyticallabware/blob/master/AnalyticalLabware/devices/Agilent/hplctalk.mac).
44
+ `hplc_talk.mac`](https://gitlab.com/heingroup/device-api/pychemstation/-/blob/main/tests/hplc_talk.mac).
45
45
  - On line 69, change the path name up to `\cmd` and `\reply`. For instance, you should have:
46
46
  `MonitorFile "[my path]\cmd", "[my path]\reply"`
47
47
  - and then add this file to the folder from the previous step.
@@ -78,13 +78,12 @@ hplc_controller = HPLCController(data_dir=DATA_DIR,
78
78
  hplc_controller.preprun()
79
79
  hplc_controller.switch_method(method_name=DEFAULT_METHOD)
80
80
  hplc_controller.run_method(experiment_name="Run 10")
81
- data_status_valid, chrom = hplc_controller.get_last_run_method_data()
81
+ chrom = hplc_controller.get_last_run_method_data()
82
82
 
83
- if data_status_valid:
84
- # afterwards, save, analyze or plot the data!
85
- values = {"x": chrom.x, "y": chrom.y}
86
- chromatogram_data = pd.DataFrame.from_dict(values)
87
- chromatogram_data.to_csv("Run 10.csv", index=False)
83
+ # afterwards, save, analyze or plot the data!
84
+ values = {"x": chrom.A.x, "y": chrom.A.y}
85
+ chromatogram_data = pd.DataFrame.from_dict(values)
86
+ chromatogram_data.to_csv("Run 10.csv", index=False)
88
87
  ```
89
88
 
90
89
  ## Adding your own MACROs
@@ -103,3 +102,6 @@ Lucy Hao
103
102
 
104
103
  - Adapted from [**AnalyticalLabware**](https://github.com/croningp/analyticallabware), created by members in the Cronin
105
104
  Group. Copyright © Cronin Group, used under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license.
105
+ - Adapted from the [MACROS](https://github.com/Bourne-Group/HPLCMethodOptimisationGUI)
106
+ used in [**Operator-free HPLC automated method development guided by Bayesian optimization**](https://pubs.rsc.org/en/content/articlelanding/2024/dd/d4dd00062e),
107
+ created by members in the Bourne Group. Copyright © Bourne Group, used under the [MIT](https://opensource.org/license/mit) license.
@@ -13,12 +13,12 @@ pychemstation/analysis/base_spectrum.py
13
13
  pychemstation/analysis/spec_utils.py
14
14
  pychemstation/analysis/utils.py
15
15
  pychemstation/control/__init__.py
16
- pychemstation/control/comm.py
17
16
  pychemstation/control/hplc.py
18
- pychemstation/control/table/__init__.py
19
- pychemstation/control/table/method.py
20
- pychemstation/control/table/sequence.py
21
- pychemstation/control/table/table_controller.py
17
+ pychemstation/control/controllers/__init__.py
18
+ pychemstation/control/controllers/comm.py
19
+ pychemstation/control/controllers/method.py
20
+ pychemstation/control/controllers/sequence.py
21
+ pychemstation/control/controllers/table_controller.py
22
22
  pychemstation/generated/__init__.py
23
23
  pychemstation/generated/dad_method.py
24
24
  pychemstation/generated/pump_method.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="pychemstation",
8
- version="0.5.4",
8
+ version="0.5.5",
9
9
  author="Lucy Hao",
10
10
  author_email="lhao03@student.ubc.ca",
11
11
  description="Library to interact with Chemstation software, primarily used in Hein lab",
File without changes
File without changes