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 (

PreparationStrategy, MGLToolsPreparationStrategy, SPORESPreparationStrategy, OpenBabelPreparationStrategy

)

class OCDocker.Toolbox.Preparation.PreparationStrategy[source]

Bases: ABC

Abstract base class for molecule preparation strategies.

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]

abstract 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]]

abstract 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: PreparationStrategy

Preparation strategy using MGLTools (prepare_ligand4.py/prepare_receptor4.py).

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

Preparation strategy using SPORES.

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

Preparation strategy using OpenBabel (for Gnina and similar).

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]]