biocrnpyler.core.Parameter
- class biocrnpyler.core.Parameter(parameter_name: str, parameter_value: str | Real, unit=None)[source]
Bases:
objectBase class for representing parameters in BioCRNpyler.
Parameters represent kinetic constants, initial concentrations, and other numerical values used in chemical reaction networks. This class provides validation for parameter names, values, and units.
- Parameters:
parameter_name (
str) – Name of the parameter. Must start with a letter and contain at least one character.parameter_value (
floatorstr) – Value of the parameter. Can be a number or a string in formats: ‘1.00’, ‘1e4’, or ‘2/5’ (rational). Strings are automatically converted to numerical values.unit (
str, optional) – Unit of the parameter (e.g., ‘1/s’, ‘nM’, ‘molecules’). If None, defaults to empty string.
- Attributes:
parameter_name (
str) – The validated name of the parameter.value (
float) – The numerical value of the parameter.unit (
str) – The unit string associated with the parameter.
See also
ParameterEntryParameter with database lookup keys.
ModelParameterParameter with search and found keys for defaulting.
ParameterDatabaseDatabase for storing and retrieving parameters.
Notes
This is the base class for all parameter types in BioCRNpyler. In practice, subclasses
ParameterEntryandModelParameterare more commonly used as they support the parameter lookup and defaulting system.Parameter values provided as strings are automatically converted:
‘1e4’ \(\rightarrow\) 10000.0
‘2/5’ \(\rightarrow\) 0.4
‘1.23’ \(\rightarrow\) 1.23
Examples
Create a basic parameter:
>>> param = bcp.Parameter('kb', 100.0, unit='1/s') >>> param.parameter_name 'kb' >>> param.value 100.0
Create a parameter from a string value:
>>> param = bcp.Parameter('ku', '1e-4', unit='1/s') >>> param.value 0.0001
Create a parameter from a rational string:
>>> param = bcp.Parameter('ratio', '3/4') >>> param.value 0.75
Methods
- __eq__(other)[source]
Test equality between parameters or parameter and number.
- Parameters:
other (
Parameterorfloat) – Object to compare with. Can be another Parameter object or a numerical value.- Returns:
True if values are equal, False otherwise.
- Return type:
bool- Raises:
TypeError – If
othercannot be compared (not a Parameter or number).
- property parameter_name: str
The name of the parameter.
- Type:
str
- property unit: str
The unit string for the parameter.
- Type:
str
- property value: Real
The numerical value of the parameter.
- Type:
float