-
Notifications
You must be signed in to change notification settings - Fork 6
/
panel.manageDataset.php
executable file
·352 lines (339 loc) · 17.7 KB
/
panel.manageDataset.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
<?php
session_start();
if (isset($_SESSION['logged_on'])) { $user = $_SESSION['user']; } else { $user = 'default'; }
?>
<style type="text/css">
html * {
font-family: arial !important;
}
</style>
<font size='3'>
Install SNP/CGH microarray and next generation sequence datasets to, or delete datasets from, your user account.
<font size='2'>
<p>
<b>IMPORTANT:</b>
<ol>
<li>Filenames should only have alphanumeric characters (letters, numbers, underscores and dashes) in their names (no spaces or other special characters!).</li>
<li>.fq and .fq.gz file extensions are not supported - rename them to .fastq or .fastq.gz (respectively).</li>
<li>Use Chrome for uploads (this will allow resuming them if they are interrupted).</li>
</ol>
</p>
<p>
Is your upload stuck? To resume it, do the following:
<ol>
<li>When all other uploads are finished, refresh the page.</li>
<li>Add the exact same files as you have previously to the project that is stuck.</li>
<li>Press the "upload" button.</li>
</ol>
</p>
</font>
</font>
<?php
if (isset($_SESSION['logged_on']))
{
require_once 'sharedFunctions.php';
// getting the current size of the user folder in Gigabytes
$currentSize = getUserUsageSize($user);
// getting user quota in Gigabytes
$quota = getUserQuota($user);
// Setting boolean variable that will indicate whether the user has exceeded it's allocated space, if true the button to add new dataset will not appear
$exceededSpace = $quota > $currentSize ? FALSE : TRUE;
if ($exceededSpace)
echo "<span style='color:#FF0000; font-weight: bold;'>You have exceeded your quota (" . $quota . "G) please clear space and then reload to add new dataset</span><br><br>";
}
?>
<table width="100%" cellpadding="0"><tr>
<td width="25%" valign="top">
<?php
// .------------------.
// | Make new project |
// '------------------'
if (isset($_SESSION['logged_on'])) {
// show Install new dataset button only if user has space
if(!$exceededSpace)
echo "<input name='button_InstallNewDataset' type='button' value='Install New Dataset' onclick='parent.show_hidden(\"Hidden_InstallNewDataset\")'><br>";
$_SESSION['pending_install_project_count'] = 0;
?>
<b><font size='2'>Datasets Pending</font></b><br>
<div class='tab' style='color:#CC0000; font-size:10pt;' id='newly_installed_list' name='newly_installed_list'></div><br>
<div style='color:#CC0000; font-size:10pt; visibility:hidden; text-align:left;' id='pending_comment' name='pending_comment'>Reload page after any current uploads have completed to prepare pending datasets
for upload.<br><br>Additional datasets can be defined with the 'Install New Dataset' button while files upload.<br></div>
<div style='color:#CC0000; font-size:10pt; visibility:hidden; text-align:center;' id='name_error_comment' name='name_error_comment'>(Entered dataset name is already in use.)</div>
<?php
}
?>
</td>
<td width="75%" valign="top">
<?php
// .---------------.
// | User projects |
// '---------------'
$userProjectCount = 0;
if (isset($_SESSION['logged_on'])) {
$projectsDir = "users/".$user."/projects/";
$projectFolders = array_diff(glob($projectsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $projectFolders), SORT_DESC, $projectFolders);
// Trim path from each folder string.
foreach($projectFolders as $key=>$folder) { $projectFolders[$key] = str_replace($projectsDir,"",$folder); }
// Split project list into ready/working/starting lists for sequential display.
$projectFolders_complete = array();
$projectFolders_working = array();
$projectFolders_starting = array();
foreach($projectFolders as $key=>$project) {
if (file_exists("users/".$user."/projects/".$project."/complete.txt")) {
array_push($projectFolders_complete,$project);
} else if (file_exists("users/".$user."/projects/".$project."/working.txt")) {
array_push($projectFolders_working, $project);
} else {
array_push($projectFolders_starting,$project);
}
}
$userProjectCount_starting = count($projectFolders_starting);
$userProjectCount_working = count($projectFolders_working);
$userProjectCount_complete = count($projectFolders_complete);
// Sort complete and working projects alphabetically.
array_multisort($projectFolders_working, SORT_ASC, $projectFolders_working);
array_multisort($projectFolders_complete, SORT_ASC, $projectFolders_complete);
// Build new 'projectFolders' array;
$projectFolders = array();
$projectFolders = array_merge($projectFolders_starting, $projectFolders_working, $projectFolders_complete);
$userProjectCount = count($projectFolders);
// displaying size if it's bigger then 0
if ($currentSize > 0)
echo "<b><font size='2'>User installed datasets: (currently using " . $currentSize . "G of " . $quota . "G)</font></b>\n\t\t\t\t";
else
echo "<b><font size='2'>User installed datasets:</font></b>\n\t\t\t\t";
echo "<br>\n\t\t\t\t";
foreach($projectFolders_starting as $key_=>$project) {
// Load colors for project.
$colorFile = "users/".$user."/projects/".$project."/colors.txt";
if (file_exists($colorFile)) {
$handle = fopen($colorFile,'r');
$colorString1 = trim(fgets($handle));
$colorString2 = trim(fgets($handle));
fclose($handle);
} else {
$colorString1 = 'null';
$colorString2 = 'null';
}
$parentFile = "users/".$user."/projects/".$project."/parent.txt";
$handle = fopen($parentFile,'r');
$parentString = trim(fgets($handle));
fclose($handle);
// getting project name
$projectNameString = file_get_contents("users/".$user."/projects/".$project."/name.txt");
$projectNameString = trim($projectNameString);
$key = $key_;
echo "\n\t\t\t\t<!-- project '{$project}', #{$key}. --!>\n\t\t\t\t";
echo "<span id='p_label_".$key."' style='color:#CC0000;'>\n\t\t\t\t";
echo "<font size='2'>".($key+1).".";
echo "<button id='project_delete_".$key."' type='button' onclick=\"parent.deleteProjectConfirmation('".$user."','".$project."','".$key."')\">Delete</button>";
echo $projectNameString;
echo "</font></span>\n\t\t\t\t";
echo "<span id='p_delete_".$key."'></span><br>\n\t\t\t\t";
echo "<div id='frameContainer.p3_".$key."'></div>\n";
}
foreach($projectFolders_working as $key_=>$project) {
// Load colors for project.
$colorFile = "users/".$user."/projects/".$project."/colors.txt";
if (file_exists($colorFile)) {
$handle = fopen($colorFile,'r');
$colorString1 = trim(fgets($handle));
$colorString2 = trim(fgets($handle));
fclose($handle);
} else {
$colorString1 = 'null';
$colorString2 = 'null';
}
$parentFile = "users/".$user."/projects/".$project."/parent.txt";
$handle = fopen($parentFile,'r');
$parentString = trim(fgets($handle));
fclose($handle);
// getting project name
$projectNameString = file_get_contents("users/".$user."/projects/".$project."/name.txt");
$projectNameString = trim($projectNameString);
$key = $key_ + $userProjectCount_starting;
echo "\n\t\t\t\t<!-- project '{$project}', #{$key}. --!>\n\t\t\t\t";
echo "<span id='p_label_".$key."' style='color:#BB9900;'>\n\t\t\t\t";
echo "<font size='2'>".($key+1).".";
echo "<button id='project_delete_".$key."' type='button' onclick=\"parent.deleteProjectConfirmation('".$user."','".$project."','".$key."')\">Delete</button>";
echo $projectNameString;
echo "</font></span>\n\t\t\t\t";
echo "<span id='p_delete_".$key."'></span><br>\n\t\t\t\t";
echo "<div id='frameContainer.p2_".$key."'></div>\n";
}
?>
<script type='text/javascript'>
function loadExternal(imageUrl) {
window.open(imageUrl);
}
</script>
<?php
foreach($projectFolders_complete as $key_=>$project) {
// Load data type for project.
$handle = fopen("users/".$user."/projects/".$project."/dataType.txt", "r");
$dataType = fgets($handle);
fclose($handle);
// Load colors for project.
$colorFile = "users/".$user."/projects/".$project."/colors.txt";
if (file_exists($colorFile)) {
$handle = fopen($colorFile,'r');
$colorString1 = trim(fgets($handle));
$colorString2 = trim(fgets($handle));
fclose($handle);
} else {
$colorString1 = 'null';
$colorString2 = 'null';
}
$parentFile = "users/".$user."/projects/".$project."/parent.txt";
$handle = fopen($parentFile,'r');
$parentString = trim(fgets($handle));
fclose($handle);
// getting project name
$projectNameString = file_get_contents("users/".$user."/projects/".$project."/name.txt");
$projectNameString = trim($projectNameString);
$key = $key_ + $userProjectCount_starting + $userProjectCount_working;
echo "\n\t\t\t\t<!-- project '{$project}', #{$key}. --!>\n\t\t\t\t";
echo "<span id='p_label_".$key."' style='color:#00AA00;'>\n\t\t\t\t";
echo "<font size='2'>".($key+1).". ";
echo "<button id='project_delete_".$key."' type='button' onclick=\"parent.deleteProjectConfirmation('".$user."','".$project."','".$key."')\">Delete</button>";
echo $projectNameString."</font>";
// display total project size
$totalSizeFile = "users/".$user."/projects/".$project. "/totalSize.txt";
// first checking if size already calculated and is stored in totalSize.txt
if (file_exists($totalSizeFile))
{
$handle = fopen($totalSizeFile,'r');
$projectSizeStr = trim(fgets($handle));
fclose($handle);
}
else // calculate size and store in totalSize.txt to avoid calculating again
{
// calculating size
$projectSizeStr = trim(shell_exec("du -sh " . "users/".$user."/projects/".$project. "/ | cut -f1"));
// saving to file
$output = fopen($totalSizeFile, 'w');
fwrite($output, $projectSizeStr);
fclose($output);
}
// printing total size
echo " <font color='black' size='1'>(". $projectSizeStr .")</font>";
echo "</span>";
echo "<span id='p_delete_".$key."'></span><br>\n\t\t\t\t";
echo "<div id='frameContainer.p1_".$key."'></div>\n";
}
}
?>
</td>
</tr></table>
<?php
//.-----------------.
//| System projects |
//'-----------------'
$projectsDir = "users/default/projects/";
$systemProjectFolders = array_diff(glob($projectsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $systemProjectFolders), SORT_DESC, $systemProjectFolders);
// Trim path from each folder string.
foreach($systemProjectFolders as $key=>$folder) { $systemProjectFolders[$key] = str_replace($projectsDir,"",$folder); }
$systemProjectCount = count($systemProjectFolders);
?>
<script type="text/javascript">
var userProjectCount = "<?php echo $userProjectCount; ?>";
var systemProjectCount = "<?php echo $systemProjectCount; ?>";
<?php
if (isset($_SESSION['logged_on'])) {
foreach($projectFolders_starting as $key_=>$project) { // frameContainer.p3_[$key] : starting.
$key = $key_;
$project = $projectFolders[$key];
// Read in dataType string for project.
$handle = fopen("users/".$user."/projects/".$project."/dataType.txt", "r");
$dataType = fgets($handle);
fclose($handle);
echo "\n// javascript for project #".$key.", '".$project."'\n";
echo "var el_p = document.getElementById('frameContainer.p3_".$key."');\n";
$script_SnpCghArray = "scripts_SnpCghArray/project.SnpCgh.install.php";
$script_WGseq_single = "scripts_seqModules/scripts_WGseq/project.single_WGseq.install_1.php";
$script_WGseq_paired = "scripts_seqModules/scripts_WGseq/project.paired_WGseq.install_1.php";
$script_ddRADseq_single = "scripts_seqModules/scripts_ddRADseq/project.single_ddRADseq.install_1.php";
$script_ddRADseq_paired = "scripts_seqModules/scripts_ddRADseq/project.paired_ddRADseq.install_1.php";
$script_RNAseq_single = "scripts_seqModules/scripts_RNAseq/project.single_RNAseq.install_1.php";
$script_RNAseq_paired = "scripts_seqModules/scripts_RNAseq/project.paired_RNAseq.install_1.php";
$script_IonExpressSeq_single = "scripts_seqModules/scripts_IonExpressSeq/project.single_IonExpressSeq.install_1.php";
$script_IonExpressSeq_paired = "scripts_seqModules/scripts_IonExpressSeq/project.paired_IonExpressSeq.install_1.php";
// Javascript to build file load button interface.
echo "el_p.innerHTML = '<iframe id=\"p_".$key."\" name=\"p_".$key."\" class=\"upload\" ";
if ((strlen($dataType) > 1) && ($dataType[2] == '1')) { echo "style=\"height:76px\" src=\"uploader.2.php\""; } else { echo "style=\"height:38px\" src=\"uploader.1.php\""; }
echo " marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\" width=\"100%\" frameborder=\"0\"></iframe>';\n";
echo "var p_iframe = document.getElementById('p_".$key."');\n";
echo "var p_js = p_iframe.contentWindow;\n";
echo "p_js.display_string = new Array();\n";
echo "p_js.target_dir = '../../users/".$user."/projects/".$project."/';\n";
echo "p_js.user = '".$user."';\n";
echo "p_js.project = '".$project."';\n";
echo "p_js.key = 'p_".$key."';\n";
if ($dataType == '0') { // SnpCgh microarray
echo "p_js.display_string[0] = 'Add : SnpCgh array data...';\n";
echo "p_js.conclusion_script = '".$script_SnpCghArray."';\n";
} else if ($dataType == '1:0') { // WGseq : single-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Single-end-read WGseq data (FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_WGseq_single."';\n";
} else if ($dataType == '1:1') { // WGseq : paired-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Paired-end-read WGseq data (1/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.display_string[1] = 'Add : Paired-end-read WGseq data (2/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_WGseq_paired."';\n";
} else if (($dataType == '1:2') || ($dataType == '1:3')) { // WGseq : [SAM/BAM/TXT]
echo "p_js.display_string[0] = 'Add : WGseq data (SAM/BAM/TXT)...';\n";
echo "p_js.conclusion_script = '".$script_WGseq_single."';\n";
} else if ($dataType == '2:0') { // ddRADseq : single-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Single-end-read ddRADseq data (FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_ddRADseq_single."';\n";
} else if ($dataType == '2:1') { // ddRADseq : paired-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Paired-end-read ddRADseq data (1/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.display_string[1] = 'Add : Paired-end-read ddRADseq data (2/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_ddRADseq_paired."';\n";
} else if (($dataType == '2:2') || ($dataType == '2:3')) { // ddRADseq : [SAM/BAM/TXT]
echo "p_js.display_string[0] = 'Add : ddRADseq data (SAM/BAM/TXT)...';\n";
echo "p_js.conclusion_script = '".$script_ddRADseq_single."';\n";
} else if ($dataType == '3:0') { // RNAseq : single-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Single-end-read RNAseq data (FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_RNAseq_single."';\n";
} else if ($dataType == '3:1') { // RNAseq : paired-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Paired-end-read RNAseq data (1/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.display_string[1] = 'Add : Paired-end-read RNAseq data (2/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_RNAseq_paired."';\n";
} else if (($dataType == '3:2') || ($dataType == '3:3')) { // RNAseq : [SAM/BAM/TXT]
echo "p_js.display_string[0] = 'Add : RNAseq data (SAM/BAM/TXT)...';\n";
echo "p_js.conclusion_script = '".$script_RNAseq_single."';\n";
} else if ($dataType == '4:0') { // IonExpressSeq : single-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Single-end-read IonExpress data (FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_IonExpressSeq_single."';\n";
} else if ($dataType == '4:1') { // IonExpressSeq : paired-end [FASTQ/ZIP/GZ]
echo "p_js.display_string[0] = 'Add : Paired-end-read IonExpress data (1/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.display_string[1] = 'Add : Paired-end-read IonExpress data (2/2; FASTQ/ZIP/GZ)...';\n";
echo "p_js.conclusion_script = '".$script_IonExpressSeq_paired."';\n";
} else if (($dataType == '4:2') || ($dataType == '4:3')) { // IonExpressSeq : [SAM/BAM/TXT]
echo "p_js.display_string[0] = 'Add : IonExpress data (SAM/BAM/TXT)...';\n";
echo "p_js.conclusion_script = '".$script_IonExpressSeq_single."';\n";
}
}
foreach($projectFolders_working as $key_=>$project) { // frameContainer.p2_[$key] : working.
$key = $key_ + $userProjectCount_starting;
$project = $projectFolders[$key];
$handle = fopen("users/".$user."/projects/".$project."/dataType.txt", "r");
$dataType = fgets($handle);
fclose($handle);
echo "\n// javascript for project #".$key.", '".$project."'\n";
echo "var el_p = document.getElementById('frameContainer.p2_".$key."');\n";
echo "el_p.innerHTML = '<iframe id=\"p_".$key."\" name=\"p_".$key."\" class=\"upload\" style=\"height:38px; border:0px;\" ";
echo "src=\"project.working.php\" marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\" width=\"100%\" frameborder=\"0\"></iframe>';\n";
echo "var p_iframe = document.getElementById('p_".$key."');\n\t";
echo "var p_js = p_iframe.contentWindow;\n";
echo "p_js.user = \"".$user."\";\n\t";
echo "p_js.project = \"".$project."\";\n\t";
echo "p_js.key = \"p_".$key."\";\n";
}
}
?>
</script>