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

Fingerprinting functions should call assignStereochemistry() when necessary #1993

Closed
bricehoff opened this issue Aug 3, 2018 · 2 comments
Closed

Comments

@bricehoff
Copy link

Description:

  • RDKit Version: '2018.03.2'
  • Platform: Linux

There seems to be a problem with EnumerateStereoisomers or GetMorganFingerprintAsBitVect and useChirality = True. Below is an example of the issue. I was expecting fp1 and fp2 to be different in the first case. Is it a bug or am I missing something ?
Cheers,
Brice

from rdkit import Chem
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers
m = Chem.MolFromSmiles('BrC=CC1OC(C2)(F)C2(Cl)C1')
isomers = tuple(EnumerateStereoisomers(m))

fp1=AllChem.GetMorganFingerprintAsBitVect(isomers[0], 4, 2048, useChirality=True)
fp2=AllChem.GetMorganFingerprintAsBitVect(isomers[1], 4, 2048, useChirality=True)
print(DataStructs.FingerprintSimilarity(fp1,fp2))
>>> 1.0

fp1=AllChem.GetMorganFingerprintAsBitVect(Chem.MolFromSmiles(Chem.MolToSmiles(isomers[0])), 4, 2048, useChirality=True)
fp2=AllChem.GetMorganFingerprintAsBitVect(Chem.MolFromSmiles(Chem.MolToSmiles(isomers[1])), 4, 2048, useChirality=True)
print(DataStructs.FingerprintSimilarity(fp1,fp2))
>>> 0.5609756097560976

@greglandrum
Copy link
Member

Hi Brice,
What's going on here is that EnumerateStereoisomers() produces molecules with the correct configuration, but it does not (re)generate the CIP labels that the Morgan fingerprinting code uses when you ask for chirality to be used in the fingerprinting. You need to call AssignStereochemistry() in order to make things work.
We can pretty easily get rid of this opportunity for you to get the wrong results in the next major release, but in the meantime all you need to do is the following:
for isomer in isomers: Chem.AssignStereochemistry(isomer,force=True,cleanIt=True)

@bricehoff
Copy link
Author

thanks !

bp-kelley pushed a commit that referenced this issue Aug 12, 2018
* add an additional equality test to testDatastructs
(can never have too many tests!)

* automatically run assignStereochemistry() for chiral fingerprints
This currently runs for the three FP types that support chirality: MFP, AP, and TT
ricrogz pushed a commit to ricrogz/rdkit that referenced this issue Aug 21, 2018
* add an additional equality test to testDatastructs
(can never have too many tests!)

* automatically run assignStereochemistry() for chiral fingerprints
This currently runs for the three FP types that support chirality: MFP, AP, and TT
@greglandrum greglandrum changed the title Problem with EnumerateStereoisomers and Morgan Similarity of isomers Fingerprinting functions should call assignStereochemistry() when necessary Sep 6, 2018
greglandrum added a commit to greglandrum/rdkit that referenced this issue Nov 11, 2022
ensure stereochemistry is assigned when calculating fingerprints using chirality (rdkit#1993)
greglandrum added a commit that referenced this issue Dec 28, 2022
* add FingerprintFuncArguments() to simplify things

* getFingerprintHelper() also uses FingerprintFuncArguments

* port atompairs and tts to use new code

* not working yet

* all tests pass

* move the includeChirality flag to the global arguments
ensure stereochemistry is assigned when calculating fingerprints using chirality (#1993)

* migrate legacy morgan fp code to use generators

* refactoring the way bit info is handled

* all tests pass

* all tests pass

* expose getArguments()

* rename getArguments->getOptions

* copyright updates

* update a test

* remove template from FingerprintArguments
some other refactoring and cleanup

* hopefully fix the windows dll builds

* partial docs update

* improve docs and API

* more docs

* more docs

* a bit of modernization

* more doc tweaks

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

No branches or pull requests

2 participants