pythonpubchem

How to use searchtype option in PubChemPy


I tried to run the code

pcp.get_compounds('CC', searchtype='superstructure', listkey_count=3)

but, it didn't work.

This code is exactly the same as one shown in the documentation ("https://pubchempy.readthedocs.io/en/latest/guide/searching.html#advanced-search-types").

Another code such as pcp.get_compounds('Aspirin', 'name', record_type='3d') which is shown in the same page worked.

Please give me some advice about how to fix this error.


Solution

  • It appears that the example in the PubChemPy advanced search documentation is missing a parameter. The example does not identify how to search, i.e., by SMILES. Substituting the following statement for the one in the example should give you the desired result.

    pcp.get_compounds('CC', 'smiles', searchtype='superstructure', listkey_count=3)