Skip to main content

Kawow (under development)

CI Python 3.10+ License: CC BY 4.0

Kawow!

Prediction of logKow, logKoa and logKaw from molecular structure.

Kawow implements several models for these partition coefficients: the Naef & Acree (2024) group-additivity scheme (RDKit SMARTS matching, published parameters), ridge regressions on Crippen atom types and Naef & Acree group counts, and models adding Molecular Quantum Graph (MQG) or PFASGroups descriptors. run_models() also classifies every prediction against regulatory bioaccumulation (B/vB) and mobility (M/vM) criteria.


Installation

pip install kawow

Or from source (Python ≥ 3.10, RDKit ≥ 2022.9):

git clone https://github.com/LucMiaz/kawow.git
cd kawow
pip install -e ".[dev]"

The XGBoost and neural-network models need pip install "kawow[ml]"; the mqg, naef_mqg and crippen_mqg models need the molecular_quantum_graph package.


Quick start

import kawow

results = kawow.run_models(
    ["CCCCO", "c1ccccc1", "OC(=O)c1ccccc1"],
    models=["crippen", "naef_crippen"],
)
for row in results:
    r = row["models"]["naef_crippen"]
    print(row["smiles"], r["logKow"], r["logKoa"], r["b_class"], r["m_class"], r["in_gap"])

run_models() returns one dict per molecule with name, smiles, ok (at least one model succeeded) and models, a dict keyed by model name. Each model entry contains:

Key Description
status, ok, error outcome of the prediction (error only on failure)
logKow, logKoa, logKaw predicted partition coefficients
is_B, is_vB, b_class bioaccumulation (Kelly et al. 2007 criterion)
is_B_aquatic, is_vB_aquatic bioaccumulation through the aquatic (BCF) route
is_M, is_vM, is_M_potential, m_class mobility
region "vB", "B", "vM", "M" or "neither"
in_gap, in_gap1, in_gap2, in_gap3, in_gap_bm, gap_labels regulatory gaps (see below)
criteria, thresholds criteria preset and threshold values used

Classification criteria

Bioaccumulation, air-breathing organisms (Kelly et al. 2007, doi:10.1126/science.1138275):

Flag Condition
B logKoa ≥ 6 and logKow ≥ 2
vB logKoa ≥ 6 and logKow ≥ 5

Aquatic bioaccumulation (is_B_aquatic, is_vB_aquatic), from BCF ≈ 0.05·Kow (Mackay et al. 2013): B at logKow > 4.6 (BCF > 2 000), vB at logKow > 5.0 (BCF > 5 000).

Mobility is defined on logKoc and applied through a logKow screening proxy. Two presets are available through the criteria argument ("uba" by default), defined in kawow/criteria.py:

Preset M (logKoc) vM (logKoc) M (logKow) Potential M/vM (logKow) vM (logKow)
uba (Neumann & Schliebner 2019; Arp & Hale 2019 screening zones) < 4.0 < 3.0 ≤ 4.5 3.5–4.5 ≤ 2.5
clp (Delegated Regulation (EU) 2023/707) < 3.0 < 2.0 ≤ 3.5 2.5–3.5 ≤ 1.5

The CLP logKow cutoffs are the Arp & Hale zones shifted by the same 1.0 log-unit as the logKoc cutoffs. Single thresholds can be changed:

results = kawow.run_models("CCCCCC", criteria="clp")
custom = kawow.get_criteria("clp", vm_logkow_threshold=2.5)   # e.g. Koc ≈ 0.35·Kow for vM
results = kawow.run_models("CCCCCC", criteria=custom)

Regulatory gaps:

Key Condition
in_gap (= in_gap3, in_gap_bm) neither M nor B by either route: logKow above the M cutoff and below the aquatic B cutoff (≈ 4.6), with logKoa < 6
in_gap1 logKow between the vM cutoff and 5.0 (neither vM nor vB)
in_gap2 logKow above the M cutoff and logKoa < 6
gap_labels list of the gaps that apply ("Gap 1" to "Gap 3")

Models

