-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_discriminant_analysis_data.php
More file actions
52 lines (43 loc) · 1.93 KB
/
dynamic_discriminant_analysis_data.php
File metadata and controls
52 lines (43 loc) · 1.93 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
50
51
<?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/";
$at = urldecode($_POST["at"]);
$bioprojects = json_decode(urldecode($_POST["bioprojects"]));
$runs = json_decode(urldecode($_POST["runs"]));
$p_adjust_method = urldecode($_POST["p_adjust_method"]);
$method = urldecode($_POST["method"]);
$alpha = urldecode($_POST["alpha"]);
$filter_thres = urldecode($_POST["filter_thres"]);
$taxa_level = urldecode($_POST["taxa_level"]);
$threshold = urldecode($_POST["threshold"]);
$tmp_path = $tmp_prefix . get_temp_folder_name() . "/";
mkdir($tmp_path, 0700);
file_put_contents($tmp_path."bioprojects.tsv", implode("\n", $bioprojects)."\n");
file_put_contents($tmp_path."runs.tsv", implode("\n", $runs)."\n");
$command = "Rscript R/dynamic_discriminant_analysis.R \"".$at."\" \"".$tmp_path."\" \"".$method."\" \"".$alpha."\" \"".$p_adjust_method."\" \"".$filter_thres."\" \"".$taxa_level."\" \"".$threshold."\" 2>&1";
// echo "<pre>".$command."</pre>\n";
exec($command, $out, $status);
// echo implode("</br/>", $out)."<br/>"; // for checking output with errors, if any
// echo $out[0]."<br/>"; // for checking output only
remove_directory_recursively($tmp_path);
echo $out[0];
?>