Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions install-thirdparty.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# How to install the dependencies of the third-party modules
HADDOCK3 is able to integrate third-party software in its workflows.
However, we are not responsible to the proper installation of such
packages, but we do help you to install them. In this document you will
find a list of all third-party packages HADDOCK3 can use and guidelines
on how to install them.


# Installing third-party packages

## `lightdock`

_pending_
To install to [lightdock](https://github.com/lightdock/lightdock) follow
the instructions in the project's website. Remember to install it under
the same Python environment you created for HADDOCK3. If you have any
doubts, please let us know.

* * *

Expand All @@ -25,6 +35,8 @@ pip install deap scipy mgzip biopython
export GDOCK_PATH=some-folder
```

**Important**: These are not the full install instructions as here only the model generation is used. Please check the [repository page](https://github.com/rvhonorato/gdock) for more information.
**Important**: These are not the full install instructions as here only
the model generation is used. Please check the [repository
page](https://github.com/rvhonorato/gdock) for more information.

* * *
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ toml==0.10.0
pdb-tools==2.1.0
jsonpickle==2.0.0
numpy==1.20.2
lightdock==0.9.0a2
1 change: 0 additions & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ dependencies:
- jsonpickle
- pip:
- pdb-tools
- lightdock
1 change: 1 addition & 0 deletions src/haddock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
v_release = "unreleased"

current_version = f"{v_major}.{v_minor}.{v_patch}-{v_release}"
contact_us = 'https://github.com/haddocking/haddock3/issues'
5 changes: 3 additions & 2 deletions src/haddock/clis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def main(
try:
params, other_params = setup_run(recipe, restart_from=restart)

except ConfigurationError as err:
except HaddockError as err:
logging.error(err)
sys.exit()
raise err

if not setup_only:
try:
Expand All @@ -121,6 +121,7 @@ def main(
workflow.run()

except HaddockError as err:
raise err
logging.error(err)

# Finish
Expand Down
4 changes: 4 additions & 0 deletions src/haddock/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class ConfigurationError(HaddockError):
pass


class ModuleError(HaddockError):
pass


class StepError(HaddockError):
pass

Expand Down
30 changes: 28 additions & 2 deletions src/haddock/gear/prepare_run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Logic pertraining to preparing the run files and folders."""
import importlib
import logging
import shutil
from contextlib import contextmanager
Expand All @@ -7,9 +8,9 @@

import toml

from haddock import haddock3_source_path
from haddock import contact_us, haddock3_source_path
from haddock.modules import modules_category
from haddock.core.exceptions import ConfigurationError
from haddock.core.exceptions import ConfigurationError, ModuleError
from haddock.gear.parameters import config_mandatory_general_parameters
from haddock.gear.restart_run import remove_folders_after_number
from haddock.libs.libutil import (
Expand Down Expand Up @@ -86,6 +87,7 @@ def setup_run(workflow_path, restart_from=None):
config_mandatory_general_parameters,
)
validate_modules_params(modules_params)
validate_installed_modules(modules_params)

if restart_from is None:
# prepares the run folders
Expand Down Expand Up @@ -176,6 +178,30 @@ def validate_modules_params(params):
raise ConfigurationError(_msg)


def validate_installed_modules(params):
"""Validate if third party-libraries are installed"""
for module_name in params.keys():
module_import_name = '.'.join([
'haddock',
'modules',
modules_category[module_name],
module_name,
])
module_lib = importlib.import_module(module_import_name)
try:
module_lib.HaddockModule.confirm_installation()
except Exception as err:
_msg = (
'A problem occurred while assessing if module '
f'{module_name!r} is installed in your system. Have you '
'installed the packages required to run this module? If '
f'yes, write us at {contact_us!r} describing your system '
'and the problems you are facing. If not, please install '
'the required packages to use the module.'
)
raise ModuleError(_msg) from err


def convert_params_to_path(params):
"""Convert parameters to path."""
convert_molecules_to_path(params)
Expand Down
10 changes: 10 additions & 0 deletions src/haddock/libs/libutil.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""General utilities."""
import logging
import shutil
import subprocess
from copy import deepcopy
from functools import partial
from operator import ge
from os import cpu_count
from pathlib import Path
Expand All @@ -12,6 +14,14 @@
logger = logging.getLogger(__name__)


check_subprocess = partial(
subprocess.run,
shell=True,
check=True,
stdout=subprocess.DEVNULL,
)


def get_result_or_same_in_list(function, value):
"""
Return the result if True or the value within a list.
Expand Down
10 changes: 10 additions & 0 deletions src/haddock/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def params(self, path_or_dict):
def run(self, params):
self.update_params(**params)

@classmethod
@abstractmethod
def confirm_installation(self):
"""
Confirm the third-party software needed for the module is installed.

HADDOCK3's own modules should just return.
"""
return

def finish_with_error(self, message=""):
if not message:
message = "Module has failed"
Expand Down
15 changes: 15 additions & 0 deletions src/haddock/modules/analysis/clustfcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
from pathlib import Path

import toml

from fcc.scripts import calc_fcc_matrix, cluster_fcc

from haddock import FCC_path
Expand All @@ -24,6 +26,19 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = False
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
dcfg = toml.load(DEFAULT_CONFIG)
exec_path = Path(FCC_path, dcfg['executable'])

if not os.access(exec_path, mode=os.F_OK):
raise Exception(f'Required {str(exec_path)} file does not exist.')

if not os.access(exec_path, mode=os.X_OK):
raise Exception(f'Required {str(exec_path)} file is not executable')

return

def run(self, **params):
logger.info("Running [clustfcc] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/analysis/seletop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def __init__(
**everything):
super().__init__(order, path, init_params)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [seletop] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/analysis/seletopclusts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def __init__(
**everything):
super().__init__(order, path, init_params)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [seletopclusts] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/refinement/emref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def __init__(
cns_script = RECIPE_PATH / "cns" / "emref.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [emref] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/refinement/flexref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = RECIPE_PATH / "cns" / "flexref.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [flexref] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/refinement/mdref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = RECIPE_PATH / "cns" / "mdref.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [mdref] module")

Expand Down
10 changes: 10 additions & 0 deletions src/haddock/modules/sampling/gdock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from haddock.core.defaults import NUM_CORES
from haddock.libs import libpdb
from haddock.libs.libontology import Format, ModuleIO, PDBFile
from haddock.libs.libutil import check_subprocess
from haddock.modules import BaseHaddockModule, working_directory


Expand All @@ -20,6 +21,8 @@
DEFAULT_CONFIG = Path(RECIPE_PATH, "defaults.toml")




def ambig2dic(ambig_f):
"""Read an ambig.tbl file and convert it to a dictionary"""
ambig_regex = r"resid\s*(\d*)\s*and\s*segid\s*(\w)"
Expand All @@ -42,6 +45,13 @@ class HaddockModule(BaseHaddockModule):
def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
super().__init__(order, path, initial_params)

@classmethod
def confirm_installation(cls):
"""Confirm this module is installed."""
gdock_path = os.environ['GDOCK_PATH']
gdock_exec = Path(gdock_path, 'gdock.py')
check_subprocess(f'{sys.executable} {gdock_exec}')

def run(self, **params):
logger.info("Running [gdock] module")

Expand Down
8 changes: 7 additions & 1 deletion src/haddock/modules/sampling/lightdock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

from haddock.core.defaults import NUM_CORES
from haddock.libs import libpdb
from haddock.modules import BaseHaddockModule, working_directory
from haddock.libs.libontology import Format, ModuleIO, PDBFile
from haddock.libs.libutil import check_subprocess
from haddock.modules import BaseHaddockModule, working_directory


logger = logging.getLogger(__name__)
Expand All @@ -29,6 +30,11 @@ def __init__(
):
super().__init__(order, path, initial_params)

@classmethod
def confirm_installation(cls):
"""Confirm this module is installed."""
check_subprocess('lightdock3.py -h')

def run(self, **params):
logger.info("Running [sampling-lightdock] module")

Expand Down
6 changes: 5 additions & 1 deletion src/haddock/modules/sampling/rigidbody/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = RECIPE_PATH / "cns" / "rigidbody.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [rigidbody] module")

Expand Down Expand Up @@ -114,7 +118,7 @@ def run(self, **params):
not_found.append(model.name)

haddock_score = HaddockModel(model).calc_haddock_score(**weights)

pdb = PDBFile(model, path=self.path)
pdb.score = haddock_score
pdb.topology = topologies
Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/scoring/emscoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = RECIPE_PATH / "cns" / "scoring.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, **params):
logger.info("Running [scoring] module")

Expand Down
4 changes: 4 additions & 0 deletions src/haddock/modules/topology/topoaa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def __init__(self, order, path, initial_params=DEFAULT_CONFIG):
cns_script = RECIPE_PATH / "cns" / "generate-topology.cns"
super().__init__(order, path, initial_params, cns_script)

@classmethod
def confirm_installation(cls):
return

def run(self, molecules, **params):
logger.info("Running [allatom] module")
logger.info("Generating topologies")
Expand Down