forked from tripal/tripal_blast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blast_ui.install
300 lines (276 loc) · 8.95 KB
/
blast_ui.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
/**
* @file
* Contains hooks to handle installation of this module.
*
* Specifically, a database table (blastdb) is created to store additional information
* related to blast database nodes such as the name/path to the NCBI BLAST database files
* and the type (protein or nucleotide) of the database.
*/
/**
* Implements hook_install().
*/
function blast_ui_install() {
tripal_create_files_dir('tripal_blast');
}
/**
* Implements hook_uninstall().
*/
function blast_ui_uninstall() {
// Remove all nodes of type blastdb
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
// Restrict to BLASTDB nodes.
->entityCondition('bundle', 'blastdb')
// Restrict to Published nodes.
->propertyCondition('status', 1)
// Restrict to nodes the current user has permission to view.
->addTag('node_access');
$entities = $query->execute();
// Get all BlastDB nodes and delete them
$nodes = node_load_multiple(array_keys($entities['node']));
foreach ($nodes as $node) {
print "Delete node " . $node->title . "\n";
$nrs = node_revision_list($node);
foreach ($nrs as $nr) {
node_revision_delete($nr->vid);
}
node_delete($node->nid);
}
}
/**
* Implements hook_schema().
* Create the blastdb database table for storing addditional info related to blastdb nodes.
*
* NOTE: This hook is called via Drupal magic during the installation process and no longer
* needs to be called explicitly in hook_install().
*/
function blast_ui_schema() {
// A table to keep extra information related to blastdb nodes.
$schema['blastdb'] = array(
'description' => t('The base table for blastdb node'),
'fields' => array(
'nid' => array(
'description' => t('The primary identifier for a node.'),
'type' => 'serial',
'unsigned' => true,
'not null' => true,
),
'name' => array(
'description' => t('The human-readable name of the blast database.'),
'type' => 'varchar',
'length' => 255,
'not null' => true,
),
'path' => array(
'description' => t('The full path and filename prefix of the blast database.'),
'type' => 'varchar',
'length' => 1023,
'not null' => true,
),
'dbtype' => array(
'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
'type' => 'varchar',
'length' => 15,
'not null' => true,
),
'dbxref_id_regex' => array(
'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
'type' => 'text',
),
'dbxref_db_id' => array(
'description' => t('The Database records from this BLAST Database reference.'),
'type' => 'int',
),
'dbxref_linkout_type' => array(
'description' => t('Type of linkout to be used for this database reference.'),
'type' => 'varchar',
'length' => 50,
'not null' => true,
'default' => 'link'
),
'cvitjs_enabled' => array(
'description' => t('Indicate if CViTjs should be used to display hits on a whole genome'),
'type' => 'int',
'not null' => false,
'default' => 0
),
),
'indexes' => array(
'name' => array('name'),
),
'primary key' => array('nid'),
'unique keys' => array(
'nid' => array('nid'),
),
);
// BLAST JOBS
// ------------------------
// Keeps track of additional information related to tripal blast jobs.
$schema['blastjob'] = array(
'description' => t('Keeps track of additional information related to tripal blast jobs.'),
'fields' => array(
'job_id' => array(
'description' => t('The Tripal job_id for the blast job.'),
'type' => 'int',
'unsigned' => true,
'not null' => true,
),
'blast_program' => array(
'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
'type' => 'varchar',
'length' => 20,
'not null' => true,
),
'target_blastdb' => array(
'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
'type' => 'int',
'unsigned' => true,
),
'target_file' => array(
'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
'type' => 'text',
),
'query_file' => array(
'description' => t('The absolute path to the query file.'),
'type' => 'text',
),
'result_filestub' => array(
'description' => t('The absolute path and filename (without extension) of the blast results.'),
'type' => 'text',
),
'options' => array(
'description' => t('A serialized array of options selected for the blast job where the key is the machine name of the option used when calling blast (ie: gapextend) and the value is the value of the option.'),
'type' => 'text',
),
),
'primary key' => array('job_id'),
'foreign keys' => array(
'job_id' => array(
'table' => 'tripal_jobs',
'columns' => array(
'job_id' => 'job_id',
),
),
),
);
return $schema;
}
/**
* Make BlastDB type more readable & support Link-outs for BLAST Hits.
*/
function blast_ui_update_7101() {
// Changing the length of the type field to allow it to be more readable.
db_change_field('blastdb', 'dbtype', 'dbtype',
array(
'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
'type' => 'varchar',
'length' => 15,
'not null' => true,
)
);
// Add fields related to Link-outs
db_add_field(
'blastdb',
'dbxref_id_regex',
array(
'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
'type' => 'text',
)
);
db_add_field(
'blastdb',
'dbxref_db_id',
array(
'description' => t('The Database records from this BLAST Database reference.'),
'type' => 'int',
)
);
}
/**
* Support complex types of link-outs such as GBrowse & JBrowse coordinate links.
*/
function blast_ui_update_7102() {
db_add_field(
'blastdb',
'dbxref_linkout_type',
array(
'description' => t('Type of linkout to be used for this database reference.'),
'type' => 'varchar',
'length' => 50,
'not null' => true,
'default' => 'link'
)
);
}
/**
* Add saving of blast job information for recent job list & resubmit functionality.
*/
function blast_ui_update_7103() {
$schema = array();
// Keeps track of additional information related to tripal blast jobs.
$schema['blastjob'] = array(
'description' => t('Keeps track of additional information related to tripal blast jobs.'),
'fields' => array(
'job_id' => array(
'description' => t('The Tripal job_id for the blast job.'),
'type' => 'int',
'unsigned' => true,
'not null' => true,
),
'blast_program' => array(
'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
'type' => 'varchar',
'length' => 20,
'not null' => true,
),
'target_blastdb' => array(
'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
'type' => 'int',
'unsigned' => true,
),
'target_file' => array(
'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
'type' => 'text',
),
'query_file' => array(
'description' => t('The absolute path to the query file.'),
'type' => 'text',
),
'result_filestub' => array(
'description' => t('The absolute path and filename (without extension) of the blast results.'),
'type' => 'text',
),
'options' => array(
'description' => t('A serialized array of options selected for the blast job where the key is the machine name of the option used when calling blast (ie: gapextend) and the value is the value of the option.'),
'type' => 'text',
),
),
'primary key' => array('job_id'),
'foreign keys' => array(
'job_id' => array(
'table' => 'tripal_jobs',
'columns' => array(
'job_id' => 'job_id',
),
),
),
);
// First create the tables.
db_create_table('blastjob', $schema['blastjob']);
}
/**
* Add fields to blastp table for CViTjs support.
*/
function blast_ui_update_7104() {
db_add_field(
'blastdb',
'cvitjs_enabled',
array(
'description' => t('Indicate if CViTjs should be used to display hits on a whole genome'),
'type' => 'int',
'not null' => false,
'default' => 0
)
);
}