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 UnitDefinitionAnnot | 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 Calibration 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

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

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[str]

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
is_internal_standard bool

If True, the molecule is used as internal standard. Defaults to False.

False

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 str

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
ChromAnalyzer

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.

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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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_csv(path, mode, ph, temperature, temperature_unit, retention_time_col_name, peak_area_col_name, id=None, values=None, unit=None, silent=False) classmethod

Reads chromatographic data from a CSV file.

Parameters:

Name Type Description Default
path str

Path to the CSV file.

required
mode Literal['timecourse', 'calibration']

Mode of the data.

required
values Optional[list[float]]

List of values. Defaults to None.

None
unit Optional[UnitDefinitionAnnot]

Unit of the values. Defaults to None.

None
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinitionAnnot

Unit of the temperature.

required
retention_time_col_name str

Name of the retention time column.

required
peak_area_col_name str

Name of the peak area column.

required
id str

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

None
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 UnitDefinitionAnnot

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 UnitDefinitionAnnot

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_thermo(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 Thermo Scientific TX0 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 TX0 files.

required
ph float

pH value of the measurement.

required
temperature float

Temperature of the measurement.

required
temperature_unit UnitDefinitionAnnot

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 UnitDefinitionAnnot

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.

set_dilution_factor(dilution_factor)

Sets the dilution factor for all 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 | 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(n_cols=2, figsize=(15, 10), show_peaks=True, show_processed=False, rt_min=None, rt_max=None, save_path=None, assigned_only=False, overlay=False)

Creates a matplotlib figure with subplots for each measurement.

Parameters:

Name Type Description Default
n_cols int

Number of columns in the subplot grid. Defaults to 2.

2
figsize tuple[float, float]

Figure size in inches (width, height). Defaults to (15, 10).

(15, 10)
show_peaks bool

If True, shows detected peaks. Defaults to True.

True
show_processed bool

If True, shows processed signal. Defaults to False.

False
rt_min float | None

Minimum retention time to display. If None, shows all data. Defaults to None.

None
rt_max float | None

Maximum retention time to display. If None, shows all data. Defaults to None.

None
save_path str | None

Path to save the figure. If None, the figure is not saved. Defaults to None.

None
assigned_only bool

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

False
overlay bool

If True, plots all chromatograms on a single axis. Defaults to False.

False

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.