Repository navigation
Expand file tree
/
Copy pathopenbabel_ajax.php
More file actions
54 lines (41 loc) · 1.7 KB
/
Copy pathopenbabel_ajax.php
File metadata and controls
54 lines (41 loc) · 1.7 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
<?php
/********************************************************************
DiSCuS - Database System for Compound Selection
Copyright (C) 2012-2013 Maciej Wojcikowski <maciek@wojcikowski.pl>
This file is part of DiSCuS.
DiSCuS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
DiSCuS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DiSCuS. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
require_once "/usr/local/lib/openbabel.php";
if($_GET['smiles']) {
$informat = 'smi';
$outformat = $_GET['output'];
$smiles = rawurldecode($_GET['smiles']);
$OBMol = new OBMol;
$OBConversion = new OBConversion;
$OBConversion->SetInAndOutFormats($informat, $outformat);
$OBConversion->ReadString($OBMol, $smiles);
# switch mime types and other format specific options
if($outformat == 'svg') {
header('Content-type: image/svg+xml');
$OBMol -> DeleteNonPolarHydrogens();
# gen2d
OBOp_c_Do(OBOp_FindType("gen2d"),$OBMol);
$OBConversion -> SetOptions('C', $OBConversion::OUTOPTIONS);
$OBConversion -> SetOptions('d', $OBConversion::OUTOPTIONS);
}
elseif($outformat == 'sdf') {
# gen2d
OBOp_c_Do(OBOp_FindType("gen2d"),$OBMol);
}
echo $OBConversion->WriteString($OBMol);
}
?>