/
moldbfg.php
executable file
·700 lines (621 loc) · 27.5 KB
/
moldbfg.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
<?php
// moldbfgb.php Norbert Haider, University of Vienna, 2007-2014
// part of MolDB6 last change: 2014-08-18
/**
* @file moldfgb.php
* @author Norbert Haider
*
* This script performs the functional group search in structure and
* reaction data collections.
*/
$myname = $_SERVER['PHP_SELF'];
require_once("functions.php");
/**
* enable or disable download of hit structures ("y" or "n"),
* set the maximum number of downloaded structures; these defaults
* can be overridden by the settings in moldb6uiconf.php
*/
$enable_download = "n";
$download_limit = 100;
/**
* Debug level
* - 0: remain silent, higher values: be more verbose
* - odd numbers: output as HTML comments,
* - even numbers: output as clear-text messages
*/
$debug = 1;
// some default settings (will be overridden by the config files)
$enable_svg = "y"; # first choice (overridden by settings in moldb6conf.php)
$enable_bitmaps = "y"; # second choice (overridden by settings in moldb6conf.php)
$enable_jme = "y"; # structure editor; fallback for 2D display
$enable_jsme = "y"; # structure editor; fallback for 2D display
$sitename = "Sristi Biosciences";
$cssfilename = "moldb.css";
// read UID and password from an include file (which should
// be stored _outside_ the web server's document_root directory
// somewhere in the include path of PHP!!!!!!!!!!!!!)
include("moldb6conf.php"); // Contains $uid and $pw of a proxy user
// with read-only access to the moldb database;
// contains $bitmapURLdir (location of .png files);
// the conf file must have valid PHP start and end tags!
include("moldb6uiconf.php"); // Contains additional settings that are relevant only
// to the web frontend (the PHP scripts), but not to
// the command-line backend (the Perl scripts)
// override setting in moldb6 configuration files here (for testing):
//$enable_svg = "n"; # first choice (overridden by settings in moldb6conf.php)
//$enable_bitmaps = "n"; # second choice (overridden by settings in moldb6conf.php)
//$enable_jme = "y"; # structure editor; fallback for 2D display
//$enable_jsme = "y"; # structure editor; fallback for 2D display
// choice of structure editors
@$curr_settings = $_COOKIE["MolDB6"];
$curr_a = explode(",",$curr_settings);
foreach ($curr_a as $curr_line) {
if (strpos($curr_line,"editor") !== FALSE) {
$ed_a = explode("=",$curr_line);
$editor = $ed_a[1];
}
}
if (!isset($editor) || ($editor == "")) {
$editor = $default_editor;
}
if ($editor == "jme") {
$edtag = "applet"; // "applet" (for JME) or "div" (for JSME)
} else {
$edtag = "div"; // "applet" (for JME) or "div" (for JSME)
}
if (config_quickcheck() > 0) { die(); }
set_charset($charset);
$user = $ro_user; # from configuration file
$password = $ro_password;
if ($user == "") {
die("no username specified!\n");
}
if (!isset($sitename) || ($sitename == "")) {
$sitename = "Sristi Biosciences";
}
@$dbstr = $_REQUEST['db'];
$dbl = explode(",",$dbstr);
$dbstr_orig = $dbstr;
$link = mysql_pconnect($hostname,"$ro_user", "$ro_password")
or die("Could not connect to database server!");
mysql_select_db($database)
or die("Could not select database!");
mysql_query("SET NAMES $mysql_charset");
if (!isset($dbl)) {
$dbl = array();
$dbl[0] = $db;
}
$dba = array();
$dbstr = "";
$dbstr2 = "";
$ndbsel = 0;
foreach ($dbl as $id) {
$db_id = check_db($id);
if (($db_id > 0) && (($ndbsel < 1) || ($multiselect == "y"))) {
$ndbsel++;
$dba[($ndbsel - 1)] = $dbl[($ndbsel - 1)];
if (strlen($dbstr)>0) { $dbstr .= ","; $dbstr2 .= " "; }
$dbstr .= "$db_id"; $dbstr2 .= "$db_id";
}
}
if (exist_db($default_db) == FALSE) {
$default_db = get_lowestdbid();
}
if ($ndbsel < 1) {
$ndbl = 1;
$dba[0] = $default_db;
$ndbsel = 1;
$dbstr = "$default_db";
$db_id = $default_db;
}
$rxnmodes = FALSE;
foreach ($dba as $db_id) {
if (exist_db($db_id)) {$mydb = get_dbproperties($db_id); }
$dbtype = $mydb['type'];
if (($dbtype >= 2) && ($enablereactions == "y")) { $rxnmodes = TRUE; }
}
$codebase = "";
if (isset($java_codebase) && ($java_codebase != "")) {
$codebase = "codebase=\"" . $java_codebase . "\"" ;
}
$svg_mode = get_svgmode();
if (!isset($MOL2SVG)) {
$svg_mode = 0;
} else {
if ($MOL2SVG == "") {
$svg_mode = 0;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<?php echo "$html_charset"; ?>">
<meta name="author" content="Norbert Haider, University of Vienna">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui-1.10.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/jquery-ui-1.10.4.min.css" rel="stylesheet">
<title><?php echo "$sitename"; ?>: functional group search</title>
<?php
insert_style($cssfilename);
if ($edtag == "div") {
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"${jsme_path}/jsme.nocache.js\"></script>\n";
}
?>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12 col-xm-12">
<?php show_header($myname , $dbstr); ?>
</div>
</div>
</div>
<?php
$maxhits = 1000; // maximum number of hits we want to allow
$max_selections = 50; // maximum number of selections in listbox
@$action = $_POST['action'];
@$mode = $_POST['mode'];
@$checkbox = $_POST['checkbox'];
//show_header($myname,$dbstr);
$ndb = get_numdb_readable();
if ($ndb == 0) {
echo "<h3>no data collection available</h3><br>\n</body>\n</html>\n";
die();
}
echo "<h2><span style=\"color:Purple\">${sitename}</span></h2>\n";
echo "<p>Search for molecules containing the following functional groups<br>\n";
echo "(multiple selections are possible)</p>\n";
echo "<form action=\"$myname\" method=post>\n";
?>
<select size="15" name="checkbox[]" multiple >
<option value="201">aromatic compound</option>
<option value="202">heterocycle</option>
<option value="199">alkene</option>
<option value="200">alkyne</option>
<option value="3">carbonyl compound (general)</option>
<option value="5"> ketone</option>
<option value="4"> aldehyde</option>
<option value="19"> acetal</option>
<option value="17"> carbonyl hydrate</option>
<option value="18"> hemiacetal</option>
<option value="23"> thioacetal</option>
<option value="24"> enamine</option>
<option value="26"> enol ether</option>
<option value="25"> enol</option>
<option value="36"> enediol</option>
<option value="9"> imine</option>
<option value="10"> hydrazone</option>
<option value="14"> oxime ether</option>
<option value="13"> oxime</option>
<option value="21"> aminal</option>
<option value="20"> hemiaminal</option>
<option value="11"> semicarbazone</option>
<option value="12"> thiosemicarbazone</option>
<option value="22"> thiohemiaminal</option>
<option value="108"> iminohetarene</option>
<option value="106"> oxohetarene</option>
<option value="107"> thioxohetarene</option>
<option value="75">carboxylic acid derivative (general)</option>
<option value="76"> carboxylic acid</option>
<option value="77"> carboxylic acid salt</option>
<option value="112"> carboxylic acid anhydride</option>
<option value="91"> carboxylic acid halide</option>
<option value="78"> carboxylic acid ester</option>
<option value="79"> lactone</option>
<option value="204"> alpha-hydroxyacid</option>
<option value="203"> alpha-aminoacid</option>
<option value="90"> nitrile</option>
<option value="88"> carboxylic acid amidine</option>
<option value="97"> imidoester</option>
<option value="105"> imidothioester</option>
<option value="109"> orthoacid derivative (general)</option>
<option value="16"> ketene acetal derivative</option>
<option value="80"> carboxylic acid amide (general)</option>
<option value="81"> primary carboxylic acid amide</option>
<option value="82"> secondary carboxylic acid amide</option>
<option value="83"> tertiary carboxylic acid amide</option>
<option value="84"> lactam</option>
<option value="113"> carboxylic acid imide (general)</option>
<option value="115"> carboxylic acid imide (N-substituted)</option>
<option value="114"> carboxylic acid imide (N-unsubstituted)</option>
<option value="85"> carboxylic acid hydrazide</option>
<option value="87"> hydroxamic acid</option>
<option value="99"> thiocarboxylic acid derivative (general)</option>
<option value="100"> thiocarboxylic acid</option>
<option value="103"> thiocarboxylic acid amide</option>
<option value="104"> thiolactam</option>
<option value="101"> thiocarboxylic acid ester</option>
<option value="102"> thiolactone</option>
<option value="116">CO2 derivative (general)</option>
<option value="134"> isourea</option>
<option value="136"> isothiourea</option>
<option value="137"> guanidine</option>
<option value="145"> isocyanate</option>
<option value="147"> isothiocyanate</option>
<option value="133"> urea</option>
<option value="125"> carbamic acid derivative (general)</option>
<option value="126"> carbamic acid</option>
<option value="127"> carbamic acid ester (urethane)</option>
<option value="117"> carbonic acid derivative (general)</option>
<option value="119"> carbonic acid diester</option>
<option value="138"> semicarbazide</option>
<option value="139"> thiosemicarbazide</option>
<option value="135"> thiourea</option>
<option value="129"> thiocarbamic acid derivative (general)</option>
<option value="130"> thiocarbamic acid</option>
<option value="131"> thiocarbamic acid ester (thiourethane)</option>
<option value="60">N-oxide</option>
<option value="46">hydroxylamine derivative</option>
<option value="47">amine (general)</option>
<option value="48"> primary amine</option>
<option value="50"> primary aromatic amine (arylamine)</option>
<option value="49"> primary aliphatic amine (alkylamine)</option>
<option value="51"> secondary amine</option>
<option value="54"> secondary aromatic amine (diarylamine)</option>
<option value="53"> secondary mixed amine (alkylarylamine)</option>
<option value="52"> secondary aliphatic aminw (dialkylamine)</option>
<option value="55"> tertiary amine</option>
<option value="58"> tertiary aromatic amine (triarylamine)</option>
<option value="57"> tertiary mixed amin (alkylarylamine)</option>
<option value="56"> tertiary aliphatic amine (trialkylamine)</option>
<option value="59"> quaternary ammonium compound</option>
<option value="45">hydrazine derivative (general)</option>
<option value="141">azo compound</option>
<option value="151">nitrite</option>
<option value="140">azide</option>
<option value="150">nitro compound</option>
<option value="149">nitroso compound</option>
<option value="152">nitrate</option>
<option value="37">ether (general)</option>
<option value="40"> diaryl ether</option>
<option value="39"> alkyl aryl ether</option>
<option value="38"> dialkyl ether</option>
<option value="27">hydroxy compound (general)</option>
<option value="34"> phenol</option>
<option value="35"> 1,2-diphenol</option>
<option value="28"> alcohol</option>
<option value="29"> primary alcohol</option>
<option value="30"> secondary alcohol</option>
<option value="31"> tertiary alcohol</option>
<option value="32"> 1,2-diol</option>
<option value="33"> 1,2-aminoalcohol</option>
<option value="43">peroxide (general)</option>
<option value="44"> hydroperoxide</option>
<option value="41">thioether</option>
<option value="178">thiol (sulfanyl compound, mercaptane; general)</option>
<option value="180"> arylthiol</option>
<option value="179"> alkylthiol</option>
<option value="42">disulfide</option>
<option value="167">sulfoxide</option>
<option value="166">sulfone</option>
<option value="161">sulfonic acid derivative (general)</option>
<option value="164">sulfonamide</option>
<option value="162">sulfonic acid</option>
<option value="163">sulfonic acid ester</option>
<option value="153">sulfuric acid derivative (general)</option>
<option value="159"> sulfuric acid diamide</option>
<option value="158"> sulfuric acid amide</option>
<option value="157"> sulfuric acid amide ester</option>
<option value="154"> sulfuric acid</option>
<option value="155"> sulfuric acid monoester</option>
<option value="181">phosphoric acid derivative (general)</option>
<option value="182"> phosphoric acid</option>
<option value="183"> phosphoric acid ester</option>
<option value="184"> phosphoric acid halide</option>
<option value="185"> phosphoric acid amide</option>
<option value="186"> thiophosphoric acid derivative</option>
<option value="187"> thiophosphoric acid</option>
<option value="188"> thiophosphoric acid ester</option>
<option value="189"> thiophosphoric acid halide</option>
<option value="190"> thiophosphoric acid amide</option>
<option value="191">phosphonic acid derivative (general)</option>
<option value="192"> phosphonic acid</option>
<option value="193"> phosphonic acid ester</option>
<option value="194">phosphine</option>
<option value="195">phosphinoxide</option>
<option value="196">boronic acid derivative (general)</option>
<option value="197"> boronic acid</option>
<option value="198"> boronic acid ester</option>
<option value="61">halogen compound (general)</option>
<option value="62"> alkyl halide</option>
<option value="67"> aryl halide</option>
<option value="68"> aryl fluoride</option>
<option value="63"> alkyl fluoride</option>
<option value="69"> aryl chloride</option>
<option value="64"> alkyl chloride</option>
<option value="70"> aryl bromide</option>
<option value="65"> alkyl bromide</option>
<option value="71"> aryl iodide</option>
<option value="66"> alkyl iodide</option>
</select><br>
<input type="hidden" name="action" value="search">
<input type="hidden" name="db" value="<?php echo "$dbstr"?>">
<input type="Submit" name="Submit" value="Search">
<input type="Reset" name="Reset" value="Reset"><p></p>
<?php
if ($rxnmodes == TRUE) {
echo "<small>There is at least one <b>reaction data</b> collection selected. Your selection of ";
echo "functional groups can be interpreted as follows:</small><br>\n";
echo "<input type=\"radio\" name=\"mode\" value=\"1\">present in any reactant<br>\n";
echo "<input type=\"radio\" name=\"mode\" value=\"2\" checked>present in any product<br>\n";
echo "<input type=\"radio\" name=\"mode\" value=\"3\">lost during the reaction<br>\n";
echo "<input type=\"radio\" name=\"mode\" value=\"4\">created during the reaction<br>\n";
$rxnh3 = "/reactions";
} else { $rxnh3 = ""; }
echo "</form>\n";
echo "<hr />\n";
echo "<h3>Found structures$rxnh3:</h3>\n";
echo "<table width=\"100%\">\n";
$hits_s = 0; // number of hit structures
$hits_r = 0; // number of hit reactions
$hitlist_s = "";
$hitlist_r = "";
if ($action=="search") {
$ncodes = count($checkbox);
if ($ncodes > $max_selections) {
$ncodes = $max_selections;
echo "ATTENTION: search is limited to $max_selections simultaneous selections!<br>\n";
}
if ($ncodes < 1) {
echo "Nothing selected... <br>\n</body>\n</html>\n";
exit;
}
$fgbits = '0000000000000000000000000000000000000000000000000000000000000000'; // 64
$fgbits .= '0000000000000000000000000000000000000000000000000000000000000000'; // 128
$fgbits .= '0000000000000000000000000000000000000000000000000000000000000000'; // 192
$fgbits .= '0000000000000000000000000000000000000000000000000000000000000000'; // 256
for ($n = 0; $n < $ncodes; $n++) {
$fgnum = $checkbox[$n];
$fgbits[($fgnum - 1)] = '1';
}
$fgdec_list = array();
$rfgdec_list = array();
for ($n = 0; $n < 8; $n++) {
$str32 = substr($fgbits, (32 * $n), 32);
$fgdec = 0+0;
$fgdec = $fgdec+0;
$fgincr = 0+0;
$fgincr = $fgincr+0;
for ($i = 0; $i < 32; $i++) {
if (substr($str32,$i,1) == '1') {
$fgincr = 1 << $i;
if ($fgincr < 0) { // v5.01; fixes PHP problem with signed/unsigned integers
$fgincr = 2147483648;
}
$fgdec = $fgdec + $fgincr +0;
}
}
$fgdec_list[$n] = $fgdec;
}
$n_structurestotal = 0;
$nhitstotal = 0;
$nhits = 0;
$hits = 0;
foreach ($dba as $db_id) {
$dbprefix = "db" . $db_id . "_";
$molstructable = $prefix . $dbprefix . $molstrucsuffix;
$moldatatable = $prefix . $dbprefix . $moldatasuffix;
$molstattable = $prefix . $dbprefix . $molstatsuffix;
$molcfptable = $prefix . $dbprefix . $molcfpsuffix;
$molfgbtable = $prefix . $dbprefix . $molfgbsuffix;
$pic2dtable = $prefix . $dbprefix . $pic2dsuffix;
#if ($usemem == 'T') {
# $molstattable = $molstattable . $memsuffix;
# $molcfptable = $molcfptable . $memsuffix;
#}
$rxnstructable = $prefix . $dbprefix . $rxnstrucsuffix;
$rxndatatable = $prefix . $dbprefix . $rxndatasuffix;
$rxnfgbtable = $prefix . $dbprefix . $rxnfgbsuffix;
$mydb = $mydb = get_dbproperties($db_id);
$dbtype = $mydb['type'];
$dbname = $mydb['name'];
$digits = $mydb['digits'];
$subdirdigits = $mydb['subdirdigits'];
#mysql_free_result($result01);
$time_start = getmicrotime();
if ($dbtype == 1) {
if (!isset($digits) || (is_numeric($digits) == false)) { $digits = 8; }
if (!isset($subdirdigits) || (is_numeric($subdirdigits) == false)) { $subdirdigits = 0; }
if ($subdirdigits < 0) { $subdirdigits = 0; }
if ($subdirdigits > ($digits - 1)) { $subdirdigits = $digits - 1; }
$qstr1 = "SELECT mol_id FROM $molfgbtable WHERE ";
$qstr2 = '';
for ($n = 0; $n < 8; $n++) {
$fgdec = intval(trim($fgdec_list[$n]));
$qnum = $n + 1;
while (strlen($qnum) < 2) { $qnum = '0' . $qnum; }
if ($fgdec > 0) {
if (strlen($qstr2) > 0) {
$qstr2 .= ' AND ';
}
$qstr2 .= '(fg' . $qnum . ' & ' . $fgdec . ' = ' . $fgdec . ')';
}
}
if ($qstr2 == '') {
echo "Nothing selected.... <br>\n</body>\n</html>\n";
exit;
}
$limit = $maxhits + 1;
$qstr = $qstr1 . $qstr2 . ' LIMIT ' . $limit;
$result = mysql_query($qstr)
or die("Query failed (#1b1)!");
$hits = 0;
$nhits = mysql_num_rows($result);
$nhitstotal = $nhitstotal + $nhits;
while($line=mysql_fetch_array($result)) {
$mol_id=$line['mol_id'];
$hits ++;
// output of the hits, if they are not too many...
if ( $hits > $maxhits ) {
echo "</table>\n<hr>\n";
echo "<p>Too many hits (>$maxhits)! Aborting....</p>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}
showHit($mol_id,"");
if (($enable_download == "y") && ($hits_s <= $download_limit)) {
$hits_s ++;
if (strlen($hitlist_s) > 0) { $hitlist_s .= ","; }
$hitlist_s .= $db_id . ":" . $mol_id;
}
} // end while($line)...
mysql_free_result($result);
// get total number of structures in the database
$n_qstr = "SELECT COUNT(mol_id) AS count FROM $molfgbtable;";
$n_result = mysql_query($n_qstr)
or die("Could not get number of entries!");
while ($n_line = mysql_fetch_array($n_result, MYSQL_ASSOC)) {
$n_structures = $n_line["count"];
}
mysql_free_result($n_result);
$n_structurestotal = $n_structurestotal + $n_structures;
} // end if ($dbtype == 1)
if (($dbtype == 2) && ($enablereactions == "y")) { // reactions
if ($mode == 1) {
$what = "rxn_id";
$role_outer = "R";
$role_inner = "";
} elseif ($mode == 2) {
$what = "rxn_id";
$role_outer = "P";
$role_inner = "";
} elseif ($mode == 3) {
$what = "rxn_id, fg01, fg02, fg03, fg04, fg05, fg06, fg07, fg08";
$role_outer = "R";
$role_inner = "P";
} elseif ($mode == 4) {
$what = "rxn_id, fg01, fg02, fg03, fg04, fg05, fg06, fg07, fg08";
$role_outer = "P";
$role_inner = "R";
}
$qstr1 = "SELECT " . $what . " FROM $rxnfgbtable WHERE role LIKE '" . $role_outer . "' AND ";
$qstr2 = '';
for ($n = 0; $n < 8; $n++) {
$fgdec = intval(trim($fgdec_list[$n]));
$qnum = $n + 1;
while (strlen($qnum) < 2) { $qnum = '0' . $qnum; }
if ($fgdec > 0) {
if (strlen($qstr2) > 0) {
$qstr2 .= ' AND ';
}
$qstr2 .= '(fg' . $qnum . ' & ' . $fgdec . ' = ' . $fgdec . ')';
}
}
if ($qstr2 == '') {
echo "Nothing selected.... <br>\n</body>\n</html>\n";
exit;
}
$limit = $maxhits + 1;
$qstr = $qstr1 . $qstr2 . ' LIMIT ' . $limit;
$result = mysql_query($qstr)
or die("Query failed (#1b2)!");
$hits = 0;
while($line=mysql_fetch_array($result)) {
$rxn_id = $line['rxn_id'];
if (($mode == 1) || ($mode == 2)) {
$hits ++;
$nhitstotal++;
// output of the hits, if they are not too many...
if ( $hits > $maxhits ) {
echo "</table>\n<hr>\n";
echo "<p>Too many hits (>$maxhits)! Aborting....</p>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}
showHitRxn($rxn_id,"");
if (($enable_download == "y") && ($hits_r <= $download_limit)) {
$hits_r ++;
if (strlen($hitlist_r) > 0) { $hitlist_r .= ","; }
$hitlist_r .= $db_id . ":" . $rxn_id;
}
} else {
$rfgdec_list[0] = $line['fg01'];
$rfgdec_list[1] = $line['fg02'];
$rfgdec_list[2] = $line['fg03'];
$rfgdec_list[3] = $line['fg04'];
$rfgdec_list[4] = $line['fg05'];
$rfgdec_list[5] = $line['fg06'];
$rfgdec_list[6] = $line['fg07'];
$rfgdec_list[7] = $line['fg08'];
$iqstr1 = "SELECT rxn_id FROM " . $rxnfgbtable . " WHERE rxn_id = " . $rxn_id;
$iqstr1 .= " AND role LIKE '" . $role_inner . "' AND ";
$iqstr2 = "";
for ($ir = 0; $ir < 8; $ir++) {
$fnum = $ir + 1;
while (strlen($fnum) < 2) { $fnum = "0" . $fnum; }
$fid = "fg" . $fnum;
if ($fgdec_list[$ir] > 0) {
if (strlen($iqstr2) > 0) { $iqstr2 .= " AND "; }
$iqstr2 .= "((" . $rfgdec_list[$ir] . " ^ " . $fid . ") & " . $fgdec_list[$ir] . " = " . $fgdec_list[$ir] . ")";
}
}
$iqstr = $iqstr1 . $iqstr2;
//echo "$iqstr<br>\n";
$iresult = mysql_query($iqstr)
or die("Query failed (#1b2i)!");
while($iline = mysql_fetch_array($iresult)) {
$rxn_id = $iline['rxn_id'];
$hits ++;
$nhitstotal++;
// output of the hits, if they are not too many...
if ( $hits > $maxhits ) {
echo "</table>\n<hr>\n";
echo "<p>Too many hits (>$maxhits)! Aborting....</p>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}
showHitRxn($rxn_id,"");
if (($enable_download == "y") && ($hits_r <= $download_limit)) {
$hits_r ++;
if (strlen($hitlist_r) > 0) { $hitlist_r .= ","; }
$hitlist_r .= $db_id . ":" . $rxn_id;
}
} // end while($iline)...
mysql_free_result($iresult);
}
} // end while($line)...
mysql_free_result($result);
// get total number of structures in the database
$n_qstr = "SELECT COUNT(rxn_id) AS count FROM $rxnfgbtable WHERE role LIKE 'P';";
$n_result = mysql_query($n_qstr)
or die("Could not get number of entries!");
while ($n_line = mysql_fetch_array($n_result, MYSQL_ASSOC)) {
$n_structures = $n_line["count"];
}
mysql_free_result($n_result);
$n_structurestotal = $n_structurestotal + $n_structures;
} // end if ($dbtype == 2)
} // foreach
echo "</table>\n<hr>\n";
$time_end = getmicrotime();
if (($enable_download == "y") && ($hits_s > 0)) {
echo "<form action=\"hits2sdf.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"hits\" value=\"$hitlist_s\">\n";
echo "<input type=\"Submit\" name=\"download\" value=\"Download\"> hit structures (max. $download_limit) as SD file<br>\n";
echo "</form>\n";
}
if (($enable_download == "y") && ($hits_r > 0)) {
echo "<form action=\"hits2rdf.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"hits\" value=\"$hitlist_r\">\n";
echo "<input type=\"Submit\" name=\"download\" value=\"Download\"> hit reactions (max. $download_limit) as RD file<br>\n";
echo "</form>\n";
}
print "<p><small>number of hits: <b>$nhitstotal</b><br>\n";
$time = $time_end - $time_start;
print "number of analyzed entries in selected data collection(s): $n_structurestotal <br>\n";
printf("time used for query: %2.3f seconds </small></p>\n", $time);
}
echo "\n";
if ($enable_prefs == "y") {
mkprefscript();
}
echo "</body>\n";
echo "</html>\n";
?>