Docking Analysis#

mockdock.analysis.unroll_multiconf_rdkit_mols(rdkit_mols)[source]#

Split one RDKit mol with multiple conformers into one mol per conformer.

Meeko/Vina often returns a single mol with N conformers; RMSD and pose indices are defined per conformer. This must match the logic in filter_poses_by_rmsd so export uses the same pose ordering as scoring.

Parameters:

rdkit_mols (list[Mol])

Return type:

list[Mol]

mockdock.analysis.aggregate_results_per_id(df, score_col='docking_score', valid_col='valid_pose_found', activity_col='pchembl_value')[source]#

Aggregate results to one row per compound ID. Enforces RMSD first, then takes best score (fallback to best_any).

Parameters:
  • df (DataFrame)

  • score_col (str)

  • valid_col (str)

  • activity_col (str)

Return type:

DataFrame

class mockdock.analysis.DockingAnalyzer(reference_ligand_path=None, fragment_smiles=None, rmsd_threshold=2.0)[source]#

Bases: object

Post-docking analysis: RMSD filtering, pose extraction, etc.

Parameters:
  • reference_ligand_path (str | Path | None)

  • fragment_smiles (str | None)

  • rmsd_threshold (float)

calculate_rmsd(probe_mol, conf_id=-1)[source]#

Calculate RMSD of the fragment between probe_mol and self.ref_mol.

Returns NaN when the reference match or coordinates are unavailable so that pose filtering does not treat the pose as passing (NaN < threshold is False).

Parameters:
  • probe_mol (Mol)

  • conf_id (int)

Return type:

float

filter_poses_by_rmsd(pose_file, smiles)[source]#

Parse DLG or PDBQT, filter poses by RMSD if applicable.

Returns:

(best_valid_score, passed_constraint, best_valid_mol,

best_any_score, best_any_mol, best_valid_pose_index, best_any_pose_index)

Parameters:
Return type:

tuple[float, bool, Mol | None, float, Mol | None, int, int]

pose_index values are 0-based indices into the list returned by RDKitMolCreate.from_pdbqt_mol (after Vina multi-conformer unrolling). -1 indicates no pose was found.

save_best_poses_sdf(output_path, results_df, df_metadata=None, id_col='id', score_col='docking_score', dlg_col='dlg_path')[source]#

Extract the best pose from each successful docking run and save to an SDF. Adds metadata from df_metadata if provided.

Pose selection strategy:
  1. Parse all poses from the DLG/PDBQT file.

  2. If RMSD checking is available, prefer the lowest-energy pose that passes the fragment-RMSD threshold.

  3. Fall back to the best-energy pose regardless of RMSD, so the SDF always contains an entry for every molecule in the top-N list.

Parameters:
  • output_path (str | Path)

  • results_df (DataFrame)

  • df_metadata (DataFrame | None)

  • id_col (str)

  • score_col (str)

  • dlg_col (str)