1 |
<?php |
2 |
include_once("inc/settings.php"); |
3 |
|
4 |
if(isset($_GET['job_name'])) { |
5 |
$job_name = $_GET['job_name']; |
6 |
} |
7 |
|
8 |
if(!isset($job_name)) { |
9 |
$errors['no_job_name'] = 1; |
10 |
} |
11 |
|
12 |
function get_output_url($job_name) { |
13 |
return "results/".$job_name."/"; |
14 |
} |
15 |
|
16 |
function get_orig_pdb_file($job_name) { |
17 |
return get_result_file($job_name, ".reconstructed.pdb"); |
18 |
} |
19 |
|
20 |
function get_renum_pdb_file($job_name) { |
21 |
return get_result_file($job_name, ".renum.pdb"); |
22 |
} |
23 |
|
24 |
function get_pdb_url($job_name) { |
25 |
if(file_exists(get_renum_pdb_file($job_name))) { |
26 |
return get_output_url($job_name).$job_name.".renum.pdb"; |
27 |
} else { |
28 |
return get_output_url($job_name).$job_name.".reconstructed.pdb"; |
29 |
} |
30 |
} |
31 |
|
32 |
function get_img_file($job_name) { |
33 |
return get_result_file($job_name, ".png"); |
34 |
} |
35 |
|
36 |
function get_img_url($job_name) { |
37 |
return get_output_url($job_name).$job_name.".png"; |
38 |
} |
39 |
|
40 |
function get_blast_img($job_name) { |
41 |
return get_output_url($job_name)."blast.png"; |
42 |
} |
43 |
|
44 |
function get_psiblast_img($job_name) { |
45 |
return get_output_url($job_name)."psiblast.png"; |
46 |
} |
47 |
|
48 |
function get_ss_compare_file($job_name) { |
49 |
return get_result_file($job_name, ".ss.compare"); |
50 |
} |
51 |
|
52 |
function get_ss_compare_img_file($job_name) { |
53 |
return get_result_file($job_name, ".ss.compare.png"); |
54 |
} |
55 |
|
56 |
function get_ss_compare_img_url($job_name) { |
57 |
return get_output_url($job_name).$job_name.".ss.compare.png"; |
58 |
} |
59 |
|
60 |
function get_ss_pred_file($job_name) { |
61 |
return get_result_file($job_name, ".horiz"); |
62 |
} |
63 |
|
64 |
function get_template_file($job_name) { |
65 |
return get_result_file($job_name, ".man.templates"); |
66 |
} |
67 |
|
68 |
function read_templates($job_name) { |
69 |
$result = array(); |
70 |
if(file_exists(get_template_file($job_name))) { |
71 |
$result = file(get_template_file($job_name), FILE_SKIP_EMPTY_LINES); |
72 |
} |
73 |
return $result; |
74 |
} |
75 |
|
76 |
function get_seq_file($job_name) { |
77 |
return get_result_file($job_name, ".fa"); |
78 |
} |
79 |
|
80 |
function get_full_seq_file($job_name) { |
81 |
return get_result_file($job_name, ".full.fa"); |
82 |
} |
83 |
|
84 |
function read_sequence($job_name) { |
85 |
if(file_exists(get_seq_file($job_name))) { |
86 |
$lines = file(get_seq_file($job_name)); |
87 |
if(count($lines) < 2) { |
88 |
return ""; |
89 |
} else { |
90 |
$seq = $lines[1]; |
91 |
return $seq; |
92 |
} |
93 |
} else { |
94 |
return ""; |
95 |
} |
96 |
} |
97 |
|
98 |
function read_full_sequence($job_name) { |
99 |
if(file_exists(get_full_seq_file($job_name))) { |
100 |
$lines = file(get_full_seq_file($job_name)); |
101 |
if(count($lines) < 2) { |
102 |
return ""; |
103 |
} else { |
104 |
$seq = $lines[1]; |
105 |
return $seq; |
106 |
} |
107 |
} else { |
108 |
return ""; |
109 |
} |
110 |
} |
111 |
|
112 |
function read_subseq_interval($job_name) { |
113 |
if(file_exists(get_full_seq_file($job_name))) { |
114 |
$lines = file(get_full_seq_file($job_name)); |
115 |
if(count($lines) < 2) { |
116 |
return ""; |
117 |
} else { |
118 |
$header = $lines[0]; |
119 |
return trim(substr($header,1)); |
120 |
} |
121 |
} else { |
122 |
return ""; |
123 |
} |
124 |
} |
125 |
|
126 |
function print_seq($seq) { |
127 |
echo '<div class="sequence">'; |
128 |
$upper = 1; |
129 |
for($i = 0; $i < strlen($seq); $i++) { |
130 |
if($i > 0 && $i % 100 == 0) { |
131 |
echo '<br/>'; |
132 |
} |
133 |
if($upper && strtoupper($seq[$i])!=$seq[$i]) { |
134 |
$upper = 0; |
135 |
echo '<span class="fadeseq">'; |
136 |
} |
137 |
if(!$upper && strtoupper($seq[$i])==$seq[$i]) { |
138 |
$upper = 1; |
139 |
echo '</span>'; |
140 |
} |
141 |
echo $seq[$i]; |
142 |
} |
143 |
echo '</div>'; |
144 |
} |
145 |
|
146 |
function create_png_preview($job_name) { |
147 |
$j = escapeshellcmd($job_name); |
148 |
$pdb_file = get_orig_pdb_file($job_name); |
149 |
$png_file = get_img_file($job_name); |
150 |
|
151 |
$width = 480; |
152 |
$height = 360; |
153 |
$cmd = $GLOBALS['script_dir']."pdb2png.sh ".$pdb_file." ".$width." ".$height." ".$png_file; |
154 |
exec($cmd); |
155 |
} |
156 |
|
157 |
function create_ss_compare_img($job_name) { |
158 |
$cmp_file = escapeshellcmd(get_ss_compare_file($job_name)); |
159 |
$img_file = escapeshellcmd(get_ss_compare_img_file($job_name)); |
160 |
$width = 880; |
161 |
$cmd = $GLOBALS['script_dir']."render_ss_compare.pl $cmp_file $width > $img_file"; |
162 |
$result = exec($cmd); |
163 |
//echo $cmd."<br/>"; |
164 |
} |
165 |
|
166 |
function renum_pdb($job_name, $offset) { |
167 |
$offs = $offset + 1; # needed because script works unintuitively, taking new starting residue instead of offset |
168 |
$old_file = escapeshellcmd(get_orig_pdb_file($job_name)); |
169 |
$new_file = escapeshellcmd(get_renum_pdb_file($job_name)); |
170 |
$chain = 'A'; |
171 |
$cmd = $GLOBALS['script_dir']."renumpdb.py ".$offs." ".$old_file." ".$new_file." ".$chain; |
172 |
$result = exec($cmd); |
173 |
} |
174 |
|
175 |
?> |
176 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
177 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
178 |
|
179 |
<head> |
180 |
<title>Structure prediction server</title> |
181 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
182 |
<link rel="stylesheet" type="text/css" href="css/default.css" /> |
183 |
|
184 |
<script type="text/javascript"> |
185 |
|
186 |
function toggle_fieldset(infobox_id) { |
187 |
var ib_obj = document.getElementById(infobox_id); |
188 |
var fs_obj = ib_obj.getElementsByTagName('fieldset')[0]; |
189 |
var div_obj = fs_obj.getElementsByTagName('div')[0]; |
190 |
var d = div_obj.style.display; |
191 |
if(d == "none") { |
192 |
div_obj.style.display = ""; |
193 |
fs_obj.style.border = ''; //"1px solid #CCCCCC"; |
194 |
fs_obj.style.margin = ''; //"top:5px bottom:5px" |
195 |
} else { |
196 |
div_obj.style.display = "none"; |
197 |
fs_obj.style.borderBottom = "none"; |
198 |
fs_obj.style.borderLeft = "none"; |
199 |
fs_obj.style.borderRight = "none"; |
200 |
fs_obj.style.marginBottom = "-10px"; |
201 |
} |
202 |
} |
203 |
|
204 |
</script> |
205 |
|
206 |
</head> |
207 |
|
208 |
<body> |
209 |
<?php include_once("inc/owl_header.inc.php") ?> |
210 |
|
211 |
<h3>Modeling result</h3> |
212 |
|
213 |
<? # job name ?> |
214 |
<div class="infobox" id="ib_name"> |
215 |
<form> |
216 |
<fieldset> |
217 |
<legend onclick="javascript:toggle_fieldset('ib_name')">Jobname</legend> |
218 |
<div> |
219 |
<? echo $job_name; ?> |
220 |
</div> |
221 |
</fieldset> |
222 |
</form> |
223 |
</div> |
224 |
|
225 |
<? # full sequence ?> |
226 |
<? $full_seq = read_full_sequence($job_name); |
227 |
if(strlen($full_seq) > 0) { ?> |
228 |
<div class="infobox" id="ib_full_seq"> |
229 |
<form><fieldset> |
230 |
<legend onclick="javascript:toggle_fieldset('ib_full_seq')" >Full sequence</legend> |
231 |
<div> |
232 |
<? print_seq($full_seq); ?> |
233 |
</div> |
234 |
</fieldset></form> |
235 |
</div> |
236 |
<? } ?> |
237 |
|
238 |
<? # sequence ?> |
239 |
<div class="infobox" id="ib_seq"> |
240 |
<form> |
241 |
<fieldset> |
242 |
<? $intv = read_subseq_interval($job_name); if(strlen($intv) > 0) { $intv = '('.$intv.')'; } ?> |
243 |
<legend onclick="javascript:toggle_fieldset('ib_seq')" >Target sequence <? echo $intv; ?> </legend> |
244 |
<div> |
245 |
<? print_seq(read_sequence($job_name)); ?> |
246 |
</div> |
247 |
</fieldset> |
248 |
</form> |
249 |
</div> |
250 |
|
251 |
<? # templates ?> |
252 |
<div class="infobox" id="ib_temps"> |
253 |
<fieldset> |
254 |
<legend onclick="javascript:toggle_fieldset('ib_temps')">Templates used for modeling</legend> |
255 |
<div> |
256 |
<?php |
257 |
$temps = read_templates($job_name); |
258 |
if(count($temps) > 0) { |
259 |
foreach($temps as $temp) { |
260 |
$code = rtrim($temp); |
261 |
$pdb = substr($code, 0, 4); |
262 |
echo '<a href="http://pdbwiki.org/index.php/'.$pdb.'">'.rtrim($temp).'</a> '; |
263 |
} |
264 |
} else { |
265 |
echo 'Template file not found'; |
266 |
} |
267 |
?> |
268 |
</div> |
269 |
</fieldset> |
270 |
</div> |
271 |
|
272 |
<? # predicted structure ?> |
273 |
<?php |
274 |
$intv = read_subseq_interval($job_name); |
275 |
if(strlen($intv) > 0) { |
276 |
$start_end = split("-",$intv); |
277 |
$offset = $start_end[0] - 1; |
278 |
if($offset > 0) { |
279 |
renum_pdb($job_name, $offset); |
280 |
} |
281 |
} |
282 |
?> |
283 |
<div class="infobox" id="ib_pdb"> |
284 |
<form> |
285 |
<fieldset> |
286 |
<legend onclick="javascript:toggle_fieldset('ib_pdb')">Predicted structure</legend> |
287 |
<div> |
288 |
<?php create_png_preview($job_name); ?> |
289 |
<A href="<?php echo get_pdb_url($job_name); ?>"><IMG src="<? echo get_img_url($job_name); ?>" border="0"></A> |
290 |
</div> |
291 |
</fieldset> |
292 |
</form> |
293 |
</div> |
294 |
|
295 |
<? # secondary structure |
296 |
if($GLOBALS['show_ss_on_result_page']) { |
297 |
?> |
298 |
<div class="infobox" id="ib_ss"> |
299 |
<form> |
300 |
<fieldset> |
301 |
<legend onclick="javascript:toggle_fieldset('ib_ss')">Secondary structure</legend> |
302 |
<div> |
303 |
<? |
304 |
create_ss_compare_img($job_name); |
305 |
if(file_exists(get_ss_compare_file($job_name))) { |
306 |
echo '<img src="'.get_ss_compare_img_url($job_name).'" alt="">'; |
307 |
} else { |
308 |
// if(file_exists(get_ss_pred_file($job_name))) { |
309 |
// $cont = file_get_contents(get_ss_pred_file($job_name)); |
310 |
// echo '<pre>'.$cont.'</pre>'; |
311 |
// } else { |
312 |
echo "Secondary structure file not found!"; |
313 |
} |
314 |
?> |
315 |
</div> |
316 |
</fieldset> |
317 |
</form> |
318 |
</div> |
319 |
<? } ?> |
320 |
|
321 |
<div class="buttons"> |
322 |
<p><a href="<?php echo get_pdb_url($job_name); ?>"><img src="images/pdb.png" alt="" /> Download pdb file</a></p> |
323 |
<a href="results.php"><img src="images/application_view_list.png" alt="" /> View result list</a> |
324 |
<p><a href="index.php"><img src="images/new.png" alt="" /> Start new job</A></p> |
325 |
</div> |
326 |
<div style="clear:both;"></div> |
327 |
<p></p> |
328 |
|
329 |
</body> |
330 |
</html> |