Utilities#
- mockdock.utils.effective_cpu_count()[source]#
Return CPUs this job may use (Slurm / Linux cgroup aware).
multiprocessing.cpu_count()often reports every logical CPU on the host (for example 128) even when Slurm grants--cpus-per-task=2. Mockdock uses this value formultiprocessing.Poolsizing, so the raw host count can spawn far too many workers and trigger OOM.- Return type:
- mockdock.utils.resolve_backend(requested_backend, n_gpus, adgpu_executable='adgpu')[source]#
Resolve which docking backend to use based on request and availability.
- mockdock.utils.standardize_smiles(smiles)[source]#
Strip salts, neutralize, and return a canonical SMILES string.
Steps applied in order: 1. Parse the SMILES — returns
Noneif invalid. 2. Keep the largest fragment (removes counter-ions like[Na+],[Cl-]). 3. Neutralize charges where chemically sensible. 4. Return RDKit canonical SMILES.
- mockdock.utils.get_robust_match(target_mol, query_mol)[source]#
Substructure match robust to kekulization / bond-order differences.
Tries an exact match first; if that fails, relaxes bond-order constraints via
AdjustQueryPropertiesbefore giving up.
- mockdock.utils.check_2d_match(mol, fragment_mol)[source]#
Check whether mol contains fragment_mol as a 2-D substructure.
Uses
get_robust_match()for kekulization-tolerant matching.- Parameters:
mol (Mol) – A valid RDKit
Molto search in. The caller is responsible for obtaining it viacheck_validity().fragment_mol (Mol | None) – The fragment pattern to look for. Returns
Trueimmediately when None (no constraint configured).
- Returns:
Trueif the fragment is found (or no constraint is configured).- Return type:
- mockdock.utils.plot_docking_results(df, score_col='docking_score', activity_col='pchembl_value', valid_col='valid_pose_found', output_path=None)[source]#
Plot docking scores vs pChEMBL values. Assumes activity_col is already log-scaled (e.g., pchembl_value).
- mockdock.utils.plot_activity_distribution(df, activity_col='pchembl_value', output_path=None)[source]#
Plot the distribution of bioactivity values.