Core Abstractions¶
This page documents the three foundational abstractions of REvoDesign: the Borg-like singleton pattern, the base class for all third-party designer/scorer modules, and the central configuration-to-UI bridge.
SingletonAbstract¶
SingletonAbstract is the Borg-like singleton base class. It enforces that only one instance of a class is created, supports dynamic derivation of independent singleton subclasses, provides instance re-initialization, and allows explicit instance reset. Subclasses must implement the singleton_init method for custom initialization logic.
REvoDesign.basic.abc_singleton.SingletonAbstract
¶
Bases: ABC
A base class that enforces the Singleton design pattern. Ensures that only one instance of the class is created, with support for dynamic derivation of new singleton classes.
Attributes:
| Name | Type | Description |
|---|---|---|
_instance |
The singleton instance of the class. |
singleton_init(*args, **kwargs)
abstractmethod
¶
Abstract method to initialize the singleton instance with custom logic.
Subclasses must implement this method to initialize their specific attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments for initialization. |
()
|
|
**kwargs
|
Keyword arguments for initialization. |
{}
|
initialize(*args, **kwargs)
classmethod
¶
Initializes the singleton instance if it doesn't exist yet. Updates the singleton instance with new variables if it already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments for initialization. |
()
|
|
**kwargs
|
Keyword arguments for initialization or updating. |
{}
|
derive(name)
classmethod
¶
Dynamically creates a derived class with independent singleton behavior.
This method allows for the creation of new singleton classes that inherit from the current class. Each derived class has its own independent singleton instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the derived class. |
required |
Returns:
| Type | Description |
|---|---|
type[T]
|
A dynamically created subclass with singleton behavior. |
reset_instance()
classmethod
¶
Resets the singleton instance for the class.
After calling this method, the next instantiation will create a new singleton instance.
ExternalDesignerAbstract¶
ExternalDesignerAbstract is the abstract base class for all third-party designer and scorer modules in REvoDesign. It inherits from ThirdPartyModuleAbstract and provides a framework for designing molecules, including serial and parallel scoring of mutants.
REvoDesign.basic.designer.ExternalDesignerAbstract
¶
Bases: ThirdPartyModuleAbstract
Abstract class for external design, providing a framework for designing molecules. This class is abstract and must be inherited and implemented by concrete design classes.
Attributes:
| Name | Type | Description |
|---|---|---|
pdb_filename |
str
|
Name of the PDB file, initially set to None, indicating not specified. |
initialized |
bool
|
Flag to indicate whether initialization has been performed, defaults to False. |
molecule |
The molecule object, storing the molecule to be designed. |
|
reload |
bool
|
A flag indicating whether to reload the design, defaults to False. |
get_weights()
¶
Retrieve the weights used in the design process. The implementation should define how these weights are calculated or retrieved.
initialize(*args, **kwargs)
abstractmethod
¶
Abstract method to initialize the design process. Must be implemented by subclasses to perform necessary setup steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args, **kwargs
|
Flexible arguments that can be passed to perform specific initialization tasks. |
required |
designer(*args, **kwargs)
¶
Abstract method to execute the design algorithm. Subclasses must provide the actual design logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args, **kwargs
|
Additional parameters that can be used during the design process. |
required |
scorer(mutant, **kwargs)
¶
Abstract method to evaluate or score a given sequence design. Determines the quality or fitness of the designed sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mutant
|
Mutant | RosettaPyProteinSequence
|
The molecular sequence being evaluated. |
required |
*args, **kwargs
|
Additional parameters for scoring, if required. |
required |
preffer_substitutions(aa)
¶
Method to setup amino acids that are preferred for substitution in further design.
parallel_scorer(mutants, nproc=2, **kwargs)
¶
Parallelize the scoring of a list of mutants.
score_mutant_mapping(mutants, scores)
staticmethod
¶
Assign scores to mutants.
ConfigBus¶
ConfigBus is the central configuration-to-UI bridge singleton. It inherits from both SingletonAbstract and CitableModuleAbstract, managing the bidirectional mapping between OmegaConf/Hydra YAML configuration and UI widget state. In headless mode only get_value/set_value are available; GUI methods are guarded by the @require_non_headless decorator.
See the Driver API for the full method reference.