[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimilarityMaps.GetSimilarityMapFromWeights scale option has no effect #7937

Open
FrederikKjeldal opened this issue Oct 18, 2024 · 0 comments
Labels

Comments

@FrederikKjeldal
Copy link

Describe the bug
The scale option in SimilarityMaps.GetSimilarityMapFromWeights has no effect.

According to the source code scale should work as

scale -- the scaling: scale < 0 -> the absolute maximum weight is used as maximum scale
                      scale = double -> this is the maximum scale

However, no difference is obtained when setting scale to different values. This is an issue when wanting to compare different molecules using similarity maps, e.g. for different partial charge schemes.

To Reproduce

from rdkit import Chem
from rdkit.Chem import Draw, rdPartialCharges
from rdkit.Chem.Draw import SimilarityMaps
import io
from PIL import Image
import rdkit

print(rdkit.__version__)


def show_png(data):
    bio = io.BytesIO(data)
    img = Image.open(bio)
    return img
atorvastatin = Chem.MolFromSmiles(
    "O=C(O)C[C@H](O)C[C@H](O)CCn2c(c(c(c2c1ccc(F)cc1)c3ccccc3)C(=O)Nc4ccccc4)C(C)C"
)
Draw.MolsToGridImage((atorvastatin,), molsPerRow=1)
rdPartialCharges.ComputeGasteigerCharges(atorvastatin)
chgs = [x.GetDoubleProp("_GasteigerCharge") for x in atorvastatin.GetAtoms()]
d = Draw.MolDraw2DCairo(400, 400)
SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin, chgs, draw2d=d)
d.FinishDrawing()
show_png(d.GetDrawingText())
d = Draw.MolDraw2DCairo(400, 400)
SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin, chgs, draw2d=d, scale=1000.0)
d.FinishDrawing()
show_png(d.GetDrawingText())
d = Draw.MolDraw2DCairo(400, 400)
SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin, chgs, draw2d=d, scale=0.01)
d.FinishDrawing()
show_png(d.GetDrawingText())

Expected behavior
The three different scales in the previous code should give different similarity maps, but currently give the same.

Screenshots
scale = -1 (default)
image
scale = 1000.0
image
scale =0.01
image

Configuration (please complete the following information):

  • RDKit version: rdkit-2024.3.5
  • OS: Mac OS Sonoma 14.5 (23F79)
  • Python version (if relevant): 3.11.5
  • Are you using conda? No
  • If you are using conda, which channel did you install the rdkit from?
  • If you are not using conda: how did you install the RDKit? pip install rdkit

Additional context
I would be happy to try to resolve this issue myself, if it is suitable for a first time contributor. Any guidance here would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant