AVH1993 commited on
Commit
8053f30
1 Parent(s): 73e7127

Add arylation example

Browse files
Files changed (5) hide show
  1. README.md +7 -5
  2. app.py +110 -0
  3. data.csv +0 -0
  4. gitattributes +35 -0
  5. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,14 @@
1
  ---
2
- title: ArylHalides
3
- emoji: 🐨
4
- colorFrom: indigo
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 4.23.0
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Direct Arylation Reaction Conditions
3
+ emoji: 🧪
4
+ colorFrom: yellow
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 4.21.0
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
+ short_description: Optimize direct arylation reaction conditions
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+
5
+ # Goal: Maximize
6
+ # Publication reporting the dataset: Ahnemanet al. Predicting reaction performance in
7
+ # C–N cross-coupling using machine learning. Science 360, 186–190 (2018)
8
+ # https://www.science.org/doi/10.1126/science.aar5169#supplementary-materials
9
+ def lookup(base: str, ligand: str, additive: str, aryl_halide: str):
10
+ data = pd.read_csv("./data.csv", delimiter=",", index_col=None)
11
+ other = pd.DataFrame.from_records(
12
+ {
13
+ "base": base,
14
+ "ligand": ligand,
15
+ "additive": additive,
16
+ "aryl_halide": aryl_halide,
17
+ },
18
+ index=[0],
19
+ )
20
+
21
+ merged_df = pd.merge(
22
+ left=data.reset_index(),
23
+ right=other,
24
+ on=other.columns.tolist(),
25
+ how="right",
26
+ sort=False,
27
+ ).dropna(subset="index")
28
+ idxs_matched = pd.Index(merged_df["index"].values)
29
+
30
+ if len(idxs_matched) < len(other):
31
+ raise IndexError(
32
+ "When doing exact lookup some rows could not be found. Try "
33
+ "approximate lookup or check reference data."
34
+ )
35
+ if len(idxs_matched) > len(other):
36
+ raise IndexError(
37
+ "When doing exact lookup some rows in the reference dataframe appear "
38
+ "duplicated. Check reference data."
39
+ )
40
+
41
+ return data["yield"][idxs_matched[0]]
42
+
43
+
44
+ base = {
45
+ "BTMG": "CN(C)/C(N(C)C)=N\\C(C)(C)C",
46
+ "MTBD": "CN1CCCN2CCCN=C12",
47
+ "P2Et": "CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC",
48
+ }
49
+ ligand = {
50
+ "XPhos": "CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)C4CCCCC4)C=CC=C2",
51
+ "t-BuXPhos": "CC(C)C(C=C(C(C)C)C=C1C(C)C)=C1C2=CC=CC=C2P(C(C)(C)C)C(C)(C)C",
52
+ "t-BuBrettPhos": "CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C(C)(C)C)C(C)(C)C)C(OC)=CC=C2OC",
53
+ "AdBrettPhos": "CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5)C3)C67CC8CC(C7)CC(C8)C6)C(C(C)C)=CC(C(C)C)=C1)C",
54
+ }
55
+
56
+ additive = {
57
+ "3,5-dimethylisoxazole": "Cc1onc(C)c1",
58
+ "3-methyl-5-phenylisoxazole": "Cc1cc(on1)c2ccccc2",
59
+ "3-methylisoxazole": "Cc1ccon1",
60
+ "3-phenylisoxazole": "o1ccc(n1)c2ccccc2",
61
+ "4-phenylisoxazole": "o1cc(cn1)c2ccccc2",
62
+ "5-(2,6-difluorophenyl)isoxazole": "Fc1cccc(F)c1c2oncc2",
63
+ "5-Phenyl-1,2,4-oxadiazole": "c1ccc(-c2ncno2)cc1",
64
+ "5-methyl-3-(1H-pyrrol-1-yl)isoxazole": "Cc1onc(c1)n2cccc2",
65
+ "5-methylisoxazole": "Cc1oncc1",
66
+ "5-phenylisoxazole": "o1nccc1c2ccccc2",
67
+ "N,N-dibenzylisoxazol-3-amine": "C(N(Cc1ccccc1)c2ccon2)c3ccccc3",
68
+ "N,N-dibenzylisoxazol-5-amine": "C(N(Cc1ccccc1)c2oncc2)c3ccccc3",
69
+ "benzo[c]isoxazole": "o1cc2ccccc2n1",
70
+ "benzo[d]isoxazole": "o1ncc2ccccc12",
71
+ "ethyl-3-methoxyisoxazole-5-carboxylate": "CCOC(=O)c1onc(OC)c1",
72
+ "ethyl-3-methylisoxazole-5-carboxylate": "CCOC(=O)c1onc(C)c1",
73
+ "ethyl-5-methylisoxazole-3-carboxylate": "CCOC(=O)c1cc(C)on1",
74
+ "ethyl-5-methylisoxazole-4-carboxylate": "CCOC(=O)c1cnoc1C",
75
+ "ethyl-isoxazole-3-carboxylate": "CCOC(=O)c1ccon1",
76
+ "ethyl-isoxazole-4-carboxylate": "CCOC(=O)c1conc1",
77
+ "methyl-5-(furan-2-yl)isoxazole-3-carboxylate": "COC(=O)c1cc(on1)c2occc2",
78
+ "methyl-5-(thiophen-2-yl)isoxazole-3-carboxylate": "COC(=O)c1cc(on1)c2sccc2",
79
+ "methyl-isoxazole-5-carboxylate": "COC(=O)c1oncc1",
80
+ }
81
+
82
+ aryl_haylide = {
83
+ '1-bromo-4-ethylbenzene': 'CCc1ccc(Br)cc1',
84
+ '1-bromo-4-methoxybenzene': 'COc1ccc(Br)cc1',
85
+ '1-chloro-4-(trifluoromethyl)benzene': 'FC(F)(F)c1ccc(Cl)cc1',
86
+ '1-chloro-4-methoxybenzene': 'COc1ccc(Cl)cc1',
87
+ '1-iodo-4-methoxybenzene': 'COc1ccc(I)cc1',
88
+ '2-bromopyridine': 'Brc1ccccn1',
89
+ '2-iodopyridine': 'Ic1ccccn1',
90
+ '3-bromopyridine': 'Brc1cccnc1',
91
+ '3-chloropyridine': 'Clc1cccnc1'
92
+ }
93
+
94
+ defaults = (
95
+ "P2Et","XPhos","5-phenylisoxazole","1-chloro-4-(trifluoromethyl)benzene"
96
+ )
97
+
98
+ iface = gr.Interface(
99
+ fn=lookup,
100
+ inputs=[
101
+ gr.Radio(label="Base", choices=list(base.keys()), value=defaults[0]),
102
+ gr.Radio(label="Ligand", choices=list(ligand.keys()), value=defaults[1]),
103
+ gr.Radio(label="Additive", choices=list(additive.keys()), value=defaults[2]),
104
+ gr.Radio(
105
+ label="Aryl Haylide", choices=list(aryl_haylide.keys()), value=defaults[3]
106
+ ),
107
+ ],
108
+ outputs=gr.Number(lookup(*defaults), label="yield value (maximize)"),
109
+ )
110
+ iface.launch()
data.csv ADDED
The diff for this file is too large to render. See raw diff
 
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ numpy
2
+ gradio
3
+ pandas