Model key Class Approach logKow R² logKoa R² logKaw R²
crippen PartitionCalculator Ridge regression on Crippen atom types + special groups 0.898 0.937 —
naef NaefAcreePartitionCalculator Naef & Acree (2024) group additivity, published parameters (no fitting) 0.857 0.777 0.654
naef_crippen NaefAcreeCrippenPartitionCalculator Ridge regression on Naef & Acree group counts + Crippen atom types 0.938 0.943 0.913
mqg MQGPartitionCalculator Ridge regression on Naef & Acree + Crippen + MQG fingerprints 0.940 0.941 0.913
naef_mqg, crippen_mqg EnsemblePartitionCalculator Ridge regression on MQG fingerprints + Naef & Acree or Crippen features — — —
pfasgroups PFASGroupsPartitionCalculator Ridge regression on PFASGroups descriptors 0.785 0.896 —
pfasgroups_crippen PFASGroupsPartitionCalculator PFASGroups + Crippen 0.911 0.941 —
pfasgroups_naef PFASGroupsPartitionCalculator PFASGroups + Naef & Acree 0.940 0.939 —
pfasgroups_naef_crippen PFASGroupsPartitionCalculator PFASGroups + Naef & Acree + Crippen 0.943 0.943 —
pfasgroups_naef_crippen_rf PFASGroupsRFPartitionCalculator Random Forest (300 trees), same features 0.909 0.926 —
pfasgroups_naef_crippen_xgb PFASGroupsXGBPartitionCalculator XGBoost (early stopping), same features; needs kawow[ml] 0.936 0.941 —
pfasgroups_naef_crippen_nn PFASGroupsNNPartitionCalculator Keras MLP [256-128-64], same features; needs kawow[ml] 0.946 0.940 —

logKow and logKoa R² are from 5-fold cross-validation with shared folds on the common evaluation set of the Naef & Acree datasets (n = 3 314 for logKow, S01; n = 1 956 for logKoa, S02), from tests/out/shared_fold_benchmark.csv (scripts/shared_fold_benchmark.py), computed before the training data were corrected (see below) and not yet rerun; the five manuscript models below are up to date. naef uses the published parameters and is evaluated on the same molecules without fitting. logKaw = logKow − logKoa is compared with the Naef & Acree S03 dataset (n = 2 130–2 150), which was not used for training. This is not a fully independent test: many logKoa values of S02 (from Ebert et al., Environ. Sci. Technol. 2023, 57, 976–984) were themselves derived from measured logKow and logKaw, and S03 includes values below −10 that can only have been estimated. Against the PHYSPROP Henry's law constants of OPERA (697 compounds), logKaw R² is 0.80 for naef_crippen, mqg and pfasgroups_naef_crippen, 0.74 for crippen and 0.55 for naef; on the 148 of those compounds that are not in S03 it is 0.61–0.68 (0.40 for naef). The old keys naefacree and naefacree_mixed still work and map to naef and naef_crippen.

Training data. The models are fitted on the supplementary data of Naef & Acree (2024), corrected: 50 records whose structure did not match the compound name now have the structure of the named compound, and five implausible logKow values are removed. tests/test_data/naef2024_corrections.csv lists every change and its reason; scripts/correct_naef_data.py applies them to the published files. Naef & Acree compiled their logKow values mainly from Klopman et al. (1994) and Sangster, and their logKoa values mainly from Ebert et al. (2023).

Check against PubChem. scripts/check_naef_structures_pubchem.py resolves every compound name of S01-S03 in PubChem with PubChemCompounds and compares the returned structure with the structure as published and as corrected. The comparison is made at four levels: identical (InChIKey), same connectivity (stereochemistry or isotopes differ), same parent (salt or charge differs) and same canonical tautomer. The result for each of the 7 503 records is in tests/test_data/naef2024_pubchem_check.csv; names that PubChem does not resolve (665 records) are not compared.

S01 S02 S03
Records (as published) 3 370 1 983 2 150
Same compound as PubChem (identical, stereo/isotopes, parent or tautomer) 2 890 1 807 1 995
Different compound, structure corrected 12 21 17
Different compound, not corrected 41 21 30
Name not resolved or structure not comparable 427 134 108

