Skip to content

Instantly share code, notes, and snippets.

@cthoyt
Created January 22, 2019 15:19
Show Gist options
  • Save cthoyt/fcd27023b7578668d1071c794ad0977a to your computer and use it in GitHub Desktop.
Save cthoyt/fcd27023b7578668d1071c794ad0977a to your computer and use it in GitHub Desktop.
import pubchempy as pcp
keys = '''MXDPZUIOZWKRAA-UZOALHFESA-K
MJUVRTYWUMPBTR-MRXNPFEDSA-N
HJBWBFZLDZWPHF-UHFFFAOYSA-N
HZIYEEMJNBKMJH-UHFFFAOYSA-N
CPZBLNMUGSZIPR-NVXWUHKLSA-N
GKDRMWXFWHEQQT-UHFFFAOYSA-N
KSMAGQUYOIHWFS—UHFFFAOYSA-N
OFZJKCQENFPZBH-UHFFFAOYSA-N
XUZMUHLSFXCVMG-UHFFFAOYSA-N
YZBLFMPOMVTDJY-LSGXYNIPSA-N
QHMBSVQNZZTUGM—ZWKOTPCHSA-N
IYDYFVUFSPQPPV—PEXOCOHZSA-N
ACWZRVQXLIRSDF-UHFFFAOYSA-N
CMJCXYNUCSMDBY-ZDUSSCGKSA-N
MJUYRTYWUMPBTR-MRXNPFEDSA-N
WIJZXSAJMHAVGX-DHLKQENFSA-N
LBHLFPGPEGDCJG—UHFFFAOYSA-N
HEAUOKZIVMZVQL-VULOTQADSA-N
NOZIJMHMKORZBA-KJCUYJGMSA-N
'''.split()
results = []
for key in keys:
compounds = pcp.get_compounds(keys[0], namespace='inchikey')
print(compounds)
results.append(compounds)
print(results[0][0].iupac_name)
@cthoyt
Copy link
Author

cthoyt commented Jan 22, 2019

The repr from the pubchempy.Compund class prints the compound identifier, but doing results[0][0].cid would actually be a better way to get at that (of course, after noticing they're all the same)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment