haddock.modules.analysis.caprieval.capri module

CAPRI module.

class haddock.modules.analysis.caprieval.capri.CAPRI(identificator: int, model: PDBFile | Path, path: Path, reference: PDBFile | Path, params: MutableMapping[str, Any], ref_id: int = 1)[source]

Bases: object

CAPRI class.

static add_chain_from_segid(pdb_path: PDBFile | Path) Path[source]

Replace the chainID with the segID.

Parameters:

pdb_path (PosixPath or haddock.libs.libontology.PDBFile) – PDB file to be replaced

calc_dockq() None[source]

Calculate the DockQ metric.

calc_fnat(cutoff: float = 5.0) None[source]

Calculate the frequency of native contacts.

Parameters:

cutoff (float) – The cutoff distance for the intermolecular contacts.

calc_global_rmsd() None[source]

Calculate the full structure RMSD.

calc_ilrmsd(cutoff: float = 10.0) None[source]

Calculate the Interface Ligand RMSD.

Parameters:

cutoff (float) – The cutoff distance for the intermolecular contacts.

calc_irmsd(cutoff: float = 5.0) None[source]

Calculate the I-RMSD.

Parameters:

cutoff (float) – The cutoff distance for the intermolecular contacts.

calc_lrmsd() None[source]

Calculate the L-RMSD.

has_cluster_info() bool[source]

Check wether this object contains cluster information.

Returns:

bool – True if this object contains cluster information.

static identify_interface(pdb_f: PDBFile | Path, cutoff: float = 5.0) dict[str, list[int]][source]

Identify the interface.

Parameters:
  • pdb_f (PosixPath or haddock.libs.libontology.PDBFile) – PDB file of the model to have its atoms identified

  • cutoff (float, optional) – Cutoff distance for the interface identification.

Returns:

interface_resdic (dict[str, list[int]]) – Dictionary holding list of interface residues ids for each chains.

run() None | CAPRI[source]

Get the CAPRI metrics.

exception haddock.modules.analysis.caprieval.capri.CAPRIError(msg: str = '')[source]

Bases: Exception

Raised when something goes wrong with the CAPRI class.

haddock.modules.analysis.caprieval.capri.calc_stats(data: list) tuple[float, float][source]

Calculate the mean and stdev.

Parameters:

data (list) – List of values.

Returns:

  • mean (float) – Mean of the values.

  • stdev (float) – Standard deviation of the values.

haddock.modules.analysis.caprieval.capri.capri_cluster_analysis(capri_list: Iterable[CAPRI], model_list: Iterable[PDBFile], output_fname: str | Path, clt_threshold: int, sort_key: str, sort_ascending: bool, path: str | Path) None[source]

Consider the cluster results for the CAPRI evaluation.

haddock.modules.analysis.caprieval.capri.dump_weights(order: int) None[source]
haddock.modules.analysis.caprieval.capri.extract_data_from_capri_class(capri_objects: list[CAPRI], sort_key: str, sort_ascending: bool, output_fname: Path, add_reference_id: bool = False) dict[int, dict[str, Any]] | None[source]

Extracts data attributes from a list of CAPRI objects into a structured dictionary, optionally sorts the data based on a specified key, and writes the sorted data to a file.

Parameters:
  • capri_objects (list[CAPRI]) – List of CAPRI objects containing data attributes to be extracted.

  • sort_key (str) – Key by which to sort the extracted data. Must correspond to a valid attribute in the CAPRI object (e.g., ‘score’, ‘irmsd’).

  • sort_ascending (bool) – If True, sorts the data in ascending order based on the sort_key; if False, sorts in descending order.

  • output_fname (Path) – Path to the output file where the sorted data will be written.

  • add_reference_id (bool, optional) – Should the reference id be added to the capri table?, by default False

Returns:

ranked_data (Union[dict[int, ParamDict], None]) – The sorted and structured data dictionary if successful, None if no data was processed.

haddock.modules.analysis.caprieval.capri.extract_models_best_references(capri_objects: list[CAPRI]) list[CAPRI][source]

Extract best reference for each input model.

Same input models are combined and best reference is later found by sorting the CAPRI objects. Only the best performing CAPRI object is kept and returned. This step was implemented to handle comparisons against multiple refs.

Parameters:

capri_objects (list[CAPRI]) – List of CAPRI object.

Returns:

selected_capri_objects (list[CAPRI]) – List of selected best CAPIR object for each model.

haddock.modules.analysis.caprieval.capri.get_previous_cns_step(sel_steps: list, st_order: int) str | None[source]

Get the previous CNS step.

Parameters:

run_path (Path) – Path to the run folder.

Returns:

cns_step (str) – Name of the CNS step.

haddock.modules.analysis.caprieval.capri.load_contacts(pdb_f: Path | PDBFile, cutoff: float = 5.0, numbering_dic: dict[str, dict[int, int]] | None = None, model2ref_chain_dict: dict[str, str] | None = None) set[tuple][source]

Load residue-based contacts.

Parameters:
  • pdb_f (PosixPath or haddock.libs.libontology.PDBFile) – PDB file of the model to have its atoms identified

  • cutoff (float, optional) – Cutoff distance for the interface identification.

Returns:

set(con_list) (set) – set of unique contacts

haddock.modules.analysis.caprieval.capri.rank_according_to_score(data: dict[int, dict[str, Any]], sort_key: str, sort_ascending: bool) dict[int, dict[str, Any]][source]

Ranks a dictionary of data based on a specified sort key and sort order, and assigns a rank to each entry based on its ‘score’ attribute.

Parameters:
  • data (dict[int, ParamDict]) – Dictionary where each key is an index and each value is a ParamDict containing data attributes.

  • sort_key (str) – Key by which to sort the data within the ParamDict. Must correspond to a valid attribute in ParamDict.

  • sort_ascending (bool) – If True, sorts the data in ascending order based on the sort_key; if False, sorts in descending order.

Returns:

dict[int, ParamDict]

A new dictionary where entries are sorted according

to the sort_key and optionally sorted order. Each entry also includes a ‘caprieval_rank’ attribute indicating its rank based on the ‘score’.

haddock.modules.analysis.caprieval.capri.save_scoring_weights(cns_step: str) Path[source]

Save the scoring weights in a json file.

Parameters:

cns_step (str) – Name of the CNS step.

Returns:

scoring_params_fname (Path) – Path to the json file.