Skip to content

API reference

The functions below are available directly from the dockcert package.

Overall assessment

dockcert.assess_docking_quality(labels=None, scores=None, rmsd_values=None, rmsd_ranked_poses=False, active_properties=None, decoy_properties=None, lower_is_better=True, roc_auc_pass=0.7, roc_auc_warn=0.6, bedroc_pass=0.5, bedroc_warn=0.3, ef1_pass=5.0, ef1_warn=2.0)

Evaluates comprehensive quality assurance for molecular docking and virtual screening.

Parameters:

Name Type Description Default
labels ndarray

Binary array of active/decoy classifications.

None
scores ndarray

Docking scores.

None
rmsd_values list of float

Pose RMSD values from redocking/cross-docking experiments.

None
rmsd_ranked_poses bool

True if rmsd_values are the ranked poses of a single docking run (verdict on the top-1 pose); False if they are top-1 RMSDs across a benchmark of complexes (verdict on the success rate).

False
active_properties dict

Properties for active ligands.

None
decoy_properties dict

Properties for decoy ligands.

None
lower_is_better bool

Sort order.

True

Returns:

Name Type Description
report DockingValidationReport

Consolidated validation report.

Enrichment metrics

dockcert.evaluate_all_enrichment_metrics(labels, scores, lower_is_better=True)

Evaluates comprehensive virtual screening enrichment statistics.

Returns:

Name Type Description
metrics_dict dict

Consolidated dictionary of all enrichment metrics.

dockcert.calculate_roc_auc(labels, scores, lower_is_better=True)

Computes the Receiver Operating Characteristic Area Under the Curve (ROC-AUC).

Parameters:

Name Type Description Default
labels ndarray

Binary array (1 = Active, 0 = Decoy/Inactive).

required
scores ndarray

Docking scores or binding affinities.

required
lower_is_better bool

If True (standard for docking energies in kcal/mol), lower scores indicate higher affinity.

True

Returns:

Name Type Description
auc float

ROC-AUC value in [0, 1].

dockcert.calculate_pr_auc(labels, scores, lower_is_better=True)

Computes the Precision-Recall Area Under the Curve (PR-AUC / Average Precision).

Parameters:

Name Type Description Default
labels ndarray

Binary array (1 = Active, 0 = Decoy).

required
scores ndarray

Docking scores.

required
lower_is_better bool

If True, lower scores rank higher.

True

Returns:

Name Type Description
pr_auc float

PR-AUC in [0, 1].

dockcert.calculate_bedroc(labels, scores, alpha=20.0, lower_is_better=True)

Computes the Boltzmann-Enhanced Discrimination of ROC (BEDROC) metric in [0, 1].

Formula (Truchon & Bayly, J. Chem. Inf. Model. 2007, 47, 488-508): BEDROC = (S - S_min) / (S_max - S_min) where S = sum_{i=1}^n exp(-alpha * r_i / N)

Parameters:

Name Type Description Default
labels ndarray

Binary array (1 = Active, 0 = Decoy).

required
scores ndarray

Docking scores.

required
alpha float

Exponential weight parameter (alpha=20.0 for top 8%, alpha=80.5 for top 2%).

20.0
lower_is_better bool

Sorting order.

True

Returns:

Name Type Description
bedroc float

Bounded early enrichment score in [0, 1].

dockcert.calculate_rie(labels, scores, alpha=20.0, lower_is_better=True)

Computes the Robust Initial Enhancement (RIE) according to Truchon & Bayly (2007).

Parameters:

Name Type Description Default
labels ndarray

Binary array (1 = Active, 0 = Decoy).

required
scores ndarray

Docking scores.

required
alpha float

Exponential weight factor (e.g. 20.0 weights the top 8% of the database).

20.0
lower_is_better bool

Sort direction.

True

Returns:

Name Type Description
rie float

Robust Initial Enhancement metric.

dockcert.calculate_enrichment_factor(labels, scores, fraction=0.01, lower_is_better=True)

Calculates the Enrichment Factor (EF_x%) and the theoretical maximum EF.

Formula: EF = (Actives_top_x / N_top_x) / (Actives_total / N_total)

Parameters:

Name Type Description Default
labels ndarray

Binary array (1 = Active, 0 = Decoy).

required
scores ndarray

Docking scores.

required
fraction float

Top database fraction to evaluate (e.g. 0.01 for EF1%, 0.05 for EF5%).

0.01
lower_is_better bool

Sorting order.

True

Returns:

Name Type Description
ef float

Observed Enrichment Factor.

ef_max float

Theoretical maximum possible EF for the dataset at this fraction.

dockcert.calculate_log_auc(labels, scores, lam=0.001, lower_is_better=True)

Computes semilogarithmic ROC area (logAUC) focusing on early False Positive Rates.

Parameters:

Name Type Description Default
labels ndarray

Binary array.

required
scores ndarray

Docking scores.

required
lam float

Lower integration limit on FPR (e.g. 0.1% = 0.001).

0.001
lower_is_better bool

Sorting order.

True

Returns:

Name Type Description
log_auc float

logAUC value in [0, 1].

dockcert.calculate_optimal_mcc(labels, scores, lower_is_better=True)

Computes the maximum Matthews Correlation Coefficient (MCC) across all candidate score thresholds.

Parameters:

Name Type Description Default
labels ndarray

Binary array.

required
scores ndarray

Docking scores.

required
lower_is_better bool

Sorting order.

True

Returns:

Name Type Description
best_mcc float

Optimal MCC in [-1, +1].

best_threshold float

Docking score threshold achieving optimal MCC.

Confidence intervals

