forked from tripal/tripal_analysis_expression
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtripal_analysis_expression.install
More file actions
executable file
·474 lines (448 loc) · 14.3 KB
/
tripal_analysis_expression.install
File metadata and controls
executable file
·474 lines (448 loc) · 14.3 KB
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<?php
/**
* @file
* Functions used to install the analysis: expression module.
*/
/**
* Implements hook_requirements().
*
* @ingroup tripal_analysis_expression
*/
function tripal_analysis_expression_requirements($phase) {
$requirements = array();
if ($phase == 'install') {
// Make sure chado is installed.
if (!$GLOBALS["chado_is_installed"]) {
$requirements['tripal_analysis_expression'] = array(
'title' => "tripal_analysis_expression",
'value' => "ERROR: Chado must be installed before this module can be enabled",
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
/**
* Implements install_hook().
*
* Permforms actions when the module is first installed.
*
* @ingroup tripal_analysis_module
*/
function tripal_analysis_expression_install() {
// Get localization function for installation.
$t = get_t();
// Register the analysis.
tripal_register_analysis_child('tripal_analysis_expression');
tripal_analysis_expression_add_cvs();
tripal_analysis_expression_add_cvterms();
// Set default cvs.
tripal_set_default_cv('arraydesignprop', 'type_id', 'arraydesign_property');
tripal_set_default_cv('biomaterialprop', 'type_id', 'biomaterial_property');
tripal_set_default_cv('biomaterial_relationship', 'type_id', 'biomaterial_relationship');
// These variables are used to set how expression information is displayed.
variable_set('chado_feature_expression_hide_expression', 0);
variable_set('chado_feature_expression_hide_biomaterial_labels', 0);
variable_set('chado_feature_expression_limit_label_length', 0);
variable_set('chado_feature_expression_min_num_biomaterials', 0);
variable_set('chado_feature_expression_expression_display', 'column');
variable_set('chado_feature_expression_biomaterial_display_width', 15);
// Make sure the arraydesign, biomateria, and protocol chado tables are a set
// as base tables. This allows the tables to be used as base tables in
// Drupal Views.
$update = db_update('tripal_views')
->fields(array(
'base_table' => 1,
))
->condition('table_name', 'arraydesign', '=')
->execute();
$update = db_update('tripal_views')
->fields(array(
'base_table' => 1,
))
->condition('table_name', 'biomaterial', '=')
->execute();
$update = db_update('tripal_views')
->fields(array(
'base_table' => 1,
))
->condition('table_name', 'protocol', '=')
->execute();
}
/**
* Add controlled vocabulary terms used by the analyis: expression module.
*
* @ingroup tripal_analysis_expression
*/
function tripal_analysis_expression_add_cvs() {
// CVs for the array design content type.
tripal_insert_cv(
'arraydesign_property',
'Contains property terms for arraydesigns.'
);
tripal_insert_cv(
'arraydesign_platformtype',
'Contains microarray platform types.'
);
tripal_insert_cv(
'arraydesign_substratetype',
'Contains microarray substrate types.'
);
// CVs for the protocol content type.
tripal_insert_cv(
'protocol_type',
'Contains protocol type.'
);
// CVs for the biomaterial content type.
tripal_insert_cv(
'biomaterial_property',
'Contains property terms for biomaterials.'
);
tripal_insert_cv(
'biomaterial_relationship',
'Contains types of relationships between biomaterials.'
);
}
/**
* Implements hook_schema().
*
* This function implments the hook schema for arraydesign, biomaterial,
* and protocol content types.
*
* @ingroup tripal_analysis_expression
*/
function tripal_analysis_expression_schema() {
$schema['chado_arraydesign'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'arraydesign_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'arraydesign_id' => array('arraydesign_id'),
),
'unique keys' => array(
'nid_vid' => array('nid', 'vid'),
'vid' => array('vid'),
),
'primary key' => array('nid'),
);
$schema['chado_protocol'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'protocol_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'protocol_id' => array('protocol_id'),
),
'unique keys' => array(
'nid_vid' => array('nid', 'vid'),
'vid' => array('vid'),
),
'primary key' => array('nid'),
);
$schema['chado_biomaterial'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'biomaterial_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'biomaterial_id' => array('biomaterial_id'),
),
'unique keys' => array(
'nid_vid' => array('nid', 'vid'),
'vid' => array('vid'),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* Add cvterms related to the analysis: expression module.
*
* @ingroup tripal_analysis_expression
*/
function tripal_analysis_expression_add_cvterms() {
tripal_insert_cvterm(array(
'name' => 'photochemical_oligo',
'def' => 'in-situ photochemically synthesized oligoes',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'glass',
'def' => 'glass array',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'Acquisition Protocol',
'def' => 'protocol for an acquisition',
'cv_name' => 'protocol_type',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'Array Design Protocol',
'def' => 'protocol for an arraydesign',
'cv_name' => 'protocol_type',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'Assay Protocol',
'def' => 'protocol for an assay',
'cv_name' => 'protocol_type',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'Quantification Protocol',
'def' => 'protocol for a quantification',
'cv_name' => 'protocol_type',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_organism_id',
'def' => 'The organism_id of the organism associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_associated_analysis_id',
'def' => 'The analysis_id of another analysis associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_biosourceprovider_id',
'def' => 'The contact_id of the contact who provided the biomaterial for an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_arraydesign_id',
'def' => 'The arraydesign_id of the arraydesign associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_assay_id',
'def' => 'The assay_id of the assay associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_acquisition_id',
'def' => 'The acquisition_id of the acquisition associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_quantification_id',
'def' => 'The quantification_id of the quantification associated with an expression experiment',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_filetype',
'def' => 'The file type of the expression data to be loaded. The file type can be either column or matrix',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_submit_job',
'def' => 'A value that indicates whether an expression loading job should be submitted.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_fileext',
'def' => 'The file extension of the expression files to be loaded',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_filepath',
'def' => 'The file path of the expression files to be loaded',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_re_start',
'def' => 'A regular expression to specify the line that imediately preceeds the start of expresion data in an expression file.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_re_end',
'def' => 'A regular expression to specify the line that imediately follows the end of expresion data in an expression file.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_feature_uniquenames',
'def' => 'Use feature uniquenames to associate expression data with biomaterials.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_assaydate',
'def' => 'The date an assay is run.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_assay_description',
'def' => 'The description of an assay.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_acquisitiondate',
'def' => 'The date an acquisition is run.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_acquisition_uri',
'def' => 'URI location that describes the acquisition.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_quantificationdate',
'def' => 'The date an quantification is run.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_quantification_uri',
'def' => 'URI location that describes the quantification.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_assay_protocol_id',
'def' => 'The protocol id associated with an assay.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_acquisition_protocol_id',
'def' => 'The protocol id associated with an acquisition.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_quantification_protocol_id',
'def' => 'The protocol id associated with a quantification.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_assay_operator_id',
'def' => 'The operator id associated with an assay.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_expression_quantification_operator_id',
'def' => 'The operator id associated with a quantification.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
// Insert the basic biomaterialprop types. These types are used in the NCBI
// BioSample database.
tripal_insert_cvterm(array(
'name' => 'sample_name',
'def' => 'Sample Name is a name that you choose for the sample. It can have any format, but we suggest that you make it concise, unique and consistent within your lab, and as informative as possible. Every Sample Name from a single Submitter must be unique.',
'cv_name' => 'biomaterial_property',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'sample_title',
'def' => 'Title of the sample.',
'cv_name' => 'biomaterial_property',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'bioproject_accession',
'def' => 'The accession number of the BioProject(s) to which the BioSample belongs. If the BioSample belongs to more than one BioProject, enter multiple bioproject_accession columns. A valid BioProject accession has prefix PRJN, PRJE or PRJD, e.g., PRJNA12345.',
'cv_name' => 'biomaterial_property',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'organism',
'def' => 'The most descriptive organism name for this sample (to the species, if relevant).',
'cv_name' => 'biomaterial_property',
'db_name' => 'tripal',
));
// We use NCBI biosample attributes as to fill the biomaterialprop cv table.
// These attributes can be accessed at the following url.
$url = "http://www.ncbi.nlm.nih.gov/biosample/docs/attributes/?format=xml";
$xml_str = file_get_contents($url);
$xml_obj = simplexml_load_string($xml_str);
foreach ($xml_obj->Attribute as $attribute) {
tripal_insert_cvterm(array(
'name' => $attribute->HarmonizedName,
'def' => $attribute->Description,
'cv_name' => 'biomaterial_property',
'db_name' => 'tripal',
));
}
}
/**
* Implements hook_uninstall().
*
* @ingroup tripal_analysis_expression
*/
function tripal_analysis_expression_uninstall() {
/*
// Get localization function for installation.
$t = get_t();
// Unregister the analysis.
tripal_unregister_analysis_child('tripal_analysis_expression');
*/
}