biocrnpyler.core.ModelParameter
- class biocrnpyler.core.ModelParameter(parameter_name: str, parameter_value: str | Real, search_key, found_key, unit=None, parameter_key=None, parameter_info=None, **kwargs)[source]
Bases:
ParameterEntryParameter with search and found keys for defaulting behavior.
A
ModelParameterextendsParameterEntrywith information about how the parameter was looked up in the database. It tracks both the original search key and the actual key where the parameter was found, enabling parameter defaulting and debugging.- Parameters:
parameter_name (
str) – Name of the parameter.parameter_value (
floatorstr) – Value of the parameter.search_key (
dict,ParameterKey,tuple, orstr) – The key originally searched for in the database. Usually includes mechanism, part_id, and name.found_key (
dict,ParameterKey,tuple, orstr) – The key where the parameter was actually found after defaulting. May have fewer fields than search_key.unit (
str, optional) – Unit of the parameter.parameter_key (
dict,ParameterKey,str, orNone, optional) – Database lookup key (inherited from ParameterEntry).parameter_info (
dict, optional) – Additional metadata (inherited from ParameterEntry).**kwargs – Additional keyword arguments passed to ParameterEntry constructor.
- Attributes:
search_key (
ParameterKey) – The original lookup key as a named tuple.found_key (
ParameterKey) – The key where parameter was found as a named tuple.
See also
ParameterBase parameter class.
ParameterEntryParameter with database key.
ParameterDatabaseDatabase with parameter defaulting.
Notes
The parameter defaulting hierarchy is:
(mechanism_name, part_id, param_name)
(mechanism_type, part_id, param_name)
(None, part_id, param_name)
(mechanism_name, None, param_name)
(mechanism_type, None, param_name)
(None, None, param_name)
The
search_keyshows what was requested, whilefound_keyshows which level of defaulting was used. This information is useful for debugging parameter lookups.Examples
Create a model parameter showing search and found keys:
>>> model_param = bcp.ModelParameter( ... 'kb', ... 100.0, ... search_key={'mechanism': 'binding', 'part_id': 'prom1'}, ... found_key={'mechanism': 'binding', 'part_id': None}, ... unit='1/s' ... ) >>> # Shows parameter was found using mechanism-level default
Methods
Convert various input types to a ParameterKey namedtuple.
Generate SBML-compatible identifier for the parameter.
- __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).
- static create_parameter_key(new_key: Dict | ParameterKey | str, parameter_name=None) ParameterKey[source]
Convert various input types to a ParameterKey namedtuple.
- Parameters:
new_key (
dict,ParameterKey,tuple,str, orNone) –Input to convert to ParameterKey:
dict: Must have keys matching ParameterKey fields
ParameterKey: Returned as-is
3-tuple: Converted to ParameterKey with proper field mapping
str: Used as ‘name’, other fields set to None
None: All fields set to None (requires parameter_name)
parameter_name (
str, optional) – Parameter name to use if not specified in new_key. Overridesnamefield if provided in dict.
- Returns:
Named tuple with fields (mechanism, part_id, name).
- Return type:
ParameterKey- Raises:
ValueError – If
new_keyis not a valid type or format.
Examples
>>> key = bcp.ParameterEntry.create_parameter_key('kb') >>> key ParameterKey(mechanism=None, part_id=None, name='kb')
>>> key = bcp.ParameterEntry.create_parameter_key( ... {'mechanism': 'transcription', 'part_id': 'prom1'}, ... parameter_name='ktx' ... ) >>> key ParameterKey(mechanism='transcription', part_id='prom1', name='ktx')
- property found_key
The key where parameter was actually found.
- Type:
ParameterKey
- get_sbml_id()[source]
Generate SBML-compatible identifier for the parameter.
Constructs an identifier string from the parameter key fields, formatted as: ‘<name>_<part_id>_<mechanism>’.
- Returns:
SBML-compatible identifier string.
- Return type:
str
- property parameter_info: Dict
Additional metadata about the parameter.
- Type:
dict
- property parameter_key: ParameterKey
The database lookup key for this parameter.
- Type:
ParameterKey
- property parameter_name: str
The name of the parameter.
- Type:
str
- property search_key
The key originally searched for in database.
- Type:
ParameterKey
- property unit: str
The unit string for the parameter.
- Type:
str
- property value: Real
The numerical value of the parameter.
- Type:
float