ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/owl-for-cmview-1.9.4/modelit/server/results.php
Revision: 1440
Committed: Thu Aug 18 07:03:28 2011 UTC (10 years, 10 months ago) by jmduarteg
File size: 5493 byte(s)
Log Message:
Tagging from bug fix branch for bug fixed version of CMView 1.9.4 (released as 1.1.1). Important bug fix of DaliRunner
Line User Rev File contents
1 hstehr 1299 <?php
2     include_once("inc/settings.php");
3    
4     function get_output_url($job_name) {
5     return "results/".$job_name."/";
6     }
7    
8     function get_seq_file($job_name) {
9     return get_result_file($job_name, ".fa");
10     }
11    
12     function view_ts_result_url($job) {
13     return "select_templates.php?job_name=$job";
14     }
15    
16     function view_sm_result_url($job) {
17     return "show_modeling_result.php?job_name=$job";
18     }
19    
20     function get_yes_img_url() {
21     return "images/tick.png";
22     }
23    
24     function get_no_img_url() {
25     return "images/cross.png";
26     }
27    
28     function get_running_img_url() {
29     return "images/anidot.gif";
30     }
31    
32     function get_run_stat_img_url() {
33     return "images/stadot.gif";
34     }
35    
36     function get_ts_job_name($job_name) {
37     return 'TS-'.$job_name;
38     }
39    
40     function is_ts_job_running($job_name) {
41     global $server_user;
42     $u = escapeshellcmd($server_user);
43     $j = escapeshellcmd(get_ts_job_name($job_name));
44     $cmd = 'qstat -u '.$u.' -xml | grep "<JB_name>'.$j.'</JB_name>"';
45     $result = exec($cmd);
46     if (strpos($result, $j) !== false) {
47     return true;
48     } else {
49     return false;
50     }
51     }
52    
53     function get_mb_job_name($job_name) {
54     return 'MB-'.$job_name;
55     }
56    
57     function is_mb_job_running($job_name) {
58     global $server_user;
59     $u = escapeshellcmd($server_user);
60     $j = escapeshellcmd(get_mb_job_name($job_name));
61     $cmd = 'qstat -u '.$u.' -xml | grep "<JB_name>'.$j.'</JB_name>"';
62     $result = exec($cmd);
63     if (strpos($result, $j) !== false) {
64     return true;
65     } else {
66     return false;
67     }
68     }
69    
70     # this file should exist if modeling was started
71     function get_template_file($job_name) {
72     return get_result_file($job_name, ".man.templates");
73     }
74    
75     # this file should exist if template searching was completed
76     function get_report_file($job_name) {
77     return get_result_file($job_name,".report");
78     }
79    
80     # this file should exist if modelling was completed
81     function get_pdb_file($job_name) {
82     return get_result_file($job_name, ".reconstructed.pdb");
83     }
84    
85     # return all job names (= subdirs in results dir) in order of creation date (taken from the fasta file)
86     function get_all_job_names() {
87     $results = array();
88     $handler = opendir(get_results_dir());
89     while ($file = readdir($handler)) {
90     if ($file != '.' && $file != '..' && is_dir(get_output_dir($file))) {
91     $seqfile = get_seq_file($file);
92     if(file_exists($seqfile)) {
93     $last_modified = filemtime($seqfile);
94     } else {
95     $last_modified = 0;
96     }
97     $results[$file] = $last_modified;
98     }
99     }
100     closedir($handler);
101     arsort($results);
102     return $results;
103     }
104    
105     # auto-refresh
106     header('Refresh: '.$refresh_rate);
107     ?>
108     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
109     <html xmlns="http://www.w3.org/1999/xhtml">
110     <head>
111     <title>Structure prediction server</title>
112     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
113     <link rel="stylesheet" type="text/css" href="css/default.css" />
114     </head>
115     <body>
116     <?php include_once("inc/owl_header.inc.php") ?>
117     <div class="main-content">
118     <h3>Results overview</h3>
119     <?php
120     echo '<div class="buttons">';
121     echo '<a href="index.php"><img src="images/new.png" alt="" /> Start new job</a>' ;
122     echo '</div>';
123     echo '<div style="clear:both;"></div>';
124     echo '<br/>';
125    
126     $jobs = get_all_job_names();
127     if(count($jobs) < 1) {
128     echo 'No results found!';
129     } else {
130     echo '<table>';
131     echo '<tr>';
132     echo '<th>Jobname</th>';
133     echo '<th>Submission date</th>';
134     echo '<th>Raw output</th>';
135     echo '<th>Template selection</th>';
136     echo '<th>Modeling result</th>';
137     echo '</tr>';
138     foreach($jobs as $job => $last_modified) {
139     echo '<tr>';
140    
141     # job name
142     #echo '<a href=".get_results_url($job).">'.$job.'</a>';
143     echo '<td>'.$job.'</td>';
144    
145     # date
146     #$last_modified = filemtime(get_output_dir($job));
147     if($last_modified == 0) {
148     echo '<td>?</td>';
149     } else {
150     echo '<td>'.date("l, dS F, Y @ h:ia", $last_modified).'</td>';
151     }
152    
153    
154     # raw output
155     echo '<td style="text-align:center;"><a href="'.get_output_url($job).'"><img src="images/eye.png" border="0" title="view" alt="view" /></a></td>';
156    
157     # template selection result
158     echo '<td style="text-align:center;">';
159     if(is_ts_job_running($job)) {
160     echo '<img border="0" src="'.get_running_img_url().'">';
161     } else {
162     if(!file_exists(get_report_file($job))) {
163     echo '<img border="0" src="'.get_no_img_url().'">';
164     } else {
165     echo '<a href="'.view_ts_result_url($job).'"><img border="0" src="'.get_yes_img_url().'"></a>';
166     }
167     }
168     echo '</td>';
169    
170     # modelling result
171     echo '<td style="text-align:center;">';
172     if(!file_exists(get_template_file($job))) {
173     echo '-';
174     } else {
175     if(is_mb_job_running($job)) {
176     echo '<img border="0" src="'.get_running_img_url().'">';
177     } else {
178     if(!file_exists(get_pdb_file($job))) {
179     echo '<img border="0" src="'.get_no_img_url().'">';
180     } else {
181     echo '<a href="'.view_sm_result_url($job).'"><img border="0" src="'.get_yes_img_url().'"></a>';
182     }
183     }
184     }
185     echo '</td>';
186     echo '</tr>';
187     }
188     echo '</table>';
189    
190     echo '<h4>Legend:</h4>';
191     echo '<img src="'.get_run_stat_img_url().'"> Job still running<br/>';
192     echo '<img src="'.get_yes_img_url().'"> Job completed. Click to see results.<br/>';
193     echo '<img src="'.get_no_img_url().'"> No results found. Job probably failed.<br/>';
194     echo '<br/>';
195     echo 'This page automatically refreshes every '.$refresh_rate.' seconds.';
196     }
197    
198     ?>
199     </div>
200     </body>
201     </html>