All 50 replaced structures differ from the PubChem structure of the name as published, and the corrected structure is the PubChem one (identical for 47, same connectivity for 3). The five removed records match PubChem, as expected, since they were removed for their values. The other 92 records that differ from PubChem (67 compounds) were checked by hand (tests/test_data/naef2024_pubchem_review.csv). Most are ambiguous names or wrong PubChem hits (26 compounds, e.g. esters such as phenyl acetate resolved to the acid anion, trade names such as Pivalone and Vernolate) and other forms or tautomers of the same compound (14). Three are name errors in which the structure and the value agree (the value is the PHYSPROP value of the structure drawn, e.g. lorazepam under the name lormetazepam). However, 20 compounds (27 records) are structure errors of the same kind as the corrected ones, three of them confirmed by the PHYSPROP value of the named compound (e.g. 2-methyl-8-quinolinol drawn as 7-methyl-8-quinolinol), and four are uncertain. These 24 compounds are not corrected in the current training data.

The Random Forest and XGBoost models of the manuscript (trained on Naef & Acree + Crippen features only) are part of the benchmark (scripts/benchmark_5model.py) and are not available through run_models().

Benchmark of the five manuscript models

5-fold cross-validation on the common evaluation set, from tests/out/benchmark_metrics_5model.csv (scripts/benchmark_5model.py). AUC, AP (average precision), balanced accuracy and MCC classify logKow ≥ 4.6 (aquatic B) and logKoa ≥ 6 (B). XGBoost results depend on the processor architecture (see manuscript/README.md); these were computed on x86-64.

Model Endpoint R² RMSE AUC AP Bal. Acc. MCC
Crippen logKow 0.906 0.636 0.992 0.964 0.921 0.872
Naef & Acree logKow 0.861 0.775 0.990 0.959 0.936 0.876
Crippen + Naef & Acree logKow 0.943 0.496 0.996 0.977 0.938 0.896
Random Forest logKow 0.917 0.597 0.991 0.965 0.914 0.877
XGBoost logKow 0.943 0.494 0.994 0.971 0.937 0.886
Crippen logKoa 0.937 0.737 0.990 0.994 0.944 0.888
Naef & Acree logKoa 0.778 1.385 0.975 0.985 0.932 0.861
Crippen + Naef & Acree logKoa 0.943 0.701 0.990 0.994 0.946 0.892
Random Forest logKoa 0.911 0.876 0.988 0.993 0.941 0.880
XGBoost logKoa 0.934 0.755 0.991 0.995 0.950 0.900

PartitionCalculator

