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
|
-- clear derived cols so old values won't be used in calculations
|
199
|
new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL;
|
200
|
new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
|
201
|
new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
|
202
|
new.matched_has_accepted = NULL;
|
203
|
new."Accepted_family__@TNRS__@vegpath.org" = NULL;
|
204
|
new."__accepted_{genus,specific_epithet}" = NULL;
|
205
|
new."[accepted_]genus__@DwC__@vegpath.org" = NULL;
|
206
|
new."[accepted_]specificEpithet__@DwC__@vegpath.org" = NULL;
|
207
|
new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
|
208
|
new.__accepted_infraspecific_label = NULL;
|
209
|
new."__accepted_infraspecific_{rank,epithet}" = NULL;
|
210
|
new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
|
211
|
new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
|
212
|
new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
|
213
|
new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = NULL;
|
214
|
new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
|
215
|
new."[scrubbed_]genus__@DwC__@vegpath.org" = NULL;
|
216
|
new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = NULL;
|
217
|
new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
|
218
|
new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
|
219
|
new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
|
220
|
new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
|
221
|
new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
|
222
|
new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
|
223
|
|
224
|
-- populate derived cols
|
225
|
new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new);
|
226
|
new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new);
|
227
|
new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new);
|
228
|
new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new);
|
229
|
new."Accepted_family__@TNRS__@vegpath.org" = (SELECT COALESCE("*Accepted_name_family",
|
230
|
CASE
|
231
|
WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
|
232
|
ELSE NULL::text
|
233
|
END) FROM (SELECT new.*) new);
|
234
|
new."__accepted_{genus,specific_epithet}" = (SELECT regexp_split_to_array("*Accepted_name_species", ' '::text) FROM (SELECT new.*) new);
|
235
|
new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet}"[1] FROM (SELECT new.*) new);
|
236
|
new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet}"[2] FROM (SELECT new.*) new);
|
237
|
new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
|
238
|
WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
239
|
WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
240
|
ELSE "*Accepted_name_species"
|
241
|
END FROM (SELECT new.*) new);
|
242
|
new.__accepted_infraspecific_label = (SELECT ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text) FROM (SELECT new.*) new);
|
243
|
new."__accepted_infraspecific_{rank,epithet}" = (SELECT regexp_split_to_array(__accepted_infraspecific_label, ' '::text) FROM (SELECT new.*) new);
|
244
|
new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[1] FROM (SELECT new.*) new);
|
245
|
new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[2] FROM (SELECT new.*) new);
|
246
|
new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text) FROM (SELECT new.*) new);
|
247
|
new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT CASE
|
248
|
WHEN matched_has_accepted THEN "*Accepted_name_rank"
|
249
|
ELSE "*Name_matched_rank"
|
250
|
END FROM (SELECT new.*) new);
|
251
|
new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
|
252
|
WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
|
253
|
ELSE "*Name_matched_accepted_family"
|
254
|
END FROM (SELECT new.*) new);
|
255
|
new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT CASE
|
256
|
WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
|
257
|
ELSE "*Genus_matched"
|
258
|
END FROM (SELECT new.*) new);
|
259
|
new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT CASE
|
260
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
261
|
ELSE "*Specific_epithet_matched"
|
262
|
END FROM (SELECT new.*) new);
|
263
|
new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
|
264
|
WHEN matched_has_accepted THEN "*Accepted_name_species"
|
265
|
ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
|
266
|
END FROM (SELECT new.*) new);
|
267
|
new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT CASE
|
268
|
WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
|
269
|
ELSE "*Infraspecific_rank"
|
270
|
END FROM (SELECT new.*) new);
|
271
|
new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT CASE
|
272
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
273
|
ELSE "*Infraspecific_epithet_matched"
|
274
|
END FROM (SELECT new.*) new);
|
275
|
new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
|
276
|
WHEN matched_has_accepted THEN "*Accepted_name"
|
277
|
ELSE "*Name_matched"
|
278
|
END FROM (SELECT new.*) new);
|
279
|
new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
|
280
|
WHEN matched_has_accepted THEN "*Accepted_name_author"
|
281
|
ELSE "*Name_matched_author"
|
282
|
END FROM (SELECT new.*) new);
|
283
|
new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT CASE
|
284
|
WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
|
285
|
ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
|
286
|
END FROM (SELECT new.*) new);
|
287
|
|
288
|
RETURN new;
|
289
|
END;
|
290
|
$$;
|
291
|
|
292
|
|
293
|
--
|
294
|
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
|
295
|
--
|
296
|
|
297
|
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
|
298
|
autogenerated, do not edit
|
299
|
|
300
|
to regenerate:
|
301
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
302
|
';
|
303
|
|
304
|
|
305
|
--
|
306
|
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
307
|
--
|
308
|
|
309
|
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
|
310
|
LANGUAGE plpgsql
|
311
|
AS $$
|
312
|
BEGIN
|
313
|
IF new.match_num IS NULL THEN
|
314
|
new.match_num = "TNRS".taxon_match__match_num__next();
|
315
|
END IF;
|
316
|
RETURN new;
|
317
|
END;
|
318
|
$$;
|
319
|
|
320
|
|
321
|
--
|
322
|
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
|
323
|
--
|
324
|
|
325
|
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
|
326
|
LANGUAGE sql
|
327
|
AS $$
|
328
|
SELECT nextval('pg_temp.taxon_match__match_num__seq');
|
329
|
$$;
|
330
|
|
331
|
|
332
|
--
|
333
|
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
|
334
|
--
|
335
|
|
336
|
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
|
337
|
LANGUAGE plpgsql
|
338
|
AS $$
|
339
|
BEGIN
|
340
|
INSERT INTO "TNRS".taxon_match_input SELECT new.*;
|
341
|
RETURN NULL;
|
342
|
END;
|
343
|
$$;
|
344
|
|
345
|
|
346
|
--
|
347
|
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
348
|
--
|
349
|
|
350
|
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
|
351
|
LANGUAGE sql IMMUTABLE
|
352
|
AS $_$
|
353
|
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
|
354
|
$_$;
|
355
|
|
356
|
|
357
|
--
|
358
|
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
|
359
|
--
|
360
|
|
361
|
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
|
362
|
LANGUAGE sql IMMUTABLE
|
363
|
AS $$
|
364
|
SELECT ARRAY[
|
365
|
]::text[]
|
366
|
$$;
|
367
|
|
368
|
|
369
|
SET default_tablespace = '';
|
370
|
|
371
|
SET default_with_oids = false;
|
372
|
|
373
|
--
|
374
|
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
375
|
--
|
376
|
|
377
|
CREATE TABLE taxon_match (
|
378
|
batch text DEFAULT now() NOT NULL,
|
379
|
match_num integer NOT NULL,
|
380
|
"*Name_number" integer NOT NULL,
|
381
|
"*Name_submitted" text NOT NULL,
|
382
|
"*Overall_score" double precision,
|
383
|
"*Name_matched" text,
|
384
|
"*Name_matched_rank" text,
|
385
|
"*Name_score" double precision,
|
386
|
"*Name_matched_author" text,
|
387
|
"*Name_matched_url" text,
|
388
|
"*Author_matched" text,
|
389
|
"*Author_score" double precision,
|
390
|
"*Family_matched" text,
|
391
|
"*Family_score" double precision,
|
392
|
"*Name_matched_accepted_family" text,
|
393
|
"*Genus_matched" text,
|
394
|
"*Genus_score" double precision,
|
395
|
"*Specific_epithet_matched" text,
|
396
|
"*Specific_epithet_score" double precision,
|
397
|
"*Infraspecific_rank" text,
|
398
|
"*Infraspecific_epithet_matched" text,
|
399
|
"*Infraspecific_epithet_score" double precision,
|
400
|
"*Infraspecific_rank_2" text,
|
401
|
"*Infraspecific_epithet_2_matched" text,
|
402
|
"*Infraspecific_epithet_2_score" double precision,
|
403
|
"*Annotations" text,
|
404
|
"*Unmatched_terms" text,
|
405
|
"*Taxonomic_status" text,
|
406
|
"*Accepted_name" text,
|
407
|
"*Accepted_name_author" text,
|
408
|
"*Accepted_name_rank" text,
|
409
|
"*Accepted_name_url" text,
|
410
|
"*Accepted_name_species" text,
|
411
|
"*Accepted_name_family" text,
|
412
|
"*Selected" text,
|
413
|
"*Source" text,
|
414
|
"*Warnings" text,
|
415
|
"*Accepted_name_lsid" text,
|
416
|
is_valid_match boolean NOT NULL,
|
417
|
scrubbed_unique_taxon_name text,
|
418
|
"[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" text,
|
419
|
"[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" text,
|
420
|
"[matched_]scientificName[_with_author]__@DwC__@vegpath.org" text,
|
421
|
matched_has_accepted boolean,
|
422
|
"Accepted_family__@TNRS__@vegpath.org" text,
|
423
|
"__accepted_{genus,specific_epithet}" text[],
|
424
|
"[accepted_]genus__@DwC__@vegpath.org" text,
|
425
|
"[accepted_]specificEpithet__@DwC__@vegpath.org" text,
|
426
|
"[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
|
427
|
__accepted_infraspecific_label text,
|
428
|
"__accepted_infraspecific_{rank,epithet}" text[],
|
429
|
"[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
|
430
|
"[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
|
431
|
"[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" text,
|
432
|
"[scrubbed_]taxonRank__@DwC__@vegpath.org" text,
|
433
|
"[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" text,
|
434
|
"[scrubbed_]genus__@DwC__@vegpath.org" text,
|
435
|
"[scrubbed_]specificEpithet__@DwC__@vegpath.org" text,
|
436
|
"[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" text,
|
437
|
"[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
|
438
|
"[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" text,
|
439
|
"[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" text,
|
440
|
"[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" text,
|
441
|
"[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" text,
|
442
|
CONSTRAINT "Accepted_family__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_family__@TNRS__@vegpath.org" IS DISTINCT FROM COALESCE("*Accepted_name_family",
|
443
|
CASE
|
444
|
WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
|
445
|
ELSE NULL::text
|
446
|
END)))),
|
447
|
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]))),
|
448
|
CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[1]))),
|
449
|
CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
|
450
|
CONSTRAINT "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
|
451
|
CASE
|
452
|
WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
453
|
WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
454
|
ELSE "*Accepted_name_species"
|
455
|
END))),
|
456
|
CONSTRAINT "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text))))),
|
457
|
CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[2]))),
|
458
|
CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
|
459
|
CONSTRAINT "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM (("*Genus_matched" || ' '::text) || "*Specific_epithet_matched")))),
|
460
|
CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))),
|
461
|
CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM
|
462
|
CASE
|
463
|
WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
|
464
|
ELSE "*Infraspecific_rank"
|
465
|
END))),
|
466
|
CONSTRAINT "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
|
467
|
CASE
|
468
|
WHEN matched_has_accepted THEN "*Accepted_name_author"
|
469
|
ELSE "*Name_matched_author"
|
470
|
END))),
|
471
|
CONSTRAINT "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
|
472
|
CASE
|
473
|
WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
|
474
|
ELSE "*Name_matched_accepted_family"
|
475
|
END))),
|
476
|
CONSTRAINT "[scrubbed_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]genus__@DwC__@vegpath.org" IS DISTINCT FROM
|
477
|
CASE
|
478
|
WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
|
479
|
ELSE "*Genus_matched"
|
480
|
END))),
|
481
|
CONSTRAINT "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
|
482
|
CASE
|
483
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
484
|
ELSE "*Infraspecific_epithet_matched"
|
485
|
END))),
|
486
|
CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
|
487
|
CASE
|
488
|
WHEN matched_has_accepted THEN "*Accepted_name"
|
489
|
ELSE "*Name_matched"
|
490
|
END))),
|
491
|
CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM
|
492
|
CASE
|
493
|
WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
|
494
|
ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
|
495
|
END))),
|
496
|
CONSTRAINT "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
|
497
|
CASE
|
498
|
WHEN matched_has_accepted THEN "*Accepted_name_species"
|
499
|
ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
|
500
|
END))),
|
501
|
CONSTRAINT "[scrubbed_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
|
502
|
CASE
|
503
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
504
|
ELSE "*Specific_epithet_matched"
|
505
|
END))),
|
506
|
CONSTRAINT "[scrubbed_]taxonRank__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonRank__@DwC__@vegpath.org" IS DISTINCT FROM
|
507
|
CASE
|
508
|
WHEN matched_has_accepted THEN "*Accepted_name_rank"
|
509
|
ELSE "*Name_matched_rank"
|
510
|
END))),
|
511
|
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)))),
|
512
|
CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM regexp_split_to_array(__accepted_infraspecific_label, ' '::text)))),
|
513
|
CONSTRAINT "__accepted_{genus,specific_epithet}" CHECK ((NOT ("__accepted_{genus,specific_epithet}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name_species", ' '::text)))),
|
514
|
CONSTRAINT matched_has_accepted CHECK ((NOT (matched_has_accepted IS DISTINCT FROM ("*Accepted_name" IS NOT NULL))))
|
515
|
);
|
516
|
|
517
|
|
518
|
--
|
519
|
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
|
520
|
--
|
521
|
|
522
|
COMMENT ON TABLE taxon_match IS '
|
523
|
whenever columns are renamed:
|
524
|
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
|
525
|
|
526
|
to remove columns or add columns at the end:
|
527
|
$ rm=1 inputs/.TNRS/data.sql.run
|
528
|
$ make schemas/remake
|
529
|
|
530
|
to add columns in the middle:
|
531
|
make the changes in inputs/.TNRS/schema.sql
|
532
|
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
|
533
|
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
|
534
|
SELECT util.derived_cols_repopulate(''"TNRS".taxon_match'');
|
535
|
$ make schemas/remake
|
536
|
|
537
|
to populate a new column:
|
538
|
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
|
539
|
UPDATE "TNRS".taxon_match SET "col" = value;
|
540
|
-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
|
541
|
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
|
542
|
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
|
543
|
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
|
544
|
|
545
|
to add a constraint: runtime: 3 min ("173620 ms")
|
546
|
';
|
547
|
|
548
|
|
549
|
--
|
550
|
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
551
|
--
|
552
|
|
553
|
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
|
554
|
= "*Unmatched_terms"
|
555
|
|
556
|
derived column
|
557
|
|
558
|
to modify expr:
|
559
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col, $$"*Unmatched_terms"$$)::util.derived_col_def);
|
560
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
561
|
|
562
|
to rename:
|
563
|
# rename column
|
564
|
# rename CHECK constraint
|
565
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
566
|
';
|
567
|
|
568
|
|
569
|
--
|
570
|
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
571
|
--
|
572
|
|
573
|
COMMENT ON COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
|
574
|
= ("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"
|
575
|
|
576
|
derived column
|
577
|
|
578
|
to modify expr:
|
579
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"$$)::util.derived_col_def);
|
580
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
581
|
|
582
|
to rename:
|
583
|
# rename column
|
584
|
# rename CHECK constraint
|
585
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
586
|
';
|
587
|
|
588
|
|
589
|
--
|
590
|
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
591
|
--
|
592
|
|
593
|
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
|
594
|
= "*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
|
595
|
|
596
|
derived column
|
597
|
|
598
|
to modify expr:
|
599
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
|
600
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
601
|
|
602
|
to rename:
|
603
|
# rename column
|
604
|
# rename CHECK constraint
|
605
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
606
|
';
|
607
|
|
608
|
|
609
|
--
|
610
|
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
|
611
|
--
|
612
|
|
613
|
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
|
614
|
= "*Accepted_name" IS NOT NULL
|
615
|
|
616
|
derived column
|
617
|
|
618
|
to modify expr:
|
619
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
|
620
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
621
|
|
622
|
to rename:
|
623
|
# rename column
|
624
|
# rename CHECK constraint
|
625
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
626
|
';
|
627
|
|
628
|
|
629
|
--
|
630
|
-- Name: COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
631
|
--
|
632
|
|
633
|
COMMENT ON COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org" IS '
|
634
|
= COALESCE("*Accepted_name_family",
|
635
|
CASE
|
636
|
WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
|
637
|
ELSE NULL::text
|
638
|
END)
|
639
|
|
640
|
derived column
|
641
|
|
642
|
to modify expr:
|
643
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col, $$COALESCE("*Accepted_name_family",
|
644
|
CASE
|
645
|
WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
|
646
|
ELSE NULL::text
|
647
|
END)$$)::util.derived_col_def);
|
648
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
649
|
|
650
|
to rename:
|
651
|
# rename column
|
652
|
# rename CHECK constraint
|
653
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
654
|
';
|
655
|
|
656
|
|
657
|
--
|
658
|
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
659
|
--
|
660
|
|
661
|
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
|
662
|
= regexp_split_to_array("*Accepted_name_species", '' ''::text)
|
663
|
|
664
|
derived column
|
665
|
|
666
|
to modify expr:
|
667
|
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);
|
668
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
669
|
|
670
|
to rename:
|
671
|
# rename column
|
672
|
# rename CHECK constraint
|
673
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
674
|
';
|
675
|
|
676
|
|
677
|
--
|
678
|
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
679
|
--
|
680
|
|
681
|
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
|
682
|
= "__accepted_{genus,specific_epithet}"[1]
|
683
|
|
684
|
derived column
|
685
|
|
686
|
to modify expr:
|
687
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[1]$$)::util.derived_col_def);
|
688
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
689
|
|
690
|
to rename:
|
691
|
# rename column
|
692
|
# rename CHECK constraint
|
693
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
694
|
';
|
695
|
|
696
|
|
697
|
--
|
698
|
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
699
|
--
|
700
|
|
701
|
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
|
702
|
= "__accepted_{genus,specific_epithet}"[2]
|
703
|
|
704
|
derived column
|
705
|
|
706
|
to modify expr:
|
707
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[2]$$)::util.derived_col_def);
|
708
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
709
|
|
710
|
to rename:
|
711
|
# rename column
|
712
|
# rename CHECK constraint
|
713
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
714
|
';
|
715
|
|
716
|
|
717
|
--
|
718
|
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
719
|
--
|
720
|
|
721
|
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
|
722
|
= CASE
|
723
|
WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
724
|
WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
725
|
ELSE "*Accepted_name_species"
|
726
|
END
|
727
|
|
728
|
derived column
|
729
|
|
730
|
to modify expr:
|
731
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
|
732
|
WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
733
|
WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
|
734
|
ELSE "*Accepted_name_species"
|
735
|
END$$)::util.derived_col_def);
|
736
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
737
|
|
738
|
to rename:
|
739
|
# rename column
|
740
|
# rename CHECK constraint
|
741
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
742
|
';
|
743
|
|
744
|
|
745
|
--
|
746
|
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
|
747
|
--
|
748
|
|
749
|
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
|
750
|
= ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''::text), '' ''::text)
|
751
|
|
752
|
derived column
|
753
|
|
754
|
to modify expr:
|
755
|
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), ''''::text), '' ''::text)$$)::util.derived_col_def);
|
756
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
757
|
|
758
|
to rename:
|
759
|
# rename column
|
760
|
# rename CHECK constraint
|
761
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
762
|
';
|
763
|
|
764
|
|
765
|
--
|
766
|
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
767
|
--
|
768
|
|
769
|
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
|
770
|
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
|
771
|
|
772
|
derived column
|
773
|
|
774
|
to modify expr:
|
775
|
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);
|
776
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
777
|
|
778
|
to rename:
|
779
|
# rename column
|
780
|
# rename CHECK constraint
|
781
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
782
|
';
|
783
|
|
784
|
|
785
|
--
|
786
|
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
787
|
--
|
788
|
|
789
|
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
|
790
|
= "__accepted_infraspecific_{rank,epithet}"[1]
|
791
|
|
792
|
derived column
|
793
|
|
794
|
to modify expr:
|
795
|
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);
|
796
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
797
|
|
798
|
to rename:
|
799
|
# rename column
|
800
|
# rename CHECK constraint
|
801
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
802
|
';
|
803
|
|
804
|
|
805
|
--
|
806
|
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
807
|
--
|
808
|
|
809
|
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
|
810
|
= "__accepted_infraspecific_{rank,epithet}"[2]
|
811
|
|
812
|
derived column
|
813
|
|
814
|
to modify expr:
|
815
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
|
816
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
817
|
|
818
|
to rename:
|
819
|
# rename column
|
820
|
# rename CHECK constraint
|
821
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
822
|
';
|
823
|
|
824
|
|
825
|
--
|
826
|
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
827
|
--
|
828
|
|
829
|
COMMENT ON COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
|
830
|
= "*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)
|
831
|
|
832
|
derived column
|
833
|
|
834
|
to modify expr:
|
835
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)$$)::util.derived_col_def);
|
836
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
837
|
|
838
|
to rename:
|
839
|
# rename column
|
840
|
# rename CHECK constraint
|
841
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
842
|
';
|
843
|
|
844
|
|
845
|
--
|
846
|
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
847
|
--
|
848
|
|
849
|
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
|
850
|
= CASE
|
851
|
WHEN matched_has_accepted THEN "*Accepted_name_rank"
|
852
|
ELSE "*Name_matched_rank"
|
853
|
END
|
854
|
|
855
|
derived column
|
856
|
|
857
|
to modify expr:
|
858
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
|
859
|
WHEN matched_has_accepted THEN "*Accepted_name_rank"
|
860
|
ELSE "*Name_matched_rank"
|
861
|
END$$)::util.derived_col_def);
|
862
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
863
|
|
864
|
to rename:
|
865
|
# rename column
|
866
|
# rename CHECK constraint
|
867
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
868
|
';
|
869
|
|
870
|
|
871
|
--
|
872
|
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
873
|
--
|
874
|
|
875
|
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
|
876
|
= CASE
|
877
|
WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
|
878
|
ELSE "*Name_matched_accepted_family"
|
879
|
END
|
880
|
|
881
|
derived column
|
882
|
|
883
|
to modify expr:
|
884
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
|
885
|
WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
|
886
|
ELSE "*Name_matched_accepted_family"
|
887
|
END$$)::util.derived_col_def);
|
888
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
889
|
|
890
|
to rename:
|
891
|
# rename column
|
892
|
# rename CHECK constraint
|
893
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
894
|
';
|
895
|
|
896
|
|
897
|
--
|
898
|
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
899
|
--
|
900
|
|
901
|
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
|
902
|
= CASE
|
903
|
WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
|
904
|
ELSE "*Genus_matched"
|
905
|
END
|
906
|
|
907
|
derived column
|
908
|
|
909
|
to modify expr:
|
910
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
|
911
|
WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
|
912
|
ELSE "*Genus_matched"
|
913
|
END$$)::util.derived_col_def);
|
914
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
915
|
|
916
|
to rename:
|
917
|
# rename column
|
918
|
# rename CHECK constraint
|
919
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
920
|
';
|
921
|
|
922
|
|
923
|
--
|
924
|
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
925
|
--
|
926
|
|
927
|
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
|
928
|
= CASE
|
929
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
930
|
ELSE "*Specific_epithet_matched"
|
931
|
END
|
932
|
|
933
|
derived column
|
934
|
|
935
|
to modify expr:
|
936
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
|
937
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
938
|
ELSE "*Specific_epithet_matched"
|
939
|
END$$)::util.derived_col_def);
|
940
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
941
|
|
942
|
to rename:
|
943
|
# rename column
|
944
|
# rename CHECK constraint
|
945
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
946
|
';
|
947
|
|
948
|
|
949
|
--
|
950
|
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
951
|
--
|
952
|
|
953
|
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
|
954
|
= CASE
|
955
|
WHEN matched_has_accepted THEN "*Accepted_name_species"
|
956
|
ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
|
957
|
END
|
958
|
|
959
|
derived column
|
960
|
|
961
|
to modify expr:
|
962
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
|
963
|
WHEN matched_has_accepted THEN "*Accepted_name_species"
|
964
|
ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
|
965
|
END$$)::util.derived_col_def);
|
966
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
967
|
|
968
|
to rename:
|
969
|
# rename column
|
970
|
# rename CHECK constraint
|
971
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
972
|
';
|
973
|
|
974
|
|
975
|
--
|
976
|
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
977
|
--
|
978
|
|
979
|
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
|
980
|
= CASE
|
981
|
WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
|
982
|
ELSE "*Infraspecific_rank"
|
983
|
END
|
984
|
|
985
|
derived column
|
986
|
|
987
|
to modify expr:
|
988
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
|
989
|
WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
|
990
|
ELSE "*Infraspecific_rank"
|
991
|
END$$)::util.derived_col_def);
|
992
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
993
|
|
994
|
to rename:
|
995
|
# rename column
|
996
|
# rename CHECK constraint
|
997
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
998
|
';
|
999
|
|
1000
|
|
1001
|
--
|
1002
|
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
1003
|
--
|
1004
|
|
1005
|
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
|
1006
|
= CASE
|
1007
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
1008
|
ELSE "*Infraspecific_epithet_matched"
|
1009
|
END
|
1010
|
|
1011
|
derived column
|
1012
|
|
1013
|
to modify expr:
|
1014
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
|
1015
|
WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
|
1016
|
ELSE "*Infraspecific_epithet_matched"
|
1017
|
END$$)::util.derived_col_def);
|
1018
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
1019
|
|
1020
|
to rename:
|
1021
|
# rename column
|
1022
|
# rename CHECK constraint
|
1023
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
1024
|
';
|
1025
|
|
1026
|
|
1027
|
--
|
1028
|
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
1029
|
--
|
1030
|
|
1031
|
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
|
1032
|
= CASE
|
1033
|
WHEN matched_has_accepted THEN "*Accepted_name"
|
1034
|
ELSE "*Name_matched"
|
1035
|
END
|
1036
|
|
1037
|
derived column
|
1038
|
|
1039
|
to modify expr:
|
1040
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
|
1041
|
WHEN matched_has_accepted THEN "*Accepted_name"
|
1042
|
ELSE "*Name_matched"
|
1043
|
END$$)::util.derived_col_def);
|
1044
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
1045
|
|
1046
|
to rename:
|
1047
|
# rename column
|
1048
|
# rename CHECK constraint
|
1049
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
1050
|
';
|
1051
|
|
1052
|
|
1053
|
--
|
1054
|
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
1055
|
--
|
1056
|
|
1057
|
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
|
1058
|
= CASE
|
1059
|
WHEN matched_has_accepted THEN "*Accepted_name_author"
|
1060
|
ELSE "*Name_matched_author"
|
1061
|
END
|
1062
|
|
1063
|
derived column
|
1064
|
|
1065
|
to modify expr:
|
1066
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
|
1067
|
WHEN matched_has_accepted THEN "*Accepted_name_author"
|
1068
|
ELSE "*Name_matched_author"
|
1069
|
END$$)::util.derived_col_def);
|
1070
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
1071
|
|
1072
|
to rename:
|
1073
|
# rename column
|
1074
|
# rename CHECK constraint
|
1075
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
1076
|
';
|
1077
|
|
1078
|
|
1079
|
--
|
1080
|
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
1081
|
--
|
1082
|
|
1083
|
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
|
1084
|
= CASE
|
1085
|
WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
|
1086
|
ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
|
1087
|
END
|
1088
|
|
1089
|
derived column
|
1090
|
|
1091
|
to modify expr:
|
1092
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
|
1093
|
WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
|
1094
|
ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
|
1095
|
END$$)::util.derived_col_def);
|
1096
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
1097
|
|
1098
|
to rename:
|
1099
|
# rename column
|
1100
|
# rename CHECK constraint
|
1101
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
1102
|
';
|
1103
|
|
1104
|
|
1105
|
--
|
1106
|
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
|
1107
|
--
|
1108
|
|
1109
|
CREATE VIEW taxon_best_match AS
|
1110
|
SELECT taxon_match.batch,
|
1111
|
taxon_match.match_num,
|
1112
|
taxon_match."*Name_number",
|
1113
|
taxon_match."*Name_submitted",
|
1114
|
taxon_match."*Overall_score",
|
1115
|
taxon_match."*Name_matched",
|
1116
|
taxon_match."*Name_matched_rank",
|
1117
|
taxon_match."*Name_score",
|
1118
|
taxon_match."*Name_matched_author",
|
1119
|
taxon_match."*Name_matched_url",
|
1120
|
taxon_match."*Author_matched",
|
1121
|
taxon_match."*Author_score",
|
1122
|
taxon_match."*Family_matched",
|
1123
|
taxon_match."*Family_score",
|
1124
|
taxon_match."*Name_matched_accepted_family",
|
1125
|
taxon_match."*Genus_matched",
|
1126
|
taxon_match."*Genus_score",
|
1127
|
taxon_match."*Specific_epithet_matched",
|
1128
|
taxon_match."*Specific_epithet_score",
|
1129
|
taxon_match."*Infraspecific_rank",
|
1130
|
taxon_match."*Infraspecific_epithet_matched",
|
1131
|
taxon_match."*Infraspecific_epithet_score",
|
1132
|
taxon_match."*Infraspecific_rank_2",
|
1133
|
taxon_match."*Infraspecific_epithet_2_matched",
|
1134
|
taxon_match."*Infraspecific_epithet_2_score",
|
1135
|
taxon_match."*Annotations",
|
1136
|
taxon_match."*Unmatched_terms",
|
1137
|
taxon_match."*Taxonomic_status",
|
1138
|
taxon_match."*Accepted_name",
|
1139
|
taxon_match."*Accepted_name_author",
|
1140
|
taxon_match."*Accepted_name_rank",
|
1141
|
taxon_match."*Accepted_name_url",
|
1142
|
taxon_match."*Accepted_name_species",
|
1143
|
taxon_match."*Accepted_name_family",
|
1144
|
taxon_match."*Selected",
|
1145
|
taxon_match."*Source",
|
1146
|
taxon_match."*Warnings",
|
1147
|
taxon_match."*Accepted_name_lsid",
|
1148
|
taxon_match.is_valid_match,
|
1149
|
taxon_match.scrubbed_unique_taxon_name,
|
1150
|
taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1151
|
taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1152
|
taxon_match.matched_has_accepted,
|
1153
|
taxon_match."__accepted_{genus,specific_epithet}",
|
1154
|
taxon_match."[accepted_]genus__@DwC__@vegpath.org",
|
1155
|
taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
|
1156
|
taxon_match.__accepted_infraspecific_label,
|
1157
|
taxon_match."__accepted_infraspecific_{rank,epithet}",
|
1158
|
taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1159
|
taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
|
1160
|
taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1161
|
taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
|
1162
|
taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
|
1163
|
taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
|
1164
|
taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
|
1165
|
taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1166
|
taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1167
|
taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
|
1168
|
taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1169
|
taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
|
1170
|
taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
|
1171
|
FROM taxon_match
|
1172
|
WHERE (taxon_match."*Selected" = 'true'::text);
|
1173
|
|
1174
|
|
1175
|
--
|
1176
|
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
|
1177
|
--
|
1178
|
|
1179
|
COMMENT ON VIEW taxon_best_match IS '
|
1180
|
to modify:
|
1181
|
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
|
1182
|
SELECT __
|
1183
|
$$);
|
1184
|
';
|
1185
|
|
1186
|
|
1187
|
--
|
1188
|
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
1189
|
--
|
1190
|
|
1191
|
CREATE VIEW "MatchedTaxon" AS
|
1192
|
SELECT taxon_best_match.batch,
|
1193
|
taxon_best_match.match_num,
|
1194
|
taxon_best_match."*Name_number",
|
1195
|
taxon_best_match."*Name_submitted",
|
1196
|
taxon_best_match."*Overall_score",
|
1197
|
taxon_best_match."*Name_matched",
|
1198
|
taxon_best_match."*Name_matched_rank",
|
1199
|
taxon_best_match."*Name_score",
|
1200
|
taxon_best_match."*Name_matched_author",
|
1201
|
taxon_best_match."*Name_matched_url",
|
1202
|
taxon_best_match."*Author_matched",
|
1203
|
taxon_best_match."*Author_score",
|
1204
|
taxon_best_match."*Family_matched",
|
1205
|
taxon_best_match."*Family_score",
|
1206
|
taxon_best_match."*Name_matched_accepted_family",
|
1207
|
taxon_best_match."*Genus_matched",
|
1208
|
taxon_best_match."*Genus_score",
|
1209
|
taxon_best_match."*Specific_epithet_matched",
|
1210
|
taxon_best_match."*Specific_epithet_score",
|
1211
|
taxon_best_match."*Infraspecific_rank",
|
1212
|
taxon_best_match."*Infraspecific_epithet_matched",
|
1213
|
taxon_best_match."*Infraspecific_epithet_score",
|
1214
|
taxon_best_match."*Infraspecific_rank_2",
|
1215
|
taxon_best_match."*Infraspecific_epithet_2_matched",
|
1216
|
taxon_best_match."*Infraspecific_epithet_2_score",
|
1217
|
taxon_best_match."*Annotations",
|
1218
|
taxon_best_match."*Unmatched_terms",
|
1219
|
taxon_best_match."*Taxonomic_status",
|
1220
|
taxon_best_match."*Accepted_name",
|
1221
|
taxon_best_match."*Accepted_name_author",
|
1222
|
taxon_best_match."*Accepted_name_rank",
|
1223
|
taxon_best_match."*Accepted_name_url",
|
1224
|
taxon_best_match."*Accepted_name_species",
|
1225
|
taxon_best_match."*Accepted_name_family",
|
1226
|
taxon_best_match."*Selected",
|
1227
|
taxon_best_match."*Source",
|
1228
|
taxon_best_match."*Warnings",
|
1229
|
taxon_best_match."*Accepted_name_lsid",
|
1230
|
taxon_best_match.is_valid_match,
|
1231
|
taxon_best_match.scrubbed_unique_taxon_name,
|
1232
|
taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1233
|
taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1234
|
taxon_best_match.matched_has_accepted,
|
1235
|
taxon_best_match."__accepted_{genus,specific_epithet}",
|
1236
|
taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
|
1237
|
taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
|
1238
|
taxon_best_match.__accepted_infraspecific_label,
|
1239
|
taxon_best_match."__accepted_infraspecific_{rank,epithet}",
|
1240
|
taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1241
|
taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
|
1242
|
taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1243
|
taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
|
1244
|
taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
|
1245
|
taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
|
1246
|
taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
|
1247
|
taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1248
|
taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1249
|
taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
|
1250
|
taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1251
|
taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
|
1252
|
taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1253
|
map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
|
1254
|
CASE
|
1255
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
|
1256
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
|
1257
|
ELSE taxon_best_match."*Accepted_name_species"
|
1258
|
END AS accepted_morphospecies_binomial
|
1259
|
FROM taxon_best_match;
|
1260
|
|
1261
|
|
1262
|
--
|
1263
|
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
1264
|
--
|
1265
|
|
1266
|
COMMENT ON VIEW "MatchedTaxon" IS '
|
1267
|
to modify:
|
1268
|
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
|
1269
|
SELECT __
|
1270
|
$$);
|
1271
|
';
|
1272
|
|
1273
|
|
1274
|
--
|
1275
|
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
1276
|
--
|
1277
|
|
1278
|
CREATE VIEW "ValidMatchedTaxon" AS
|
1279
|
SELECT "MatchedTaxon".batch,
|
1280
|
"MatchedTaxon".match_num,
|
1281
|
"MatchedTaxon"."*Name_number",
|
1282
|
"MatchedTaxon"."*Name_submitted",
|
1283
|
"MatchedTaxon"."*Overall_score",
|
1284
|
"MatchedTaxon"."*Name_matched",
|
1285
|
"MatchedTaxon"."*Name_matched_rank",
|
1286
|
"MatchedTaxon"."*Name_score",
|
1287
|
"MatchedTaxon"."*Name_matched_author",
|
1288
|
"MatchedTaxon"."*Name_matched_url",
|
1289
|
"MatchedTaxon"."*Author_matched",
|
1290
|
"MatchedTaxon"."*Author_score",
|
1291
|
"MatchedTaxon"."*Family_matched",
|
1292
|
"MatchedTaxon"."*Family_score",
|
1293
|
"MatchedTaxon"."*Name_matched_accepted_family",
|
1294
|
"MatchedTaxon"."*Genus_matched",
|
1295
|
"MatchedTaxon"."*Genus_score",
|
1296
|
"MatchedTaxon"."*Specific_epithet_matched",
|
1297
|
"MatchedTaxon"."*Specific_epithet_score",
|
1298
|
"MatchedTaxon"."*Infraspecific_rank",
|
1299
|
"MatchedTaxon"."*Infraspecific_epithet_matched",
|
1300
|
"MatchedTaxon"."*Infraspecific_epithet_score",
|
1301
|
"MatchedTaxon"."*Infraspecific_rank_2",
|
1302
|
"MatchedTaxon"."*Infraspecific_epithet_2_matched",
|
1303
|
"MatchedTaxon"."*Infraspecific_epithet_2_score",
|
1304
|
"MatchedTaxon"."*Annotations",
|
1305
|
"MatchedTaxon"."*Unmatched_terms",
|
1306
|
"MatchedTaxon"."*Taxonomic_status",
|
1307
|
"MatchedTaxon"."*Accepted_name",
|
1308
|
"MatchedTaxon"."*Accepted_name_author",
|
1309
|
"MatchedTaxon"."*Accepted_name_rank",
|
1310
|
"MatchedTaxon"."*Accepted_name_url",
|
1311
|
"MatchedTaxon"."*Accepted_name_species",
|
1312
|
"MatchedTaxon"."*Accepted_name_family",
|
1313
|
"MatchedTaxon"."*Selected",
|
1314
|
"MatchedTaxon"."*Source",
|
1315
|
"MatchedTaxon"."*Warnings",
|
1316
|
"MatchedTaxon"."*Accepted_name_lsid",
|
1317
|
"MatchedTaxon".is_valid_match,
|
1318
|
"MatchedTaxon".scrubbed_unique_taxon_name,
|
1319
|
"MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1320
|
"MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1321
|
"MatchedTaxon".matched_has_accepted,
|
1322
|
"MatchedTaxon"."__accepted_{genus,specific_epithet}",
|
1323
|
"MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
|
1324
|
"MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
|
1325
|
"MatchedTaxon".__accepted_infraspecific_label,
|
1326
|
"MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
|
1327
|
"MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1328
|
"MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
|
1329
|
"MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1330
|
"MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
|
1331
|
"MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
|
1332
|
"MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
|
1333
|
"MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
|
1334
|
"MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1335
|
"MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1336
|
"MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
|
1337
|
"MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1338
|
"MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
|
1339
|
"MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1340
|
"MatchedTaxon"."taxonomicStatus",
|
1341
|
"MatchedTaxon".accepted_morphospecies_binomial
|
1342
|
FROM "MatchedTaxon"
|
1343
|
WHERE "MatchedTaxon".is_valid_match;
|
1344
|
|
1345
|
|
1346
|
--
|
1347
|
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
1348
|
--
|
1349
|
|
1350
|
COMMENT ON VIEW "ValidMatchedTaxon" IS '
|
1351
|
to update, use * as the column list
|
1352
|
';
|
1353
|
|
1354
|
|
1355
|
--
|
1356
|
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
1357
|
--
|
1358
|
|
1359
|
CREATE TABLE batch (
|
1360
|
id text NOT NULL,
|
1361
|
id_by_time text,
|
1362
|
time_submitted timestamp with time zone DEFAULT now(),
|
1363
|
client_version text
|
1364
|
);
|
1365
|
|
1366
|
|
1367
|
--
|
1368
|
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
1369
|
--
|
1370
|
|
1371
|
CREATE TABLE batch_download_settings (
|
1372
|
id text NOT NULL,
|
1373
|
"E-mail" text,
|
1374
|
"Id" text,
|
1375
|
"Job type" text,
|
1376
|
"Contains Id" boolean,
|
1377
|
"Start time" text,
|
1378
|
"Finish time" text,
|
1379
|
"TNRS version" text,
|
1380
|
"Sources selected" text,
|
1381
|
"Match threshold" double precision,
|
1382
|
"Classification" text,
|
1383
|
"Allow partial matches?" boolean,
|
1384
|
"Sort by source" boolean,
|
1385
|
"Constrain by higher taxonomy" boolean
|
1386
|
);
|
1387
|
|
1388
|
|
1389
|
--
|
1390
|
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
|
1391
|
--
|
1392
|
|
1393
|
COMMENT ON TABLE batch_download_settings IS '
|
1394
|
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
|
1395
|
';
|
1396
|
|
1397
|
|
1398
|
--
|
1399
|
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
1400
|
--
|
1401
|
|
1402
|
CREATE TABLE client_version (
|
1403
|
id text NOT NULL,
|
1404
|
global_rev integer NOT NULL,
|
1405
|
"/lib/tnrs.py rev" integer,
|
1406
|
"/bin/tnrs_db rev" integer
|
1407
|
);
|
1408
|
|
1409
|
|
1410
|
--
|
1411
|
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
|
1412
|
--
|
1413
|
|
1414
|
COMMENT ON TABLE client_version IS '
|
1415
|
contains svn revisions
|
1416
|
';
|
1417
|
|
1418
|
|
1419
|
--
|
1420
|
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
|
1421
|
--
|
1422
|
|
1423
|
COMMENT ON COLUMN client_version.global_rev IS '
|
1424
|
from `svn info .` > Last Changed Rev
|
1425
|
';
|
1426
|
|
1427
|
|
1428
|
--
|
1429
|
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
1430
|
--
|
1431
|
|
1432
|
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
|
1433
|
from `svn info lib/tnrs.py` > Last Changed Rev
|
1434
|
';
|
1435
|
|
1436
|
|
1437
|
--
|
1438
|
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
1439
|
--
|
1440
|
|
1441
|
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
|
1442
|
from `svn info bin/tnrs_db` > Last Changed Rev
|
1443
|
';
|
1444
|
|
1445
|
|
1446
|
--
|
1447
|
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
|
1448
|
--
|
1449
|
|
1450
|
CREATE VIEW taxon_match_input AS
|
1451
|
SELECT taxon_match."*Name_number" AS "Name_number",
|
1452
|
taxon_match."*Name_submitted" AS "Name_submitted",
|
1453
|
taxon_match."*Overall_score" AS "Overall_score",
|
1454
|
taxon_match."*Name_matched" AS "Name_matched",
|
1455
|
taxon_match."*Name_matched_rank" AS "Name_matched_rank",
|
1456
|
taxon_match."*Name_score" AS "Name_score",
|
1457
|
taxon_match."*Name_matched_author" AS "Name_matched_author",
|
1458
|
taxon_match."*Name_matched_url" AS "Name_matched_url",
|
1459
|
taxon_match."*Author_matched" AS "Author_matched",
|
1460
|
taxon_match."*Author_score" AS "Author_score",
|
1461
|
taxon_match."*Family_matched" AS "Family_matched",
|
1462
|
taxon_match."*Family_score" AS "Family_score",
|
1463
|
taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
|
1464
|
taxon_match."*Genus_matched" AS "Genus_matched",
|
1465
|
taxon_match."*Genus_score" AS "Genus_score",
|
1466
|
taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
|
1467
|
taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
|
1468
|
taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
|
1469
|
taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
|
1470
|
taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
|
1471
|
taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
|
1472
|
taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
|
1473
|
taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
|
1474
|
taxon_match."*Annotations" AS "Annotations",
|
1475
|
taxon_match."*Unmatched_terms" AS "Unmatched_terms",
|
1476
|
taxon_match."*Taxonomic_status" AS "Taxonomic_status",
|
1477
|
taxon_match."*Accepted_name" AS "Accepted_name",
|
1478
|
taxon_match."*Accepted_name_author" AS "Accepted_name_author",
|
1479
|
taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
|
1480
|
taxon_match."*Accepted_name_url" AS "Accepted_name_url",
|
1481
|
taxon_match."*Accepted_name_species" AS "Accepted_name_species",
|
1482
|
taxon_match."*Accepted_name_family" AS "Accepted_name_family",
|
1483
|
taxon_match."*Selected" AS "Selected",
|
1484
|
taxon_match."*Source" AS "Source",
|
1485
|
taxon_match."*Warnings" AS "Warnings",
|
1486
|
taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
|
1487
|
FROM taxon_match;
|
1488
|
|
1489
|
|
1490
|
--
|
1491
|
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
1492
|
--
|
1493
|
|
1494
|
CREATE TABLE taxon_match_input__copy_to (
|
1495
|
"Name_number" integer,
|
1496
|
"Name_submitted" text,
|
1497
|
"Overall_score" double precision,
|
1498
|
"Name_matched" text,
|
1499
|
"Name_matched_rank" text,
|
1500
|
"Name_score" double precision,
|
1501
|
"Name_matched_author" text,
|
1502
|
"Name_matched_url" text,
|
1503
|
"Author_matched" text,
|
1504
|
"Author_score" double precision,
|
1505
|
"Family_matched" text,
|
1506
|
"Family_score" double precision,
|
1507
|
"Name_matched_accepted_family" text,
|
1508
|
"Genus_matched" text,
|
1509
|
"Genus_score" double precision,
|
1510
|
"Specific_epithet_matched" text,
|
1511
|
"Specific_epithet_score" double precision,
|
1512
|
"Infraspecific_rank" text,
|
1513
|
"Infraspecific_epithet_matched" text,
|
1514
|
"Infraspecific_epithet_score" double precision,
|
1515
|
"Infraspecific_rank_2" text,
|
1516
|
"Infraspecific_epithet_2_matched" text,
|
1517
|
"Infraspecific_epithet_2_score" double precision,
|
1518
|
"Annotations" text,
|
1519
|
"Unmatched_terms" text,
|
1520
|
"Taxonomic_status" text,
|
1521
|
"Accepted_name" text,
|
1522
|
"Accepted_name_author" text,
|
1523
|
"Accepted_name_rank" text,
|
1524
|
"Accepted_name_url" text,
|
1525
|
"Accepted_name_species" text,
|
1526
|
"Accepted_name_family" text,
|
1527
|
"Selected" text,
|
1528
|
"Source" text,
|
1529
|
"Warnings" text,
|
1530
|
"Accepted_name_lsid" text
|
1531
|
);
|
1532
|
|
1533
|
|
1534
|
--
|
1535
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
|
1536
|
--
|
1537
|
|
1538
|
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
|
1539
|
SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
|
1540
|
taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
|
1541
|
COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
|
1542
|
taxon_match."*Genus_matched" AS scrubbed_genus,
|
1543
|
taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
|
1544
|
taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
|
1545
|
taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
|
1546
|
taxon_match."*Name_matched_author" AS scrubbed_author,
|
1547
|
taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
|
1548
|
(taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
|
1549
|
FROM taxon_match;
|
1550
|
|
1551
|
|
1552
|
--
|
1553
|
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
|
1554
|
--
|
1555
|
|
1556
|
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
|
1557
|
to modify:
|
1558
|
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
|
1559
|
SELECT __
|
1560
|
$$);
|
1561
|
|
1562
|
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.
|
1563
|
';
|
1564
|
|
1565
|
|
1566
|
--
|
1567
|
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
|
1568
|
--
|
1569
|
|
1570
|
CREATE VIEW taxon_scrub AS
|
1571
|
SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
|
1572
|
"ValidMatchedTaxon".batch,
|
1573
|
"ValidMatchedTaxon".match_num,
|
1574
|
"ValidMatchedTaxon"."*Name_number",
|
1575
|
"ValidMatchedTaxon"."*Name_submitted",
|
1576
|
"ValidMatchedTaxon"."*Overall_score",
|
1577
|
"ValidMatchedTaxon"."*Name_matched",
|
1578
|
"ValidMatchedTaxon"."*Name_matched_rank",
|
1579
|
"ValidMatchedTaxon"."*Name_score",
|
1580
|
"ValidMatchedTaxon"."*Name_matched_author",
|
1581
|
"ValidMatchedTaxon"."*Name_matched_url",
|
1582
|
"ValidMatchedTaxon"."*Author_matched",
|
1583
|
"ValidMatchedTaxon"."*Author_score",
|
1584
|
"ValidMatchedTaxon"."*Family_matched",
|
1585
|
"ValidMatchedTaxon"."*Family_score",
|
1586
|
"ValidMatchedTaxon"."*Name_matched_accepted_family",
|
1587
|
"ValidMatchedTaxon"."*Genus_matched",
|
1588
|
"ValidMatchedTaxon"."*Genus_score",
|
1589
|
"ValidMatchedTaxon"."*Specific_epithet_matched",
|
1590
|
"ValidMatchedTaxon"."*Specific_epithet_score",
|
1591
|
"ValidMatchedTaxon"."*Infraspecific_rank",
|
1592
|
"ValidMatchedTaxon"."*Infraspecific_epithet_matched",
|
1593
|
"ValidMatchedTaxon"."*Infraspecific_epithet_score",
|
1594
|
"ValidMatchedTaxon"."*Infraspecific_rank_2",
|
1595
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
|
1596
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
|
1597
|
"ValidMatchedTaxon"."*Annotations",
|
1598
|
"ValidMatchedTaxon"."*Unmatched_terms",
|
1599
|
"ValidMatchedTaxon"."*Taxonomic_status",
|
1600
|
"ValidMatchedTaxon"."*Accepted_name",
|
1601
|
"ValidMatchedTaxon"."*Accepted_name_author",
|
1602
|
"ValidMatchedTaxon"."*Accepted_name_rank",
|
1603
|
"ValidMatchedTaxon"."*Accepted_name_url",
|
1604
|
"ValidMatchedTaxon"."*Accepted_name_species",
|
1605
|
"ValidMatchedTaxon"."*Accepted_name_family",
|
1606
|
"ValidMatchedTaxon"."*Selected",
|
1607
|
"ValidMatchedTaxon"."*Source",
|
1608
|
"ValidMatchedTaxon"."*Warnings",
|
1609
|
"ValidMatchedTaxon"."*Accepted_name_lsid",
|
1610
|
"ValidMatchedTaxon".is_valid_match,
|
1611
|
"ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1612
|
"ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1613
|
"ValidMatchedTaxon".matched_has_accepted,
|
1614
|
"ValidMatchedTaxon"."__accepted_{genus,specific_epithet}",
|
1615
|
"ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
|
1616
|
"ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
|
1617
|
"ValidMatchedTaxon".__accepted_infraspecific_label,
|
1618
|
"ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
|
1619
|
"ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1620
|
"ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
|
1621
|
"ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1622
|
"ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
|
1623
|
"ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
|
1624
|
"ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
|
1625
|
"ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
|
1626
|
"ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1627
|
"ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
|
1628
|
"ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
|
1629
|
"ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
|
1630
|
"ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
|
1631
|
"ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
|
1632
|
"ValidMatchedTaxon"."taxonomicStatus",
|
1633
|
"ValidMatchedTaxon".accepted_morphospecies_binomial,
|
1634
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
|
1635
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
|
1636
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
|
1637
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
|
1638
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
|
1639
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
|
1640
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
|
1641
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
|
1642
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
|
1643
|
CASE
|
1644
|
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")
|
1645
|
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")
|
1646
|
ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
|
1647
|
END AS scrubbed_morphospecies_binomial
|
1648
|
FROM ("ValidMatchedTaxon"
|
1649
|
LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
|
1650
|
|
1651
|
|
1652
|
--
|
1653
|
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
|
1654
|
--
|
1655
|
|
1656
|
COMMENT ON VIEW taxon_scrub IS '
|
1657
|
to modify:
|
1658
|
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
|
1659
|
SELECT __
|
1660
|
$$);
|
1661
|
';
|
1662
|
|
1663
|
|
1664
|
--
|
1665
|
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1666
|
--
|
1667
|
|
1668
|
ALTER TABLE ONLY batch_download_settings
|
1669
|
ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
|
1670
|
|
1671
|
|
1672
|
--
|
1673
|
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1674
|
--
|
1675
|
|
1676
|
ALTER TABLE ONLY batch
|
1677
|
ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
|
1678
|
|
1679
|
|
1680
|
--
|
1681
|
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1682
|
--
|
1683
|
|
1684
|
ALTER TABLE ONLY batch
|
1685
|
ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
|
1686
|
|
1687
|
|
1688
|
--
|
1689
|
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1690
|
--
|
1691
|
|
1692
|
ALTER TABLE ONLY client_version
|
1693
|
ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
|
1694
|
|
1695
|
|
1696
|
--
|
1697
|
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1698
|
--
|
1699
|
|
1700
|
ALTER TABLE ONLY taxon_match
|
1701
|
ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
|
1702
|
|
1703
|
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
|
1704
|
|
1705
|
|
1706
|
--
|
1707
|
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1708
|
--
|
1709
|
|
1710
|
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
|
1711
|
|
1712
|
|
1713
|
--
|
1714
|
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1715
|
--
|
1716
|
|
1717
|
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
|
1718
|
|
1719
|
|
1720
|
--
|
1721
|
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1722
|
--
|
1723
|
|
1724
|
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
|
1725
|
|
1726
|
|
1727
|
--
|
1728
|
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1729
|
--
|
1730
|
|
1731
|
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
|
1732
|
|
1733
|
|
1734
|
--
|
1735
|
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1736
|
--
|
1737
|
|
1738
|
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
|
1739
|
|
1740
|
|
1741
|
--
|
1742
|
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
|
1743
|
--
|
1744
|
|
1745
|
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
|
1746
|
|
1747
|
|
1748
|
--
|
1749
|
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1750
|
--
|
1751
|
|
1752
|
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
|
1753
|
|
1754
|
|
1755
|
--
|
1756
|
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
|
1757
|
--
|
1758
|
|
1759
|
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
|
1760
|
|
1761
|
|
1762
|
--
|
1763
|
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1764
|
--
|
1765
|
|
1766
|
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
|
1767
|
|
1768
|
|
1769
|
--
|
1770
|
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
|
1771
|
--
|
1772
|
|
1773
|
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();
|
1774
|
|
1775
|
|
1776
|
--
|
1777
|
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1778
|
--
|
1779
|
|
1780
|
ALTER TABLE ONLY batch
|
1781
|
ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1782
|
|
1783
|
|
1784
|
--
|
1785
|
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1786
|
--
|
1787
|
|
1788
|
ALTER TABLE ONLY batch_download_settings
|
1789
|
ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1790
|
|
1791
|
|
1792
|
--
|
1793
|
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1794
|
--
|
1795
|
|
1796
|
ALTER TABLE ONLY taxon_match
|
1797
|
ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1798
|
|
1799
|
|
1800
|
--
|
1801
|
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
|
1802
|
--
|
1803
|
|
1804
|
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
|
1805
|
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
|
1806
|
GRANT ALL ON SCHEMA "TNRS" TO bien;
|
1807
|
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
|
1808
|
|
1809
|
|
1810
|
--
|
1811
|
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
|
1812
|
--
|
1813
|
|
1814
|
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
|
1815
|
REVOKE ALL ON TABLE taxon_match FROM bien;
|
1816
|
GRANT ALL ON TABLE taxon_match TO bien;
|
1817
|
GRANT SELECT ON TABLE taxon_match TO bien_read;
|
1818
|
|
1819
|
|
1820
|
--
|
1821
|
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
|
1822
|
--
|
1823
|
|
1824
|
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
|
1825
|
REVOKE ALL ON TABLE taxon_best_match FROM bien;
|
1826
|
GRANT ALL ON TABLE taxon_best_match TO bien;
|
1827
|
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
|
1828
|
|
1829
|
|
1830
|
--
|
1831
|
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1832
|
--
|
1833
|
|
1834
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
|
1835
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
|
1836
|
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
|
1837
|
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
|
1838
|
|
1839
|
|
1840
|
--
|
1841
|
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1842
|
--
|
1843
|
|
1844
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
|
1845
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
|
1846
|
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
|
1847
|
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
|
1848
|
|
1849
|
|
1850
|
--
|
1851
|
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
|
1852
|
--
|
1853
|
|
1854
|
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
|
1855
|
REVOKE ALL ON TABLE taxon_match_input FROM bien;
|
1856
|
GRANT ALL ON TABLE taxon_match_input TO bien;
|
1857
|
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
|
1858
|
|
1859
|
|
1860
|
--
|
1861
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
|
1862
|
--
|
1863
|
|
1864
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
|
1865
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
|
1866
|
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
|
1867
|
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
|
1868
|
|
1869
|
|
1870
|
--
|
1871
|
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
|
1872
|
--
|
1873
|
|
1874
|
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
|
1875
|
REVOKE ALL ON TABLE taxon_scrub FROM bien;
|
1876
|
GRANT ALL ON TABLE taxon_scrub TO bien;
|
1877
|
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
|
1878
|
|
1879
|
|
1880
|
--
|
1881
|
-- PostgreSQL database dump complete
|
1882
|
--
|
1883
|
|