-
Notifications
You must be signed in to change notification settings - Fork 13
/
tripal_blast.install
executable file
·106 lines (98 loc) · 3.25 KB
/
tripal_blast.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
<?php
/**
* @file
* .install file of Tripal BLAST.
*
* 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.
*/
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\tripal_blast\TripalBlastDatabaseInterface;
/**
* Implements hook_install().
*
* @see tripal.info
*/
function tripal_blast_install() {
// Retreives the Drupal relative directory for a Tripal module.
// @upgrade tripal_create_files_dir('tripal_blast');
}
/**
* Implements hook_uninstall().
*/
function tripal_blast_uninstall() {
// Delete configuration entity.
$database_entity = \Drupal::entityTypeManager()->getStorage('tripalblastdatabase');
$entity_query = $database_entity->getQuery();
$blast_db = $entity_query
->condition('id', '>', 0)
->execute();
// Load multiples or single item load($id)
$db = $database_entity->loadMultiple($blast_db);
foreach($db as $id => $db_obj) {
$db_id = $db_obj->getId();
$databae_entity->load($db_id)
->delete();
}
}
/**
* Implements hook_schema().
* Create the blast job database table for storing blast job requests.
*/
function tripal_blast_schema() {
// 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;
}