-
Notifications
You must be signed in to change notification settings - Fork 3
/
database_administration.php
executable file
·404 lines (327 loc) · 19.4 KB
/
database_administration.php
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
<?php
$body_class = "no-sidebar"; // This page does not have a sidebar
require 'php_header.php'; // Require the PHP header housing required PHP functions
require 'html_header.php'; // Require the HTML header housing the HTML structure of the page
?>
</div>
<!-- Main -->
<div class="wrapper">
<div class="container" id="main">
<!-- Content -->
<article id="content">
<header>
<h2>Need to make some changes?</h2>
<p>The database administration options below let you add, remove and modify databases to your heart's content.</p>
</header>
<?php
// If the user is an administrator
if (is_user_administrator()) {
#############################################
# FETCH AVAILABLE GEMINI DBS
#############################################
$databases = parse_all_available_database_files();
#############################################
# FETCH ANNOTATION INFORMATION
#############################################
// Fetch all annotations from the DB (including inactive ones)
$annotations = fetch_all_annotations("all");
if ($annotations === false || count(array_keys($annotations)) == 0) {
error("Problem fetching Seave annotations. Please try again.");
}
#############################################
// Disk space available
echo "<h3 style=\"text-align:center;\">Disk space currently in use: <br>".storage_space("used")."/".storage_space("total")."</h3><br>";
#############################################
# SUCCESS/ERROR MESSAGES
#############################################
if_set_display_error("db_admin_new_db_bad_url", "The URL your specified does not exist (did not return 200).");
if (isset($_SESSION["db_admin_new_db_download_fail"])) { if_set_display_error("db_admin_new_db_download_fail", "Error downloading database file:<br>".$_SESSION["db_admin_new_db_download_fail"]); }
if_set_display_error("db_admin_new_db_bad_filename", "The database file you submitted does not end with \".db\" and was therefore not added.");
if_set_display_error("db_admin_new_db_db_exists", "A database with that filename already exists on Seave. Please delete it first before importing again.");
if_set_display_error("db_admin_new_db_group_doesnt_exist", "The group specified doesn't exist.");
if (isset($_SESSION["db_admin_delete_db_fail"])) { if_set_display_error("db_admin_delete_db_fail", "Could not delete database file:<br>".$_SESSION["db_admin_delete_db_fail"]); }
if_set_display_error("db_admin_db_summary_no_db", "The database you specified to regenerate a report for does not exist.");
if (isset($_SESSION["db_admin_db_summary_failed"])) { if_set_display_error("db_admin_db_summary_failed", "Could not regenerate summary report for the database:<br>".$_SESSION["db_admin_db_summary_failed"]); }
if_set_display_error("db_admin_db_annotation_large_ped", "The PED file specified is too large (over 1MB).");
if_set_display_error("db_admin_db_annotation_no_ped", "The file you uploaded does not end with .ped.");
if_set_display_error("db_admin_db_annotation_failed", "Could not update annotation. GEMINI error.");
if_set_display_error("db_admin_db_rename_nonexistant_db", "The database you selected to rename does not exist.");
if_set_display_error("db_admin_db_rename_no_new_db", "You did not submit a new database name to replace the old one or it did not end with .db.");
if_set_display_error("db_admin_db_rename_new_db_already_exists", "The name database name you specified already exists. Please choose another.");
if_set_display_error("db_admin_db_rename_fail", "Problem renaming the database.");
if_set_display_error("db_admin_db_move_nonexistant_group", "The group you specified does not exist.");
if_set_display_error("db_admin_db_move_nonexistant_db", "The database you specified does not exist.");
if_set_display_error("db_admin_db_move_already_exists", "A database with the same filename as the one you are moving already exists in the group you specified.");
if_set_display_error("db_admin_db_move_fail", "Could not move the database.");
if_set_display_error("db_admin_could_not_fetch_annotation_information", "Problem fetching annotation information.");
if (isset($_SESSION["db_admin_delete_db_success"])) { if_set_display_success("db_admin_delete_db_success", "Successfully deleted database file: <br>".$_SESSION["db_admin_delete_db_success"]); }
if (isset($_SESSION["db_admin_db_summary_success"])) { if_set_display_success("db_admin_db_summary_success", "Successfully regenerated summary report for the database:<br>".$_SESSION["db_admin_db_summary_success"]); }
if (isset($_SESSION["db_admin_db_annotation_success"])) { if_set_display_success("db_admin_db_annotation_success", "Successfully updated the pedigree annotation for the database:<br>".$_SESSION["db_admin_db_annotation_success"]); }
if (isset($_SESSION["db_admin_db_rename_success"])) { if_set_display_success("db_admin_db_rename_success", "Successfully renamed the database:<br>".$_SESSION["db_admin_db_rename_success"]); }
if (isset($_SESSION["db_admin_db_move_success"])) { if_set_display_success("db_admin_db_move_success", "Successfully moved the database:<br>".$_SESSION["db_admin_db_move_success"]); }
if (isset($_SESSION["db_admin_new_db_success"])) { if_set_display_success("db_admin_new_db_success", "Successfully downloaded database file:<br>".$_SESSION["db_admin_new_db_success"]); }
#############################################
# VIEW REQUESTED ANNOTATION INFORMATION
#############################################
if (isset($_SESSION["db_admin_annotation_information"])) {
success("Showing annotation history for the annotation: \"".$_SESSION["db_admin_annotation"]."\"");
annotation_history_table($_SESSION["db_admin_annotation_information"]);
unset($_SESSION["db_admin_annotation"]);
unset($_SESSION["db_admin_annotation_information"]);
}
#############################################
# ADD A DATABASE FORM
#############################################
echo "<div class=\"row\">";
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2>Add a new database</h2>";
echo "<p>New databases must be added by specifying a URL to the database file. This functionality is targeted towards imports from DNA Nexus or Dropbox which allow you to generate a download link your database. Databases will be placed in the default Seave group.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>URL to database</h4>";
echo "<input type=\"text\" name=\"db_url\" placeholder=\"http://www.example.com/database.db\">";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Group to import into</h4>";
echo "<select name=\"add_db_group\">";
// Go through each group
foreach (array_keys($databases) as $group) {
echo "<option value=\"".$group."\">".$group."</option>";
}
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Add database\" /></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "<p style=\"color: red;\">Important: databases must end with a .db suffix. Once you press the submit button below, you will need to wait for the server to download the file you specified. Please DO NOT refresh or stop the page during this time, this process could take quite some time if the database you specified is large.</p>";
echo "</section>";
#############################################
# DELETE DATABASE FORM
#############################################
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2>Delete a database</h2>";
echo "<p>If you no longer require a database or something went wrong with a database import, you may wish to delete a database. Simply select the database you wish to delete below.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Database to delete</h4>";
echo "<select name=\"delete_db_name\">";
// Go through each group
foreach (array_keys($databases) as $group) {
// Go through each database file
foreach ($databases[$group] as $database) {
$db_name_for_dropdown = $group." - ".$database; // Remove the path for printing to the dropdown as the db name
echo "<option value=\"".$group."/".$database."\">".$db_name_for_dropdown."</option>";
}
}
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Delete database\" /></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "<p style=\"color: red;\">Caution: once a database is deleted it cannot be restored.</p>";
echo "</section>";
echo "</div>";
#############################################
# ANNOTATE DATABASE FORM
#############################################
echo "<div class=\"row\">";
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2 style=\"padding-top:10px;\">Annotate a database</h2>";
echo "<p>To unlock the family-based analysis types within Seave you need to specify familial information.</p>";
echo "<p>This is done using a pedigree file (.ped) and the form below allows you to upload a PED file to annotate any database. After the database has been successfully annotated with your pedigree file, the familial analysis page will appear upon selecting the database for analysis.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\" enctype=\"multipart/form-data\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Database to annotate</h4>";
echo "<select name=\"database_dropdown\">";
// Go through each group
foreach (array_keys($databases) as $group) {
// Go through each database file
foreach ($databases[$group] as $database) {
$db_name_for_dropdown = $group." - ".$database; // Remove the path for printing to the dropdown as the db name
echo "<option value=\"".$group."/".$database."\">".$db_name_for_dropdown."</option>";
}
}
echo "</select>";
echo "</div>";
echo "<div class=\"12u\">";
echo "<h4>Upload pedigree file</h4>";
echo "<input type=\"file\" name=\"pedfile\" id=\"pedfile\"><br>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Annotate database\"></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "</section>";
#############################################
# RENAME A DATABASE
#############################################
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2 style=\"padding-top:10px;\">Rename a database</h2>";
echo "<p>If you need to rename a database, select the database to be renamed from the dropdown below and type in a new name in the box below the dropdown.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\" enctype=\"multipart/form-data\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Database to rename</h4>";
echo "<select name=\"database_dropdown\">";
// Go through each group
foreach (array_keys($databases) as $group) {
// Go through each database file
foreach ($databases[$group] as $database) {
$db_name_for_dropdown = $group." - ".$database; // Remove the path for printing to the dropdown as the db name
echo "<option value=\"".$group."/".$database."\">".$db_name_for_dropdown."</option>";
}
}
echo "</select>";
echo "</div>";
echo "<div class=\"12u\">";
echo "<h4>New filename</h4>";
echo "<input type=\"text\" name=\"db_new_name\" placeholder=\"new_name.db\">";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Rename database\"></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "<p style=\"color: red;\">Important: databases must end with a .db suffix.</p>";
echo "</section>";
echo "</div>";
#############################################
# RE-GENERATE DATABASE SUMMARY
#############################################
echo "<div class=\"row\">";
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2 style=\"padding-top:10px;\">Re-generate a summary</h2>";
echo "<p>Database summary reports are automatically generated when a database is imported. However, if changes to Seave are made to modify this report, you may want an updated report.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Database to generate a summary for</h4>";
echo "<select name=\"regenerate_summary_db_name\">";
// Go through each group
foreach (array_keys($databases) as $group) {
// Go through each database file
foreach ($databases[$group] as $database) {
$db_name_for_dropdown = $group." - ".$database; // Remove the path for printing to the dropdown as the db name
echo "<option value=\"".$group."/".$database."\">".$db_name_for_dropdown."</option>";
}
}
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Re-generate summary\" /></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "<p style=\"color: red;\">Important: this report may take several minutes to generate, during which time Seave will be unusable for you.</p>";
echo "</section>";
#############################################
# MOVE DATABASE FROM ONE GROUP TO ANOTHER
#############################################
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2 style=\"padding-top:10px;\">Move database</h2>";
echo "<p>Databases on Seave belong to a single group. To move a database from one group to another, select it from the dropdown below and then select the group to move it to from the second dropdown.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Database to move</h4>";
echo "<select name=\"move_db_name\">";
// Go through each group
foreach (array_keys($databases) as $group) {
// Go through each database file
foreach ($databases[$group] as $database) {
$db_name_for_dropdown = $group." - ".$database; // Remove the path for printing to the dropdown as the db name
echo "<option value=\"".$group."/".$database."\">".$db_name_for_dropdown."</option>";
}
}
echo "</select>";
echo "</div>";
echo "<div class=\"12u\">";
echo "<h4>Group to move the database into</h4>";
echo "<select name=\"move_db_group\">";
// Go through each group
foreach (array_keys($databases) as $group) {
echo "<option value=\"".$group."\">".$group."</option>";
}
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"Move database\" /></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "</section>";
echo "</div>";
#############################################
# VIEW ALL ANNOTATION VERSIONS FOR A GIVEN ANNOTATION
#############################################
echo "<div class=\"row\">";
echo "<section class=\"6u 12u(narrower)\">";
echo "<h2 style=\"padding-top:10px;\">View annotation history</h2>";
echo "<p>Annotations within Seave are updated over time. This section allows you to see how a given annotation has been updated including the versions used, the method of update and time of update.</p>";
echo "<form action=\"actions/action_database_administration\" method=\"post\">";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<h4>Annotation source</h4>";
echo "<select name=\"view_annotation_history\">";
// Go through each annotation
foreach (array_keys($annotations) as $annotation_name) {
echo "<option value=\"".$annotation_name."\">".$annotation_name."</option>";
}
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class=\"row 50%\">";
echo "<div class=\"12u\">";
echo "<ul class=\"actions\">";
echo "<li><input type=\"submit\" value=\"View annotation history\" /></li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</form>";
echo "</section>";
echo "</div>";
} else {
error("You do not have permission to view this page.");
echo "<a href=\"home\" class=\"button\">Home</a>";
}
?>
</article>
</div>
</div>
<?php
require 'html_footer.php';
?>