-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
Not a bug but the return type of get_cids is list[int]. However, when called with domain = "substance", it returns a list of dictionaries that contains both SID and CID.
import pubchempy as pcp
pcp.get_cids("8000-78-0", namespace="name", domain="substance") # garlic oilreturns
[{'SID': 442031951, 'CID': [6850738]},
{'SID': 445479966, 'CID': [6850738]},
{'SID': 446464370, 'CID': [6850738]},
{'SID': 479884108, 'CID': [6850738]},
{'SID': 480557704, 'CID': [6850738]},
{'SID': 481120361, 'CID': [6850738]},
{'SID': 488195857, 'CID': [6850738]},
{'SID': 497868770, 'CID': [6850738]},
{'SID': 503477764, 'CID': [6850738]},
{'SID': 504051010, 'CID': [6850738]},
{'SID': 507705895, 'CID': [6850738]},
{'SID': 135264271},
{'SID': 176258937},
{'SID': 349326089},
{'SID': 363901999},
{'SID': 441076689},
{'SID': 472186491},
{'SID': 472388580},
{'SID': 477517504},
{'SID': 482032741},
{'SID': 485460846},
{'SID': 486323371},
{'SID': 488208578},
{'SID': 496304552}]
What I am doing now is the following, e.g. when looking for a substance with its CASRN (useful when the get_compounds returns an empty list for a given CASRN):
cids = pcp.get_cids(casrn, namespace="name", domain="substance")
cid_list = []
if len(cids)> 0:
for cid in cids:
if 'CID' in cid.keys():
cid_list.append(cid['CID'])
cid_list = list(set(cid_list)) # Removing duplicatesMetadata
Metadata
Assignees
Labels
No labels