-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
168 lines (140 loc) · 5.5 KB
/
Copy pathsubmit.php
File metadata and controls
168 lines (140 loc) · 5.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content=""/>
<meta name="author" content=""/>
<link rel="icon" href="favicon.ico"/>
<title>
Cover Template for Bootstrap
</title>
<link rel="stylesheet" href="bootstrap.min.css"/>
<link href="cover.css" rel="stylesheet"/>
</head>
<body>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">
ChemPredict
</h3>
<nav>
<ul class="nav masthead-nav">
<li>
<a href="index.php">
Home
</a>
</li>
<li class="active">
<a href="#">
Results
</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="inner cover">
<h1 class="cover-heading">
Results
</h1>
<p class="lead">
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once "/usr/local/lib/openbabel.php";
$target_dir = "uploads/";
//upload file
$tmpfname1 = tempnam("uploads", date("Ymd"));
$fileinfo1 =new SplFileInfo(basename($_FILES["file1"]["name"]));
$extension1=$fileinfo1->getExtension();
$target_file1 = $tmpfname1.".".$extension1;
move_uploaded_file($_FILES["file1"]["tmp_name"], $target_file1);
$tmpfname2 = tempnam("uploads", date("Ymd"));
$fileinfo2 =new SplFileInfo(basename($_FILES["file2"]["name"]));
$extension2=$fileinfo2->getExtension();
$target_file2 = $tmpfname2.".".$extension2;
move_uploaded_file($_FILES["file2"]["tmp_name"], $target_file2);
//end of upload file
//translate file to smiles format
$obMol = new OBMol;
$obConversion = new OBConversion;
$obConversion->SetInAndOutFormats($extension1, "smi");
$obConversion->ReadFile($obMol, $target_file1);
$outMDL = $obConversion->WriteString($obMol);
$smilesfilename1=$tmpfname1.".smi";
$handle = fopen($smilesfilename1, "w");
fwrite($handle, $outMDL);
fclose($handle);
$smilesfilename2=$tmpfname2.".smi";
$obConversion->SetInAndOutFormats($extension2, "smi");
$obConversion->ReadFile($obMol, $target_file2);
$outMDL = $obConversion->WriteString($obMol);
$handle = fopen($smilesfilename2, "w");
fwrite($handle, $outMDL);
fclose($handle);
unlink($tmpfname1); //delete tmpfilename
unlink($tmpfname2);
//end of translate file to smiles format
//graphics
$obConversion->SetInAndOutFormats("smi", "svg");
$obConversion->ReadFile($obMol, $tmpfname1.".smi");
$outMDL = $obConversion->WriteString($obMol);
echo "Reactants: ".$outMDL;
$obConversion->ReadFile($obMol, $tmpfname2.".smi");
$outMDL = $obConversion->WriteString($obMol);
echo $outMDL."<br>";
//end of graphics
$runpython="/home/mzhu7/chemroutes/openbabel.py ".$tmpfname1.".smi ".$tmpfname2.".smi";
//echo $runpython;
$command=escapeshellcmd($runpython);
$output=shell_exec($command);
$outputs= explode("\n",$output);
echo "Products: ";
for ($i=0;$i<count($outputs)-1;$i++){
$obConversion->ReadString($obMol, $outputs[$i]);
$outMDL = $obConversion->WriteString($obMol);
echo $outMDL;
}
?>
</p>
</div>
<div class="mastfoot">
<div class="inner">
<p>
By Binghe Wang's lab, 2016
</p>
</div>
</div>
</div>
</div>
</div>
<!--
Bootstrap core JavaScript
==================================================
-->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src="bootstrap.min.js">
</script>
<script>
$( "#num_reactants" ).change(function() {
$("#files").empty();
var i;
var fileindex;
for(i=1;i<=this.value;i++){
fileindex="file"+i;
$("#files").append("<input type='file' name="+fileindex+" ><br>");
}
console.log(this.value)
});
</script>
</body>
</html>