-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleaned2.query
52 lines (44 loc) · 866 Bytes
/
cleaned2.query
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- assemble data for reaction analytics
set search_path to reaxys;
select * into reaxys.cleaned from
(
select
reaction.*,
rxnsmiles,
reagents,
catalysts,
solvents,
max(yield) as yield,
conditions
from
(select reaxys_reaction_id, reactant_id, product_id, unnest(variations) as variation_id from reaction) reaction,
variation,
substance,
rdfile
where
reaction.variation_id = variation.variation_id and
substance.substance_id = any(variation.products) and
rx_id = reaxys_reaction_id and
stages is null
group by
reaxys_reaction_id,
reactant_id,
product_id,
rxnsmiles,
reaction.variation_id,
reagents,
catalysts,
solvents,
stages,
variation.conditions
) g
;
select * into reaxys.full_reaction_set from
(
select cleaned.*, time, temperature
from
reaxys.cleaned
left join reaxys.conditions
on
condition_id = any(conditions)
) x;