dockcert.bootstrap_enrichment_ci(labels, scores, n_resamples=1000, confidence_level=0.95, lower_is_better=True, random_state=42)

Computes stratified non-parametric bootstrap 95% Confidence Intervals for all key metrics.

Parameters:

Name Type Description Default
labels ndarray

Binary label array (1 = Active, 0 = Decoy).

required
scores ndarray

Docking scores.

required
n_resamples int

Number of bootstrap iterations.

1000
confidence_level float

Confidence level.

0.95
lower_is_better bool

Sorting direction.

True
random_state int

Seed for reproducibility.

42

Returns:

Name Type Description
ci_dict dict

Mapping metric_name -> (point_estimate, ci_lower, ci_upper).

Redocking

dockcert.calculate_symmetry_corrected_rmsd(coords_ref, coords_dock, elements=None, elements_dock=None, max_mappings=200000)

Symmetry-corrected heavy-atom RMSD without superposition (the redocking convention).

Both poses are turned into molecular graphs (bonds inferred from distances) and the RMSD is minimised over all element- and bond-preserving atom correspondences (graph isomorphisms). This handles symmetric groups and a different atom order between the crystal ligand and the docking output, and matches the definition of RDKit CalcRMS and spyrmsd.

If the two graphs are not isomorphic (e.g. a missing atom or a distorted bond), it falls back to a per-element Hungarian assignment, which ignores bonding and is only a LOWER BOUND.

Parameters:

Name Type Description Default
coords_ref ndarray

Heavy-atom coordinates (shape [N, 3]); the atom order may differ.

required
coords_dock ndarray

Heavy-atom coordinates (shape [N, 3]); the atom order may differ.

required
elements list of str

Element symbols of the reference atoms. Without it, the plain RMSD is returned.

None
elements_dock list of str

Element symbols of the docked atoms (default: the reference list, i.e. same atom order).

None
max_mappings int

Cap on the number of enumerated isomorphisms.

200000

Returns:

Name Type Description
rmsd_sym float

Symmetry-corrected RMSD in Angstroms.

dockcert.calculate_heavy_atom_rmsd(coords_ref, coords_dock)

Computes standard Cartesian Root-Mean-Square Deviation (RMSD) between two matching atom sets.

Parameters:

Name Type Description Default
coords_ref ndarray

Reference coordinates (shape: [N, 3]).

required
coords_dock ndarray

Docked pose coordinates (shape: [N, 3]), same atom order as the reference.

required

Returns:

Name Type Description
rmsd float

RMSD in Angstroms.

dockcert.evaluate_redocking_success(rmsd_values, threshold_pass=2.0, threshold_warn=3.0, ranked_poses=False)

Evaluates redocking against the 2 A pose-recovery criterion.

  • ranked_poses=True: rmsd_values are the poses of ONE docking run in score order. The verdict uses the top-scored pose, which is the pose a user of the result would take. The best of the N poses is reported separately because it measures sampling, not scoring. PASS: top-1 <= 2 A. WARNING: a lower-ranked pose <= 2 A (scoring failure) or top-1 <= 3 A. FAIL otherwise.
  • ranked_poses=False: rmsd_values are the top-scored poses of a benchmark of complexes. PASS: success rate (<= 2 A) >= 70 %. WARNING: >= 50 %. FAIL otherwise.

Returns:

Name Type Description
result dict

n_poses, top_rmsd, mean/median/min RMSD, success_rate_2a, status and recommendation.

Decoy bias

dockcert.evaluate_decoy_bias(active_properties, decoy_properties)

Evaluates potential artificial enrichment bias by comparing property distributions (e.g., MW, LogP, HBD, HBA, Rotatable Bonds) between actives and decoys.

Parameters:

Name Type Description Default
active_properties dict

Mapping of property name -> 1D array for active molecules.

required
decoy_properties dict

Mapping of property name -> 1D array for decoy molecules.

required

Returns:

Name Type Description
result dict

Property-by-property Kolmogorov-Smirnov and Wasserstein statistics, bias risk classification (LOW / MODERATE / HIGH), and recommendations.

Parsers

dockcert.parsers.generic_csv.load_docking_csv(filepath, score_column=None, label_column=None)

Loads virtual screening tabular results with automated column discovery.

Parameters:

Name Type Description Default
filepath str

Path to CSV/TSV table.

required
score_column str

Name of score/affinity column. If None, auto-detected.

None
label_column str

Name of active/decoy label column. If None, auto-detected.

None

Returns:

Name Type Description
labels ndarray

Binary 1/0 array of active status.

scores ndarray

Array of docking scores.

properties_dict dict

Mapping property_name -> array of values.

metadata dict

Dataset summary metadata.

dockcert.parsers.structure_io.load_poses(filepath)

Returns every pose in a structure file as (heavy-atom coordinates [N, 3], element symbols).

For docking output the poses keep the program's ranking order (pose 0 = top-scored).

dockcert.parsers.structure_io.load_molecule_coordinates(filepath)

Extracts 3D heavy-atom coordinates and element symbols of the FIRST pose of an SDF, PDB, or PDBQT file. Use load_poses() for multi-pose docking output.

dockcert.parsers.vina_smina.parse_vina_log(filepath)

Parses AutoDock Vina / Smina output log files to extract binding affinity and RMSD values.

Parameters:

Name Type Description Default
filepath str

Path to Vina log file.

required

Returns:

Name Type Description
affinities list of float

Estimated binding affinity (kcal/mol) for each mode.

rmsd_lb list of float

RMSD lower bound from best mode.

rmsd_ub list of float

RMSD upper bound from best mode.