1
SELECT cvterm.cvterm_id AS trait_id,
2
(((((cvterm.name)::text || '|'::text) || (db.name)::text) || ':'::text) || (dbxref.accession)::text) AS trait_name
3
FROM (((((cv
4
JOIN cvprop ON (((cv.cv_id = cvprop.cv_id) AND (cvprop.type_id IN ( SELECT cvterm_1.cvterm_id
5
FROM cvterm cvterm_1
6
WHERE ((cvterm_1.name)::text = 'trait_ontology'::text))))))
7
JOIN cvterm ON ((cvprop.cv_id = cvterm.cv_id)))
8
JOIN dbxref USING (dbxref_id))
9
JOIN db ON ((dbxref.db_id = db.db_id)))
10
LEFT JOIN cvterm_relationship is_variable ON (((cvterm.cvterm_id = is_variable.subject_id) AND (is_variable.type_id = ( SELECT cvterm_1.cvterm_id
11
FROM cvterm cvterm_1
12
WHERE ((cvterm_1.name)::text = 'VARIABLE_OF'::text))))))
13
WHERE (is_variable.subject_id IS NOT NULL)
14
GROUP BY cvterm.cvterm_id, (((((cvterm.name)::text || '|'::text) || (db.name)::text) || ':'::text) || (dbxref.accession)::text)
15
UNION
16
SELECT cvterm.cvterm_id AS trait_id,
17
(((((cvterm.name)::text || '|'::text) || (db.name)::text) || ':'::text) || (dbxref.accession)::text) AS trait_name
18
FROM (((((cv
19
JOIN cvprop ON (((cv.cv_id = cvprop.cv_id) AND (cvprop.type_id IN ( SELECT cvterm_1.cvterm_id
20
FROM cvterm cvterm_1
21
WHERE ((cvterm_1.name)::text = 'composed_trait_ontology'::text))))))
22
JOIN cvterm ON ((cvprop.cv_id = cvterm.cv_id)))
23
JOIN dbxref USING (dbxref_id))
24
JOIN db ON ((dbxref.db_id = db.db_id)))
25
LEFT JOIN cvterm_relationship is_subject ON ((cvterm.cvterm_id = is_subject.subject_id)))
26
WHERE (is_subject.subject_id IS NOT NULL)
27
GROUP BY cvterm.cvterm_id, (((((cvterm.name)::text || '|'::text) || (db.name)::text) || ':'::text) || (dbxref.accession)::text)
28
ORDER BY 2;