-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeature_selection.php
More file actions
287 lines (258 loc) · 9.16 KB
/
Copy pathfeature_selection.php
File metadata and controls
287 lines (258 loc) · 9.16 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
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
276
277
278
279
280
281
282
283
284
285
286
287
<?php
session_start();
?>
<?php
include "navigation.html";
require_once 'login.php';
require_once 'redir.php';
$dbfs = array( "natm", "ncar", "nnit", "noxy", "nsul", "ncycl", "nhdon", "nhacc", "nrotb", "mw", "TPSA", "XLogP" );
?>
<div id="write" class="container">
<form action="feature_selection.php" method="post">
<h2>Statistics by Features</h2>
<hr>
<p>You can select one or more Feartures.</p>
<div class="inbox">
<div class="item">
<input type="checkbox" name="natm">
<p class="featureTable">Number of Atoms </p>
<input type="checkbox" name="ncar">
<p class="featureTable">Number of Carbons</p>
</div>
<div class="item">
<input type="checkbox" name="nnit">
<p class="featureTable">Number of Nitrogens </p>
<input type="checkbox" name="noxy">
<p class="featureTable">Number of Oxygens</p>
</div>
<div class="item">
<input type="checkbox" name="nsul">
<p class="featureTable">Number of Sulphurs </p>
<input type="checkbox" name="ncycl">
<p class="featureTable">Number of Cycles</p>
</div>
<div class="item">
<input type="checkbox" name="nhdon">
<p class="featureTable">Number of Hydrogen Donors </p>
<input type="checkbox" name="nhacc">
<p class="featureTable">Number of Hydrogen Acceptors</p>
</div>
<div class="item">
<input type="checkbox" name="nrotb">
<p class="featureTable">Number of Rotatable Bonds </p>
<input type="checkbox" name="mw">
<p class="featureTable">Molecular Weight</p>
</div>
<div class="item">
<input type="checkbox" name="TPSA">
<p class="featureTable">The Polar Surface Area </p>
<input type="checkbox" name="XLogP">
<p class="featureTable">Estimated LogP</p>
</div>
<div class="item">
<input class="button" type="submit" value="Submit">
</div>
</div>
<script src="script.js"></script>
</form>
<h2>Results of feature(s) statistics</h2>
<hr>
<?php
// Results
if ( !empty( $_POST ) ) {
echo <<<_MAIN2
<table class="pure-table tablesorter" align="center" id="myTable">
<thead>
<th>Features</th>
<th>Average</th>
<th>Maximum</th>
<th>Minimum</th>
<th>Standard Deviation</th>
<th>Variance</th>
</tr>
</thead>
<tbody>
_MAIN2;
// connect to MySQL
// the information is stored in login.php
$db_server = mysql_connect( $db_hostname, $db_username, $db_password );
if ( !$db_server )die( "Unable to connect to database: " . mysql_error() );
mysql_select_db( $db_database, $db_server )or die( "Unable to select database: " . mysql_error() );
// calculate the average and standard deviation for the chosen feature
if ( $_POST[ 'natm' ] == on ) {
// claculate the statistics
// sprintf: Return a formatted string
$query = sprintf( "SELECT AVG(natm), MAX(natm), MIN(natm), STDDEV(natm), VARIANCE(natm) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Atoms</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'ncar' ] == on ) {
$query = sprintf( "SELECT AVG(ncar), MAX(ncar), MIN(ncar), STDDEV(ncar), VARIANCE(ncar) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Carbons</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'nnit' ] == on ) {
$query = sprintf( "SELECT AVG(nnit), MAX(nnit), MIN(nnit), STDDEV(nnit), VARIANCE(nnit) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Nitrogens</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'noxy' ] == on ) {
$query = sprintf( "SELECT AVG(noxy), MAX(noxy), MIN(noxy), STDDEV(noxy), VARIANCE(noxy) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Oxygens</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'nsul' ] == on ) {
$query = sprintf( "SELECT AVG(nsul), MAX(nsul), MIN(nsul), STDDEV(nsul), VARIANCE(nsul) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Sulphurs</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'ncycl' ] == on ) {
$query = sprintf( "SELECT AVG(ncycl), MAX(ncycl), MIN(ncycl), STDDEV(ncycl), VARIANCE(ncycl) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Cycles</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'nhdon' ] == on ) {
$query = sprintf( "SELECT AVG(nhdon), MAX(nhdon), MIN(nhdon), STDDEV(nhdon), VARIANCE(nhdon) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Hydrogen Donors</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'nhacc' ] == on ) {
$query = sprintf( "SELECT AVG(nhacc), MAX(nhacc), MIN(nhacc), STDDEV(nhacc), VARIANCE(nhacc) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Hydrogen Acceptors</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'nrotb' ] == on ) {
$query = sprintf( "SELECT AVG(nrotb), MAX(nrotb), MIN(nrotb), STDDEV(nrotb), VARIANCE(nrotb) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Number of Rotatable Bonds</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'mw' ] == on ) {
$query = sprintf( "SELECT AVG(mw), MAX(mw), MIN(mw), STDDEV(mw), VARIANCE(mw) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Molecular Weight</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'TPSA' ] == on ) {
$query = sprintf( "SELECT AVG(TPSA), MAX(TPSA), MIN(TPSA), STDDEV(TPSA), VARIANCE(TPSA) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>The Polar Surface Area</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
if ( $_POST[ 'XLogP' ] == on ) {
$query = sprintf( "SELECT AVG(XLogP), MAX(XLogP), MIN(XLogP), STDDEV(XLogP), VARIANCE(XLogP) FROM Compounds" );
$result = mysql_query( $query );
$row = mysql_fetch_row( $result );
echo '<tr>';
echo "<td>Estimated LogP</td>";
echo '<td>' .round($row[ 0 ], 4) . '</td>';
echo '<td>' .round($row[ 1 ], 4) . '</td>';
echo '<td>' .round($row[ 2 ], 4) . '</td>';
echo '<td>' .round($row[ 3 ], 4) . '</td>';
echo '<td>' .round($row[ 4 ], 4) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo "</div>";
} else {
echo "<p>No query is given!";
echo "<br>";
echo "</p>";
echo "</div>";
}
mysql_close( $db_server );
echo <<<_TAIL1
<br>
<br>
<br>
</body>
</html>
_TAIL1;
?>
</div>