File: cv-logical-definitions-views.sql

package info (click to toggle)
libchado-perl 1.23-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,976 kB
  • ctags: 10,378
  • sloc: xml: 192,540; sql: 165,945; perl: 28,339; sh: 101; python: 73; makefile: 46
file content (46 lines) | stat: -rw-r--r-- 1,897 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- Cross-products, logical definitions

-- These views are for advanced use - you will only need them if
-- you are loading ontologies that use either advanced obo format 1.2
-- features or OWL DL ontologies. Please read the relevant documentation
-- first

-- keywords: defined classes, OWL, Aristotelian definitions

CREATE OR REPLACE VIEW is_anonymous_cvterm AS
 SELECT cvterm_id
 FROM cvtermprop_with_propname
 WHERE propname='is_anonymous' AND value='1';

CREATE OR REPLACE VIEW cvterm_ldef_intersection AS
SELECT *
FROM 
 cvterm_relationship_with_typename
WHERE
 typename='intersection_of';

COMMENT ON VIEW cvterm_ldef_intersection IS 'for advanced OWL/Description Logic style definitions, chado allows the specification of an equivalentClass using intersection_of links between the defined term and the cross-product';


CREATE OR REPLACE VIEW cvterm_genus AS
SELECT
 i.subject_id AS cvterm_id,
 i.object_id AS genus_id
FROM
 cvterm_ldef_intersection AS i
WHERE
 i.object_id NOT IN (SELECT cvterm_id FROM is_anonymous_cvterm);

COMMENT ON VIEW cvterm_genus IS 'In a logical (cross-product) definition, there is a generic term (genus) and discriminating characteristics. E.g. a biosynthesis (genus) which outputs cysteine (differentia). The genus is the -true- is_a parent';

CREATE OR REPLACE VIEW cvterm_differentium AS
SELECT
 i.subject_id AS cvterm_id,
 diff.*
FROM
 cvterm_ldef_intersection AS i
 INNER JOIN cvterm_relationship AS diff ON (i.object_id=diff.subject_id)
 INNER JOIN is_anonymous_cvterm AS anon  ON (anon.cvterm_id=i.object_id);

COMMENT ON VIEW cvterm_differentium IS 'In a logical (cross-product) definition, there is a generic term (genus) and discriminating characteristics. E.g. a biosynthesis (genus) which outputs cysteine (differentia). Each differentium is a link via a relation to another cvterm which discriminates the defined term from other is_a siblings';