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

Assay.from_aid().to_dict() fails for multiple AIDs #77

Open
watplatt opened this issue Jul 13, 2023 · 0 comments
Open

Assay.from_aid().to_dict() fails for multiple AIDs #77

watplatt opened this issue Jul 13, 2023 · 0 comments

Comments

@watplatt
Copy link

Assay.from_aid(2016).to_dict() fails. The reason is that a lot of 'comment' entries are absent altogether. The result is access to other records (e.g. 'target') is denied even if they do exist.

I can catch the exception, but it is a false failure (the 'target' may be there, but I can't get to it) for the records I want.
Here's the report...

KeyError Traceback (most recent call last)
Input In [36], in <cell line: 6>()
3 except Exception as x:
4 print(x)
----> 6 print(Assay.from_aid(2016).to_dict())

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1187, in Assay.to_dict(self, properties)
1185 if not properties:
1186 properties = [p for p in dir(Assay) if isinstance(getattr(Assay, p), property)]
-> 1187 return {p: getattr(self, p) for p in properties}

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1187, in (.0)
1185 if not properties:
1186 properties = [p for p in dir(Assay) if isinstance(getattr(Assay, p), property)]
-> 1187 return {p: getattr(self, p) for p in properties}

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1217, in Assay.comments(self)
1214 @Property
1215 def comments(self):
1216 """Comments and additional information."""
-> 1217 return [comment for comment in self.record['assay']['descr']['comment'] if comment]

KeyError: 'comment'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant