[ase-users] Potential Pubchem API Integration

Ask Hjorth Larsen asklarsen at gmail.com
Sat Aug 10 20:41:35 CEST 2019


Hi,

Am Fr., 9. Aug. 2019 um 21:48 Uhr schrieb Ben Comer via ase-users
<ase-users at listserv.fysik.dtu.dk>:
>
> Hello all,
>
> I've noticed that ASE has a very limited number of molecules that can be
> easily made into an atoms object. An easy fix for this could be to
> integrate a restful API to a chemical database to query and pull in
> structures from the internet. Pubchem
> (https://pubchem.ncbi.nlm.nih.gov/) might make sense for this, since it
> does not require an API key to access. We could just use the requests
> library to access molecules by name (or anything else, like cid fro
> example.) Some code to access the API would be a fairly short putt, we
> might make something like this:
>
> from io import StringIO
> from ase.io import read
> import requests
>
>
> def pubchem(name):
>      r =
> requests.get("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/{}/sdf".format(name))
>      f_like = StringIO(r.text)
>      atoms = read(f_like, format = 'sdf')
>      return atoms
>
> atoms = pubchem('ammonia')
> print(atoms)
>
>
> Just an idea, what do you guys think?

Looks very nice.  One question: How does the user know which search
strings are accepted?  There should probably be a way of searching
based on systematic name, formula, or something.

Best regards
Ask

>
>
> Thanks,
>
> Ben Comer
>
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users


More information about the ase-users mailing list