Skip to content

Instantly share code, notes, and snippets.

@matteoferla
matteoferla / set_to_neutral_pH
Last active March 15, 2024 19:13
A small function to fix the pH protonation/deprotonation of RDKit Chem objects —fixes the charge of simple, i.e. biological cases. So amino acid is fine, but complex artificial drug won't be.
from rdkit import mol
def set_to_neutral_pH(mol: Chem):
"""
Not great, but does the job.
* Protonates amines, but not aromatic bound amines.
* Deprotonates carboxylic acid, phosphoric acid and sulfuric acid, without ruining esters.
"""
protons_added = 0