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, concs, conc_unit, 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 |
concs |
list[float]
|
List of concentrations of the molecule matching the order of the |
required |
conc_unit |
UnitDefinition
|
description |
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 |
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 |
required |
pubchem_cid |
int
|
PubChem CID of the molecule. |
required |
retention_time |
float
|
Retention time tolerance for peak annotation in minutes. |
required |
retention_tolerance |
float
|
Retention time tolerance for peak annotation in minutes. Defaults to 0.1. |
0.1
|
init_conc |
float | None
|
Initial concentration of the molecule. Defaults to None. |
None
|
conc_unit |
UnitDefinition | None
|
Unit of the concentration. Defaults to None. |
None
|
name |
str | None
|
Name of the molecule. If not provided, the name is retrieved from the PubChem database. Defaults to None. |
None
|
wavelength |
float | None
|
Wavelength of the detector on which the molecule was detected. 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 |
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 |
{}
|
read_agilent(path, ph, temperature, id=None, name='Chromatographic measurement', reaction_times=None, time_unit=None, temperature_unit=C, silent=False)
classmethod
Reads chromatographic data from an Agilent .csv or .txt file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the directory containing the Agilent files. |
required |
ph |
float
|
pH value of the measurement. |
required |
temperature |
float
|
Temperature of the measurement. |
required |
id |
str
|
Unique identifier of the ChromAnalyzer object. If not provided, the |
None
|
name |
str
|
Name the measurement. Defaults to "Chromatographic measurement". |
'Chromatographic measurement'
|
reaction_times |
list[float]
|
List of reaction times, corresponding to each measurement. If not provided, reaction times must be part of the file names. |
None
|
time_unit |
UnitDefinition
|
Unit of the time values. If the reaction times are part of the file name, this argument can be omitted. |
None
|
temperature_unit |
UnitDefinition
|
Unit of the temperature. Defaults to Celsius (C). |
C
|
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, id=None, name='Chromatographic measurement', reaction_times=None, time_unit=None, temperature_unit=C, silent=False)
classmethod
Reads chromatographic from a directory, containing Allotrope Simple Model (ASM) files. Measurements are assumed to be named alphabetically, allowing sorting by file name.
Tip
The reaction time ad the corresponding unit can be part of the file name of each individual ASM file.
In this case, the reaction_times
and time_unit
arguments can be omitted.
units can be defined as sec
, second
, min
, minute
, or hour
.
Examples for valid file names are m0 12.5 min.json
, m0 12 min
, m0 12.5 minutes
, m0 12.5min
,
m0 50mins.json
, m0 50.12 seconds.json
, m0_50sec.json
.
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 |
id |
str
|
Unique identifier of the ChromAnalyzer object. If not provided, the |
None
|
name |
str
|
Name the measurement. Defaults to "Chromatographic measurement". |
'Chromatographic measurement'
|
reaction_times |
list[float]
|
List of reaction times, corresponding to each measurement in the directory. |
None
|
time_unit |
UnitDefinition
|
Unit of the time values. |
None
|
temperature_unit |
UnitDefinition
|
description. Defaults to C. |
C
|
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, id=None, name='Chromatographic measurement', reaction_times=None, time_unit=None, temperature_unit=C, silent=False)
classmethod
Reads chromatographic data from an Agilent .csv or .txt file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the directory containing the Agilent files. |
required |
ph |
float
|
pH value of the measurement. |
required |
temperature |
float
|
Temperature of the measurement. |
required |
id |
str
|
Unique identifier of the ChromAnalyzer object. If not provided, the |
None
|
name |
str
|
Name the measurement. Defaults to "Chromatographic measurement". |
'Chromatographic measurement'
|
reaction_times |
list[float]
|
List of reaction times, corresponding to each measurement. If not provided, reaction times must be part of the file names. |
None
|
time_unit |
UnitDefinition
|
Unit of the time values. If the reaction times are part of the file name, this argument can be omitted. |
None
|
temperature_unit |
UnitDefinition
|
Unit of the temperature. Defaults to Celsius (C). |
C
|
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, id=None, name='Chromatographic measurement', reaction_times=None, time_unit=None, temperature_unit=C, 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 |
id |
str
|
Unique identifier of the ChromAnalyzer object. If not provided, the |
None
|
name |
str
|
Name the measurement. Defaults to "Chromatographic measurement". |
'Chromatographic measurement'
|
reaction_times |
list[float]
|
List of reaction times, corresponding to each measurement in the directory. |
None
|
time_unit |
UnitDefinition
|
Unit of the time values. If the reaction times are part of the file name, this argument can be omitted. |
None
|
temperature_unit |
UnitDefinition
|
Unit of the temperature. Defaults to Celsius (C). |
C
|
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)
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. |