libcns: creating CNS files

CNS scripts util functions.

haddock.libs.libcns.filter_empty_vars(v: Any) bool[source]

Filter empty variables.

See: https://github.com/haddocking/haddock3/issues/162

Returns:

bool – Returns True if the variable is not empty, and False if the variable is empty. That is, False reflects those variables that should not be written in CNS.

Raises:

TypeError – If the type of value is not supported by CNS.

haddock.libs.libcns.generate_default_header(path: str | Path | None = None) tuple[str, str, str, str, str, str][source]

Generate CNS default header.

haddock.libs.libcns.load_ambig(value: Any, eval_line: str = 'eval (${}={})') str

Write the CNS eval line depending on the type of value.

haddock.libs.libcns.load_axis(*, param_header: str = '\n! Axis\n', **params: Any) str

Write the values at the header section.

“Empty variables” are ignored. These are defined accoring to filter_empty_vars().

Parameters:

params (dict) – Dictionary containing the key:value pairs for the parameters to be written to CNS. Values cannot be of dictionary type.

Returns:

str – The string with the CNS parameters defined.

haddock.libs.libcns.load_boxtyp20(waterbox_param: Path) str[source]

Add boxtyp20 eval line.

haddock.libs.libcns.load_dihe(value: Any, eval_line: str = 'eval (${}={})') str

Write the CNS eval line depending on the type of value.

haddock.libs.libcns.load_hbond(value: Any, eval_line: str = 'eval (${}={})') str

Write the CNS eval line depending on the type of value.

Add the link header.

haddock.libs.libcns.load_scatter(scatter_lib: Path) str[source]

Add scatter library.

haddock.libs.libcns.load_tensor(*, param_header: str = '\n! Tensors\n', **params: Any) str

Write the values at the header section.

“Empty variables” are ignored. These are defined accoring to filter_empty_vars().

Parameters:

params (dict) – Dictionary containing the key:value pairs for the parameters to be written to CNS. Values cannot be of dictionary type.

Returns:

str – The string with the CNS parameters defined.

haddock.libs.libcns.load_tensor_tbl(value: Any, eval_line: str = 'eval (${}={})') str

Write the CNS eval line depending on the type of value.

haddock.libs.libcns.load_trans_vectors(*, param_header: str = '\n! Translation vectors\n', **params: Any) str

Write the values at the header section.

“Empty variables” are ignored. These are defined accoring to filter_empty_vars().

Parameters:

params (dict) – Dictionary containing the key:value pairs for the parameters to be written to CNS. Values cannot be of dictionary type.

Returns:

str – The string with the CNS parameters defined.

haddock.libs.libcns.load_unambig(value: Any, eval_line: str = 'eval (${}={})') str

Write the CNS eval line depending on the type of value.

haddock.libs.libcns.load_workflow_params(param_header: str = '\n! Parameters\n', **params: Any) str[source]

Write the values at the header section.

“Empty variables” are ignored. These are defined accoring to filter_empty_vars().

Parameters:

params (dict) – Dictionary containing the key:value pairs for the parameters to be written to CNS. Values cannot be of dictionary type.

Returns:

str – The string with the CNS parameters defined.

haddock.libs.libcns.prepare_cns_input(model_number: int, input_element: PDBFile | list[haddock.libs.libontology.PDBFile], step_path: str | Path, recipe_str: str, defaults: Any, identifier: str, ambig_fname: str | Path = '', native_segid: bool = False, default_params_path: Path | None = None) Path[source]

Generate the .inp file needed by the CNS engine.

Parameters:
  • model_number (int) – The number of the model. Will be used as file name suffix.

  • input_element (libs.libontology.Persisten, list of those)

haddock.libs.libcns.prepare_expected_pdb(model_obj: PDBFile | tuple[haddock.libs.libontology.PDBFile, ...], model_nb: int, path: str | Path, identifier: str) PDBFile[source]

Prepare a PDBobject.

haddock.libs.libcns.prepare_multiple_input(pdb_input_list: list[Union[str, pathlib.Path]], psf_input_list: list[Union[str, pathlib.Path]]) str[source]

Prepare multiple input files.

haddock.libs.libcns.prepare_output(*, param_header: str = '\n! Output structure\n', **params: Any) str

Write the values at the header section.

“Empty variables” are ignored. These are defined accoring to filter_empty_vars().

Parameters:

params (dict) – Dictionary containing the key:value pairs for the parameters to be written to CNS. Values cannot be of dictionary type.

Returns:

str – The string with the CNS parameters defined.

haddock.libs.libcns.prepare_single_input(pdb_input: str | Path, psf_input: None | str | Path | list[FilePathT] = None) str[source]

Input of the CNS file.

This section will be written for any recipe even if some CNS variables are not used, it should not be an issue.

haddock.libs.libcns.write_eval_line(param: Any, value: Any, eval_line: str = 'eval (${}={})') str[source]

Write the CNS eval line depending on the type of value.