Skip to content

Documentation for ChromAnalyzer

Bases: BaseModel

add_molecule(molecule, init_conc=None, conc_unit=None, retention_tolerance=None)

Adds a molecule to the list of species, allowing to update the initial concentration, concentration unit, and retention time tolerance.

Parameters:

Name Type Description Default
molecule Molecule

The molecule object to be added.

required
init_conc float | None

The initial concentration of the molecule. Defaults to None.

None
conc_unit UnitDefinition | None

The unit of the concentration. Defaults to None.

None
retention_tolerance float | None

Retention time tolerance for peak annotation in minutes. Defaults to None.

None

add_molecule_from_standard(standard, init_conc, conc_unit)

Adds a molecule to the list of species based on a Standard object.

add_protein(protein, init_conc=None, conc_unit=None)

Adds a protein to the list of proteins or updates an existing protein based on the pubchem_cid of the molecule.

Parameters:

Name Type Description Default
protein Protein

The protein object to be added.

required

add_standard(molecule, wavelength=None, visualize=True)

Creates a standard curve for a molecule based on the peak areas and concentrations.

Parameters:

Name Type Description Default
molecule Molecule

The molecule for which the standard curve should be created.

required
wavelength float | None

The wavelength of the detector. Defaults to None.

None
visualize bool

If True, the standard curve is visualized. Defaults to True.

True

add_to_enzymeml(enzdoc, calculate_concentration=True, extrapolate=False)

Adds the data from the ChromAnalyzer to an existing EnzymeML document.

Parameters:

Name Type Description Default
enzdoc EnzymeMLDocument

The EnzymeML document to which the data should be added.

required
calculate_concentration bool

If True, the concentrations of the species are calculated. Defaults to True.

True
extrapolate bool

If True, the concentrations are extrapolated to if the measured peak areas are outside the calibration range. Defaults to False.

False

Returns:

Name Type Description
EnzymeMLDocument EnzymeMLDocument

The updated EnzymeML document.

define_internal_standard(id, pubchem_cid, name, init_conc, conc_unit, retention_time, retention_tolerance=0.1, wavelength=None)

Defines an molecule as the internal standard for concentration calculation.

Parameters:

Name Type Description Default
id str

Internal identifier of the molecule such as s0 or asd45.

required
pubchem_cid int

PubChem CID of the molecule.

required
name str

Name of the internal standard molecule.

required
init_conc float

Initial concentration of the internal standard.

required
conc_unit UnitDefinition

Unit of the concentration.

required
retention_time float

Retention time of the internal standard in minutes.

required
retention_tolerance float

Retention time tolerance for peak annotation in minutes. Defaults to 0.1.

0.1
wavelength float | None

Wavelength of the detector on which the molecule was detected. Defaults to None.

None

define_molecule(id, pubchem_cid, retention_time, retention_tolerance=0.1, init_conc=None, conc_unit=None, name=None, wavelength=None)

Defines and adds a molecule to the list of molecules.

Parameters:

Name Type Description Default
id str

Internal identifier of the molecule, such as s0 or asd45.

required
pubchem_cid int

PubChem CID of the molecule, which uniquely identifies the compound.

required
retention_time Optional[float]

Retention time for peak annotation in minutes. If the molecule is not detected in the chromatograms, this can be set to None.

required
retention_tolerance float

Tolerance in minutes for retention time used in peak annotation. Defaults to 0.1.

0.1
init_conc Optional[float]

Initial concentration of the molecule. If not provided, it defaults to None.

None
conc_unit Optional[UnitDefinition]

Unit of the initial concentration. If not provided, it defaults to None.

None
name Optional[str]

Name of the molecule. If not provided, the name is fetched from the PubChem database. Defaults to None.

None
wavelength Optional[float]

Wavelength of the detector where the molecule was detected. If not provided, it defaults to None.

None

Returns:

Name Type Description
Molecule Molecule

The molecule object that was added to the list of species.

define_protein(id, name, init_conc, conc_unit, sequence=None, organism=None, organism_tax_id=None, constant=True)

Adds a protein to the list of proteins or updates an existing protein based on the pubchem_cid of the molecule.

Parameters:

Name Type Description Default
id str

