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

fp.ToList() fails for empty molecule #5677

Closed
baoilleach opened this issue Oct 22, 2022 · 1 comment
Closed

fp.ToList() fails for empty molecule #5677

baoilleach opened this issue Oct 22, 2022 · 1 comment
Labels
Milestone

Comments

@baoilleach
Copy link
Contributor

RDKit: 2021.09.5

from rdkit import Chem
from rdkit.Chem import AllChem
smi = ""
mol = Chem.MolFromSmiles(smi)
assert mol.GetNumAtoms() == 0
fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=1024)
print(fp.ToList())

I would expect this to produce a list of 1024 zeroes. Instead I get:

IndexError: cannot fit 'int' into an index-sized integer

@bp-kelley
Copy link
Contributor

The fix is pretty simple, in wrap_ExplicitBV we don't check to see if there are no bits set:

    auto pos = sv.dp_bits->find_first();
    l[pos] = 1;

I'll make a quick PR

bp-kelley pushed a commit to bp-kelley/rdkit that referenced this issue Oct 31, 2022
greglandrum pushed a commit that referenced this issue Nov 23, 2022
* Fixes #5677

* Response to review

* Fix bad push

Co-authored-by: Brian Kelley <bkelley@relaytx.com>
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

3 participants