-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtripal_cv_xray.install
179 lines (160 loc) · 4.07 KB
/
tripal_cv_xray.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
* Hook Schema.
*/
function tripal_cv_xray_schema() {
$schema = [];
$schema['tripal_cvterm_entity_linker'] = tripal_cv_xray_cvterm_entity_linker();
$schema['tripal_cv_xray_config'] = tripal_cv_xray_entity_config_schema();
return $schema;
}
function tripal_cv_xray_install() {
tripal_insert_cvterm([
'id' => 'data:2353',
'name' => 'Ontological data',
'cv_name' => 'EDAM',
'definition' => 'An identifier of a biological or bioinformatics database.',
]);
}
/**
* Get config table. This table is necessary for adding entities to the index
* dynamically via hooks.
*
* @return array
*/
function tripal_cv_xray_entity_config_schema() {
$schema = [
'description' => 'cvxray admin table. Tracks what entities and what CVs should be indexed.',
'fields' => [
'cv_xray_config_id' => [
'type' => 'serial',
'not null' => TRUE,
],
'shortname' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'chado db name (cv shortname)',
],
'bundle_id' => [
'type' => 'int',
'description' => 'tripal bundle ID',
'not null' => TRUE,
],
],
'foreign keys' => [
'bundle_id' => [
'table' => 'tripal_bundle',
'columns' => [
'uid' => 'id',
],
],
],
];
return $schema;
}
/**
* Get linker table schema.
*
* @return array
*/
function tripal_cv_xray_cvterm_entity_linker() {
$schema = [
'description' => 'This table is used for tracking cvterm annotations.',
'fields' => [
'cvterm_entity_id' => [
'type' => 'serial',
'not null' => TRUE,
],
'cvterm_id' => [
'description' => 'chado cvterm id',
'type' => 'int',
'not null' => TRUE,
],
'database' => [
'description' => 'Database shortname for term.',
'type' => 'varchar',
'not null' => TRUE,
],
'accession' => [
'description' => 'Term accession.',
'type' => 'varchar',
'not null' => TRUE,
],
'entity_id' => [
'description' => 'entity id',
'type' => 'int',
'not null' => TRUE,
],
],
'primary key' => [
'cvterm_entity_id',
],
'indexes' => [
'cvterm_id_index' => ['cvterm_id'],
'entity_id_index' => ['entity_id'],
'accession_index' => ['accession'],
'db_index' => ['database'],
],
'foreign keys' => [
'cvterm' => [
'table' => 'cvterm',
'columns' => [
'uid' => 'cvterm_id',
],
],
'entity_id' => [
'table' => 'tripal_entity',
'columns' => [
'uid' => 'id',
],
],
],
];
return $schema;
}
/**
* Implements hook_uninstall.
*/
function tripal_cv_xray_uninstall() {
if (db_table_exists('tripal_cvterm_entity_index')) {
db_drop_table("tripal_cvterm_entity_index");
}
if (db_table_exists('tripal_cvterm_entity_linker')) {
db_drop_table('tripal_cvterm_entity_linker');
}
}
/**
* Create linker table if missing.
*/
function tripal_cv_xray_update_7100() {
if (!db_table_exists('tripal_cvterm_entity_linker')) {
$schema = tripal_cvterm_entity_linker();
db_create_table('tripal_cvterm_entity_linker', $schema);
}
}
/**
* Add the ontological data term.
*/
function tripal_cv_xray_update_7101() {
//https://www.ebi.ac.uk/ols/ontologies/edam/terms?iri=http%3A%2F%2Fedamontology.org%2Fdata_2353
tripal_insert_cvterm([
'id' => 'data:2353',
'name' => 'Ontological data',
'cv_name' => 'EDAM',
'definition' => 'An identifier of a biological or bioinformatics database.',
]);
}
/**
* Creates the configuration table used for hooks. Remove the unused index
* table (we use the linker table instead.)
*/
function tripal_cv_xray_update_7102() {
if (!db_table_exists('tripal_cv_xray_config')) {
$schema = tripal_cv_xray_entity_config_schema();
db_create_table('tripal_cv_xray_config', $schema);
}
if (db_table_exists('tripal_cvterm_entity_index')) {
db_drop_table("tripal_cvterm_entity_index");
}
}