1
|
--
|
2
|
-- PostgreSQL database dump
|
3
|
--
|
4
|
|
5
|
SET statement_timeout = 0;
|
6
|
SET lock_timeout = 0;
|
7
|
SET client_encoding = 'UTF8';
|
8
|
SET standard_conforming_strings = on;
|
9
|
SET check_function_bodies = false;
|
10
|
SET client_min_messages = warning;
|
11
|
|
12
|
--
|
13
|
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
|
14
|
--
|
15
|
|
16
|
--CREATE SCHEMA "TNRS";
|
17
|
|
18
|
|
19
|
--
|
20
|
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
|
21
|
--
|
22
|
|
23
|
COMMENT ON SCHEMA "TNRS" IS '
|
24
|
IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
|
25
|
on vegbiendev:
|
26
|
# back up existing TNRS schema (in case of an accidental incorrect change):
|
27
|
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
|
28
|
$ svn up
|
29
|
$ svn di
|
30
|
# make the changes shown in the diff
|
31
|
## to change column types:
|
32
|
SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[
|
33
|
(''col'', ''new_type'')
|
34
|
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
|
35
|
$ rm=1 inputs/.TNRS/schema.sql.run
|
36
|
# repeat until `svn di` shows no diff
|
37
|
# back up new TNRS schema:
|
38
|
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
|
39
|
';
|
40
|
|
41
|
|
42
|
SET search_path = "TNRS", pg_catalog;
|
43
|
|
44
|
--
|
45
|
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
46
|
--
|
47
|
|
48
|
CREATE FUNCTION batch__fill() RETURNS trigger
|
49
|
LANGUAGE plpgsql
|
50
|
AS $$
|
51
|
BEGIN
|
52
|
new.id_by_time = new.time_submitted;
|
53
|
new.id = COALESCE(new.id, new.id_by_time);
|
54
|
RETURN new;
|
55
|
END;
|
56
|
$$;
|
57
|
|
58
|
|
59
|
--
|
60
|
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
61
|
--
|
62
|
|
63
|
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
|
64
|
LANGUAGE sql STABLE STRICT
|
65
|
AS $_$
|
66
|
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
|
67
|
$_$;
|
68
|
|
69
|
|
70
|
--
|
71
|
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
72
|
--
|
73
|
|
74
|
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
|
75
|
LANGUAGE sql STABLE STRICT
|
76
|
AS $_$
|
77
|
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
|
78
|
$_$;
|
79
|
|
80
|
|
81
|
--
|
82
|
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
|
83
|
--
|
84
|
|
85
|
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
|
86
|
LANGUAGE sql IMMUTABLE
|
87
|
AS $_$
|
88
|
/* from http://wiki.vegpath.org/2013-11-14_conference_call#taxonomic-fields:
|
89
|
"taxonomic_status should be accepted instead of synonym when an accepted name is
|
90
|
available (this is not always the case when a name is marked as a synonym)" */
|
91
|
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
|
92
|
$_$;
|
93
|
|
94
|
|
95
|
--
|
96
|
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
|
97
|
--
|
98
|
|
99
|
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
|
100
|
LANGUAGE plpgsql
|
101
|
AS $$
|
102
|
BEGIN
|
103
|
PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
|
104
|
RETURN NULL;
|
105
|
END;
|
106
|
$$;
|
107
|
|
108
|
|
109
|
--
|
110
|
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
111
|
--
|
112
|
|
113
|
CREATE FUNCTION taxon_match__fill() RETURNS trigger
|
114
|
LANGUAGE plpgsql
|
115
|
AS $$
|
116
|
BEGIN
|
117
|
DECLARE
|
118
|
"Specific_epithet_is_plant" boolean :=
|
119
|
(CASE
|
120
|
WHEN new."*Infraspecific_epithet_matched" IS NOT NULL
|
121
|
OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
|
122
|
OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
|
123
|
THEN true
|
124
|
ELSE NULL -- ambiguous
|
125
|
END);
|
126
|
never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
|
127
|
-- author disambiguates
|
128
|
family_is_homonym boolean = NOT never_homonym
|
129
|
AND "TNRS".family_is_homonym(new."*Family_matched");
|
130
|
genus_is_homonym boolean = NOT never_homonym
|
131
|
AND "TNRS".genus_is_homonym(new."*Genus_matched");
|
132
|
BEGIN
|
133
|
/* exclude homonyms because these are not valid matches (TNRS provides a
|
134
|
name, but the name is not meaningful because it is not unambiguous) */
|
135
|
new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
|
136
|
AND COALESCE(CASE
|
137
|
WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
|
138
|
THEN true
|
139
|
ELSE -- consider genus
|
140
|
(CASE
|
141
|
WHEN new."*Genus_score" = 1 -- exact match
|
142
|
THEN
|
143
|
(CASE
|
144
|
WHEN NOT genus_is_homonym THEN true
|
145
|
ELSE "Specific_epithet_is_plant"
|
146
|
END)
|
147
|
WHEN new."*Genus_score" >= 0.85 -- fuzzy match
|
148
|
THEN "Specific_epithet_is_plant"
|
149
|
ELSE NULL -- ambiguous
|
150
|
END)
|
151
|
END, false);
|
152
|
END;
|
153
|
|
154
|
DECLARE
|
155
|
matched_taxon_name_with_author text = NULLIF(concat_ws(' '
|
156
|
, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
|
157
|
new."*Name_matched")
|
158
|
, NULLIF(new."*Name_matched", 'No suitable matches found.')
|
159
|
, new."*Name_matched_author"
|
160
|
), '');
|
161
|
accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
|
162
|
, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
|
163
|
new."*Accepted_name")
|
164
|
, new."*Accepted_name"
|
165
|
, new."*Accepted_name_author"
|
166
|
), '');
|
167
|
BEGIN
|
168
|
new.scrubbed_unique_taxon_name = COALESCE(
|
169
|
accepted_taxon_name_with_author, matched_taxon_name_with_author);
|
170
|
END;
|
171
|
|
172
|
RETURN new;
|
173
|
END;
|
174
|
$$;
|
175
|
|
176
|
|
177
|
--
|
178
|
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
|
179
|
--
|
180
|
|
181
|
COMMENT ON FUNCTION taxon_match__fill() IS '
|
182
|
IMPORTANT: when changing this function, you must regenerate the derived cols:
|
183
|
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
|
184
|
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
|
185
|
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
|
186
|
runtime: 1.5 min ("92633 ms")
|
187
|
';
|
188
|
|
189
|
|
190
|
--
|
191
|
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
|
192
|
--
|
193
|
|
194
|
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
|
195
|
LANGUAGE plpgsql
|
196
|
AS $$
|
197
|
BEGIN
|
198
|
new."__accepted_{genus,specific_epithet}" = (SELECT
|
199
|
regexp_split_to_array("*Accepted_name_species", ' '::text)
|
200
|
FROM (SELECT new.*) new);
|
201
|
|
202
|
new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT
|
203
|
"__accepted_{genus,specific_epithet}"[1]
|
204
|
FROM (SELECT new.*) new);
|
205
|
|
206
|
new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT
|
207
|
"__accepted_{genus,specific_epithet}"[2]
|
208
|
FROM (SELECT new.*) new);
|
209
|
|
210
|
new.__accepted_infraspecific_label = (SELECT
|
211
|
ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)
|
212
|
FROM (SELECT new.*) new);
|
213
|
|
214
|
new."__accepted_infraspecific_{rank,epithet}" = (SELECT
|
215
|
regexp_split_to_array(__accepted_infraspecific_label, ' '::text)
|
216
|
FROM (SELECT new.*) new);
|
217
|
|
218
|
new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT
|
219
|
"__accepted_infraspecific_{rank,epithet}"[1]
|
220
|
FROM (SELECT new.*) new);
|
221
|
|
222
|
new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT
|
223
|
"__accepted_infraspecific_{rank,epithet}"[2]
|
224
|
FROM (SELECT new.*) new);
|
225
|
|
226
|
RETURN new;
|
227
|
END;
|
228
|
$$;
|
229
|
|
230
|
|
231
|
--
|
232
|
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
|
233
|
--
|
234
|
|
235
|
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
|
236
|
autogenerated, do not edit
|
237
|
|
238
|
to regenerate:
|
239
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
240
|
';
|
241
|
|
242
|
|
243
|
--
|
244
|
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
245
|
--
|
246
|
|
247
|
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
|
248
|
LANGUAGE plpgsql
|
249
|
AS $$
|
250
|
BEGIN
|
251
|
IF new.match_num IS NULL THEN
|
252
|
new.match_num = "TNRS".taxon_match__match_num__next();
|
253
|
END IF;
|
254
|
RETURN new;
|
255
|
END;
|
256
|
$$;
|
257
|
|
258
|
|
259
|
--
|
260
|
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
|
261
|
--
|
262
|
|
263
|
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
|
264
|
LANGUAGE sql
|
265
|
AS $$
|
266
|
SELECT nextval('pg_temp.taxon_match__match_num__seq');
|
267
|
$$;
|
268
|
|
269
|
|
270
|
--
|
271
|
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
|
272
|
--
|
273
|
|
274
|
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
|
275
|
LANGUAGE plpgsql
|
276
|
AS $$
|
277
|
BEGIN
|
278
|
INSERT INTO "TNRS".taxon_match_input SELECT new.*;
|
279
|
RETURN NULL;
|
280
|
END;
|
281
|
$$;
|
282
|
|
283
|
|
284
|
--
|
285
|
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
286
|
--
|
287
|
|
288
|
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
|
289
|
LANGUAGE sql IMMUTABLE
|
290
|
AS $_$
|
291
|
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
|
292
|
$_$;
|
293
|
|
294
|
|
295
|
--
|
296
|
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
|
297
|
--
|
298
|
|
299
|
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
|
300
|
LANGUAGE sql IMMUTABLE
|
301
|
AS $$
|
302
|
SELECT ARRAY[
|
303
|
]::text[]
|
304
|
$$;
|
305
|
|
306
|
|
307
|
SET default_tablespace = '';
|
308
|
|
309
|
SET default_with_oids = false;
|
310
|
|
311
|
--
|
312
|
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
313
|
--
|
314
|
|
315
|
CREATE TABLE taxon_match (
|
316
|
batch text DEFAULT now() NOT NULL,
|
317
|
match_num integer NOT NULL,
|
318
|
"*Name_number" integer NOT NULL,
|
319
|
"*Name_submitted" text NOT NULL,
|
320
|
"*Overall_score" double precision,
|
321
|
"*Name_matched" text,
|
322
|
"*Name_matched_rank" text,
|
323
|
"*Name_score" double precision,
|
324
|
"*Name_matched_author" text,
|
325
|
"*Name_matched_url" text,
|
326
|
"*Author_matched" text,
|
327
|
"*Author_score" double precision,
|
328
|
"*Family_matched" text,
|
329
|
"*Family_score" double precision,
|
330
|
"*Name_matched_accepted_family" text,
|
331
|
"*Genus_matched" text,
|
332
|
"*Genus_score" double precision,
|
333
|
"*Specific_epithet_matched" text,
|
334
|
"*Specific_epithet_score" double precision,
|
335
|
"*Infraspecific_rank" text,
|
336
|
"*Infraspecific_epithet_matched" text,
|
337
|
"*Infraspecific_epithet_score" double precision,
|
338
|
"*Infraspecific_rank_2" text,
|
339
|
"*Infraspecific_epithet_2_matched" text,
|
340
|
"*Infraspecific_epithet_2_score" double precision,
|
341
|
"*Annotations" text,
|
342
|
"*Unmatched_terms" text,
|
343
|
"*Taxonomic_status" text,
|
344
|
"*Accepted_name" text,
|
345
|
"*Accepted_name_author" text,
|
346
|
"*Accepted_name_rank" text,
|
347
|
"*Accepted_name_url" text,
|
348
|
"*Accepted_name_species" text,
|
349
|
"*Accepted_name_family" text,
|
350
|
"*Selected" text,
|
351
|
"*Source" text,
|
352
|
"*Warnings" text,
|
353
|
"*Accepted_name_lsid" text,
|
354
|
is_valid_match boolean NOT NULL,
|
355
|
scrubbed_unique_taxon_name text,
|
356
|
"__accepted_{genus,specific_epithet}" text[],
|
357
|
"[accepted_]genus__@DwC__@vegpath.org" text,
|
358
|
"[accepted_]specificEpithet__@DwC__@vegpath.org" text,
|
359
|
__accepted_infraspecific_label text,
|
360
|
"__accepted_infraspecific_{rank,epithet}" text[],
|
361
|
"[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
|
362
|
"[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
|
363
|
CONSTRAINT "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[1]))),
|
364
|
CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[1]))),
|
365
|
CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
|
366
|
CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[2]))),
|
367
|
CONSTRAINT __accepted_infraspecific_label CHECK ((NOT (__accepted_infraspecific_label IS DISTINCT FROM ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)))),
|
368
|
CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM regexp_split_to_array(__accepted_infraspecific_label, ' '::text)))),
|
369
|
CONSTRAINT "__accepted_{genus,specific_epithet}" CHECK ((NOT ("__accepted_{genus,specific_epithet}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name_species", ' '::text))))
|
370
|
);
|
371
|
|
372
|
|
373
|
--
|
374
|
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
|
375
|
--
|
376
|
|
377
|
COMMENT ON TABLE taxon_match IS '
|
378
|
whenever columns are renamed:
|
379
|
SELECT util.derived_cols_sync(''"TNRS".taxon_match'');
|
380
|
|
381
|
to remove columns or add columns at the end:
|
382
|
$ rm=1 inputs/.TNRS/data.sql.run
|
383
|
$ make schemas/remake
|
384
|
|
385
|
to add columns in the middle:
|
386
|
make the changes in inputs/.TNRS/schema.sql
|
387
|
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
|
388
|
$ make schemas/remake
|
389
|
|
390
|
to populate a new column:
|
391
|
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
|
392
|
UPDATE "TNRS".taxon_match SET "col" = value;
|
393
|
-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
|
394
|
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
|
395
|
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
|
396
|
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
|
397
|
|
398
|
to add a constraint: runtime: 3 min ("173620 ms")
|
399
|
';
|
400
|
|
401
|
|
402
|
--
|
403
|
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
404
|
--
|
405
|
|
406
|
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
|
407
|
derived column; = regexp_split_to_array("*Accepted_name_species", '' ''::text)
|
408
|
|
409
|
to modify:
|
410
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet}'')::util.col, $$regexp_split_to_array("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
|
411
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
412
|
';
|
413
|
|
414
|
|
415
|
--
|
416
|
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
417
|
--
|
418
|
|
419
|
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
|
420
|
derived column; = "__accepted_{genus,specific_epithet}"[1]
|
421
|
|
422
|
to modify:
|
423
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[1]$$)::util.derived_col_def);
|
424
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
425
|
';
|
426
|
|
427
|
|
428
|
--
|
429
|
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
430
|
--
|
431
|
|
432
|
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
|
433
|
derived column; = "__accepted_{genus,specific_epithet}"[2]
|
434
|
|
435
|
to modify:
|
436
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[2]$$)::util.derived_col_def);
|
437
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
438
|
';
|
439
|
|
440
|
|
441
|
--
|
442
|
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
|
443
|
--
|
444
|
|
445
|
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
|
446
|
derived column; = ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''), '' '')
|
447
|
|
448
|
to modify:
|
449
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''), '' '')$$)::util.derived_col_def);
|
450
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
451
|
';
|
452
|
|
453
|
|
454
|
--
|
455
|
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
456
|
--
|
457
|
|
458
|
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
|
459
|
derived column; = regexp_split_to_array("__accepted_infraspecific_label", '' ''::text)
|
460
|
|
461
|
to modify:
|
462
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$regexp_split_to_array("__accepted_infraspecific_label", '' ''::text)$$)::util.derived_col_def);
|
463
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
464
|
';
|
465
|
|
466
|
|
467
|
--
|
468
|
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
469
|
--
|
470
|
|
471
|
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
|
472
|
derived column; = "__accepted_infraspecific_{rank,epithet}"[1]
|
473
|
|
474
|
to modify:
|
475
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[1]$$)::util.derived_col_def);
|
476
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
477
|
';
|
478
|
|
479
|
|
480
|
--
|
481
|
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
482
|
--
|
483
|
|
484
|
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
|
485
|
derived column; = "__accepted_infraspecific_{rank,epithet}"[2]
|
486
|
|
487
|
to modify:
|
488
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
|
489
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
490
|
';
|
491
|
|
492
|
|
493
|
--
|
494
|
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
|
495
|
--
|
496
|
|
497
|
CREATE VIEW taxon_best_match AS
|
498
|
SELECT taxon_match.batch,
|
499
|
taxon_match.match_num,
|
500
|
taxon_match."*Name_number",
|
501
|
taxon_match."*Name_submitted",
|
502
|
taxon_match."*Overall_score",
|
503
|
taxon_match."*Name_matched",
|
504
|
taxon_match."*Name_matched_rank",
|
505
|
taxon_match."*Name_score",
|
506
|
taxon_match."*Name_matched_author",
|
507
|
taxon_match."*Name_matched_url",
|
508
|
taxon_match."*Author_matched",
|
509
|
taxon_match."*Author_score",
|
510
|
taxon_match."*Family_matched",
|
511
|
taxon_match."*Family_score",
|
512
|
taxon_match."*Name_matched_accepted_family",
|
513
|
taxon_match."*Genus_matched",
|
514
|
taxon_match."*Genus_score",
|
515
|
taxon_match."*Specific_epithet_matched",
|
516
|
taxon_match."*Specific_epithet_score",
|
517
|
taxon_match."*Infraspecific_rank",
|
518
|
taxon_match."*Infraspecific_epithet_matched",
|
519
|
taxon_match."*Infraspecific_epithet_score",
|
520
|
taxon_match."*Infraspecific_rank_2",
|
521
|
taxon_match."*Infraspecific_epithet_2_matched",
|
522
|
taxon_match."*Infraspecific_epithet_2_score",
|
523
|
taxon_match."*Annotations",
|
524
|
taxon_match."*Unmatched_terms",
|
525
|
taxon_match."*Taxonomic_status",
|
526
|
taxon_match."*Accepted_name",
|
527
|
taxon_match."*Accepted_name_author",
|
528
|
taxon_match."*Accepted_name_rank",
|
529
|
taxon_match."*Accepted_name_url",
|
530
|
taxon_match."*Accepted_name_species",
|
531
|
taxon_match."*Accepted_name_family",
|
532
|
taxon_match."*Selected",
|
533
|
taxon_match."*Source",
|
534
|
taxon_match."*Warnings",
|
535
|
taxon_match."*Accepted_name_lsid",
|
536
|
taxon_match.is_valid_match,
|
537
|
taxon_match.scrubbed_unique_taxon_name
|
538
|
FROM taxon_match
|
539
|
WHERE (taxon_match."*Selected" = 'true'::text);
|
540
|
|
541
|
|
542
|
--
|
543
|
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
|
544
|
--
|
545
|
|
546
|
COMMENT ON VIEW taxon_best_match IS '
|
547
|
to modify:
|
548
|
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
|
549
|
SELECT __
|
550
|
$$);
|
551
|
';
|
552
|
|
553
|
|
554
|
--
|
555
|
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
556
|
--
|
557
|
|
558
|
CREATE VIEW "MatchedTaxon" AS
|
559
|
SELECT taxon_best_match.batch,
|
560
|
taxon_best_match.match_num,
|
561
|
taxon_best_match."*Name_number",
|
562
|
taxon_best_match."*Name_submitted",
|
563
|
taxon_best_match."*Overall_score",
|
564
|
taxon_best_match."*Name_matched",
|
565
|
taxon_best_match."*Name_matched_rank",
|
566
|
taxon_best_match."*Name_score",
|
567
|
taxon_best_match."*Name_matched_author",
|
568
|
taxon_best_match."*Name_matched_url",
|
569
|
taxon_best_match."*Author_matched",
|
570
|
taxon_best_match."*Author_score",
|
571
|
taxon_best_match."*Family_matched",
|
572
|
taxon_best_match."*Family_score",
|
573
|
taxon_best_match."*Name_matched_accepted_family",
|
574
|
taxon_best_match."*Genus_matched",
|
575
|
taxon_best_match."*Genus_score",
|
576
|
taxon_best_match."*Specific_epithet_matched",
|
577
|
taxon_best_match."*Specific_epithet_score",
|
578
|
taxon_best_match."*Infraspecific_rank",
|
579
|
taxon_best_match."*Infraspecific_epithet_matched",
|
580
|
taxon_best_match."*Infraspecific_epithet_score",
|
581
|
taxon_best_match."*Infraspecific_rank_2",
|
582
|
taxon_best_match."*Infraspecific_epithet_2_matched",
|
583
|
taxon_best_match."*Infraspecific_epithet_2_score",
|
584
|
taxon_best_match."*Annotations",
|
585
|
taxon_best_match."*Unmatched_terms",
|
586
|
taxon_best_match."*Taxonomic_status",
|
587
|
taxon_best_match."*Accepted_name",
|
588
|
taxon_best_match."*Accepted_name_author",
|
589
|
taxon_best_match."*Accepted_name_rank",
|
590
|
taxon_best_match."*Accepted_name_url",
|
591
|
taxon_best_match."*Accepted_name_species",
|
592
|
taxon_best_match."*Accepted_name_family",
|
593
|
taxon_best_match."*Selected",
|
594
|
taxon_best_match."*Source",
|
595
|
taxon_best_match."*Warnings",
|
596
|
taxon_best_match."*Accepted_name_lsid",
|
597
|
taxon_best_match.is_valid_match,
|
598
|
taxon_best_match.scrubbed_unique_taxon_name,
|
599
|
map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
|
600
|
CASE
|
601
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
|
602
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
|
603
|
ELSE taxon_best_match."*Accepted_name_species"
|
604
|
END AS accepted_morphospecies_binomial
|
605
|
FROM taxon_best_match;
|
606
|
|
607
|
|
608
|
--
|
609
|
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
610
|
--
|
611
|
|
612
|
COMMENT ON VIEW "MatchedTaxon" IS '
|
613
|
to modify:
|
614
|
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
|
615
|
SELECT __
|
616
|
$$);
|
617
|
';
|
618
|
|
619
|
|
620
|
--
|
621
|
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
622
|
--
|
623
|
|
624
|
CREATE VIEW "ValidMatchedTaxon" AS
|
625
|
SELECT "MatchedTaxon".batch,
|
626
|
"MatchedTaxon".match_num,
|
627
|
"MatchedTaxon"."*Name_number",
|
628
|
"MatchedTaxon"."*Name_submitted",
|
629
|
"MatchedTaxon"."*Overall_score",
|
630
|
"MatchedTaxon"."*Name_matched",
|
631
|
"MatchedTaxon"."*Name_matched_rank",
|
632
|
"MatchedTaxon"."*Name_score",
|
633
|
"MatchedTaxon"."*Name_matched_author",
|
634
|
"MatchedTaxon"."*Name_matched_url",
|
635
|
"MatchedTaxon"."*Author_matched",
|
636
|
"MatchedTaxon"."*Author_score",
|
637
|
"MatchedTaxon"."*Family_matched",
|
638
|
"MatchedTaxon"."*Family_score",
|
639
|
"MatchedTaxon"."*Name_matched_accepted_family",
|
640
|
"MatchedTaxon"."*Genus_matched",
|
641
|
"MatchedTaxon"."*Genus_score",
|
642
|
"MatchedTaxon"."*Specific_epithet_matched",
|
643
|
"MatchedTaxon"."*Specific_epithet_score",
|
644
|
"MatchedTaxon"."*Infraspecific_rank",
|
645
|
"MatchedTaxon"."*Infraspecific_epithet_matched",
|
646
|
"MatchedTaxon"."*Infraspecific_epithet_score",
|
647
|
"MatchedTaxon"."*Infraspecific_rank_2",
|
648
|
"MatchedTaxon"."*Infraspecific_epithet_2_matched",
|
649
|
"MatchedTaxon"."*Infraspecific_epithet_2_score",
|
650
|
"MatchedTaxon"."*Annotations",
|
651
|
"MatchedTaxon"."*Unmatched_terms",
|
652
|
"MatchedTaxon"."*Taxonomic_status",
|
653
|
"MatchedTaxon"."*Accepted_name",
|
654
|
"MatchedTaxon"."*Accepted_name_author",
|
655
|
"MatchedTaxon"."*Accepted_name_rank",
|
656
|
"MatchedTaxon"."*Accepted_name_url",
|
657
|
"MatchedTaxon"."*Accepted_name_species",
|
658
|
"MatchedTaxon"."*Accepted_name_family",
|
659
|
"MatchedTaxon"."*Selected",
|
660
|
"MatchedTaxon"."*Source",
|
661
|
"MatchedTaxon"."*Warnings",
|
662
|
"MatchedTaxon"."*Accepted_name_lsid",
|
663
|
"MatchedTaxon".is_valid_match,
|
664
|
"MatchedTaxon".scrubbed_unique_taxon_name,
|
665
|
"MatchedTaxon"."taxonomicStatus",
|
666
|
"MatchedTaxon".accepted_morphospecies_binomial
|
667
|
FROM "MatchedTaxon"
|
668
|
WHERE "MatchedTaxon".is_valid_match;
|
669
|
|
670
|
|
671
|
--
|
672
|
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
673
|
--
|
674
|
|
675
|
COMMENT ON VIEW "ValidMatchedTaxon" IS '
|
676
|
to update, use * as the column list
|
677
|
';
|
678
|
|
679
|
|
680
|
--
|
681
|
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
682
|
--
|
683
|
|
684
|
CREATE TABLE batch (
|
685
|
id text NOT NULL,
|
686
|
id_by_time text,
|
687
|
time_submitted timestamp with time zone DEFAULT now(),
|
688
|
client_version text
|
689
|
);
|
690
|
|
691
|
|
692
|
--
|
693
|
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
694
|
--
|
695
|
|
696
|
CREATE TABLE batch_download_settings (
|
697
|
id text NOT NULL,
|
698
|
"E-mail" text,
|
699
|
"Id" text,
|
700
|
"Job type" text,
|
701
|
"Contains Id" boolean,
|
702
|
"Start time" text,
|
703
|
"Finish time" text,
|
704
|
"TNRS version" text,
|
705
|
"Sources selected" text,
|
706
|
"Match threshold" double precision,
|
707
|
"Classification" text,
|
708
|
"Allow partial matches?" boolean,
|
709
|
"Sort by source" boolean,
|
710
|
"Constrain by higher taxonomy" boolean
|
711
|
);
|
712
|
|
713
|
|
714
|
--
|
715
|
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
|
716
|
--
|
717
|
|
718
|
COMMENT ON TABLE batch_download_settings IS '
|
719
|
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
|
720
|
';
|
721
|
|
722
|
|
723
|
--
|
724
|
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
725
|
--
|
726
|
|
727
|
CREATE TABLE client_version (
|
728
|
id text NOT NULL,
|
729
|
global_rev integer NOT NULL,
|
730
|
"/lib/tnrs.py rev" integer,
|
731
|
"/bin/tnrs_db rev" integer
|
732
|
);
|
733
|
|
734
|
|
735
|
--
|
736
|
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
|
737
|
--
|
738
|
|
739
|
COMMENT ON TABLE client_version IS '
|
740
|
contains svn revisions
|
741
|
';
|
742
|
|
743
|
|
744
|
--
|
745
|
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
|
746
|
--
|
747
|
|
748
|
COMMENT ON COLUMN client_version.global_rev IS '
|
749
|
from `svn info .` > Last Changed Rev
|
750
|
';
|
751
|
|
752
|
|
753
|
--
|
754
|
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
755
|
--
|
756
|
|
757
|
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
|
758
|
from `svn info lib/tnrs.py` > Last Changed Rev
|
759
|
';
|
760
|
|
761
|
|
762
|
--
|
763
|
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
764
|
--
|
765
|
|
766
|
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
|
767
|
from `svn info bin/tnrs_db` > Last Changed Rev
|
768
|
';
|
769
|
|
770
|
|
771
|
--
|
772
|
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
|
773
|
--
|
774
|
|
775
|
CREATE VIEW taxon_match_input AS
|
776
|
SELECT taxon_match."*Name_number" AS "Name_number",
|
777
|
taxon_match."*Name_submitted" AS "Name_submitted",
|
778
|
taxon_match."*Overall_score" AS "Overall_score",
|
779
|
taxon_match."*Name_matched" AS "Name_matched",
|
780
|
taxon_match."*Name_matched_rank" AS "Name_matched_rank",
|
781
|
taxon_match."*Name_score" AS "Name_score",
|
782
|
taxon_match."*Name_matched_author" AS "Name_matched_author",
|
783
|
taxon_match."*Name_matched_url" AS "Name_matched_url",
|
784
|
taxon_match."*Author_matched" AS "Author_matched",
|
785
|
taxon_match."*Author_score" AS "Author_score",
|
786
|
taxon_match."*Family_matched" AS "Family_matched",
|
787
|
taxon_match."*Family_score" AS "Family_score",
|
788
|
taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
|
789
|
taxon_match."*Genus_matched" AS "Genus_matched",
|
790
|
taxon_match."*Genus_score" AS "Genus_score",
|
791
|
taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
|
792
|
taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
|
793
|
taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
|
794
|
taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
|
795
|
taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
|
796
|
taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
|
797
|
taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
|
798
|
taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
|
799
|
taxon_match."*Annotations" AS "Annotations",
|
800
|
taxon_match."*Unmatched_terms" AS "Unmatched_terms",
|
801
|
taxon_match."*Taxonomic_status" AS "Taxonomic_status",
|
802
|
taxon_match."*Accepted_name" AS "Accepted_name",
|
803
|
taxon_match."*Accepted_name_author" AS "Accepted_name_author",
|
804
|
taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
|
805
|
taxon_match."*Accepted_name_url" AS "Accepted_name_url",
|
806
|
taxon_match."*Accepted_name_species" AS "Accepted_name_species",
|
807
|
taxon_match."*Accepted_name_family" AS "Accepted_name_family",
|
808
|
taxon_match."*Selected" AS "Selected",
|
809
|
taxon_match."*Source" AS "Source",
|
810
|
taxon_match."*Warnings" AS "Warnings",
|
811
|
taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
|
812
|
FROM taxon_match;
|
813
|
|
814
|
|
815
|
--
|
816
|
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
817
|
--
|
818
|
|
819
|
CREATE TABLE taxon_match_input__copy_to (
|
820
|
"Name_number" integer,
|
821
|
"Name_submitted" text,
|
822
|
"Overall_score" double precision,
|
823
|
"Name_matched" text,
|
824
|
"Name_matched_rank" text,
|
825
|
"Name_score" double precision,
|
826
|
"Name_matched_author" text,
|
827
|
"Name_matched_url" text,
|
828
|
"Author_matched" text,
|
829
|
"Author_score" double precision,
|
830
|
"Family_matched" text,
|
831
|
"Family_score" double precision,
|
832
|
"Name_matched_accepted_family" text,
|
833
|
"Genus_matched" text,
|
834
|
"Genus_score" double precision,
|
835
|
"Specific_epithet_matched" text,
|
836
|
"Specific_epithet_score" double precision,
|
837
|
"Infraspecific_rank" text,
|
838
|
"Infraspecific_epithet_matched" text,
|
839
|
"Infraspecific_epithet_score" double precision,
|
840
|
"Infraspecific_rank_2" text,
|
841
|
"Infraspecific_epithet_2_matched" text,
|
842
|
"Infraspecific_epithet_2_score" double precision,
|
843
|
"Annotations" text,
|
844
|
"Unmatched_terms" text,
|
845
|
"Taxonomic_status" text,
|
846
|
"Accepted_name" text,
|
847
|
"Accepted_name_author" text,
|
848
|
"Accepted_name_rank" text,
|
849
|
"Accepted_name_url" text,
|
850
|
"Accepted_name_species" text,
|
851
|
"Accepted_name_family" text,
|
852
|
"Selected" text,
|
853
|
"Source" text,
|
854
|
"Warnings" text,
|
855
|
"Accepted_name_lsid" text
|
856
|
);
|
857
|
|
858
|
|
859
|
--
|
860
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
|
861
|
--
|
862
|
|
863
|
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
|
864
|
SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
|
865
|
taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
|
866
|
COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
|
867
|
taxon_match."*Genus_matched" AS scrubbed_genus,
|
868
|
taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
|
869
|
taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
|
870
|
taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
|
871
|
taxon_match."*Name_matched_author" AS scrubbed_author,
|
872
|
taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
|
873
|
(taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
|
874
|
FROM taxon_match;
|
875
|
|
876
|
|
877
|
--
|
878
|
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
|
879
|
--
|
880
|
|
881
|
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
|
882
|
to modify:
|
883
|
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
|
884
|
SELECT __
|
885
|
$$);
|
886
|
|
887
|
scrubbed_family: Name_matched_accepted_family was missing from the TNRS results at one point, so Family_matched is used as a workaround to populate this. the workaround is for *accepted names only*, as no opinion names do not have an Accepted_name_family to prepend to the scrubbed name to parse.
|
888
|
';
|
889
|
|
890
|
|
891
|
--
|
892
|
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
|
893
|
--
|
894
|
|
895
|
CREATE VIEW taxon_scrub AS
|
896
|
SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
|
897
|
"ValidMatchedTaxon".batch,
|
898
|
"ValidMatchedTaxon".match_num,
|
899
|
"ValidMatchedTaxon"."*Name_number",
|
900
|
"ValidMatchedTaxon"."*Name_submitted",
|
901
|
"ValidMatchedTaxon"."*Overall_score",
|
902
|
"ValidMatchedTaxon"."*Name_matched",
|
903
|
"ValidMatchedTaxon"."*Name_matched_rank",
|
904
|
"ValidMatchedTaxon"."*Name_score",
|
905
|
"ValidMatchedTaxon"."*Name_matched_author",
|
906
|
"ValidMatchedTaxon"."*Name_matched_url",
|
907
|
"ValidMatchedTaxon"."*Author_matched",
|
908
|
"ValidMatchedTaxon"."*Author_score",
|
909
|
"ValidMatchedTaxon"."*Family_matched",
|
910
|
"ValidMatchedTaxon"."*Family_score",
|
911
|
"ValidMatchedTaxon"."*Name_matched_accepted_family",
|
912
|
"ValidMatchedTaxon"."*Genus_matched",
|
913
|
"ValidMatchedTaxon"."*Genus_score",
|
914
|
"ValidMatchedTaxon"."*Specific_epithet_matched",
|
915
|
"ValidMatchedTaxon"."*Specific_epithet_score",
|
916
|
"ValidMatchedTaxon"."*Infraspecific_rank",
|
917
|
"ValidMatchedTaxon"."*Infraspecific_epithet_matched",
|
918
|
"ValidMatchedTaxon"."*Infraspecific_epithet_score",
|
919
|
"ValidMatchedTaxon"."*Infraspecific_rank_2",
|
920
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
|
921
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
|
922
|
"ValidMatchedTaxon"."*Annotations",
|
923
|
"ValidMatchedTaxon"."*Unmatched_terms",
|
924
|
"ValidMatchedTaxon"."*Taxonomic_status",
|
925
|
"ValidMatchedTaxon"."*Accepted_name",
|
926
|
"ValidMatchedTaxon"."*Accepted_name_author",
|
927
|
"ValidMatchedTaxon"."*Accepted_name_rank",
|
928
|
"ValidMatchedTaxon"."*Accepted_name_url",
|
929
|
"ValidMatchedTaxon"."*Accepted_name_species",
|
930
|
"ValidMatchedTaxon"."*Accepted_name_family",
|
931
|
"ValidMatchedTaxon"."*Selected",
|
932
|
"ValidMatchedTaxon"."*Source",
|
933
|
"ValidMatchedTaxon"."*Warnings",
|
934
|
"ValidMatchedTaxon"."*Accepted_name_lsid",
|
935
|
"ValidMatchedTaxon".is_valid_match,
|
936
|
"ValidMatchedTaxon"."taxonomicStatus",
|
937
|
"ValidMatchedTaxon".accepted_morphospecies_binomial,
|
938
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
|
939
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
|
940
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
|
941
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
|
942
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
|
943
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
|
944
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
|
945
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
|
946
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
|
947
|
CASE
|
948
|
WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'family'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, "ValidMatchedTaxon"."*Unmatched_terms")
|
949
|
WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'genus'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, "ValidMatchedTaxon"."*Unmatched_terms")
|
950
|
ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
|
951
|
END AS scrubbed_morphospecies_binomial
|
952
|
FROM ("ValidMatchedTaxon"
|
953
|
LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
|
954
|
|
955
|
|
956
|
--
|
957
|
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
|
958
|
--
|
959
|
|
960
|
COMMENT ON VIEW taxon_scrub IS '
|
961
|
to modify:
|
962
|
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
|
963
|
SELECT __
|
964
|
$$);
|
965
|
';
|
966
|
|
967
|
|
968
|
--
|
969
|
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
970
|
--
|
971
|
|
972
|
ALTER TABLE ONLY batch_download_settings
|
973
|
ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
|
974
|
|
975
|
|
976
|
--
|
977
|
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
978
|
--
|
979
|
|
980
|
ALTER TABLE ONLY batch
|
981
|
ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
|
982
|
|
983
|
|
984
|
--
|
985
|
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
986
|
--
|
987
|
|
988
|
ALTER TABLE ONLY batch
|
989
|
ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
|
990
|
|
991
|
|
992
|
--
|
993
|
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
994
|
--
|
995
|
|
996
|
ALTER TABLE ONLY client_version
|
997
|
ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
|
998
|
|
999
|
|
1000
|
--
|
1001
|
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1002
|
--
|
1003
|
|
1004
|
ALTER TABLE ONLY taxon_match
|
1005
|
ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
|
1006
|
|
1007
|
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
|
1008
|
|
1009
|
|
1010
|
--
|
1011
|
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1012
|
--
|
1013
|
|
1014
|
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
|
1015
|
|
1016
|
|
1017
|
--
|
1018
|
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1019
|
--
|
1020
|
|
1021
|
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
|
1022
|
|
1023
|
|
1024
|
--
|
1025
|
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1026
|
--
|
1027
|
|
1028
|
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
|
1029
|
|
1030
|
|
1031
|
--
|
1032
|
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1033
|
--
|
1034
|
|
1035
|
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
|
1036
|
|
1037
|
|
1038
|
--
|
1039
|
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1040
|
--
|
1041
|
|
1042
|
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
|
1043
|
|
1044
|
|
1045
|
--
|
1046
|
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
|
1047
|
--
|
1048
|
|
1049
|
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
|
1050
|
|
1051
|
|
1052
|
--
|
1053
|
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1054
|
--
|
1055
|
|
1056
|
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
|
1057
|
|
1058
|
|
1059
|
--
|
1060
|
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
|
1061
|
--
|
1062
|
|
1063
|
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
|
1064
|
|
1065
|
|
1066
|
--
|
1067
|
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1068
|
--
|
1069
|
|
1070
|
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
|
1071
|
|
1072
|
|
1073
|
--
|
1074
|
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
|
1075
|
--
|
1076
|
|
1077
|
CREATE TRIGGER taxon_match_input__copy_to__insert BEFORE INSERT ON taxon_match_input__copy_to FOR EACH ROW EXECUTE PROCEDURE taxon_match_input__copy_to__insert();
|
1078
|
|
1079
|
|
1080
|
--
|
1081
|
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1082
|
--
|
1083
|
|
1084
|
ALTER TABLE ONLY batch
|
1085
|
ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1086
|
|
1087
|
|
1088
|
--
|
1089
|
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1090
|
--
|
1091
|
|
1092
|
ALTER TABLE ONLY batch_download_settings
|
1093
|
ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1094
|
|
1095
|
|
1096
|
--
|
1097
|
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1098
|
--
|
1099
|
|
1100
|
ALTER TABLE ONLY taxon_match
|
1101
|
ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1102
|
|
1103
|
|
1104
|
--
|
1105
|
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
|
1106
|
--
|
1107
|
|
1108
|
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
|
1109
|
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
|
1110
|
GRANT ALL ON SCHEMA "TNRS" TO bien;
|
1111
|
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
|
1112
|
|
1113
|
|
1114
|
--
|
1115
|
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
|
1116
|
--
|
1117
|
|
1118
|
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
|
1119
|
REVOKE ALL ON TABLE taxon_match FROM bien;
|
1120
|
GRANT ALL ON TABLE taxon_match TO bien;
|
1121
|
GRANT SELECT ON TABLE taxon_match TO bien_read;
|
1122
|
|
1123
|
|
1124
|
--
|
1125
|
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
|
1126
|
--
|
1127
|
|
1128
|
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
|
1129
|
REVOKE ALL ON TABLE taxon_best_match FROM bien;
|
1130
|
GRANT ALL ON TABLE taxon_best_match TO bien;
|
1131
|
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
|
1132
|
|
1133
|
|
1134
|
--
|
1135
|
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1136
|
--
|
1137
|
|
1138
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
|
1139
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
|
1140
|
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
|
1141
|
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
|
1142
|
|
1143
|
|
1144
|
--
|
1145
|
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1146
|
--
|
1147
|
|
1148
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
|
1149
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
|
1150
|
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
|
1151
|
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
|
1152
|
|
1153
|
|
1154
|
--
|
1155
|
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
|
1156
|
--
|
1157
|
|
1158
|
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
|
1159
|
REVOKE ALL ON TABLE taxon_match_input FROM bien;
|
1160
|
GRANT ALL ON TABLE taxon_match_input TO bien;
|
1161
|
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
|
1162
|
|
1163
|
|
1164
|
--
|
1165
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
|
1166
|
--
|
1167
|
|
1168
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
|
1169
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
|
1170
|
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
|
1171
|
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
|
1172
|
|
1173
|
|
1174
|
--
|
1175
|
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
|
1176
|
--
|
1177
|
|
1178
|
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
|
1179
|
REVOKE ALL ON TABLE taxon_scrub FROM bien;
|
1180
|
GRANT ALL ON TABLE taxon_scrub TO bien;
|
1181
|
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
|
1182
|
|
1183
|
|
1184
|
--
|
1185
|
-- PostgreSQL database dump complete
|
1186
|
--
|
1187
|
|