def get_cids(self, cas):
"""
Use the PubChem API to get the CID
:param cas: string - CAS identifier
:return: list of CIDs
"""
uri = "http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/%s/cids/json" \
"?email=%s"
try:
response = get((uri % (cas, app.config['ADMIN_EMAIL']))).json()
try:
cids = response['IdentifierList']['CID']
return cids
except KeyError:
return None
except (exceptions.ConnectionError, TimeoutError, exceptions.Timeout,
exceptions.ConnectTimeout, exceptions.ReadTimeout) as e:
# Error. return the error and the CAS number that this error occured on
sys.stderr.write("Error: %s. Occurred on CAS: %s", (e, cas))
sys.stderr.flush()
sys.stdout.flush()
评论列表
文章目录