-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimulatecheck.php
275 lines (219 loc) · 9.68 KB
/
simulatecheck.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
<?php
session_start();
$id = $_SESSION['userid'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<link rel="stylesheet" type="text/css" href="style2.css" media="screen" />
<title>Tissue Culture Portal</title>
</head>
<body>
<div id="wrapper">
<?php
include('includes/header.php');
include('includes/nav1.php');
include('check1.php');
include('check.php');
$treatment=$_POST['treatment'];
$type=$_POST['type'];
$hormone1=$_POST['hormone1'];
$hormone2=$_POST['hormone2'];
$kinintype=$_POST['kinintype'];
$sql3="SELECT * FROM upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'";
$result3=mysql_query($sql3);
if (mysql_num_rows($result3) > 0) {
// get the minimum and maximum value of hormone1
$sql5="SELECT min(auxin) as minsize, max(auxin) as maxsize FROM upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'";
$result5=mysql_query($sql5);
$row = mysql_fetch_assoc($result5);
$minsize = $row['minsize'];
$maxsize = $row['maxsize'];
$auxinmax = $maxsize;
$auxinmin = $minsize;
// get the minimum and maximum value of hormone2
$sql15="SELECT min(cytokinin) as minsize, max(cytokinin) as maxsize FROM upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'";
$result15=mysql_query($sql15);
$row = mysql_fetch_assoc($result15);
$minsize = $row['minsize'];
$maxsize = $row['maxsize'];
$cytokininmax = $maxsize;
$cytokininmin = $minsize;
}
else {
echo '<br></br><br></br><br></br><br></br>';
echo '<center><strong><font size="4" color="red">NO RECORD FOUND FOR SELECTED PARAMETERS!</font>';
echo '<br></br><br></br><br></br><br></br>';
exit;
}
// get the total number of records and make sure it matches
$results = mysql_query("select (COUNT(auxin)) as n1, (COUNT(auxin)) as n2 from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype' ");
while($rows=mysql_fetch_array($results))
{
$n1=$rows['n1'];
$n2=$rows['n2'];
}
if($n1!=$n2){
echo "THE NUMBER OF UPLOADED INDEPENDENT VARIABLES DOES NOT MATCH. PLS VERIFY AND RE-UPLOAD";
exit;
}
// get the sum of x1, x2 and response
$result = mysql_query("select (sum(auxin)) as sumx1,(sum(cytokinin)) as sumx2, (sum(response)) as sumresponse from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype' ");
while($rows=mysql_fetch_array($result))
{
$sumx1=$rows['sumx1'];
$sumx2=$rows['sumx2'];
$sumresponse=$rows['sumresponse'];
$x1bar =$sumx1/$n1;
$x2bar =$sumx2/$n1;
$responsebar =$sumresponse/$n1;
}
// Get the sum of the x1*x2, x1*response, x2*response
$result1 = mysql_query("select sum(auxin * cytokinin) as sumx1x2, sum(auxin * response) as sumx1response, sum(cytokinin * response) as sumx2response from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'");
while($rows=mysql_fetch_array($result1))
{
$sumx1x2=$rows['sumx1x2'];
$sumx1response=$rows['sumx1response'];
$sumx2response=$rows['sumx2response'];
}
//Get the sum of x1 squared, x2 squared, response squared respectively
$result2 = mysql_query("select sum(auxin * auxin) as sumx1squared, sum(cytokinin * cytokinin) as sumx2squared, sum(response * response) as sumresponsesquared from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'");
while($rows=mysql_fetch_array($result2))
{
$sumx1squared=$rows['sumx1squared'];
$sumx2squared=$rows['sumx2squared'];
$sumresponsesquared=$rows['sumresponsesquared'];
}
$x1_x1barsum = 0;
$x2_x2barsum = 0;
$response_responsebarsum = 0;
// get the standard deviation of x1, x2 and response
$result = mysql_query("select auxin,cytokinin,response from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'");
while($rows=mysql_fetch_array($result))
{
$auxin=$rows['auxin'];
$x1_x1bar = $auxin - $x1bar;
$x1_x1barsum= $x1_x1barsum + pow($x1_x1bar,2);
$cytokinin=$rows['cytokinin'];
$x2_x2bar = $cytokinin - $x2bar;
$x2_x2barsum= $x2_x2barsum + pow($x2_x2bar,2);
$response=$rows['response'];
$response_responsebar = $response - $responsebar;
$response_responsebarsum= $response_responsebarsum + pow($response_responsebar,2);
}
$sdx1 = sqrt(($x1_x1barsum)/($n1-1));
$sdx2 = sqrt(($x2_x2barsum)/($n1-1));
$sdresponse = sqrt(($response_responsebarsum)/($n1-1));
// Do the math
$numerator= $sumx1x2 - ($sumx1*$sumx2)/$n1;
$denominator1 = $sumx1squared - ($sumx1*$sumx1)/$n1;
$denominator2 = $sumx2squared - ($sumx2*$sumx2)/$n1;
$denominator = sqrt($denominator1*$denominator2);
$correlationx1x2 = $numerator/$denominator;
$numerator= $sumx1response - ($sumx1*$sumresponse)/$n1;
$denominator1 = $sumx1squared - ($sumx1*$sumx1)/$n1;
$denominator2 = $sumresponsesquared - ($sumresponse*$sumresponse)/$n1;
$denominator = sqrt($denominator1*$denominator2);
$correlationx1response = $numerator/$denominator;
$numerator= $sumx2response - ($sumx2*$sumresponse)/$n1;
$denominator1 = $sumx2squared - ($sumx2*$sumx2)/$n1;
$denominator2 = $sumresponsesquared - ($sumresponse*$sumresponse)/$n1;
$denominator = sqrt($denominator1*$denominator2);
$correlationx2response = $numerator/$denominator;
$R1 = (pow($correlationx1response,2)+ pow($correlationx2response,2))- 2*($correlationx1response)*$correlationx2response*$correlationx1x2;
$R2 = 1-(pow($correlationx1x2,2));
$R = sqrt($R1/$R2);
$R = number_format($R, 2, '.', ',');
$b1 = (($correlationx1response - ($correlationx2response*$correlationx1x2))/(1 - pow($correlationx1x2,2)));
$b1 = $b1 *($sdresponse/$sdx1);
$b2 = (($correlationx2response - ($correlationx1response*$correlationx1x2))/(1 - pow($correlationx1x2,2)));
$b2 = $b2 *($sdresponse/$sdx2);
$a = $responsebar - ($b1*$x1bar) -($b2*$x2bar);
$auxinarray = array();
$cytokininarray = array();
$index = 0;
$x = $auxinmin;
while($x<=$auxinmax)
{
if($auxinmax >1 && $auxinmax <100){
$increment = 1;
}
if($auxinmax >= 0 && $auxinmax <= 1 ){
$increment = 0.1;
}
$auxinarray[$index] = $auxinmin;
$auxinmin = $auxinmin + $increment;
$x = $x + $increment;
$index++;
}
$auxinindex = $index;
$index = 0;
$x = $cytokininmin;
while($x<=$cytokininmax)
{
if($cytokininmax >1 && $cytokininmax <100){
$increment = 1;
}
if($cytokininmax >= 0 && $cytokininmax <= 1 ){
$increment = 0.1;
}
$cytokininarray[$index] = $cytokininmin;
$cytokininmin = $cytokininmin + $increment;
$x = $x + $increment;
$index++;
}
$cytokininindex = $index;
$testarray = array();
$result4 = mysql_query("select auxinname, cytokininname, treatment, type from upload WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'");
while($rows=mysql_fetch_array($result4))
{
$auxinname=$rows['auxinname'];
$treatment=$rows['treatment'];
$type=$rows['type'];
$cytokininname=$rows['cytokininname'];
}
$SQL10 = "DELETE FROM output where userid='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'";
$result = mysql_query($SQL10);
for($i=0;$i<=$auxinindex;$i++){
for($j=0;$j<=$cytokininindex-1;$j++){
$prediction = $a + ($b1*$auxinarray[$i]) + ($b2*$cytokininarray[$j]);
$prediction = number_format($prediction, 2, '.', ',');
$query1 = "insert into output(userid, auxin, auxinname, cytokinin, cytokininname, response, treatment, type) values('".$id."', '".$auxinarray[$i]."','".$auxinname."','".$cytokininarray[$j]."','".$cytokininname."','".$prediction."','".$treatment."','".$type."')";
mysqli_query($connection,$query1);
}
}
$SQL11 = "DELETE FROM output where userid='$id' and cytokinin='' or auxin=''";
$result = mysql_query($SQL11);
$result5 = mysql_query("select max(response) as yield from output WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype'");
while($rows=mysql_fetch_array($result5))
{
$yield=$rows['yield'];
}
$result6 = mysql_query("select auxin, cytokinin from output WHERE userid ='$id' and treatment='$treatment' and type='$type' and cytokininname='$kinintype' and response ='$yield'");
$row = mysql_fetch_assoc($result6);
$auxin = $row['auxin'];
$cytokinin = $row['cytokinin'];
?>
</table>
<div id="content">
<br>
<br>
<strong><font size="6" color="#be345"><?php echo "<br />SIMULATION RESULT"; echo "<br/>"?></font></b></td></font></strong>
<strong><font size="5" color="#000000"><?php echo "<br />The Correlation Coefficient factor of the data is <font color='#be345'> ", $R;?></font></b></td></font></strong>
<strong><font size="5" color="#000000"><?php echo "<br />The best response Yield is <font color='#be345'> ", $yield;?></font></b></td></font></strong>
<td><strong><font size="5" color="#000000"><?php echo "<br/>The best Auxin Concentration Mixture is <font color='#be345'> ", $auxin;echo 'mg/L';?></font></b></td></font></strong></td>
<td><strong><font size="5" color="#000000"><?php echo "<br/>The best Cytokinin Concentration Mixture is <font color='#be345'>", $cytokinin;echo 'mg/L';?></font></b></td></font></strong></td>
<br>
<br>
</table>
</form>
<br></br><br></br> <br></br><br></br>
</div> <!-- end #content -->
<?php include('includes/footer.php'); ?>
</div> <!-- End #wrapper -->
</body>
</html>