Internal identifier of the protein such as p0 or asd45.

required
name str

Name of the protein.

required
init_conc float

Initial concentration of the protein.

required
conc_unit UnitDefinition

Unit of the concentration.

required
sequence str

Amino acid sequence of the protein. Defaults to None.

None
organism str

Name of the organism. Defaults to None.

None
organism_tax_id int

NCBI taxonomy ID of the organism. Defaults to None.

None
constant bool

Boolean indicating whether the protein concentration is constant. Defaults to True.

True

from_json(path) classmethod

Load an instance of the class from a JSON file.

Parameters:

Name Type Description Default
path str

The file path to the JSON file.

required

Returns:

Type Description

An instance of the class populated with data from the JSON file.

Raises:

Type Description
FileNotFoundError

If the specified file does not exist.

JSONDecodeError

If the file contains invalid JSON.

process_chromatograms(prominence=0.03, min_retention_time=None, max_retention_time=None, **hplc_py_kwargs)

Processes the chromatograms using the hplc-py library.

Info

Please consider using OpenChrom or other chromatography software to calculate peak areas. Especially for complex chromatograms, the results may be more accurate.

Parameters:

Name Type Description Default
prominence float

The prominence of the peaks to be detected. Defaults to 0.03.

0.03
min_retention_time float | None

The minimum retention time to be considered in the peak detection. Defaults to None.

None
max_retention_time float | None

The maximum retention time to be considered in the peak detection. Defaults to None.

None
hplc_py_kwargs

Keyword arguments to be passed to the fit_peaks method of the hplc-py library. For more information, visit the HPLC-Py Documentation.

{}

read_agilent(path, ph, temperature, temperature_unit=C, mode=None, values=None, unit=None, id=None, name='Chromatographic measurement', silent=False) classmethod

Reads Agilent Report.txt or RESULTS.csv files within a *.D directories within the specified path.

Parameters:

Name Type Description Default
path str

Path to the directory containing the Shimadzu files.

required
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinition

Unit of the temperature. Defaults to Celsius (C).

C
mode Optional[Literal['timecourse', 'calibration']]

Mode of the data. If "timecourse", values should be a list of reaction times. If "calibration", values should be a list of concentrations. Defaults to None.

None
values list[float]

A list of reaction times (for "timecourse" mode) or concentrations (for "calibration" mode), corresponding to each measurement in the directory.

None
unit UnitDefinition

Unit of the values provided. It can be the time unit for reaction times or the concentration unit for calibration mode, depending on the mode.

None
id str

Unique identifier of the ChromAnalyzer object. If not provided, the path is used as ID.

None
name str

Name of the measurement. Defaults to "Chromatographic measurement".

'Chromatographic measurement'
silent bool

If True, no success message is printed. Defaults to False.

False

Returns:

Name Type Description
ChromAnalyzer ChromAnalyzer

ChromAnalyzer object containing the measurements.

read_asm(path, ph, temperature, temperature_unit=C, mode=None, values=None, unit=None, id=None, name='Chromatographic measurement', silent=False) classmethod

Reads chromatographic data from a directory containing Allotrope Simple Model (ASM) json files. Measurements are assumed to be named alphabetically, allowing sorting by file name.

Parameters:

Name Type Description Default
path str

Path to the directory containing the ASM files.

required
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinition

Unit of the temperature. Defaults to Celsius (C).

C
mode Optional[Literal['timecourse', 'calibration']]

Mode of the data. If "timecourse", values should be a list of reaction times. If "calibration", values should be a list of concentrations. Defaults to None.

None
values list[float]

A list of reaction times (for "timecourse" mode) or concentrations (for "calibration" mode), corresponding to each measurement in the directory.

None
unit UnitDefinition

Unit of the values provided. It can be the time unit for reaction times or the concentration unit for calibration mode, depending on the mode.

None
id str

Unique identifier of the ChromAnalyzer object. If not provided, the path is used as ID.

None
name str

Name of the measurement. Defaults to "Chromatographic measurement".

'Chromatographic measurement'
silent bool

If True, no success message is printed. Defaults to False.

False

Returns:

Name Type Description
ChromAnalyzer ChromAnalyzer