Ridge regression on Crippen atom types and special groups, fitted on the Naef & Acree datasets. Coefficients are stored in kawow/data/*.json, so nothing is fitted at import time.

from kawow import PartitionCalculator

calc = PartitionCalculator()

calc.predict("CCCCO")    # 1-butanol
# {'logKow': 1.095, 'logKoa': 4.368, 'logKaw': -3.273, 'status': 'ok', 'name': 'CCCCO', 'smiles': 'CCCCO'}

for r in calc.predict_batch(["c1ccccc1", "CCCCCCCCCC", "OC(=O)c1ccccc1"]):
    print(r["smiles"], r["logKow"], r["logKoa"], r["logKaw"])

predict() also accepts InChI strings, RDKit molecules, SDF files, lists and multi-line SMILES blocks (SMILES name per line); it returns a list for multiple molecules and skips inputs that cannot be parsed.

calc.model_info["logKow"]
# {'target': 'logKow', 'n_train': 3234, 'alpha': 51.79, 'r2_cv': 0.898, 'rmse_cv': 0.6643,
#  'intercept': 0.399, ...}  (plus the fitted coefficients)

Re-fit on your own data (overwrites the JSON files in the package directory):

import kawow
kawow.fit(sdf_logkow="my_logkow.sdf", sdf_logkoa="my_logkoa.sdf",
          logkow_prop="logP", logkoa_prop="logKoa")
calc = kawow.PartitionCalculator()   # reload after fitting

NaefAcreePartitionCalculator

Implements the Naef & Acree (2024) method: each SMARTS pattern of the paper's supplementary tables is matched against the molecule and its tabulated contribution is added, so every contribution is directly interpretable.

from kawow import NaefAcreePartitionCalculator

calc = NaefAcreePartitionCalculator()
calc.predict("c1ccccc1")
# {'logKow': 2.35, 'logKoa': 3.14, 'logKaw': -0.79, 'in_coverage': True}

batch = NaefAcreePartitionCalculator(smiles=["c1ccccc1", "CCCCCCCCCC", "OC(=O)c1ccccc1"])
for mol, coeffs in batch.results.items():
    print(coeffs)
Dataset Property n R² RMSE
S01 (full) logKow 3 339 0.860 0.776
S02 (full) logKoa 1 983 0.785 1.385
S03 (full) logKaw 2 150 0.654 1.757
Common evaluation set logKow 3 314 0.861 0.775
Common evaluation set logKoa 1 956 0.778 1.385

The remaining error is concentrated in specific chemotypes, notably heteroatom-rich agrochemical scaffolds.

logKow vs Naef S01 logKoa vs Naef S02 logKow vs Arp & Hale
logKow vs S01 logKoa vs S02 logKow vs Arp & Hale

Features

The Crippen feature vector (compute_features) has 78 entries: counts of the 72 Crippen atom types of RDKit's Crippen.txt (first-match priority, SMARTS only; RDKit's logP contributions are not used) and six special groups following Naef & Acree (2024): intramolecular H-bond donor/acceptor pairs within five bonds, carbon count of pure saturated hydrocarbons, carbon count of pure unsaturated acyclic hydrocarbons, carboxylic-acid groups beyond the first, hydroxyl groups beyond the first, and endocyclic C–C single bonds. See docs/features.md, which also describes the PFASGroups descriptors.

Additional metrics

The benchmark also reports Lin's concordance correlation coefficient (CCC; Lin 1989), the RMSE normalised by the standard deviation and by the range of the data, and a BIC-approximated Bayes factor for a non-zero correlation (Ly et al. 2015), in tests/out/shared_fold_benchmark.csv. The functions are in kawow.metrics.

Model Property n CCC NRMSE (σ) NRMSE (range) log₁₀(BF₁₀)
Crippen logKow 3319 0.946 0.319 0.039 >10^300
Crippen logKoa 1956 0.968 0.252 0.043 >10^300
NaefAcree logKow 3319 0.925 0.378 0.046 >10^300
NaefAcree logKoa 1956 0.894 0.472 0.082 >10^300
NaefAcree + Crippen logKow 3319 0.968 0.249 0.030 >10^300
NaefAcree + Crippen logKoa 1956 0.971 0.239 0.041 >10^300
MQG alone logKow 3319 0.483 0.817 0.099 >10^300
MQG alone logKoa 1956 0.783 0.594 0.102 >10^300
MQG + NaefAcree + Crippen logKow 3319 0.969 0.245 0.030 >10^300
MQG + NaefAcree + Crippen logKoa 1956 0.970 0.242 0.042 >10^300
PFASGroups logKow 3319 0.880 0.464 0.056 >10^300
PFASGroups logKoa 1956 0.945 0.322 0.056 >10^300
PFASGroups + Crippen logKow 3319 0.954 0.298 0.036 >10^300
PFASGroups + Crippen logKoa 1956 0.970 0.242 0.042 >10^300
PFASGroups + NaefAcree logKow 3319 0.969 0.246 0.030 >10^300
PFASGroups + NaefAcree logKoa 1956 0.968 0.247 0.043 >10^300
PFASGroups + NaefAcree + Crippen logKow 3319 0.970 0.240 0.029 >10^300
PFASGroups + NaefAcree + Crippen logKoa 1956 0.970 0.239 0.041 >10^300
PFASGroups + NaefAcree + Crippen (RF) logKow 3319 0.953 0.303 — >10^300
PFASGroups + NaefAcree + Crippen (RF) logKoa 1956 0.962 0.273 — >10^300
PFASGroups + NaefAcree + Crippen (XGB) logKow 3319 0.968 0.254 — >10^300
PFASGroups + NaefAcree + Crippen (XGB) logKoa 1956 0.970 0.244 — >10^300
PFASGroups + NaefAcree + Crippen (NN) logKow 3319 — — — >10^300
PFASGroups + NaefAcree + Crippen (NN) logKoa 1956 — — — >10^300

Y-randomisation

python scripts/shared_fold_benchmark.py --y-randomization permutes the target values (1 000 permutations by default, --y-rand-permutations) for the trainable models of the shared-fold benchmark and writes tests/out/y_randomization.csv. A model captures a genuine structure–property relationship when its observed R² lies far above the permuted values, that is when the p-value (fraction of permuted R² ≥ observed R²) is close to zero. The y-randomisation reported in the manuscript (Crippen and Crippen + Naef & Acree, 300 permutations) is produced by manuscript/yrandomization.py.


Manuscript

The manuscript/ folder contains the scripts that reproduce the figures and SI tables of A Vanishing Partitioning Gap (Miaz & Cousins); see manuscript/README.md.


References

Naef, R.; Acree, W. E. Calculation of the Three Partition Coefficients logPow, logKoa and logKaw of Organic Molecules at Standard Conditions at Once by Means of a Generally Applicable Group-Additivity Method. Liquids 2024, 4 (1), 231–260. doi:10.3390/liquids4010011

Kelly, B. C.; Ikonomou, M. G.; Blair, J. D.; Morin, A. E.; Gobas, F. A. P. C. Food Web–Specific Biomagnification of Persistent Organic Pollutants. Science 2007, 317 (5835), 236–239. doi:10.1126/science.1138275

Mackay, D.; Arnot, J. A.; Gobas, F. A. P. C.; Powell, D. E. Mathematical Relationships between Metrics of Chemical Bioaccumulation in Fish. Environ. Toxicol. Chem. 2013, 32 (7), 1459–1466. doi:10.1002/etc.2205

Neumann, M.; Schliebner, I. Protecting the Sources of Our Drinking Water: The Criteria for Identifying PMT and vPvM Substances under EU Regulation REACH; TEXTE 127/2019; German Environment Agency (UBA), 2019.

Arp, H. P. H.; Hale, S. E. REACH: Improvement of Guidance and Methods for the Identification and Assessment of PMT/vPvM Substances; TEXTE 126/2019; German Environment Agency (UBA), 2019.

Arp, H. P. H.; Hale, S. E. Assessing the Persistence and Mobility of Organic Substances to Protect Freshwater Resources. ACS Environ. Au 2022, 2 (6), 482–509. doi:10.1021/acsenvironau.2c00024 (supplementary data vg2c00024_si_001)

Commission Delegated Regulation (EU) 2023/707 amending Regulation (EC) No 1272/2008 as regards hazard classes and criteria for the classification, labelling and packaging of substances and mixtures. ELI

Lin, L. I.-K. A Concordance Correlation Coefficient to Evaluate Reproducibility. Biometrics 1989, 45, 255–268. doi:10.2307/2532051

Ly, A.; Verhagen, A. J.; Wagenmakers, E.-J. Harold Jeffreys's Default Bayes Factor Hypothesis Tests. J. Math. Psychol. 2016, 72, 19–32. doi:10.1016/j.jmp.2015.06.004

Steiger, J. H. Tests for Comparing Elements of a Correlation Matrix. Psychol. Bull. 1980, 87, 245–251. doi:10.1037/0033-2909.87.2.245

Chicco, D.; Tötsch, N.; Jurman, G. The Matthews Correlation Coefficient (MCC) Is More Reliable Than Balanced Accuracy. BioData Mining 2021, 14, 13. doi:10.1186/s13040-021-00244-z

License

CC BY 4.0 — Luc T. Miaz, 2026

Metadata

Release files for kawow 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kawow 1.1.1
File Size Uploaded Provenance Actions
kawow-1.1.1.tar.gz 28.3 MB Without provenance Details for kawow-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kawow 1.1.1
File Interpreter ABI Platform Actions
kawow-1.1.1-py3-none-any.whl Python 3 none any Details for kawow-1.1.1-py3-none-any.whl

Total release size: 57.3 MB

Release files / kawow-1.1.1.tar.gz

Download URL kawow-1.1.1.tar.gz
Size 28.3 MB
Tags Source
SHA-256 checksum
How to use checksums
0832ab49bb0c2e1fec1532a02d87972b7568b8f10828143f8ca23d00838c89b2
BLAKE2b-256 checksum
How to use checksums
856119c43321e73e139f5a9e158a3bac2938b8ca78c2c574dce58f2f9dbadf8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / kawow-1.1.1-py3-none-any.whl

Download URL kawow-1.1.1-py3-none-any.whl
Size 29.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9e1eaaa79838f20d2de4da584f0154ed9634f96967f3c5876f6f3cd65bbc7a49
BLAKE2b-256 checksum
How to use checksums
94bb9231c362ca6040da86691ca16e40d69a59c9cfd18ef067040c5372ef122e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for kawow 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page