This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_testing.php
116 lines (90 loc) · 4 KB
/
run_testing.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
<!DOCTYPE html>
<html>
<!-- NAVIGATION BAR-->
<?php include "header.html";?>
<!-- TITLES -->
<div id="header_bar" class="jumbotron">
<h1>CopyCAT</h1>
<h3>
Copy number Clonal Analysis of Tumors
</h3>
</div>
<?php
/////////////////////////////////////////////////////
////////////// DEBUG MODE ///////////////////////
/////////////////////////////////////////////////////
$debug="-d"; //put -d here when testing
$aResult = array();
if( !isset($_POST['code']) ) { $aResult['error'] = 'ERROR: No code passed to run.php';}
$code=$_POST["code"];
$url="analysis.php?code=$code";
$run_url="run_testing_now.php"; //// IMPORTANT
$filename="user_uploads/$code";
$back_button= "<form action=\"./\" method=GET><button type=\"submit\" class=\"center btn btn-danger\">Back</button></form>";
//$continue_button= "<form action=\"$url\"><input type=\"hidden\" name = \"code\" value=\"$code\"><button type=\"submit\" class=\"center btn btn-success\">Continue</button></form>";
$continue_button= "<form action=\"$run_url\" method=\"post\"><input type=\"hidden\" name = \"code\" value=\"$code\"><button type=\"submit\" class=\"center btn btn-success\">Continue</button></form>";
if (!file_exists ($filename)) {
echo "<div class=\"alert center alert-danger\" role=\"alert\">No file uploaded</div>";
echo "$back_button";
exit;
}
$myfile = fopen($filename, "r") or die("Unable to open file!");
$line_counter=0;
$previous_bins=0;
$bin_history=array();
$consistent=true;
while(!feof($myfile)) {
$bin_counter=0;
$line=fgets($myfile);
$line =trim(preg_replace( '/\s+/', ' ', $line ));
if ($line=="" or $line==" ") {
continue;
}
$array=array_map("trim",explode(' ',$line));
//var_dump($array);
$bin_counter=count($array);
//echo $bin_counter . "<br>";
//echo $previous_bins. "<br>";
if ($previous_bins != 0 and $previous_bins != $bin_counter) {
$consistent=false;
echo $line;
var_dump($array);
}
$previous_bins=$bin_counter;
$line_counter=$line_counter+1;
$bin_history[]=$bin_counter;
}
fclose($myfile);
if ($consistent) {
if ($previous_bins > 500) {
echo "<div class=\"alert center alert-success\" role=\"alert\">Great! File was uploaded and has acceptable dimensions: $line_counter samples by $previous_bins bins</div>";
} else {
echo "<div class=\"alert center alert-warning\" role=\"alert\">File was uploaded and has acceptable dimensions: $line_counter samples by $previous_bins bins, but the analysis is unlikely to work optimally without more bins. We recommend at least 500 bins for higher accuracy.</div>";
}
if (!file_exists("user_data/$code")) {
//$oldmask = umask(0);
//mkdir("user_data/$code");
//umask($oldmask);
//
//echo shell_exec("./prepare_copycat -c $code &> user_data/$code/prepare_copycat.log");
//echo shell_exec("./run_copycat $debug -c $code &> user_data/$code/run_copycat.log &");
}
else {
echo "<div class=\"alert center alert-info\" role=\"alert\">File already submitted once. Please continue.</div>";
}
echo "<div style=\"margin-left:1%;\"><div class=\"col-sm-1\">";
echo "$back_button";
echo "</div><div class=\"col-sm-1\">";
echo "$continue_button";
echo "</div></div>";
}
else {
echo "<div class=\"alert center alert-danger\" role=\"alert\">All lines in file must have the same number of elements (separated by spaces). This file had the following numbers of elements per line: ";
foreach ($bin_history as $num)
echo $num . ", ";
echo "</div>";
echo "$back_button";
}
?>
</body>
</html>