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

TypeError when trying to download a compund with None as cid #13

Closed
llazzaro opened this issue Jun 3, 2016 · 1 comment
Closed

TypeError when trying to download a compund with None as cid #13

llazzaro opened this issue Jun 3, 2016 · 1 comment
Labels
Milestone

Comments

@llazzaro
Copy link
Contributor

llazzaro commented Jun 3, 2016

I was doing a search with get_compounds with smiles string and I got a compound with None as cid.
I know it could not make sense to ask for a compound with a cid as None, but we could do a check on the cid formats.
I will analyse why get_compounds returned a Compound object with None as cid later.
I can provide a fix to this issue and to get_compunds if there is a bug there also (I will open other ticket in that case)

This was the error:

Traceback (most recent call last):
  File "convert_old_ligand_to_pubchem.py", line 29, in <module>
    pcp.download('sdf', temp_filename, pubchem_ligand.cid, 'cid')
  File "/home/leonardo/workspace/PubChemPy/pubchempy.py", line 450, in download
    response = get(identifier, namespace, domain, operation, outformat, searchtype, **kwargs)
  File "/home/leonardo/workspace/PubChemPy/pubchempy.py", line 287, in get
    response = request(identifier, namespace, domain, operation, output, searchtype, **kwargs).read()
  File "/home/leonardo/workspace/PubChemPy/pubchempy.py", line 247, in request
    identifier = ','.join(str(x) for x in identifier)
TypeError: 'NoneType' object is not iterable
@mcs07 mcs07 closed this as completed in f2cfc9a Jun 5, 2016
mcs07 added a commit that referenced this issue Jun 5, 2016
fix #13 check if identifier is None and raise an exception to let the user know that the identifier is invalid
@mcs07
Copy link
Owner

mcs07 commented Jun 6, 2016

By the way, it is expected to sometimes return a compound without a CID for a SMILES input. It happens when you provide a valid SMILES that doesn't match any compound record in PubChem. In these cases, get_compounds returns a compound record that has been generated on the fly that contains calculated properties but no CID.

@mcs07 mcs07 added the bug label Apr 11, 2017
@mcs07 mcs07 modified the milestone: v1.0.4 Apr 11, 2017
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

2 participants