-
Notifications
You must be signed in to change notification settings - Fork 1
/
nd_genotypes.install
141 lines (121 loc) · 4.64 KB
/
nd_genotypes.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
<?php
/**
*
*/
/**
* Implements hook_install().
*/
function nd_genotypes_enable() {
// Determine the PostgreSQL version.
nd_genotypes_recheck_postgresql_version();
// Warn users if they don't have a high enough version.
$pg_version = nd_genotypes_get_postgresql_version();
drupal_set_message(t('Your postgresql version is: %curr', array('%curr' => $pg_version)));
// If not using PostgreSQL 9.3+, give an error
if (is_numeric($pg_version)) {
if ($pg_version < 9.3) {
drupal_set_message(t('This module requires PostgreSQL 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Incompatible postgresql version detected. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
}
else {
drupal_set_message(t('Could not determine current version of PostgreSQL. This module requires 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Unable to determine postgresql version. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
// Ensure we have the vocab terms we would like to use as defaults.
tripal_insert_cv(
'MIXSCV',
'Controlled vocabularies for the MIxS family of metadata checklists. See http://gensc.org/gc_wiki/index.php/MIxS for details on the MIxS checklists.'
);
tripal_insert_cvterm(array(
'id' => 'MVC:0000491',
'name' => 'extracted',
'cv_name' => 'MIXSCV',
'definition' => 'A material separation in which a desired component (the subject) of an input material (the object) is separated from the remainder',
));
tripal_insert_cvterm(array(
'id' => 'RO:0002607',
'name' => 'is marker for',
'cv_name' => 'relationship',
'definition' => 'c is marker for d iff the presence or occurrence of d is correlated with the presence of occurrence of c, and the observation of c is used to infer the presence or occurrence of d. Note that this does not imply that c and d are in a direct causal relationship, as it may be the case that there is a third entity e that stands in a direct causal relationship with c and d.',
));
tripal_insert_cvterm(array(
'id' => 'local:count',
'name' => 'count',
'cv_name' => 'local',
'definition' => 'An integer indicating the number of something in a generic sense.',
));
tripal_insert_cvterm(array(
'id' => 'local:germ_marker_summary',
'name' => 'germ_marker_summary',
'cv_name' => 'local',
'definition' => 'Germplasm Marker Summary',
));
}
/**
* Implements hook_install().
*/
function nd_genotypes_install() {
// Create the genotype_call table for storing genotypes in chado.
chado_create_custom_table(
'genotype_call',
nd_genotypes_genotype_call_schema_template(),
TRUE, NULL, FALSE
);
// Move our module up in the list priority-wise
// so our templates can override default tripal ones.
// First grab the weight of tripal_core.
$tripal_weight = db_query('SELECT weight FROM {system} WHERE name = :name',
array(':name' => 'tripal_core'))->fetchField();
// Next, update our weight to be one heavier, so it moves lower in the execution order.
db_query('UPDATE {system} SET weight = :weight WHERE name = :name',
array(':name' => 'nd_genotypes', ':weight' => $tripal_weight + 1));
// Give them some guidance!
// drupal_set_message('In order to see the genotype and sequence pane on feature nodes, you have to set the type(s) used for variants and markers in the module settings. Click the configure link beside the module name.','warning');
}
/**
* Implements hook_schema().
*/
function nd_genotypes_schema() {
$schema = array();
$schema['ndg_matrix_variant_user_lists'] = array(
'description' => 'Stores user entered variant name lists for use the the genotype matrix.',
'fields' => array(
'list_id' => array(
'description' => 'The primary identifier for variant name list.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE
),
'list' => array(
'description' => 'An array of variant names.',
'pgsql_type' => 'json',
'not null' => TRUE,
),
'created' => array(
'description' => 'The date this list was first entered.',
'type' => 'varchar',
'pgsql_type' => 'date',
),
'num_accessed' => array(
'description' => 'The number of times this list was accessed.',
'type' => 'int',
'default' => 1
),
),
'indexes' => array( ),
'unique keys' => array( ),
'primary key' => array('list_id'),
);
return $schema;
}