Skip to main content

Library to interact with Chemstation software, primarily used in Hein lab

Project description

Agilent HPLC Macro Control

PyPI - Downloads

PyPI Latest Release

Unofficial Python package to control Agilent Chemstation; we are not affiliated with Agilent. Check out the docs for usage instructions. This project is under active development, and breaking changes may occur at any moment.

Getting started

Before running this library, these are the steps you need to complete.

Add python package

pip install pychemstation

Add required MACRO script

  1. Open ChemStation
  2. Run this in the ChemStation command line: Print _AutoPath$. Go to this path in your file navigator, as this is where you will put your MACRO file(s).
  3. Download the hplc_talk.mac.
    • On line 69, change the path name up to \cmd and \reply. For instance, you should have: MonitorFile "[my path]\cmd", "[my path]\reply"
    • and then add this file to the folder from the previous step.
  4. To have these MACRO files be read by ChemStation, you must either:
    • Open ChemStation and run:
macro hplc_talk.mac
HPLCTalk_Run
  • OR add the above lines to a MACRO file named: user.mac, and then put user.mac in the same folder from step 3.
    • ChemStation will automatically load these MACRO files for you. However, sometimes this does not work, and if it does not, you will have to run the lines in the user.mac manually.

Example Usage

from pychemstation.control import HPLCController
import pandas as pd

# these paths will be unique to your Chemstation setup
DEFAULT_COMMAND_PATH = "C:\\Users\\User\\Desktop\\Lucy\\"
DEFAULT_METHOD = "GENERAL-POROSHELL"
DEFAULT_METHOD_DIR = "C:\\ChemStation\\1\\Methods\\"
DATA_DIR = "C:\\Users\\Public\\Documents\\ChemStation\\2\\Data"
SEQUENCE_DIR = "C:\\USERS\\PUBLIC\\DOCUMENTS\\CHEMSTATION\\2\\Sequence"

hplc_controller = HPLCController(data_dir=DATA_DIR,
                                 comm_dir=DEFAULT_COMMAND_PATH,
                                 sequence_dir=SEQUENCE_DIR,
                                 method_dir=DEFAULT_METHOD_DIR)

hplc_controller.preprun()
hplc_controller.switch_method(method_name=DEFAULT_METHOD)
hplc_controller.run_method(experiment_name="Run 10")
data_status_valid, chrom = hplc_controller.get_last_run_method_data()

if data_status_valid:
    # afterwards, save, analyze or plot the data!
    values = {"x": chrom.x, "y": chrom.y}
    chromatogram_data = pd.DataFrame.from_dict(values)
    chromatogram_data.to_csv("Run 10.csv", index=False) 

Adding your own MACROs

If you wish to add your own MACRO functions, then all you need to do is write you MACRO (using Agilent's) MACRO guide, put the file in the user.mac file and then list the function you want to use.

Developing

If you would like to contribute to this project, check out our GitLab!

Authors and Acknowledgements

Lucy Hao

  • Adapted from AnalyticalLabware, created by members in the Cronin Group. Copyright © Cronin Group, used under the CC-BY-4.0 license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pychemstation-0.5.1.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pychemstation-0.5.1-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

Details for the file pychemstation-0.5.1.tar.gz.

File metadata

  • Download URL: pychemstation-0.5.1.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pychemstation-0.5.1.tar.gz
Algorithm Hash digest
SHA256 5e94b00d8921d9c224b33af93e472dcf2d85c0086b9887dfef90d0a651f9b716
MD5 ae2133b932a3eb8da171f758f08dd3a8
BLAKE2b-256 b172d7f8e7d94e98aee21574acf4b40b54677a225b6b4788f2439875e159197a

See more details on using hashes here.

File details

Details for the file pychemstation-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pychemstation-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pychemstation-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55e26e12eb3867b8311eddfc981e8a51a91325235d29b72f232f7f1126c9ddf3
MD5 45e3edfb3ece1da3ed938919ce7baf64
BLAKE2b-256 53727227684cd0a73e408f1098794c7868ff4a54e5b79428ffb3359554b5bdbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page