ChromAnalyzer object containing the measurements.

read_chromeleon(path, ph, temperature, temperature_unit=C, mode=None, values=None, unit=None, id=None, name='Chromatographic measurement', silent=False) classmethod

Reads Chromeleon txt files from a directory. The files in the directory are assumed to be of one calibration or timecourse measurement series.

Parameters:

Name Type Description Default
path str

Path to the directory containing the Shimadzu files.

required
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinition

Unit of the temperature. Defaults to Celsius (C).

C
mode Optional[Literal['timecourse', 'calibration']]

Mode of the data. If "timecourse", values should be a list of reaction times. If "calibration", values should be a list of concentrations. Defaults to None.

None
values list[float]

A list of reaction times (for "timecourse" mode) or concentrations (for "calibration" mode), corresponding to each measurement in the directory.

None
unit UnitDefinition

Unit of the values provided. It can be the time unit for reaction times or the concentration unit for calibration mode, depending on the mode.

None
id str

Unique identifier of the ChromAnalyzer object. If not provided, the path is used as ID.

None
name str

Name of the measurement. Defaults to "Chromatographic measurement".

'Chromatographic measurement'
silent bool

If True, no success message is printed. Defaults to False.

False

Returns:

Name Type Description
ChromAnalyzer ChromAnalyzer

ChromAnalyzer object containing the measurements.

read_shimadzu(path, ph, temperature, temperature_unit=C, mode=None, values=None, unit=None, id=None, name='Chromatographic measurement', silent=False) classmethod

Reads chromatographic data from a directory containing Shimadzu files. Measurements are assumed to be named alphabetically, allowing sorting by file name.

Parameters:

Name Type Description Default
path str

Path to the directory containing the Shimadzu files.

required
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinition

Unit of the temperature. Defaults to Celsius (C).

C
mode Optional[Literal['timecourse', 'calibration']]

Mode of the data. If "timecourse", values should be a list of reaction times. If "calibration", values should be a list of concentrations. Defaults to None.

None
values list[float]

A list of reaction times (for "timecourse" mode) or concentrations (for "calibration" mode), corresponding to each measurement in the directory.

None
unit UnitDefinition

Unit of the values provided. It can be the time unit for reaction times or the concentration unit for calibration mode, depending on the mode.

None
id str

Unique identifier of the ChromAnalyzer object. If not provided, the path is used as ID.

None
name str

Name of the measurement. Defaults to "Chromatographic measurement".

'Chromatographic measurement'
silent bool

If True, no success message is printed. Defaults to False.

False

Returns:

Name Type Description
ChromAnalyzer ChromAnalyzer

ChromAnalyzer object containing the measurements.

to_enzymeml(name, calculate_concentration=True, extrapolate=False)

Creates an EnzymeML document from the data in the ChromAnalyzer.

Parameters:

Name Type Description Default
name str

Name of the EnzymeML document.

required
calculate_concentration bool

If True, the concentrations of the species are calculated. Defaults to True.

True
extrapolate bool

If True, the concentrations are extrapolated to if the measured peak areas are outside the calibration range. Defaults to False.

False

Returns:

Name Type Description
EnzymeMLDocument EnzymeMLDocument

description

to_json(path)

Serialize the instance to a JSON file. Parameters: path (str or Path): The file path where the JSON data will be saved. If the parent directory does not exist, it will be created. Returns: None: This method does not return a value. It writes the instance's attributes to a JSON file at the specified path.

visualize_all(assigned_only=False, dark_mode=False, show=False)

Plots the fitted peaks of the chromatograms in an interactive figure.

Parameters:

Name Type Description Default
assigned_only bool

If True, only the peaks that are assigned to a molecule are plotted. Defaults to False.

False
dark_mode bool

If True, the figure is displayed in dark mode. Defaults to False.

False

Returns:

Type Description
Figure

go.Figure: description

visualize_spectra(dark_mode=False)

Plots all chromatograms in the ChromAnalyzer in a single plot.

Parameters:

Name Type Description Default
dark_mode bool

If True, the figure is displayed in dark mode. Defaults to False.

False

Returns:

Type Description
Figure

go.Figure: The plotly figure object.