-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlims.install
342 lines (327 loc) · 9.98 KB
/
lims.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
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
<?php
/**
* @file
* Defines drupal database tables needed by this module.
*/
/**
* Add support for single sample sequence runs.
*/
function lims_update_7001(&$sandbox) {
$spec = array(
'description' => 'The sample_id of the single un-indexed sample.',
'type' => 'int',
'unsigned' => TRUE,
);
db_add_field('lims_seqrun','sample_id',$spec);
db_drop_unique_key('lims_seqrun_samples','by_id');
}
/**
* Bug Fix: Filename is not unique.
*/
function lims_update_7002(&$sandbox) {
db_drop_unique_key('lims_seqrun','file');
}
/**
* Make technology option more specific. Assuming Illumin HiSeq was all HiSeq 2500.
*/
function lims_update_7003(&$sandbox) {
db_query('UPDATE {lims_seqrun} SET technology=:new WHERE technology=:old',
array(':old' => 'Illumina HiSeq', ':new' => 'Illumina HiSeq 2500'));
}
/**
* Add support for quality information.
*/
function lims_update_7004(&$sandbox) {
$table = array(
'description' => 'Additional information for samples including quality stats.',
'fields' => array(
'sample_info_id' => array(
'description' => 'The primary identifier for a piece of sample information.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'sample_id' => array(
'description' => 'The primary identifier for a sample.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'info_label' => array(
'description' => 'A human-readable label for the type of information (e.g. "Number of Bases").',
'type' => 'varchar',
'length' => 150,
),
'value' => array(
'description' => 'The piece of information.',
'type' => 'text',
),
),
'indexes' => array(
'sample_info_label' => array('info_label'),
'sample_id' => array('sample_id'),
),
'unique keys' => array(),
'foreign keys' => array(
'lims_seqrun_samples' => array(
'table' => 'lims_seqrun_samples',
'columns' => array('sample_id' => 'sample_id'),
),
),
'primary key' => array('sample_info_id'),
);
db_create_table('lims_seqrun_samples_info', $table);
}
/**
* Increases the character limit for the Library Type dropdown.
*/
function lims_update_7005(&$sandbox) {
$table = 'lims_seqrun';
$column = 'library_type';
$spec = array(
'description' => 'The method of library preparation for sequencing.',
'type' => 'varchar',
'length' => 100,
);
// Have to specify 2 columns, in this case the column name is staying the same
db_change_field($table,$column,$column,$spec);
}
/**
* Implements hook_schema().
* Defines our database tables to the Drupal Schema API which then
* creates/removes them on installation/uninstallation of our module.
*/
function lims_schema() {
$schema = array();
$schema['lims_seqrun'] = array(
'description' => 'Contains "Sequencing Run" node type-specific data.',
'fields' => array(
'run_id' => array(
'description' => 'The primary identifier for a Sequencing Run.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'The primary identifier for a node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'run_name' => array(
'description' => 'A short, descriptive name for the run.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filename' => array(
'description' => 'The full name of the file including path and extension.',
'type' => 'varchar',
'length' => 500,
'default' => '',
),
'md5sum' => array(
'description' => 'The MD5 hash describing the file.',
'type' => 'varchar',
'length' => 50,
'default' => '',
),
'library_type' => array(
'description' => 'The method of library preparation for sequencing.',
'type' => 'varchar',
'length' => 100,
),
'insert_length' => array(
'description' => 'The length of the insert in base pairs.',
'type' => 'int',
'unsigned' => TRUE,
),
'fragment_length' => array(
'description' => 'The length of the fragment in base pairs.',
'type' => 'int',
'unsigned' => TRUE,
),
'index_type' => array(
'description' => 'The collection of barcodes used to identify samples.',
'type' => 'varchar',
'length' => 30
),
'technology' => array(
'description' => 'The sequencing platform.',
'type' => 'varchar',
'length' => 30
),
'read_type' => array(
'description' => 'The method used to generate the reads.',
'type' => 'varchar',
'length' => 30
),
'description' => array(
'description' => 'Additional details related to a sequencing run.',
'type' => 'text'
),
'samples_fid' => array(
'description' => 'The file id containing sample information.',
'type' => 'int',
'unsigned' => TRUE,
),
'sample_id' => array(
'description' => 'The sample_id of the single un-indexed sample.',
'type' => 'int',
'unsigned' => TRUE,
),
),
'indexes' => array(
'library_type' => array('library_type'),
'library_type' => array('index_type'),
'library_type' => array('technology'),
'library_type' => array('read_type'),
),
'unique keys' => array(
'nid' => array('nid'),
),
'foreign keys' => array(
'node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
'file_managed' => array(
'table' => 'file_managed',
'columns' => array('samples_fid' => 'fid'),
),
'single_sample' => array(
'table' => 'lims_seqrun_samples',
'columns' => array('sample_id' => 'sample_id'),
),
),
'primary key' => array('run_id'),
);
$schema['lims_seqrun_species'] = array(
'description' => 'The species sequenced during a "Sequencing Run".',
'fields' => array(
'run_id' => array(
'description' => 'The primary identifier for a Sequencing Run.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'organism_id' => array(
'description' => 'The primary identifier for a chado organism.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'indexes' => array(
'organism_id' => array('organism_id'),
),
'unique keys' => array(),
'foreign keys' => array(
'chado.organism' => array(
'table' => 'chado.organism',
'columns' => array('organism_id' => 'organism_id'),
),
),
'primary key' => array('run_id', 'organism_id'),
);
$schema['lims_seqrun_samples'] = array(
'description' => 'The samples sequenced during a "Sequencing Run".',
'fields' => array(
'sample_id' => array(
'description' => 'The primary identifier for a sample.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'samples_fid' => array(
'description' => 'The file id containing sample information.',
'type' => 'int',
'unsigned' => TRUE,
),
'index_id' => array(
'description' => 'An identifier for the index.',
'type' => 'varchar',
'length' => 80
),
'index_seq' => array(
'description' => 'The sequence of the index.',
'type' => 'varchar',
'length' => 80
),
'sample_name' => array(
'description' => 'The name of the sample used when sequencing.',
'type' => 'varchar',
'length' => 80
),
'sample_accession' => array(
'description' => 'The KnowPulse Accession of the germplasm the DNA/RNA was extracted from.',
'type' => 'varchar',
'length' => 80
),
'sample_stock_id' => array(
'description' => 'The chado stock_id of the germplasm the DNA/RNA was extracted from.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'plate_well' => array(
'description' => 'The location the sample was placed on the plate.',
'type' => 'varchar',
'length' => 10
),
'sample_description' => array(
'description' => 'A free-text description of the sample.',
'type' => 'text',
),
),
'indexes' => array(
'sample_accession' => array('sample_accession'),
'samples_fid' => array('samples_fid'),
),
'unique keys' => array(
'by_id' => array('samples_fid', 'index_id')
),
'foreign keys' => array( ),
'primary key' => array('sample_id'),
);
$schema['lims_seqrun_samples_info'] = array(
'description' => 'Additional information for samples including quality stats.',
'fields' => array(
'sample_info_id' => array(
'description' => 'The primary identifier for a piece of sample information.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'sample_id' => array(
'description' => 'The primary identifier for a sample.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'info_label' => array(
'description' => 'A human-readable label for the type of information (e.g. "Number of Bases").',
'type' => 'varchar',
'length' => 150,
),
'value' => array(
'description' => 'The piece of information.',
'type' => 'text',
),
),
'indexes' => array(
'sample_info_label' => array('info_label'),
'sample_id' => array('sample_id'),
),
'unique keys' => array(),
'foreign keys' => array(
'lims_seqrun_samples' => array(
'table' => 'lims_seqrun_samples',
'columns' => array('sample_id' => 'sample_id'),
),
),
'primary key' => array('sample_info_id'),
);
return $schema;
}