-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_snapper3_db.sql
More file actions
128 lines (115 loc) · 2.97 KB
/
setup_snapper3_db.sql
File metadata and controls
128 lines (115 loc) · 2.97 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
-- table definitions for all snapperdb3 databases
DROP TABLE IF EXISTS samples;
CREATE TABLE samples (
pk_id SERIAL PRIMARY KEY,
sample_name text,
molis_id text,
ngs_id integer,
ignore_sample boolean DEFAULT FALSE,
ignore_zscore boolean DEFAULT FALSE,
date_added timestamp
);
DROP TABLE IF EXISTS contigs;
CREATE TABLE contigs (
pk_id SERIAL PRIMARY KEY,
name text,
length integer
);
DROP TABLE IF EXISTS variants;
CREATE TABLE variants (
pk_id SERIAL PRIMARY KEY,
fk_sample_id integer references samples(pk_id),
fk_contig_id integer references contigs(pk_id),
a_pos integer[],
c_pos integer[],
g_pos integer[],
t_pos integer[],
n_pos integer[],
gap_pos integer[]
);
DROP TABLE IF EXISTS sample_clusters;
CREATE TABLE sample_clusters (
pk_id SERIAL PRIMARY KEY,
fk_sample_id integer references samples(pk_id),
t0 integer,
t2 integer,
t5 integer,
t10 integer,
t25 integer,
t50 integer,
t100 integer,
t250 integer,
t0_mean double precision,
t2_mean double precision,
t5_mean double precision,
t10_mean double precision,
t25_mean double precision,
t50_mean double precision,
t100_mean double precision,
t250_mean double precision
);
DROP TABLE IF EXISTS cluster_stats;
CREATE TABLE cluster_stats (
pk_id SERIAL PRIMARY KEY,
cluster_level text,
cluster_name integer,
nof_members integer,
nof_pairwise_dists integer,
mean_pwise_dist double precision,
stddev double precision
);
DROP TABLE IF EXISTS merge_log;
CREATE TABLE merge_log (
pk_id SERIAL PRIMARY KEY,
cluster_level text,
source_cluster integer,
target_cluster integer,
time_of_merge timestamp
);
DROP TABLE IF EXISTS sample_history;
CREATE TABLE sample_history (
pk_id SERIAL PRIMARY KEY,
fk_sample_id integer references samples(pk_id),
t0_old integer,
t2_old integer,
t5_old integer,
t10_old integer,
t25_old integer,
t50_old integer,
t100_old integer,
t250_old integer,
t0_new integer,
t2_new integer,
t5_new integer,
t10_new integer,
t25_new integer,
t50_new integer,
t100_new integer,
t250_new integer,
renamed_at timestamp
);
-- #################################################################################################
-- adding trees table
DROP TABLE IF EXISTS trees;
CREATE TABLE trees (
pk_id SERIAL PRIMARY KEY,
nwkfile bytea,
t5_name integer,
sample_set integer[],
t50_size integer,
mod_date timestamp,
created_at timestamp,
lockdown boolean DEFAULT FALSE
);
CREATE EXTENSION intarray;
-- #################################################################################################
-- adding distance table
DROP TABLE IF EXISTS distances;
CREATE TABLE distances (
id_1 INTEGER NOT NULL,
id_2 INTEGER NOT NULL,
distance INTEGER NOT NULL,
PRIMARY KEY (id_1, id_2)
);
CREATE UNIQUE INDEX ON distances
(LEAST(id_1, id_2), GREATEST(id_1, id_2));