-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
37 lines (26 loc) · 850 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from comchem import *
import json
def props(casrn='57-83-0'):
# gets the properties for the CASRN requested
cmpd = detail(casrn, "properties")
return cmpd
def trifl():
# gets a list of all compounds starting with "trifluoro*"
hits = query("trifluoro*")
print(hits)
def key2casrn(key):
# convert a substance CASRN into its InChIKey
# uses code to find the lowest molecular weight hit for the InChIkey
casrn = key2cas(key)
print(casrn)
def cas2png(casrn='57-83-0'):
# create a png of a molecule based on its CASRN (via SVG from ComChem)
chemimg(casrn, 'png')
print('image saved to ' + casrn + '.py')
subs = ['57-83-0', '71-43-2', '118-96-7']
for sub in subs:
out = props(sub)
print(json.dumps(out, indent=4))
# key2cas('UHOVQNZJYSORNB-UHFFFAOYSA-N')
# trifl()
# cas2png('57-83-0')