dockingHandler

DockingHandler.setLigand(ligand_pdb)

Set ligand attribute of class with ligand pdb.

DockingHandler.setReceptor(receptor_pdb)

Set receptor attribute of class with receptor pdb.

DockingHandler.addPose(pose_index, euler, …)

Add pose from zdock line informations.

DockingHandler.computeContactMap(nb_threads, …)

Function that compute contact map for given poses and distance.

DockingHandler.computeFrequencies(nb_poses)

Compute contact frequencies and residues at interface frequencies for given poses.

DockingHandler.rescorePoses(nb_poses, type_score)

Rescore N poses according to given type_score.

DockingHandler.serializeRescoring(output_file)

Write rescoring results in a file.

DockingHandler.getRankedPoses(score, nb_poses)

Get poses ranked by given score

DockingHandler.clusterPoses(ranked_by, …)

Cluster the poses according to BSAS clustering.

DockingHandler.getRankedClusterRepresentatives(…)

Get clusters representatives in decreasing order of given score

DockingHandler.getRankedClusters(ranked_by)

Get clusters in decreasing order of given score

DockingHandler.loadScores(score_file)

Load scores from a score file serialized by serializeRescoring.

class PdbAtoms
class DockingHandler(grid_dimension: int, step: float, initial_euler: Tuple[float, float, float], baryRec: Tuple[float, float, float], baryLig: Tuple[float, float, float])

A class that handles docking results

grid_dimension: int = None

size N of the NxNxN grid used in the docking

step: float = None

spacing between grid cells

initial_euler: Tuple[float, float, float] = None

initial rotation of the ligand in Euler angles

baryRec: Tuple[float, float, float] = None

receptor initial translation to center

baryLig: Tuple[float, float, float] = None

ligand initial translation to center

ligand: 'pyproteinsExt.structure.coordinates.Structure' = None

ligand pdb parsed by pyproteinsExt. Set with setLigand method.

receptor: 'pyproteinsExt.structure.coordinates.Structure' = None

receptor pdb parsed by pyproteinsExt. Set with setReceptor method

poses: List[Pose] = None

List of docking poses. Set with calls to addPose method.

offsetRec: Tuple[float, float, float] = None

Corrected initial translation of receptor

offsetLig: Tuple[float, float, float] = None

Corrected initial translation of ligand

freq: Frequencies = None

Object that stores frequencies computations. Set with computeFrequencies method.

clusters: Dict[str, Dict[Pose, List[Pose]]] = None

Poses clusters. Dictionary with score as key and dictionnary as value with representative pose as key and other poses that belongs to cluster as value. Set with clusterPoses.

property cmap_poses

Poses with contact map computed

Returns

Poses with contact map computed

Return type

List[DockingPP.pose.Pose]

property rescored_poses

Rescored poses

Returns

Poses with rescoring

Return type

List[DockingPP.pose.Pose]

setLigand(ligand_pdb: str)

Set ligand attribute of class with ligand pdb.

Parameters

ligand_pdb (str) – Path to ligand pdb

setReceptor(receptor_pdb: str)

Set receptor attribute of class with receptor pdb.

Parameters

receptor_pdb (str) – Path to receptor pdb

addPose(pose_index: int, euler: Tuple[float, float, float], translation: Tuple[float, float, float])

Add pose from zdock line informations. Used in loader.loadZdock

Parameters
  • pose_index (int) – Index of the pose

  • euler (Tuple[float, float, float]) – Euler vector of the pose

  • translation (Tuple[float, float, float]) – Translation vector of the pose

computeContactMap(nb_threads: int, nb_poses: int, distance: float = 5)

Function that compute contact map for given poses and distance. It uses ccmap module, decode and store its results.

Parameters
  • nb_threads (int) – Number of threads to compute contact map

  • nb_poses (int) – Number of poses to compute contact map

  • distance (float, optional) – Distance (in Angstrom) below which two residues are considered in contact. Defaults to 5.

Raises

error.IncompatiblePoseNumber – Raise if you want to compute on more poses than loaded.

computeFrequencies(nb_poses: int)

Compute contact frequencies and residues at interface frequencies for given poses. Contact map has to be computed before.

Contact frequencies : For each contact between residue i of ligand and residue j of the receptor, count and relative frequency among poses are computed.

Frequencies of residues at interface : For each residue of the ligand and each residue of the receptor, count and relative frequency of the number of time the residue appears at interface among poses is computed.

Set freq attribute of the class. freq is a DockingPP.frequencies.Frequencies object.

Parameters

nb_poses (int) – Number of poses to compute frequencies

Raises

error.IncompatiblePoseNumber – Raise if you try to compute frequency with more poses than poses with contact map.

Examples

Compute frequencies for 1BJ1 complex with 50 poses

>>> DH.computeFrequencies(50)
>>> DH.freq.rel_frequencies_contact
{(312, 171): 0.5, (262, 170): 0.66, (313, 172): 0.5, (266, 5): 0.22, (320, 168): 0.64, (314, 161): 0.5, (259, 167): 0.34 ... }
>>> DH.freq.rel_frequencies_residue
{'ligand': {129: 0.74, 4: 0.7, 5: 0.68, 8: 0.74, 160: 0.5, 161: 0.5, 162: 0.74, 163: 0.54, 164: 0.72, 165: 0.7, 166: 0.66, 167: 0.72, 168: 0.7 ... }, 'receptor': {259: 0.48, 262: 1.0, 263: 0.66, 264: 1.0, 265: 0.7, 266: 1.0, 267: 0.66, 269: 0.62, 271: 0.94, 31: 0.9 ... }}
rescorePoses(nb_poses: int, type_score: str)

Rescore N poses according to given type_score. A new score will be computed for each pose

