cordial greeting. I'm more of a chemist than a programmer. I am trying to use RDKit to draw in highlight or in some way (as a program called openeye does) the polar surface area of a molecule in two dimensions. I have the following code, I don't know if this can be improved in any way, there should be no polar area on the aromatic ring, but the program still gives me red dots, I understand that it is due to the partial charge calculated by the Gasteiger model
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem import AllChem
from rdkit.Chem import Descriptors
#from rdkit.Chem import DrawMol
def highlight_psa_atoms(mol):
# Gasteiger charges
AllChem.ComputeGasteigerCharges(mol)
#
psa_atoms = [atom.GetIdx() for atom in mol.GetAtoms() if atom.GetDoubleProp("_GasteigerCharge") < 0]
#
highlight_style = {atom_id: (1, 0, 0) for atom_id in psa_atoms}
return highlight_style
#
smiles = "CC(=O)OC1=CC=CC=C1C(O)=O"
#
mol = Chem.MolFromSmiles(smiles)
#
highlight_style = highlight_psa_atoms(mol)
#
img = Draw.MolToImage(mol, size=(300, 300), highlightAtoms=highlight_style, wedgeBonds=True, kekulize=True, wedgeLineWidth=2)
img
I know the output is way less beautiful than it is with openeye but maybe that's what you are looking for.
I'd recommend to directly visualize the contributions to the TPSA. Because the ring is not contributing to the TPSA it has no highlighting.
By default atom species P and S are (in terms of RDKit) not contributing to the TPSA. You can turn this on and off with the parameter
includeSandP=True
.Good find,
GetSimilarityMapFromWeights
allows you to put weights on certain atoms. Depending on the weights you can color it. Best in your case would be a diverging colormap. You can find all the colormaps here. Try the following:Give it a try and let me know.