mims-harvard/TDC

PubChem Fingerprint Failed

peiyaoli opened this issue · 3 comments

Describe the bug

I tried to convert smiles to PubChem Fingerprints but failed:

NameError: name 'canonicalize' is not defined

I have double-checked the code, the bug is quite obvious:

function canonicalize needs to be imported from

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

  • OS:
  • Python version:
  • TDC version:
  • Any other relevant information:

Additional context
Add any other context about the problem here.

Hi!Can you send codes to reproduce the error?

Hi, @kexinhuang12345

Here is my code:

from tdc.chem_utils import MolConvert

convert = MolConvert(src="SMILES", dst="PubChem")
convert("B12B3B4B1C234")

Here is the exception info:


NameError Traceback (most recent call last)
Cell In[5], line 1
----> 1 convert("B12B3B4B1C234")

File ~/miniconda3/envs/QQ/lib/python3.9/site-packages/tdc/chem_utils/featurize/molconvert.py:1017, in MolConvert.call(self, x)
1015 if type(x) == str:
1016 if self.func != smiles2morgan:
-> 1017 return self.func(x)
1018 else:
1019 return self.func(x, radius=self._radius, nBits=self._nbits)

File ~/miniconda3/envs/QQ/lib/python3.9/site-packages/tdc/chem_utils/featurize/molconvert.py:985, in MolConvert.init..(x)
983 elif dst == "PubChem":
984 f2 = smiles2pubchem
--> 985 self.func = lambda x: f2(f1(x))
986 elif src in threeD_format:
987 pass

File ~/miniconda3/envs/QQ/lib/python3.9/site-packages/tdc/chem_utils/featurize/_smiles2pubchem.py:940, in smiles2pubchem(s)
939 def smiles2pubchem(s):
--> 940 s = canonicalize(s)
941 try:
942 features = calcPubChemFingerAll(s)

NameError: name 'canonicalize' is not defined

I think you just forgort to import canonicalize functions. :)

Hi! Just fixed in 08b86d1