Open Cajac102 opened 3 years ago
May you share a MWE yielding this problem? With a minimal
import pubchempy as pcp
def retrieve_similar(structure=""):
"""Retrieve PubChem entries of similar structure."""
similars = pcp.get_compounds(structure,
'smiles',
searchtype='similarity',
threshold=0.7,
as_dataframe=True)
print(similars)
# the example working fine
retrieve_similar("Cc1noc(C)c1Br")
(or, retrieve_similar("Cn1c(=O)c2nc(Cl)[nH]c2n(C)c1=O")
, respectively), I interpret the output for both like a successful interaction with the database (Python 3.9.2, PubChemPy 1.0.4). For documentation, the archive below includes a Jupyter notebook with a one-time code.
Thanks! With your example,
retrieve_similar("Cn1c(=O)c2nc(Cl)[nH]c2n(C)c1=O")
works perfectly for me too. However,
ligand_smile = "Cn1c(=O)c2nc(Cl)[nH]c2n(C)c1=O"
retrieve_similar(ligand_smile)
throws a JSON decode error again.
I found two fixes.
retrieve_similar(str(ligand_smile))
This confuses me because type(ligand_smile)
and type("Cn1c(=O)c2nc(Cl)[nH]c2n(C)c1=O")
both give me <class 'str'>
.
Hey,
I am trying to search pubchem for similar compounds with this call:
similars = pcp.get_compounds(smile, 'smiles', searchtype='similarity', threshold=0.7, as_dataframe=True)
This works well for some SMILES, for example for "Cc1noc(C)c1Br". But for others, e.g. "Cn1c(=O)c2nc(Cl)[nH]c2n(C)c1=O", I get the following error:
If I turn the double quotation marks around the SMILES into single ones, I get
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 215438 column 3 (char 4812373)
I would be glad if you could help me here!
Cheers, Caro