-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAEFiles.php
156 lines (95 loc) · 2.86 KB
/
getAEFiles.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
<?php
require "../phplib/genlibraries.php";
redirectOutside();
/*if($_POST){
$dt = getDataTypeFromFileType($_REQUEST['filetype']);
echo json_encode($dt);
}else{
redirect($GLOBALS['URL']);
}*/
$files = $GLOBALS['sdrfCol']->find(array("_id.DBId" => $_REQUEST["id"]));
$id = explode(":", $_REQUEST["id"])[1];
$taxon = "";
foreach($files as $f) {
$urls = $f["urls"];
if(isset($urls) && ($taxon == "")) {
foreach($urls as $a) {
if($taxon == "") {
foreach($a as $k => $v) {
preg_match('/Taxon/', $v, $matches, PREG_OFFSET_CAPTURE);
if(!empty($matches)) {
$t = explode("_", $v);
$taxon = $t[sizeof($t) - 1];
break;
}
}
}
}
}
}
echo '<table class="table table-striped table-bordered">
<tbody>
<tr>
<th>File Name</th>
<th>Click here to load file to Workspace</th>
<th>Click here to download file</th>
</tr>';
$c = 0;
foreach($files as $f) {
$urls = $f["urls"];
if(isset($urls)) {
foreach($urls as $a) {
echo '<tr>';
foreach($a as $k => $v) {
preg_match('/Taxon/', $v, $matches, PREG_OFFSET_CAPTURE);
if(empty($matches)) {
$type = explode("|", $k);
$zipName = explode("/", $v);
$zipName = $zipName[sizeof($zipName) - 1];
$fileName = $f[$type[0]]["id"];
//$fileName = $v;
if(gettype($fileName) == "array") {
$fileName = implode(", ", $fileName);
// ARRAYS NOT SHOWN!!!!
}
$isFQ = false;
if (strpos($k, 'FASTQ_URI') !== false) $isFQ = true;
$ext = strtoupper(pathinfo($fileName, PATHINFO_EXTENSION));
$e = strtoupper(pathinfo($v, PATHINFO_EXTENSION));
//var_dump($e);
$file_type = $GLOBALS['fileTypesCol']->findOne(array("_id" => $ext));
if(isset($file_type) || ($ext == "")) {
if($isFQ) {
$urlFile = $f["Scan_Name"]["Comment"]["FASTQ_URI"];
} else {
if($e == "ZIP") $urlFile = "https://www.ebi.ac.uk/arrayexpress/files/$id/$zipName/$fileName";
else $urlFile = $v;
}
if($fileName == "") {
$fileName = end(explode('/',$v));
$urlFile = $v;
}
$repID = $_REQUEST["id"];
echo '<td>';
echo /*$f["_id"]["record"].' '.*/$fileName;
//if($taxon != "") echo " ($taxon)";
echo '</td>';
echo '<td>';
echo "<a href=\"".$GLOBALS['URL']."/applib/getData.php?uploadType=repository&url=$urlFile&repo=AE&taxon=$taxon&id=$repID\"
class=\"btn green\"><i class=\"fa fa-cloud-upload\"></i> IMPORT FILE TO WORKSPACE </a>";
echo '</td>';
echo '<td>';
echo "<a href=\"$urlFile\"
target=\"_blank\" class=\"btn green\"><i class=\"fa fa-download\"></i> DOWNLOAD FILE </a>";
echo '</td>';
$c ++;
}
}
}
echo '</tr>';
}
}
}
if($c == 0) echo "<td colspan=\"3\">No available files compatible with this experiment.</td>";
echo '</tbody>
</table>';