biocrnpyler.components.LocalComponentEnumerator

class biocrnpyler.components.LocalComponentEnumerator(name: str)[source]

Bases: ComponentEnumerator

Component enumerator that operates on individual components.

A LocalComponentEnumerator processes components independently, creating new components based solely on the properties of a single input component. This is the most common type of enumerator, used when enumeration does not require knowledge of other components in the mixture.

Parameters:

name (str) – Name identifier for the local component enumerator.

Attributes:

name (str) – The name of the enumerator (inherited from ComponentEnumerator).

See also

ComponentEnumerator

Base class for component enumerators.

GlobalComponentEnumerator

Enumerator requiring all mixture components.

Notes

Local component enumerators are appropriate when:

  • Enumeration depends only on the component being processed

  • No cross-component interactions are needed

  • Components can be processed independently

Common examples include:

  • Generating RNA transcripts from DNA components

  • Creating protein products from RNA components

  • Expanding DNA assemblies into constituent parts

The enumerate_components method receives only the single component being processed.

Examples

Create a custom local enumerator:

>>> class TranscriptEnumerator(bcp.LocalComponentEnumerator):
...     def __init__(self):
...         super().__init__(name='TranscriptEnumerator')
...
...     def enumerate_components(self, component=None):
...         if isinstance(component, bcp.DNA):
...             # Create RNA transcript from DNA
...             transcript = bcp.RNA(name=f'{component.name}_transcript')
...             return [transcript]
...         return []

Methods

enumerate_components

Enumerate new components from an input component.

enumerate_components(component=None) List[source]

Enumerate new components from an input component.

This method creates new components based on the input component. The base implementation returns an empty list and issues a warning. Subclasses should override this method to provide specific enumeration behavior.

Parameters:

component (Component, optional) – The input component to enumerate from. Can be None for enumerators that do not require an input component.

Returns:

List of newly enumerated components. Base implementation returns an empty list.

Return type:

list of Component

Warns:

UserWarning – Issues a warning when the default implementation is called, indicating that a subclass should override this method.

See also

Component.enumerate_components

Component-level enumeration method.

Notes

This method is called during CRN compilation as part of the component enumeration phase. Subclasses should implement specific logic to generate derived components.