mber Core Components
September 26, 2025 ยท View on GitHub
This document describes the core components of the mber package, which provide the foundation for all protocols and workflows.
Overview
The core components of mber are organized into several key areas:
- Data Structures - Classes for representing design states and related data
- Modules - Base implementations of the design pipeline modules
- Configuration - Configuration classes for various components
- Utilities - Core utility functions for common tasks
Data Structures
mber.core.data.serializable.SerializableDataclass
Base class providing serialization capabilities for dataclasses. All state-related classes inherit from this.
Key features:
- Pickle serialization/deserialization
- Formatted string representation
- Value formatting based on data types
mber.core.data.state
Contains the core data structures for representing design states:
ProtocolInfo- Protocol version and metadataConfigData- Container for all configuration objectsTemplateData- Template information and preparation resultsTrajectoryData- Trajectory optimization resultsBinderData- Individual binder data and metricsEvaluationData- Collection of evaluated bindersDesignState- Main design state container combining all data
Example of working with design state:
from mber.core.data.state import DesignState, TemplateData
# Create new design state
state = DesignState(
template_data=TemplateData(
target_id="P01234",
target_name="Example Protein"
)
)
# Add data to state
state.template_data.target_hotspot_residues = "A10,A25"
# Save state to directory
state.to_dir("./output/my_design")
# Load state from directory
loaded_state = DesignState.from_dir("./output/my_design")
Modules
Base Module Classes
The core modules define the base implementations of the main pipeline components:
BaseTemplateModule- Template preparationBaseTrajectoryModule- Trajectory optimizationBaseEvaluationModule- Binder evaluation
All modules inherit from BaseModule which provides common functionality like logging, configuration management, and resource cleanup.
Each module follows a standard interface:
# Standard module interface
def setup(self, design_state): ... # Set up resources
def run(self, design_state): ... # Run the main logic
def teardown(self, design_state): ... # Clean up
mber.core.modules.template.BaseTemplateModule
Handles template preparation, including:
- Target structure processing
- Hotspot detection
- Structure truncation
- Binder sequence initialization
- Position-specific bias generation
mber.core.modules.trajectory.BaseTrajectoryModule
Handles trajectory optimization, including:
- AlphaFold model setup
- Loss function configuration
- Sequence optimization
- Position-specific scoring matrix (PSSM) generation
mber.core.modules.evaluation.BaseEvaluationModule
Handles binder evaluation, including:
- Complex structure prediction
- Structure relaxation
- Scoring and metrics calculation
- Sequence-based evaluation
Configuration
mber.core.modules.config
Contains base configuration classes for all modules:
BaseTemplateConfig- Template module configurationBaseModelConfig- Model configurationBaseLossConfig- Loss function configurationBaseTrajectoryConfig- Trajectory optimization configurationBaseEvaluationConfig- Evaluation configurationBaseEnvironmentConfig- Computational environment configuration
Example:
from mber.core.modules.config import BaseTemplateConfig
config = BaseTemplateConfig(
sasa_threshold=50.0,
pae_threshold=30.0,
distance_threshold=25.0,
folding_model="esmfold"
)
Core Functions
mber.core.sasa
Solvent accessible surface area (SASA) calculation and hotspot detection:
SASAHotspotFinder- Find surface-exposed residuesHotspotSelectionStrategy- Select hotspots using different strategiesfind_hotspots- Main entry point for hotspot detection
Example:
from mber.core.sasa import find_hotspots, HotspotSelectionStrategy
# Find hotspots with 'top_k' strategy
hotspots = find_hotspots(
pdb_content="...", # PDB file content as string
region_str="A:10-100", # Region of interest
sasa_threshold=50.0, # Threshold for surface exposure
hotspot_strategy=HotspotSelectionStrategy.top_k # Selection strategy
)
mber.core.truncation
Protein structure truncation functionality:
ProteinTruncator- Truncate structures based on distances and PAEparse_region_str- Parse region specification strings
Example:
from mber.core.truncation import ProteinTruncator
truncator = ProteinTruncator(
pdb_content="...", # PDB file content
region_str="A:10-100", # Region of interest
pae_matrix=None # Optional PAE matrix
)
# Create truncation
truncated_pdb, full_pdb, target_chain = truncator.create_truncation(
hotspots_str="A10,A25", # Hotspot residues
pae_threshold=25.0, # PAE threshold
distance_threshold=25.0, # Distance threshold
gap_penalty=10.0 # Gap penalty for optimization
)
mber.core.logging
Centralized logging utilities:
MberLogger- Set up and manage loggingLogStore- Store and retrieve logsStdoutCapturer- Capture stdout for logging
Example:
from mber.core.logging import MberLogger
# Set up logger
logger, log_store = MberLogger.setup_logger("MyModule")
# Log messages
MberLogger.log(logger, log_store, "This is an info message", level="info")
MberLogger.log(logger, log_store, "This is a warning", level="warning")
# Get logs
logs = log_store.get_logs()
Design State Lifecycle
The typical lifecycle of a design state through the mber pipeline:
-
Initialization: Create a new
DesignStatewith basic target information -
Template Preparation:
- Process target structure
- Identify hotspots
- Create structure truncation
- Initialize binder sequence
-
Trajectory Optimization:
- Set up AlphaFold model
- Configure loss functions
- Run sequence optimization
- Create position-specific scoring matrix
-
Evaluation:
- Predict complex structures
- Calculate metrics (iPTM, pLDDT, etc.)
- Perform structure relaxation
- Score sequences
-
Serialization: Save the complete design state to disk
Implementation Guide
When extending the core functionality, follow these guidelines:
- Subclassing: Extend the base classes rather than modifying them directly
- Configuration: Define configuration parameters in dataclasses
- Timing: Use the
@time_method()decorator for performance tracking - Logging: Use the standard logging utilities
- Serialization: Override serialization methods if needed
- Documentation: Document extensions thoroughly
- Type Hints: Use proper type annotations
Key Extension Points
When developing new protocols or features, these are key points to extend:
- Custom Modules: Extend base modules with protocol-specific logic
- Custom Configs: Add protocol-specific configuration parameters
- Custom State: Add protocol-specific data fields
- Custom Losses: Implement specialized loss functions
- Custom Models: Add new folding or language models