-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtripal_analysis_blast.install
More file actions
executable file
·648 lines (605 loc) · 22.3 KB
/
tripal_analysis_blast.install
File metadata and controls
executable file
·648 lines (605 loc) · 22.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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<?php
/**
* @file
* Contains functions used to install/uninstall tripal_analysis_blast.
*/
/*******************************************************************************
* Implementation of hook_install().
*/
function tripal_analysis_blast_install() {
// For Tripal v2 backwards compatibility, register this
// module as an analysis.
if (module_exists('tripal_analysis')) {
tripal_register_analysis_child('tripal_analysis_blast');
}
// Add cvterms.
tripal_analysis_blast_add_cvterms();
// Add custom tables.
tripal_analysis_blast_add_blast_organisms_table();
tripal_analysis_blast_add_blast_hit_data_table();
// Create default parser for swissprot, DB:genbank, and go-seqdb.
$sql_db = "SELECT db_id, name FROM {db} WHERE lower(name) like :name";
$sql_parser = "INSERT INTO {tripal_analysis_blast} ".
" (db_id, displayname, regex_hit_id, regex_hit_def, ".
" regex_hit_accession, genbank_style, regex_hit_organism) ".
"VALUES (:db_id, :displayname, :regex_hit_id, :regex_hit_def, :regex_hit_accession, :genbank_style, :regex_hit_organism)";
// Add swissprot parser.
$results = chado_query($sql_db, array(':name' => "%swissprot%"));
foreach ($results AS $db) {
db_query(
$sql_parser,
array(
':db_id' => $db->db_id,
':displayname' => 'ExPASy Swissprot',
':regex_hit_id' => '^sp\|.*?\|(.*?)\s.*?$',
':regex_hit_def' => '^sp\|.*?\|.*?\s(.*)$',
':regex_hit_accession' => 'sp\|(.*?)\|.*?\s.*?$',
':genbank_style' => 0,
':regex_hit_organism' => '^.*?OS=(.*?)\s\w\w=.*$')
);
}
// Add trembl parser.
$results = chado_query($sql_db, array(':name' => "%trembl%"));
foreach ($results AS $db) {
db_query(
$sql_parser,
array(
':db_id' => $db->db_id,
':displayname' => 'ExPASy TrEMBL',
':regex_hit_id' => '^.*?\|(.*?)\s.*?$',
':regex_hit_def' => '^.*?\|.*?\s(.*)$',
':regex_hit_accession' => '^(.*?)\|.*?\s.*?$',
':genbank_style' => 0,
':regex_hit_organism' => '^.*?OS=(.*?)\s\w\w=.*$')
);
}
// Add NCBI genbank parser.
$results = chado_query($sql_db, array(':name' => "%genbank%"));
foreach ($results AS $db) {
db_query(
$sql_parser,
array(
':db_id' => $db->db_id,
':displayname' => 'Genbank',
':regex_hit_id' => '',
':regex_hit_def' => '',
':regex_hit_accession' => '',
':genbank_style' => 1,
':regex_hit_organism' => '')
);
}
// Create 'Analysis Blast' entity type
tripal_analysis_blast_create_entity_type();
}
/*******************************************************************************
* Implementation of hook_uninstall().
*/
function tripal_analysis_blast_uninstall() {
// Delete all information associate with the module
// Drupal complains when the user tries to uninstall tripal_analysis
// and tripal_analysis_blast at the same time. This is because Drupal drops
// the {tripal_analysis} table before we can delete anything from it. Thus,
// we perform a db_table_exists() check before the deletion
// For Tripal v2 backwards compatibility, unregister this
// module as an analysis.
if (module_exists('tripal_analysis')) {
tripal_unregister_analysis_child('tripal_analysis_blast');
}
// Delete module's variables from variables table.
db_query("DELETE FROM {variable} WHERE name = :name",
array('name' => 'tripal_analysis_blast_setting'));
}
/**
* Add the blast_organism table to the Chado database as a custom table.
*
* The blast_organisms table is used to help when integrating with
* Drupal Views. Trying to get a list of organisms for a drop down
* in Views would require querying the blast_hit_data table which has
* a lot of redunancy and takes too long. This table was created
* to speed up the query the popluates a drop down list
*/
function tripal_analysis_blast_add_blast_organisms_table() {
$schema = array(
'table' => 'blast_organisms',
'fields' => array(
'blast_org_id' => array('type' => 'serial', 'not null' => TRUE),
'blast_org_name' => array('type' => 'varchar', 'length' => 1025, 'not null' => FALSE),
),
'primary key' => array('blast_org_id'),
'indexes' => array(
'blast_org_name_idx' => array('blast_org_name'),
),
'unique keys' => array(
'blast_org_name_uq' => array('blast_org_name'),
)
);
// Note: we have to set the $redirect argument below to FALSE or it
// breaks the installation.
chado_create_custom_table('blast_organisms', $schema, TRUE, NULL, FALSE);
}
/**
* Add the blast_hit_data custom table to the chado schema.
*/
function tripal_analysis_blast_add_blast_hit_data_table() {
$schema = array(
'table' => 'blast_hit_data',
'fields' => array(
'analysisfeature_id' => array('type' => 'int', 'not null' => TRUE),
'analysis_id' => array('type' => 'int', 'not null' => TRUE),
'feature_id' => array('type' => 'int', 'not null' => TRUE),
'db_id' => array('type' => 'int', 'not null' => TRUE),
'hit_num' => array('type' => 'int', 'not null' => TRUE),
'hit_name' => array('type' => 'varchar', 'length' => 1025, 'not null' => FALSE),
'hit_url' => array('type' => 'text', 'not null' => FALSE),
'hit_description' => array('type' => 'text', 'not null' => FALSE),
'hit_organism' => array('type' => 'varchar', 'length' => 1025, 'not null' => FALSE),
'blast_org_id' => array('type' => 'int', 'not null' => FALSE),
'hit_accession' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE),
'hit_best_eval' => array('type' => 'float', 'size' => 'big', 'not null' => FALSE),
'hit_best_score' => array('type' => 'float', 'size' => 'big', 'not null' => FALSE),
'hit_pid' => array('type' => 'float', 'size' => 'big', 'not null' => FALSE),
),
'indexes' => array(
'analysisfeature_id' => array('analysisfeature_id'),
'feature_id' => array('feature_id'),
'analysis_id' => array('analysis_id'),
'blast_org_id' => array('blast_org_id'),
'db_id' => array('db_id'),
'hit_organism' => array('hit_organism'),
'hit_name' => array('hit_organism'),
'hit_accession' => array('hit_accession'),
'hit_best_eval' => array('hit_best_eval'),
),
'foreign keys' => array(
'db' => array(
'table' => 'db',
'columns' => array(
'db_id' => 'db_id',
),
),
'analysisfeature' => array(
'table' => 'analysisfeature',
'columns' => array(
'analysisfeature_id' => 'analysisfeature_id',
),
),
'analysis' => array(
'table' => 'analysis',
'columns' => array(
'analysis_id' => 'analysis_id',
),
),
'feature' => array(
'table' => 'feature',
'columns' => array(
'feature_id' => 'feature_id',
),
),
'blast_organisms' => array(
'table' => 'blast_organisms',
'columns' => array(
'blast_org_id' => 'blast_org_id',
),
),
)
);
// Note: we have to set the $redirect argument below to FALSE or it
// breaks the installation.
chado_create_custom_table('blast_hit_data', $schema, TRUE, NULL, FALSE);
}
/*******************************************************************************
* Implementation of hook_schema(). This table stores the parsers for blast xml
* xml results.
*/
function tripal_analysis_blast_schema() {
$schema = array();
$schema['tripal_analysis_blast'] = array(
'fields' => array(
'db_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'displayname' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, ),
'regex_hit_id' => array('type' => 'varchar', 'length' => 255, ),
'regex_hit_def' => array('type' => 'varchar', 'length' => 255, ),
'regex_hit_accession' => array('type' => 'varchar', 'length' => 255, ),
'regex_hit_organism' => array('type' => 'varchar', 'length' => 255, ),
'hit_organism' => array('type' => 'varchar', 'length' => 255, ),
'genbank_style' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
),
'indexes' => array(
'db_id' => array('db_id')
),
'primary key' => array('db_id'),
);
return $schema;
}
/*******************************************************************************
* Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
* Analysis' are enabled before installation
*/
function tripal_analysis_blast_requirements($phase) {
$requirements = array();
if ($phase == 'install') {
// make sure chado is installed
if (!$GLOBALS["chado_is_installed"]) {
$requirements ['tripal_feature'] = array(
'title' => "t ripal_feature",
'value' => "ERROR: Chado must be installed before this module can be enabled",
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
/*******************************************************************************
* Provide update script for adding new cvterms
*/
function tripal_analysis_blast_update_7200() {
if (chado_table_exists('tripal_analysis_blast')) {
try {
$sql = "ALTER TABLE chado.tripal_analysis_blast SET schema public";
db_query($sql);
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to change the vocabulary from tripal_library_types to library_type: '. $error);
}
}
}
/*******************************************************************************
* Function for adding cvterms
*/
function tripal_analysis_blast_add_cvterms() {
// Add the cvterms for the anlysisprop table
tripal_insert_cvterm(array(
'name' => 'analysis_blast_settings',
'definition' => 'Settings of a blast analysis, including db_id, output file, and run parameters separated by a bar |',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastdb',
'def' => 'The database used for blasting',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastfile',
'def' => 'The input file or directory that contains the XML blast output',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastparameters',
'def' => 'The parameters used when performing blast.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_no_parsed',
'def' => 'Indicates if the input file should be parsed to map results to features',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_query_re',
'def' => 'The regular expression for finding the feature name in the query definition line of the blast results',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_query_type',
'def' => 'The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_query_uniquename',
'def' => 'Indicates if the matched name in the query definition line of the blast results is feature uniquename',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastfile_ext',
'def' => 'Indicates the extension of the blast files. This is required if the blastfile setting is a directory.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_is_concat',
'def' => 'Indicates if the blast results XML file is a series of concatenated XML results. Such is the case, for example, if Blast2GO was used to perform the analysis.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_search_keywords',
'def' => 'Indicates the fields that should be stored in the analysisfeatureprop table for the blast results.',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
// add cvterms for the blast search keywords
tripal_insert_cvterm(array(
'name' => 'blast_match_name',
'def' => 'The blast match name',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_match_description',
'def' => 'The match description',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_match_organism',
'def' => 'The organism the blast match belongs to',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_match_accession',
'def' => 'The accession of the blast match',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_database',
'def' => 'The name of the database blasted against',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_evalue',
'def' => 'The blast match e-valuue score (best e-value if multiple HSPs',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_score',
'def' => 'The blast hit match bit score',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'blast_pid',
'def' => 'The blast hit match percent identity',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
// Add cvterm 'analysis_blast_output_iteration_hits' for inserting into featureprop table
tripal_insert_cvterm(array(
'name' => 'analysis_blast_output_iteration_hits',
'def' => 'Hits of a blast '.
'output iteration. Each iteration corresponds to a chado feature, and is '.
'the content between <iteration> and </iteration> tags in the blast xml '.
'output file. This cvterm represents all hits in the iteration',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
// Add cvterms for the best hits report
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_query',
'def' => 'query name of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_match',
'def' => 'match name of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_description',
'def' => 'description of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_evalue',
'def' => 'evalue of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_identity',
'def' => 'identity (%) of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_besthit_length',
'def' => 'length of the best hit associated with a feature and a blast analysis ',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
}
/**
* Create Analysis Blast Entity Type
*/
function tripal_analysis_blast_create_entity_type () {
// Add the vocabulary term.
$term = tripal_insert_cvterm(array(
'id' => 'format:1333',
'name' => 'BLAST results',
'cv_name' => 'EDAM',
'definition' => 'Format of results of a sequence database search using some variant of BLAST. This includes score data, alignment data and summary table.',
));
// Next add the content type
$cvterm = chado_get_cvterm(['id' => 'format:1333']);
$args = array(
'vocabulary' => 'format',
'accession' => '1333',
'term_name' => 'BLAST results',
'storage_args' => array(
'data_table' => 'analysis',
'type_linker_table' => 'analysisprop',
'type_column' => 'type_id',
'type_value' => 'blast_analysis'
)
);
# Make sure the 'format' cv is in the db2cv_mview materialized view
$mview_id = tripal_get_mview_id('db2cv_mview');
tripal_populate_mview($mview_id);
$bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
if (!$bundle) {
if (!tripal_create_bundle($args)) {
$msg = t('Error encountered creating !type Content Type.', ['!type' => $args['term_name']]);
throw new Exception($msg);
}
}
}
/**
* Adds missing foreign key constraints
*
*/
function tripal_analysis_blast_update_7201() {
// There was a bug in the function for creating a custom table that
// kept foreign key constraints from being added. So, we need to add those
// to keep from error messages appear, we will drop the FK if it already
// exists and then re-add it.
try {
db_query('
ALTER TABLE chado.blast_hit_data
DROP CONSTRAINT IF EXISTS blast_hit_data_db_id_fkey CASCADE
');
db_query('
ALTER TABLE chado.blast_hit_data
DROP CONSTRAINT IF EXISTS blast_hit_data_analysisfeature_id_fkey CASCADE
');
db_query('
ALTER TABLE chado.blast_hit_data
DROP CONSTRAINT IF EXISTS blast_hit_data_analysis_id_fkey CASCADE
');
db_query('
ALTER TABLE chado.blast_hit_data
DROP CONSTRAINT IF EXISTS blast_hit_data_feature_id_fkey CASCADE
');
db_query('
ALTER TABLE chado.blast_hit_data
DROP CONSTRAINT IF EXISTS blast_hit_data_blast_org_id_fkey CASCADE
');
db_query('
ALTER TABLE chado.blast_hit_data
ADD CONSTRAINT blast_hit_data_db_id_fkey
FOREIGN KEY (db_id) REFERENCES chado.db (db_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
');
db_query('
ALTER TABLE chado.blast_hit_data
ADD CONSTRAINT blast_hit_data_analysisfeature_id_fkey
FOREIGN KEY (analysisfeature_id) REFERENCES chado.analysisfeature (analysisfeature_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
');
db_query('
ALTER TABLE chado.blast_hit_data
ADD CONSTRAINT blast_hit_data_analysis_id_fkey
FOREIGN KEY (analysis_id) REFERENCES chado.analysis (analysis_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
');
db_query('
ALTER TABLE chado.blast_hit_data
ADD CONSTRAINT blast_hit_data_feature_id_fkey
FOREIGN KEY (feature_id) REFERENCES chado.feature (feature_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
');
db_query('
ALTER TABLE chado.blast_hit_data
ADD CONSTRAINT blast_hit_data_blast_org_id_fkey
FOREIGN KEY (blast_org_id) REFERENCES chado.blast_organisms (blast_org_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
');
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to update foriegn key: '. $error);
}
}
/**
* Adds the blast property terms to the correct vocabulary.
*
*/
function tripal_analysis_blast_update_7202() {
try {
module_load_include('inc', 'tripal_cv', 'api/tripal_cv.api');
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastdb',
'def' => 'The database used for blasting',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
tripal_insert_cvterm(array(
'name' => 'analysis_blast_blastfile',
'def' => 'The input file or directory that contains the XML blast output',
'cv_name' => 'tripal',
'db_name' => 'tripal',
));
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to update terms: '. $error);
}
}
/**
* Adds the Tripal v3 vocabulary term for blast results.
*/
function tripal_analysis_blast_update_7300() {
try {
$term = tripal_insert_cvterm(array(
'id' => 'format:1333',
'name' => 'BLAST results',
'cv_name' => 'EDAM',
'definition' => 'Format of results of a sequence database search using some variant of BLAST. This includes score data, alignment data and summary table.',
));
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to update terms: '. $error);
}
}
/**
* Create Blast results entity type.
*/
function tripal_analysis_blast_update_7301() {
try {
tripal_analysis_blast_create_entity_type();
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Failed to create entity type [Blast results]: '. $error);
}
}
/**
* Add cvterm mapping for the 'BLAST results' entity type
*/
function tripal_analysis_blast_update_7302() {
try {
$identifier = array(
'cv_id' => array('name' => 'EDAM'),
'name' => 'BLAST results'
);
$cvterm = tripal_get_cvterm($identifier);
tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'analysis', NULL);
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Could not perform update: '. $error);
}
}
/**
* Turn on auto_attach for the blast field to prevent AJAX problems on entity first load.
*/
function tripal_analysis_blast_update_7303() {
try {
$bundles = field_info_instances('TripalEntity');
foreach ($bundles as $bundle_name => $fields) {
$instance_info = field_info_instance('TripalEntity', 'format__blast_results', $bundle_name);
if ($instance_info) {
$instance_info['settings']['auto_attach'] = TRUE;
field_update_instance($instance_info);
}
}
}
catch (\PDOException $e) {
$error = $e->getMessage();
throw new DrupalUpdateException('Could not perform update: '. $error);
}
}