-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.php
343 lines (290 loc) · 15.5 KB
/
index.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
<?php
##########################################################################
# Copyright 2013, Philip Ewels ([email protected]) #
# #
# This file is part of Labrador. #
# #
# Labrador is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# Labrador is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with Labrador. If not, see <http://www.gnu.org/licenses/>. #
##########################################################################
include('includes/start.php');
include('includes/header.php');
?>
<div class="homepage sidebar-mainpage">
<?php if(!empty($msg)): ?>
<div class="alert alert-<?php echo $error ? 'error' : 'success'; ?>">
<button type="button" class="close" data-dismiss="alert">×</button>
<?php echo $error ? '<strong>Error!</strong><br>' : ''; ?>
<?php foreach($msg as $var) echo $var.'<br>'; ?>
</div>
<?php endif; ?>
<div class="pull-right visible-desktop home-lab">
<a data-toggle="modal" href="#tutorial_video_modal"><img src="img/screencast_thumb.png"></a>
</div>
<h1>
<?php if(isset($logo) && !empty($logo)){ ?>
<img class="pull-left visible-desktop" src="<?php echo $logo; ?>" style="margin: 0 20px 10px 0;">
<?php } ?>
<?php echo $homepage_title; ?> <small><?php echo $homepage_subtitle; ?></small></h1>
<p class="lead">
<?php
if(isset($data_root)){
$data_root_base = preg_split('/\//', $data_root);
$space_left_cmd = shell_exec ("df -h | grep $data_root_base[1]");
$space_headers = preg_split('/\s+/', $space_left_cmd);
$available = preg_replace("/P|T|G/", "", $space_headers[1]);
$usednumber = preg_replace("/P|T|G/", "", $space_headers[2]);
if( is_numeric($available) & is_numeric($usednumber) & ($usednumber/$available < .25 )) {
$fontcol = "red"; }
else {
$fontcol = "green"; }
if( is_numeric($available) & is_numeric($usednumber)){
echo 'System Status: <span style="color:'.$fontcol.'">';
$space_left = ('Total Space = '.$space_headers[1].' Used Space = '.$space_headers[2].' Percent Used= '.$space_headers[4]);
echo $space_left;
echo '</span>';
}
}
?>
<P>Please submit feature requests and bug reports at <A HREF="https://github.com/ewels/labrador/issues">https://github.com/ewels/labrador/issues</A>
You can use labrador to find and download processed data or request new datasets.
Projects are annotated with how they were processed. <a class="labrador_help_toggle" href="#labrador_help" title="Help"><i class="icon-question-sign"></i></a></p>
<div class="labrador_help" style="display:none;">
<div class="well">
<h2>Help!</h2>
<p>Each page within Labrador has this question mark icon in the top right. Click the icon for contextual help about the page that you are on.
<strong>You can also read the full <a href="<?php echo $labrador_url; ?>documentation/">Labrador documentation</a></strong>.</p>
<h3>What is Labrador?</h3>
<p>Labrador is a web based tool to manage projects and automate the processing of publicly available datasets.</p>
<p>Researchers can use it to search through previously processed data, find how it was analysed, read processing reports and download the relevant files to their computers.
If a required dataset isn't yet available, they can <a href="project.php">Create a New Project</a> - this information about the required data sets is then passed on to your resident bioinformaticians, who can process it for you.
The status of projects is tracked, and everything is kept together in a logical place.</p>
<p>Administrators (bioinformaticians) can delegate the process of choosing required data to researchers. Labrador automatically retrieves public data accession numbers and
can write bash scripts to download and process data. This helps to standardise in-house processing and streamline pipelines.</p>
<h3>What does this page do?</h3>
<p>You're currently viewing the home page of Labrador. Here, you can browse all of the projects in the system. Rows in the table are colour-coded to indicate their current status
<em>(complete / currently processing / not started)</em>.</p>
<p>You can quickly filter the projects by their species and data type using the tools on the left. Options within a filter group combine as OR, options between groups combine as AND.
If you're looking for something specific you can filter by the first letter of the project's name, or just use a free text filter at the top.
These tools don't interrogate all of the information held within Labrador - if you would like a more complete search please use the Search Bar at the top.</p>
<p>Clicking on a project row will take you to that project's page: here you can find out more information about the project and access it's datasets and reports.</p>
<h3>Data structure</h3>
<p>Labrador maintains records of each project in a hierarchy, summarised below:</p>
<ul>
<li>Projects
<ul>
<li>Description, status, contacts</li>
<li>Publications</li>
<li>Datasets
<ul>
<li>Downloads</li>
<li>Processing Records</li>
<li>Reports</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>The name of each project corresponds to a folder with the same name on the server. <em>eg.</em> 'Norris_2013' would correspond to <code><?php echo $data_root; ?>Norris_2013/</code></p>
</div>
</div>
<p>You can use the table below to browse the projects and datasets.
You can filter the visible data using the tools on the left.
If you're looking for something really specific, try the search bar at the top of the page.</p>
<p id="filter_status_bar"><strong>Key:</strong>
<input type="checkbox" name="filter_status" id="filter_status_pc" value="Processing Complete" <?php if(!isset($_GET['assigned_projects']) && !isset($_GET['unassigned'])) { echo 'checked="checked"'; } ?>>
<input type="checkbox" name="filter_status" id="filter_status_cp" value="Currently Processing" checked="checked">
<input type="checkbox" name="filter_status" id="filter_status_ns" value="Not Started" checked="checked">
<input type="checkbox" name="filter_status" id="filter_status_nf" value="Directory Not Found" checked="checked">
<label for="filter_status_pc" <?php if(!isset($_GET['assigned_projects']) && !isset($_GET['unassigned'])) { echo 'class="checked"'; } ?>><span></span> Processing Complete</label>
<label for="filter_status_cp" class="checked"><span class=" info"></span> Currently Processing</label>
<label for="filter_status_ns" class="checked"><span class=" error"></span> Not Started</label>
<label for="filter_status_nf" class="checked"><span class=" warning"></span> Directory not found</label>
</p>
<table id="paper-browser-table" class="table table-hover table-condensed table-bordered sortable">
<thead>
<tr>
<th data-sort="string-ins">Name</th>
<th data-sort="int">Datasets</th>
<th data-sort="string-ins">Species</th>
<th data-sort="string-ins">Cell Types</th>
<th data-sort="string-ins">Data Types</th>
<th data-sort="string-ins">Last Modified</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT *, `projects`.`id` AS `pid` FROM `projects`";
if(isset($_GET['contact'])){
$user_id = mysqli_fetch_array(mysqli_query($dblink, sprintf("SELECT `id` FROM `users` WHERE `email` = '%s'", $_GET['contact'])));
$sql .= sprintf(" LEFT JOIN `project_contacts` on `projects`.`id` = `project_contacts`.`project_id` WHERE `project_contacts`.`user_id` = '%s'", $user_id['id']);
} else if($admin && isset($_GET['assigned_projects']) && filter_var($_GET['assigned_projects'], FILTER_VALIDATE_EMAIL)){
$assigned = filter_var($_GET['assigned_projects'], FILTER_SANITIZE_EMAIL);
$sql .= " WHERE `assigned_to` = '".mysqli_real_escape_string($dblink, $assigned)."'";
} else if($admin && isset($_GET['assigned_projects'])){
$sql .= " WHERE `assigned_to` = '".$user['email']."'";
} else if($admin && isset($_GET['unassigned'])){
$sql .= " WHERE `assigned_to` IS NULL OR `assigned_to` = ''";
}
$sql .= " ORDER BY `id` DESC";
$projects = mysqli_query($dblink, $sql);
if(mysqli_num_rows($projects) > 0){
while($project = mysqli_fetch_array($projects)){
// Check directory exists
if(file_exists($data_root.$project['name']) || $project['status'] == 'Not Started' || $project['status'] == 'Currently Processing' || $project['status'] == ''){
$file_exists = true;
} else {
$file_exists = false;
$project['status'] = 'Directory Not Found';
}
// Find papers
$papers_q = mysqli_query($dblink, "SELECT * FROM `papers` WHERE `project_id` = '".$project['pid']."'");
$papers = array();
while($paper = mysqli_fetch_array($papers_q)){
$authors = explode(' ', $paper['authors']);
$papers[] = $authors[0].' '.$paper['journal'].' ('.$paper['year'].')';
}
// Project last modified
$last_mod = $project['modified'];
// Find datasets
$datasets = mysqli_query($dblink, "SELECT * FROM `datasets` WHERE `project_id` = '".$project['pid']."'");
$num_datasets = mysqli_num_rows($datasets);
$species = array();
$cell_types = array();
$data_types = array();
while($dataset = mysqli_fetch_array($datasets)){
if(!in_array($dataset['species'], $species)){
$species[] = $dataset['species'];
}
if(!in_array($dataset['cell_type'], $cell_types)){
$cell_types[] = $dataset['cell_type'];
}
if(!in_array($dataset['data_type'], $data_types)){
$data_types[] = $dataset['data_type'];
}
if($dataset['modified'] !== NULL){
if($last_mod === NULL){
$last_mod = $dataset['modified'];
} else {
$last_mod = max($last_mod, $dataset['modified']);
}
}
}
$last_mod = $last_mod === NULL ? '' : date('Y/m/d', $last_mod);
?>
<tr id="project_<?php echo $project['pid']; ?>" data-status="<?php echo $project['status']; ?>" class="project <?php
if($project['status'] == 'Not Started' || ($project['status'] == '' && !file_exists($data_root.$project['name']))){
echo "error";
} else if($project['status'] == 'Currently Processing'){
echo "info";
} else if(!$file_exists){
echo "warning";
} ?>">
<td class="project_name">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo $project['name'];
if($project['status'] == 'Not Started'){
echo ' <i class="icon-time" title="Project has not yet started processing"></i>';
} else if($project['status'] == 'Currently Processing'){
echo ' <i class="icon-pencil" title="Project is currently being processed by '.$project['assigned_to'].'"></i>';
} else if(!$file_exists){
echo ' <i class="icon-folder-open" title="Directory not found"></i><i class="icon-warning-sign" title="Directory not found"></i>';
} ?>
</a>
</td>
<td class="num num_datasets">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo $num_datasets; ?>
</a>
</td>
<td class="species">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo implode(', ', $species); ?>
</a>
</td>
<td class="cell_type">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo implode(', ', $cell_types); ?>
</a>
</td>
<td class="data_type">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo implode(', ', $data_types); ?>
</a>
</td>
<td class="last_mod">
<a href="project.php?id=<?php echo $project['pid']; ?>">
<?php echo $last_mod; ?>
</a>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
<?php if(!isset($logo)) { $logo = "img/puppy.jpg"; } ?>
<img class="pull-right visible-desktop" src=<?php echo $logo; ?> style="margin: 0 -20px -40px 0;">
<div class="clearfix"></div>
<footer>
<hr>
<p><small>Labrador Data Management System. Written by <a href="http://phil.ewels.co.uk" target="_blank">Phil Ewels</a> at the <a href="http://www.babraham.ac.uk" target="_blank">Babraham Institute</a>, Cambridge, UK.</small></p>
<p><small><a href="<?php echo $labrador_url; ?>documentation/">Read the Labrador Documenation here</a>.</small></p>
</footer>
</div>
<div class="homepage sidebar-nav">
<h2>Filters</h2>
<ul class="nav nav-list filters">
<li class="nav-header">Text Filter</li>
<li class="text-filter"><input type="text" id="homepage_text_filter"></li>
<li class="nav-header">Project Name</li>
<?php foreach (range('A', 'Z') as $i){
echo '<li class="alphabetical-filter"><a href="#">'.$i.'</a></li> ';
} ?>
<li class="alphabetical-filter"><a href="#">0-9</a></li>
<li class="nav-header">Species</li>
<?php
$query = "SELECT `species` FROM `datasets` GROUP BY `species` ORDER BY count(`species`) DESC";
$species_q = mysqli_query($dblink, $query);
if(mysqli_num_rows($species_q) > 0){
while($species = mysqli_fetch_array($species_q)){
echo '<li class="species-filter"><a href="#">'.$species['species'].'</a></li>';
}
}
?>
<li class="nav-header">Data Types</li>
<?php
$query = "SELECT `data_type` FROM `datasets` GROUP BY `data_type` ORDER BY count(`data_type`) DESC";
$data_type_q = mysqli_query($dblink, $query);
if(mysqli_num_rows($data_type_q) > 0){
while($data_type = mysqli_fetch_array($data_type_q)){
echo '<li class="datatype-filter"><a href="#">'.$data_type['data_type'].'</a></li>';
}
}
?>
</ul>
</div><!--/.sidebar-nav -->
</div> <!-- /container -->
<!-- Tutorial Video Modal -->
<div id="tutorial_video_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="tutorial_video_modal_label" aria-hidden="true">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3 id="tutorial_video_modal_label">Labrador Tutorial Video</h3>
</div>
<div class="modal-body">
<iframe width="530px" height="298px" src="//www.youtube.com/embed/m03HTQtSGFg" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php if(function_exists('labrador_login_modal')){ labrador_login_modal(); } ?>
<?php include('includes/javascript.php'); ?>
<script src="js/home.js" type="text/javascript"></script>
</body>
</html>