Parameters
  • nb_poses (int) – Number of poses to rescore

  • type_score (str) –

    Score to use

    Available type score
    • contacts_sum : sum of relative frequencies of each contact of the pose

    • contacts_average : contacts_sum normalised by number of contacts in the pose

    • contacts_log_sum : sum of log of relative frequencies of each contact of the pose

    • contacts_square_sum : sum of square of relative frequencies of each contact of the pose

    • residues_sum : sum of relative frequencies of each interface residue (ligand and receptor) of the pose

    • residues_average : residues_sum normalised by number of interface residues in the pose

    • residues_log_sum : sum of log of relative frequencies of each interface residue of the pose

    • residues_square_sum : sum of square of relative frequencies of each interface residue of the pose

    • all : to compute all above scores

Raises
  • error.IncompatiblePoseNumber – Raise if you try to rescore more poses than poses with contact map

  • error.InvalidScore – Raise if you give an invalid type score.

Examples

For 1BJ1, rescore 2000 poses with all scores and display the first 2

>>> DH.rescorePoses(2000, type_score = "all")
>>> for p in DH.poses[:2]:
>>>     print(p.index, p.rescoring)
1 {'contacts_sum': 38.180000000000014, 'contacts_average': 0.4061702127659576, 'contacts_log_sum': -94.55436888131206, 'contacts_square_sum': 17.90280000000001, 'residues_sum': 42.06, 'residues_average': 0.7378947368421053, 'residues_log_sum': -20.625622826512405, 'residues_square_sum': 33.8476}
2 {'contacts_sum': 38.00000000000001, 'contacts_average': 0.44186046511627913, 'contacts_log_sum': -75.18567402702058, 'contacts_square_sum': 18.285600000000002, 'residues_sum': 40.12, 'residues_average': 0.7569811320754717, 'residues_log_sum': -17.346104879674645, 'residues_square_sum': 32.776}
serializeRescoring(output_file: str, scores_to_write: List[str] = ['residues_sum', 'residues_average', 'residues_log_sum', 'residues_square_sum', 'contacts_sum', 'contacts_average', 'contacts_log_sum', 'contacts_square_sum'])

Write rescoring results in a file.

Parameters
  • output_file (str) – File to write results. The first line is a comment that resumes the number of poses used. The second line is the header with pose index followed by scores as given in scores_to_write list. The next lines are the scores for each pose.

  • scores_to_write (List[str], optional) – List of scores to write. The scores will be write in the given order. Defaults to [“residues_sum”, “residues_average”, “residues_log_sum”, “residues_square_sum”, “contacts_sum”, “contacts_average”, “contacts_log_sum”, “contacts_square_sum”].

getRankedPoses(score: str, nb_poses: int) → List[DockingPP.pose.Pose]

Get poses ranked by given score

Parameters
  • score (str) – Score to rank by

  • nb_poses (int) – Number of poses to get

Raises

error.IncompatiblePoseNumber – Raises if you try to rank more poses than rescored poses.

Returns

List of poses in decreasing score order

Return type

List[DockingPP.pose.Pose]

clusterPoses(ranked_by: str, dist_cutoff: float, nb_poses: int)

Cluster the poses according to BSAS clustering. Clusters are computed for poses ranked by the given score in descending order.

BSAS clustering : Each pose is assigned to the first cluster when the distance between the pose and the representative of the cluster is less than given cutoff. If pose can’t be assigned to any cluster, it creates a new one.

Set cluster attribute of the class. cluster is an ordered dictionary with representative Pose object as key and other Pose objects that belong to the cluster as values.

Parameters
  • ranked_by (str) – Score for ranking

  • dist_cutoff (float) – Distance below which a pose is assigned to a cluster

  • nb_poses (int) – Number of poses to cluster

getRankedClusterRepresentatives(ranked_by: str) → List[Tuple[int, DockingPP.pose.Pose]]

Get clusters representatives in decreasing order of given score

Raises
  • error.ClustersNotComputed – Raise when clusters are not computed

  • error.InvalidScore – Raise if score is not computed or invalid

Returns

List of tuple where first element is the cluster number and second is the representative pose.

Return type

List[Tuple[int, DockingPP.pose.Pose]]

Examples

For 1BJ1, get contact_sums clusters representatives and display the first 2 indexes

>>> representatives = DH.getRankedClusterRepresentatives("contacts_sum")
>>> for clust in representatives[:2]:
>>>       print("cluster", clust[0], "representative index", clust[1].index)
cluster 0 representative index 16
cluster 1 representative index 74
getRankedClusters(ranked_by: str) → List[Tuple[int, List[DockingPP.pose.Pose]]]

Get clusters in decreasing order of given score

Parameters

ranked_by (str) – Score to rank by

Raises
  • error.ClustersNotComputed – Raise if clusters are not computed

  • error.InvalidScore – Raise if score is not computed or invalid

Returns

List of tuples where first element is cluster number and second is the list of poses inside the cluster.

Return type

List[Tuple[int, List[DockingPP.pose.Pose]]]

Examples

For 1BJ1, get contacts_sum clusters and display pose index.

>>> clusters = DH.getRankedClusters("contacts_sum")
>>> for clust in clusters[:2]:
>>>     print("cluster :", clust[0], "poses :", [p.index for p in clust[1]])
cluster : 0 poses : [16, 1, 5, ...]
cluster : 1 poses : [74, 452, 1212, ...]
loadScores(score_file: str)

Load scores from a score file serialized by serializeRescoring. Load scores for each pose in rescoring Pose attribute, and store the number of rescored poses.

Parameters

score_file (str) – Path to score file

Raises

error.IncompatiblePoseNumber – Raises if you try to load scores for more poses than loaded.