Skip to content

Methods Module

CE method management and execution.

ChemstationAPI.controllers.methods_module.MethodsModule

MethodsModule(communicator: ChemstationCommunicator)

CE method management for analytical method control and execution.

Provides comprehensive method management for ChemStation CE methods including file operations, parameter editing, and execution with custom parameters. Methods are stored as .M files containing instrument parameters, acquisition settings, and data analysis rules.

Method Execution Modes
  1. Direct execution: Run current method with existing parameters
  2. Custom execution: Run method with specified data filename
  3. Parameterized execution: Run method with custom vial/sample information
File Management
  • Methods stored as .M files in ChemStation method directory
  • Runtime parameter access through RC.NET registers
  • Template execution with parameter modification

Attributes:

Name Type Description
comm

ChemStation communicator for command execution

validation

Method existence and parameter validation

system

System state monitoring and control

Initialize Methods module with ChemStation communicator.

Parameters:

Name Type Description Default
communicator ChemstationCommunicator

ChemStation communication interface for method operations and system commands

required

Functions

load

load(method_name: str, method_path: str = '_METHODPATHS$') -> None

Load CE method from file into ChemStation active memory.

Loads the specified method file and makes it the current active method. All instrument parameters are updated including voltage, temperature, vial assignments, and detection settings. Previous unsaved changes are lost.

Parameters:

Name Type Description Default
method_name str

Method filename without .M extension Examples: "CE_Protein_Analysis", "MEKC_SmallMolecules"

required
method_path str

Directory containing methods. Defaults to ChemStation method directory (_METHPATH$)

'_METHODPATHS$'

Raises:

Type Description
MethodError

If method file cannot be loaded or is corrupted

ValidationError

If method file doesn't exist in specified directory

FileNotFoundError

If method path is invalid

Examples:

>>> # Load standard analysis method
>>> methods.load("CE_Protein_Analysis")
>>> # Load method from custom directory  
>>> methods.load("TestMethod", "C:\Custom\Methods\")
Note

Method loading overwrites current instrument settings and includes automatic validation of method file existence before loading.

save

save(method_name: str = '_METHFILE$', method_path: str = '_METHODPATHS$', comment: str = '" "') -> None

Save current method with specified name and optional comment.

Saves the currently loaded method with all current parameter settings to a .M file. If no name specified, overwrites the current method file. Comment is stored in method file metadata for documentation purposes.

Parameters:

Name Type Description Default
method_name str

Filename for saved method (without .M extension) Defaults to current method name (_METHFILE$) Examples: "Modified_CE_Method", "Optimized_Analysis_v3"

'_METHFILE$'
method_path str

Directory for saving method. Defaults to ChemStation method directory (_METHPATH$)

'_METHODPATHS$'
comment str

Optional comment describing method changes or purpose. Use quotes for multi-word comments

'" "'

Raises:

Type Description
MethodError

If method cannot be saved due to file permissions

ValidationError

If method name contains invalid characters

PermissionError

If insufficient write permissions to directory

Examples:

>>> # Save current method with new name
>>> methods.save("Optimized_CE_Method", comment="Improved resolution")
>>> # Overwrite current method
>>> methods.save()
Note

Existing files with same name are overwritten without warning. Method name should follow Windows filename conventions.

run

run(data_name: str, data_dir: str = '_DATAPATH$') -> None

Execute current method and save data with specified name.

Runs the currently loaded method using existing method parameters including vial assignments, sample information, and all analytical conditions from the previous analysis setup. Only the output data filename is changed.

Parameters:

Name Type Description Default
data_name str

Name for the data file (without extension) Examples: "Sample001", "QC_Standard_20240315", "Blank_Run"

required
data_dir str

Directory for data storage. Defaults to ChemStation data directory (_DATAPATH$)

'_DATAPATH$'

Raises:

Type Description
MethodError

If method execution fails or cannot start

ValidationError

If data directory is invalid or required vials missing

SystemError

If instrument is not ready for analysis

Examples:

>>> # Run analysis with descriptive name
>>> methods.run("Protein_Sample_001")
>>> # Run QC standard with custom directory
>>> methods.run("QC_Standard_Daily", "C:\QC_Data\")
Requirements
  • Method must be loaded before execution
  • Required vials must be present and positioned
  • Instrument must be in ready state
Note

All other parameters (vials, method settings, sample info) remain the same as previous analysis. Progress can be monitored via system.method_on().

execution_method_with_parameters

execution_method_with_parameters(vial: int, method_name: str, sample_name: str = '', comment: str = '', subdirectory_name: str = '') -> None

Execute CE method with custom vial and sample parameters.

Executes a method with specified sample parameters by creating a temporary method register, modifying sample information, and running the analysis. Allows running the same method on different samples without manually editing method files.

Process workflow: 1. Creates temporary register (TemporaryRegisterMethod) 2. Loads specified method and copies parameters
3. Modifies vial number and sample information 4. Executes analysis with custom parameters 5. Data saved with automatic filename generation

Parameters:

Name Type Description Default
vial int

Carousel position for sample (1-48). Must contain sample vial

required
method_name str

Method to execute (without .M extension) Examples: "CE_Protein", "MEKC_Drugs", "CZE_Inorganics"

required
sample_name str

Descriptive sample name for data file and records Examples: "BSA_1mg_ml", "Drug_Standard_Mix", "Unknown_001"

''
comment str

Path to text file containing method comment/description. File content will be embedded in the method documentation

''
subdirectory_name str

Optional subdirectory for data organization. If empty, uses current data subdirectory

''

Raises:

Type Description
MethodError

If method execution fails or method not found

VialError

If specified vial is not present in carousel

ValidationError

If method name is invalid or doesn't exist

Examples:

>>> # Analyze protein sample with comment file
>>> methods.execution_method_with_parameters(
...     vial=15,
...     method_name="CE_Protein_Analysis", 
...     sample_name="BSA_Standard_1mg_ml",
...     comment="C:\Comments\protein_method.txt"
... )
>>> 
>>> # Run development sample in organized subdirectory
>>> methods.execution_method_with_parameters(
...     vial=22,
...     method_name="Development_CZE",
...     sample_name="Test_Sample_v3",
...     subdirectory_name="Method_Development"
... )
Requirements
  • Method file must exist in method directory
  • Vial must be physically present in carousel
  • Instrument must be ready for analysis
Note

Data filename generated automatically with timestamp. Sample information stored in data file metadata. Temporary register cleaned up after execution. Comment file validation needs to be implemented.