biocrnpyler.components.GlobalComponentEnumerator

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

Bases: ComponentEnumerator

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:

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

Attributes:

name (str) – 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]
... )

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.