biocrnpyler.components.component_enumerator

Classes

ComponentEnumerator(name)

Base class for enumerating new components from existing components.

GlobalComponentEnumerator(name)

Component enumerator that operates on all mixture components.

LocalComponentEnumerator(name)

Component enumerator that operates on individual components.

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

Base class for enumerating new components from existing components.

A ComponentEnumerator creates new components in a process similar to mechanisms. Component enumerators are used during CRN compilation to expand or transform components, generating derived components that are then compiled into species and reactions.

Parameters:
namestr

Name identifier for the component enumerator.

Attributes:
namestr

The name of the enumerator.

See also

LocalComponentEnumerator

Enumerator for single-component processing.

GlobalComponentEnumerator

Enumerator requiring all mixture components.

Mechanism

Base class for reaction generation.

Notes

This is a base class that should be subclassed to implement specific enumeration behavior. The key method to override is enumerate_components.

Component enumerators are used during the mixture compilation process to:

  • Generate derived components (e.g., transcripts from DNA)

  • Transform components based on context

  • Create component variants or states

Examples

Create a custom component enumerator:

>>> class MyEnumerator(bcp.ComponentEnumerator):
...     def __init__(self):
...         super().__init__(name='MyEnumerator')
...
...     def enumerate_components(self, component=None):
...         # Custom enumeration logic
...         new_components = []
...         # ... generate new components ...
...         return new_components
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:
componentComponent, optional

The input component to enumerate from. Can be None for enumerators that do not require an input component.

Returns:
list of Component

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

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.

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

Component enumerator that operates on all mixture components.

A GlobalComponentEnumerator has access to all components in the mixture, allowing for complex enumeration that depends on interactions or relationships between multiple components. This is used when enumeration decisions require global context.

Parameters:
namestr

Name identifier for the global component enumerator.

Attributes:
namestr

The name of the enumerator (inherited from ComponentEnumerator).

See also

ComponentEnumerator

Base class for component enumerators.

LocalComponentEnumerator

Enumerator for single-component processing.

Notes

Global component enumerators are appropriate when:

  • Enumeration depends on multiple components

  • Cross-component interactions must be considered

  • Global context or mixture-wide information is needed

The enumerate_components method typically receives all components in the mixture, allowing the enumerator to make decisions based on the complete set of components.

Common examples include:

  • Generating complexes between components

  • Creating interaction networks

  • Enumerating components based on global constraints

Performance note: Global enumerators may be more computationally expensive than local enumerators since they must consider all components.

Examples

Create a custom global enumerator:

>>> class ComplexEnumerator(bcp.GlobalComponentEnumerator):
...     def __init__(self):
...         super().__init__(name='ComplexEnumerator')
...
...     def enumerate_components(self, component=None):
...         # Access all components (passed via mixture)
...         # Generate complexes between compatible components
...         new_complexes = []
...         # ... complex enumeration logic ...
...         return new_complexes

Use in a mixture:

>>> enumerator = ComplexEnumerator()
>>> mixture = bcp.Mixture(
...     components=[comp1, comp2, comp3],
...     global_component_enumerators=[enumerator]
... )
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:
componentComponent, optional

The input component to enumerate from. Can be None for enumerators that do not require an input component.

Returns:
list of Component

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

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.

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

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:
namestr

Name identifier for the local component enumerator.

Attributes:
namestr

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 []
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:
componentComponent, optional

The input component to enumerate from. Can be None for enumerators that do not require an input component.

Returns:
list of Component

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

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.