-
Notifications
You must be signed in to change notification settings - Fork 6
/
panel.hapmap.php
executable file
·199 lines (194 loc) · 10.8 KB
/
panel.hapmap.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
<?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'>Use NGS datasets to construct a haplotype map.</font><br><br>
<script type="text/javascript">
function showColors(colorName,targetToChange,contentString) {
if (document.getElementById(targetToChange)) {
var select = document.getElementById(targetToChange);
select.innerHTML = '';
fillerString = '<div style=\"width:35px; height:20px; overflow:hidden; display:inline-block; background-color:';
if (colorName == "deep pink") { fillerString = fillerString + 'rgb(255,0 ,127)';
} else if (colorName == "magenta") { fillerString = fillerString + 'rgb(255,0 ,255)';
} else if (colorName == "electric indigo") { fillerString = fillerString + 'rgb(127,0 ,255)';
} else if (colorName == "blue") { fillerString = fillerString + 'rgb(0 ,0 ,255)';
} else if (colorName == "dodger blue") { fillerString = fillerString + 'rgb(0 ,127,255)';
} else if (colorName == "cyan") { fillerString = fillerString + 'rgb(0 ,255,255)';
} else if (colorName == "spring green") { fillerString = fillerString + 'rgb(0 ,255,127)';
} else if (colorName == "green") { fillerString = fillerString + 'rgb(0 ,255,0 )';
} else if (colorName == "chartreuse") { fillerString = fillerString + 'rgb(127,255,0 )';
} else if (colorName == "yellow") { fillerString = fillerString + 'rgb(255,255,0 )';
} else if (colorName == "dark orange") { fillerString = fillerString + 'rgb(255,127,0 )';
} else if (colorName == "red") { fillerString = fillerString + 'rgb(255,0 ,0 )';
} else { fillerString = fillerString + 'rgb(127,127,127)';
}
fillerString = fillerString + '\"><center><b>' + contentString + '</b></center></div>';
select.innerHTML = fillerString;
}
}
</script>
<?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 generate new hapmap</span><br><br>";
}
?>
<table width="100%" cellpadding="0"><tr valign="top">
<td width="50%">
<?php
if (isset($_SESSION['user']) != 0) {
$hapmapsDir = "users/".$user."/hapmaps/";
$hapmapFolders = array_diff(glob($hapmapsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $hapmapFolders), SORT_DESC, $hapmapFolders);
// Trim path from each folder string.
foreach($hapmapFolders as $key=>$folder) { $hapmapFolders[$key] = str_replace($hapmapsDir,"",$folder); }
// displaying size if it's bigger then 0
if ($currentSize > 0)
echo "<b><font size='2'>User generated hapmaps: (currently using " . $currentSize . "G of " . $quota . "G)</font></b>\n\t\t\t\t";
else
echo "<div class='hapmap'><b><font size='2' >User generated hapmaps:</font></b><br>\n\t\t";
// show generate new hapmap button only if user has space
if (!$exceededSpace)
{
echo "<input name='button_GenerateNewHapmap' type='button' value='Generate New Hapmap' onclick='";
echo "parent.show_hidden(\"Hidden_GenerateNewHapmap\"); ";
echo "parent.reload_hidden(\"Hidden_GenerateNewHapmap\",\"hapmap.create_window.php\"); ";
echo "'>\n\t\t";
}
foreach($hapmapFolders as $key=>$hapmap) {
echo "<div class='tab'><table><tr><td>\n\t\t\t\t";
if (file_exists("users/".$user."/hapmaps/".$hapmap."/complete.txt")) {
echo "<span id='h_label_".$key."' style='color:#00AA00;'>";
} else if (file_exists("users/".$user."/hapmaps/".$hapmap."/working.txt")) {
echo "<span id='h_label_".$key."' style='color:#BB9900;'>";
} else {
echo "<span id='h_label_".$key."' style='color:#CC0000;'>";
}
echo "<button id='hapmap_delete_".$key."' type='button' onclick=\"parent.deleteHapmapConfirmation('".$user."','".$hapmap."','".$key."')\">Delete</button>\n\t\t";
echo "<font size='2'>".$hapmap."</font></span></td><td>\n\t\t\t\t";
echo "<span id='h_delete_".$key."'></span>\n\t\t\t\t";
echo "<td><div id='userHapmapA_".$key."' >[a]</div></td>\n\t\t\t\t";
echo "<td><div id='userHapmapHET_".$key."'>[ab]</div></td>\n\t\t\t\t";
echo "<td><div id='userHapmapB_".$key."' >[b]</div></td>\n\t\t\t\t";
echo "<td><div id='userHapmapHOM_".$key."'>[hom]</div></td></tr></table>\n\t\t\t\t";
echo "<div id='frameContainer.h_".$key."'></div></div>\n\t\t\t\t";
echo "<script type='text/javascript'>\n\t\t\t\t";
echo "var el_h_".$key." = document.getElementById('frameContainer.h_".$key."');\n\t\t\t\t";
echo "function hapmap_UI_refresh_1_".$key."() {\n\t\t\t\t";
echo " var frameString3 = '<iframe id=\"h_".$key."\" name=\"h_".$key."\" class=\"upload\" style=\"height:38px\" src=\"hapmap.addTo.php\"';\n\t\t\t\t";
echo " var frameString4 = ' marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\" width=\"100%\" frameborder=\"0\"></iframe>';\n\t\t\t\t";
echo " var frameString5 = '<iframe id=\"h2_".$key."\" name=\"h2_".$key."\" class=\"upload\" style=\"height:38px\" src=\"hapmap.finalize.php\"';\n\t\t\t\t";
echo " var frameString6 = ' marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\" width=\"100%\" frameborder=\"0\"></iframe>';\n\t\t\t\t";
echo " el_h_".$key.".innerHTML = frameString3.concat(frameString4,frameString5,frameString6);\n\t\t\t\t";
echo "var h_iframe = document.getElementById('h_".$key."');\n\t\t\t\t";
echo "var h_js = h_iframe.contentWindow;\n\t\t\t\t";
echo "h_js.hapmap = '".$hapmap."';\n\t\t\t\t";
echo "h_js.user = '".$user."';\n\t\t\t\t";
echo "h_js.key = 'h_".$key."';\n\t\t\t\t";
echo "var h2_iframe = document.getElementById('h2_".$key."');\n\t\t\t\t";
echo "var h2_js = h2_iframe.contentWindow;\n\t\t\t\t";
echo "h2_js.hapmap = '".$hapmap."';\n\t\t\t\t";
echo "h2_js.user = '".$user."';\n\t\t\t\t";
echo "h2_js.key = 'h2_".$key."';\n\t\t\t\t";
echo "}\n\t\t\t\t";
echo "function hapmap_UI_refresh_2_".$key."() {\n\t\t\t\t";
echo " var frameString1 = '<iframe id=\"h_".$key."\" name=\"h_".$key."\" class=\"upload\" src=\"hapmap.working.php\" ';\n\t\t\t\t";
echo " var frameString2 = 'marginwidth=\"0\" marginheight=\"0\" vspace=\"0\" hspace=\"0\" width=\"100%\" frameborder=\"0\"></iframe>';\n\t\t\t\t";
echo " el_h_".$key.".innerHTML = frameString1.concat(frameString2);\n\t\t\t\t";
echo "var h_iframe = document.getElementById('h_".$key."');\n\t\t\t\t";
echo "var h_js = h_iframe.contentWindow;\n\t\t\t\t";
echo "h_js.hapmap = '".$hapmap."';\n\t\t\t\t";
echo "h_js.user = '".$user."';\n\t\t\t\t";
echo "h_js.key = 'h_".$key."';\n\t\t\t\t";
echo "}\n\t\t\t\t";
if (file_exists("users/".$user."/hapmaps/".$hapmap."/complete.txt")) {
// No user interface required.
} elseif (file_exists("users/".$user."/hapmaps/".$hapmap."/working.txt")) {
// The hapmap is being processed.
// Load 'hapmap.working.php' into an internal frame 'h_$key'.
echo "hapmap_UI_refresh_2_".$key."();\n\t\t\t\t";
} else {
echo "hapmap_UI_refresh_1_".$key."();\n\t\t\t\t";
}
echo "</script>\n\t\t\t\t";
}
}?>
</div>
</td><td width="50%">
<br>
<?php
$hapmapsDir = "users/default/hapmaps/";
$systemHapmapFolders = array_diff(glob($hapmapsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $systemHapmapFolders), SORT_DESC, $systemHapmapFolders);
// Trim path from each folder string.
foreach($systemHapmapFolders as $key=>$folder) { $systemHapmapFolders[$key] = str_replace($hapmapsDir,"",$folder); }
echo "<div class='hapmap'><b><font size='2'>System hapmaps:</font></b>\n\t\t\t\t";
foreach ($systemHapmapFolders as $key=>$hapmap) {
echo "<div class='tab'><table><tr><td><font size='2'>".$hapmap."</font></td>\n\t\t\t\t";
echo "<td><div id='defaultHapmapA_".$key."' >[a]</div></td>\n\t\t\t\t";
echo "<td><div id='defaultHapmapHET_".$key."'>[ab]</div></td>\n\t\t\t\t";
echo "<td><div id='defaultHapmapB_".$key."' >[b]</div></td>\n\t\t\t\t";
echo "<td><div id='defaultHapmapHOM_".$key."'>[hom]</div></td></tr></table>\n\t\t\t\t";
echo "</div>\n\t\t\t\t";
}
?>
</td></tr></table>
<script type="text/javascript">
// javascript which needs to run for the hapmap panel.
<?php
if (isset($_SESSION['user']) != 0) {
$hapmapsDir = "users/".$user."/hapmaps/";
$hapmapFolders = array_diff(glob($hapmapsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $hapmapFolders), SORT_DESC, $hapmapFolders);
// Trim path from each folder string.
foreach ($hapmapFolders as $key=>$folder) { $hapmapFolders[$key] = str_replace($hapmapsDir,"",$folder); }
foreach ($hapmapFolders as $key=>$hapmap) {
$filename = "users/".$user."/hapmaps/".$hapmap."/colors.txt";
if (!file_exists($filename)) {
continue;
}
$handle = fopen($filename, 'r');
$colorString1 = trim(fgets($handle));
$colorString2 = trim(fgets($handle));
fclose($handle);
echo "\t\t\t\t\tshowColors('".$colorString1."','userHapmapA_".$key."','a');\n";
echo "\t\t\t\t\tshowColors('".$colorString2."','userHapmapB_".$key."','b');\n";
echo "\t\t\t\t\tshowColors('red','userHapmapHOM_".$key."','hom');\n";
echo "\t\t\t\t\tshowColors('grey','userHapmapHET_".$key."','ab');\n\n";
}
}
$hapmapsDir = "users/default/hapmaps/";
$systemHapmapFolders = array_diff(glob($hapmapsDir."*"), array('..', '.'));
// Sort directories by date, newest first.
array_multisort(array_map('filemtime', $systemHapmapFolders), SORT_DESC, $systemHapmapFolders);
// Trim path from each folder string.
foreach ($systemHapmapFolders as $key=>$folder) { $systemHapmapFolders[$key] = str_replace($hapmapsDir,"",$folder); }
foreach ($systemHapmapFolders as $key=>$hapmap) {
$handle = fopen("users/default/hapmaps/".$hapmap."/colors.txt",'r');
$colorString1 = trim(fgets($handle));
$colorString2 = trim(fgets($handle));
fclose($handle);
echo "\t\t\t\t\tshowColors('".$colorString1."','defaultHapmapA_".$key."','a');\n";
echo "\t\t\t\t\tshowColors('".$colorString2."','defaultHapmapB_".$key."','b');\n";
echo "\t\t\t\t\tshowColors('red','defaultHapmapHOM_".$key."','hom');\n";
echo "\t\t\t\t\tshowColors('grey','defaultHapmapHET_".$key."','ab');\n\n";
}
?>
</script>