-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbioproject_covariate_analysis_data.php
More file actions
49 lines (41 loc) · 1.75 KB
/
bioproject_covariate_analysis_data.php
File metadata and controls
49 lines (41 loc) · 1.75 KB
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
<?php
function get_temp_folder_name() {
$t = microtime();
$sec = explode(" ", $t)[0];
$msec = explode(" ", $t)[1];
$timestamp = ($sec*1000000 + $msec * 1000000)% 1000000000;
return basename($timestamp);
}
function remove_directory_recursively($dir) {
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it,
RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
if ($file->isDir()){
rmdir($file->getPathname());
} else {
unlink($file->getPathname());
}
}
rmdir($dir);
}
$tmp_prefix = "demo_output/";
$bioproject = (isset($_POST["bioproject"])) ? urldecode($_POST["bioproject"]) : "";
$at = (isset($_POST["at"])) ? urldecode($_POST["at"]) : "";
$is = (isset($_POST["is"])) ? urldecode($_POST["is"]) : "";
$confounders = (isset($_POST["confounders"])) ? urldecode($_POST["confounders"]) : "";
if ($confounders !== "") {
$tmp_path = $tmp_prefix . get_temp_folder_name() . "/";
mkdir($tmp_path, 0700);
$command = "Rscript R/bioproject_covariate_analysis.R \"".$bioproject."\" \"".$at."\" \"".$is."\" \"".$confounders."\" \"".$tmp_path."\" 2>&1";
// echo "<pre>".$command."</pre>\n";
exec($command, $out, $status);
$heatmap = $out[count($out)-1];
// echo implode("</br/>", $out)."<br/>"; // for checking output with errors, if any
// echo $heatmap."<br/>"; // for checking output only
remove_directory_recursively($tmp_path);
echo $heatmap;
} else {
echo "No covariate analysis possible";
}
?>