Skip to content

Commit

Permalink
add fallback logic to define cns_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
rvhonorato committed Sep 19, 2024
1 parent 0f9c4b9 commit 3f66ce6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/haddock/core/defaults.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
"""All default parameters used by the framework."""

import importlib.resources
import os
import string
import sys
from pathlib import Path

import yaml
from pkg_resources import resource_filename

import haddock
from haddock import core_path
from haddock import core_path, log


BINARY_DIR = Path(importlib.resources.files(haddock) / "bin") # type: ignore

cns_exec = Path(resource_filename("haddock", "bin/cns"))
cns_exec = Path(resource_filename("haddock", "bin/cns_"))
if not cns_exec.exists():
log.warning("CNS executable not found at %s", cns_exec)
_cns_exec = os.environ.get("CNS_EXEC")
if _cns_exec is None:
log.error(
"Please define the location the CNS binary by setting a CNS_EXEC system variable"
)
sys.exit(1)
else:
cns_exec = Path(_cns_exec)

CONTACT_FCC_EXEC = Path(resource_filename("haddock", "bin/contact_fcc"))
FAST_RMSDMATRIX_EXEC = Path(resource_filename("haddock", "bin/fast-rmsdmatrix"))
Expand Down
7 changes: 3 additions & 4 deletions src/haddock/modules/topology/topoaa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
from functools import partial
from pathlib import Path

from haddock.core.defaults import MODULE_DEFAULT_YAML
from haddock.core.defaults import MODULE_DEFAULT_YAML, cns_exec
from haddock.core.typing import FilePath, Optional, ParamDict, ParamMap, Union
from haddock.libs import libpdb
from haddock.libs.libcns import (
generate_default_header,
load_workflow_params,
prepare_output,
prepare_single_input,
)
)
from haddock.libs.libontology import Format, PDBFile, TopologyFile
from haddock.libs.libstructure import make_molecules
from haddock.libs.libsubprocess import CNSJob
Expand Down Expand Up @@ -262,13 +262,12 @@ def _run(self) -> None:
# Add new job to the pool
output_filename = Path(f"{model.stem}.{Format.CNS_OUTPUT}")
err_fname = f"{model.stem}.cnserr"

job = CNSJob(
topoaa_input,
output_filename,
err_fname,
envvars=self.envvars,
cns_exec=self.params["cns_exec"],
cns_exec=cns_exec,
)

jobs.append(job)
Expand Down

0 comments on commit 3f66ce6

Please sign in to comment.