biocrnpyler.core.ParameterEntry

class biocrnpyler.core.ParameterEntry(parameter_name: str, parameter_value: str | Real, parameter_key=None, parameter_info=None, **kwargs)[source]

Bases: Parameter

Parameter with database lookup key and metadata.

A ParameterEntry extends Parameter with a lookup key for database storage and retrieval, plus additional metadata about the parameter’s origin and context.

Parameters:
  • parameter_name (str) – Name of the parameter.

  • parameter_value (float or str) – Value of the parameter.

  • parameter_key (dict, ParameterKey, str, or None, optional) – Lookup key for the parameter database.

  • parameter_info (dict, optional) – Additional metadata about the parameter (e.g., source file, comments). If dict contains ‘unit’ key, it will update the parameter’s unit.

  • **kwargs – Additional keyword arguments passed to Parameter constructor, including ‘unit’.

Attributes:
  • parameter_key (ParameterKey) – The lookup key as a named tuple (mechanism, part_id, name).

  • parameter_info (dict) – Dictionary of additional parameter metadata.

See also

Parameter

Base parameter class.

ModelParameter

Parameter with search and found keys.

ParameterDatabase

Database for storing parameter entries.

Notes

The parameter_key value can be any of the following:

  • dict: {‘mechanism’: …, ‘part_id’: …, ‘name’: …}

  • ParameterKey namedtuple: (mechanism, part_id, name)

  • str: parameter name (other fields set to None)

  • None: creates key with all fields None except name

using the following conventions:

  • mechanism: str or None (mechanism name or type)

  • part_id: str or None (component/part identifier)

  • name: str (parameter name)

These keys enable flexible parameter lookup with defaulting behavior in the ParameterDatabase.

Examples

Create a parameter entry with full key:

>>> entry = bcp.ParameterEntry(
...     'kb',
...     100.0,
...     parameter_key={'mechanism': 'binding', 'part_id': 'promoter1'},
...     unit='1/s'
... )

Create a parameter entry with just a name:

>>> entry = bcp.ParameterEntry('ku', 0.01, parameter_key='ku')
>>> entry.parameter_key
ParameterKey(mechanism=None, part_id=None, name='ku')

Methods

create_parameter_key

Convert various input types to a ParameterKey namedtuple.

get_sbml_id

Generate SBML-compatible identifier for the parameter.

__eq__(other)[source]

Test equality between parameters or parameter and number.

Parameters:

other (Parameter or float) – 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 other cannot 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, or None) –

    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. Overrides name field if provided in dict.

Returns:

Named tuple with fields (mechanism, part_id, name).

Return type:

ParameterKey

Raises:

ValueError – If new_key is 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')
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 unit: str

The unit string for the parameter.

Type:

str

property value: Real

The numerical value of the parameter.

Type:

float