OCDocker.Toolbox.Preparation module¶
Strategy Pattern implementation for molecule preparation.
This module provides an abstract interface and concrete implementations for preparing ligands and receptors using different tools (MGLTools, SPORES, OpenBabel).
Usage:
from OCDocker.Toolbox.Preparation import MGLToolsPreparationStrategy
- class OCDocker.Toolbox.Preparation.PreparationStrategy[source]¶
Bases:
ABCAbstract base for ligand and receptor preparation backends.
Concrete strategies build external-tool command lines and run preparation with shared availability checks, output-directory creation, and overwrite handling.
- get_ligand_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a ligand.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
- Returns:
Command list that would be executed
- Return type:
list[str]
- get_receptor_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a receptor.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
- Returns:
Command list that would be executed
- Return type:
list[str]
- abstractmethod prepare_ligand(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a ligand molecule.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- abstractmethod prepare_receptor(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a receptor molecule.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- class OCDocker.Toolbox.Preparation.MGLToolsPreparationStrategy[source]¶
Bases:
PreparationStrategyPrepare ligands and receptors with MGLTools scripts.
Uses
prepare_ligand4.pyandprepare_receptor4.pyvia the configuredpythonshinterpreter fromOCDocker.Config.ToolsConfig.- get_ligand_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a ligand.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
- Returns:
Command list that would be executed
- Return type:
list[str]
- get_receptor_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a receptor.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
- Returns:
Command list that would be executed
- Return type:
list[str]
- prepare_ligand(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a ligand molecule.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- prepare_receptor(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a receptor molecule.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- class OCDocker.Toolbox.Preparation.SPORESPreparationStrategy[source]¶
Bases:
PreparationStrategyPrepare receptors with the SPORES external tool.
Converts receptor structures to MOL2 and applies SPORES protonation and typing using the configured
sporesexecutable.- get_ligand_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a ligand.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
- Returns:
Command list that would be executed
- Return type:
list[str]
- get_receptor_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a receptor.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
- Returns:
Command list that would be executed (same as ligand for SPORES)
- Return type:
list[str]
- prepare_ligand(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a ligand molecule.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- prepare_receptor(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a receptor molecule.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Return type:
int | str | Tuple[int, str]
- class OCDocker.Toolbox.Preparation.OpenBabelPreparationStrategy[source]¶
Bases:
PreparationStrategyPrepare ligands and receptors with Open Babel.
Uses the configured
obabelexecutable for format conversion and optional protonation when MGLTools is unavailable (e.g. Gnina workflows).- get_ligand_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a ligand.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
- Returns:
Command list that would be executed (OpenBabel conversion)
- Return type:
list[str]
- get_receptor_command(input_path, output_path)[source]¶
Get the command list that would be used to prepare a receptor.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
- Returns:
Command list that would be executed (OpenBabel conversion)
- Return type:
list[str]
- prepare_ligand(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a ligand molecule.
- Parameters:
input_path (str) – Path to input ligand file
output_path (str) – Path to output prepared ligand file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]
- prepare_receptor(input_path, output_path, log_file='', overwrite=False)[source]¶
Prepare a receptor molecule.
- Parameters:
input_path (str) – Path to input receptor file
output_path (str) – Path to output prepared receptor file
log_file (str, optional) – Path to log file (empty to suppress)
overwrite (bool, optional) – Whether to overwrite existing output file (default is False)
- Returns:
Error code or tuple of (error_code, stderr)
- Return type:
Union[int, str, Tuple[int, str]]