[Bio] / PRAST / WebPage / Genome.pm Repository:
ViewVC logotype

Annotation of /PRAST/WebPage/Genome.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : arodri7 1.1 package PRAST::WebPage::Genome;
2 :    
3 :     use strict;
4 :     use warnings;
5 :    
6 :     use POSIX;
7 :    
8 :     use base qw( WebPage PRAST::WebPage::JobDetails );
9 :     use WebConfig;
10 :    
11 :     use RAST::RASTShared qw( get_menu_job );
12 :    
13 :     1;
14 :    
15 :    
16 :     =pod
17 :    
18 :     =head1 NAME
19 :    
20 :     Genome - displays detailed information about a genome job
21 :    
22 :     =head1 DESCRIPTION
23 :    
24 :     Job Details (Genome) page
25 :    
26 :     =head1 METHODS
27 :    
28 :     =over 4
29 :    
30 :     =item * B<init> ()
31 :    
32 :     Called when the web page is instanciated.
33 :    
34 :     =cut
35 :    
36 :     sub init {
37 :     my $self = shift;
38 :    
39 :     $self->title("Job Details");
40 :    
41 :     # sanity check on job
42 :     my $id = $self->application->cgi->param('job') || '';
43 :     my $job;
44 :     eval { $job = $self->app->data_handle('RAST')->Job->init({ id => $id }); };
45 :     unless ($job) {
46 :     $self->app->error("Unable to retrieve the job '$id'.");
47 :     }
48 :     $self->data('job', $job);
49 :    
50 :     # add links
51 :     &get_menu_job($self->app->menu, $job);
52 :    
53 :     # register quality revision actions
54 :     $self->application->register_action($self, 'set_correction_requests', 'Correct selected quality problems');
55 :     $self->application->register_action($self, 'accept_genome_quality', 'Accept quality and proceed');
56 :    
57 :     }
58 :    
59 :    
60 :     =item * B<output> ()
61 :    
62 :     Returns the html output of the page.
63 :    
64 :     =cut
65 :    
66 :     sub output {
67 :     my ($self) = @_;
68 :    
69 :     my $job = $self->data('job');
70 :    
71 :     my $content = '<h1>Jobs Details #'.$job->id.'</h1>';
72 :    
73 :     if ($job->ready_for_browsing) {
74 :    
75 :     # check for PrivateOrganismPreferences
76 :     my $application = $self->application;
77 :     my $user = $application->session->user;
78 :     my $prefs = $application->dbmaster->Preferences->get_objects( { user => $user, name => 'PrivateOrganismPeer' } );
79 :     my $job_is_peer = 0;
80 :     if (scalar(@$prefs)) {
81 :     foreach my $pref (@$prefs) {
82 :     if ($pref->value eq $job->genome_id) {
83 :     $job_is_peer = 1;
84 :     last;
85 :     }
86 :     }
87 :     } else {
88 :     $application->dbmaster->Preferences->create( { user => $user, name => 'PrivateOrganismPeer', value => $job->genome_id } );
89 :     $job_is_peer = 1;
90 :     }
91 :    
92 :     if (! $job_is_peer) {
93 :     $application->add_message('info', "This job is not currently in your preferences for comparison organisms. To edit your preferences, please go to <a href='?page=PrivateOrganismPreferences'>Private Organism Preferences</a>.");
94 :     }
95 :    
96 :     $content .= '<p> &raquo; <a target="_blank" href="seedviewer.cgi?page=Organism&organism='.
97 :     $job->genome_id.'">Browse annotated genome in SEED Viewer</a></p>';
98 :    
99 :     #$content .= '<p> &raquo; <a href="?page=ExportGenome&job='.
100 :     # $job->id.'&format=default">Export the annotated genome as GenBank (default)</a> ';
101 :     #$content .= ' <a href="?page=ExportGenome&job='.
102 :     # $job->id.'"> (with custom options) </a></p>';
103 :    
104 :     }
105 :    
106 :     # check for downloads
107 :     my $downloads = $job->downloads();
108 :     if (scalar(@$downloads)) {
109 :     my @values = map { $_->[0] } @$downloads;
110 :     my %labels = map { $_->[0] => $_->[1] || $_->[0] } @$downloads;
111 :     my @default = grep { 1 if $_->[1] eq 'Genbank' } @$downloads;
112 :    
113 :     $content .= $self->start_form('download', { page => 'DownloadFile', job => $job->id });
114 :     $content .= '<p> &raquo; Available downloads for this job: ';
115 :     $content .= $self->app->cgi->popup_menu( -name => 'file',
116 :     -values => \@values,
117 :     -labels => \%labels,
118 :     -default => $default[0][0],
119 :     );
120 :     $content .= "<input type='submit' value=' Download '>";
121 :     $content .= $self->end_form;
122 :     }
123 :     else {
124 :     if ($job->ready_for_browsing) {
125 :     $content .= '<p> &raquo; No downloads available for this genome yet.</p>';
126 :     }
127 :     }
128 :    
129 :    
130 :     if ($self->app->session->user->has_right(undef, 'edit', 'genome', $job->genome_id, 1) and
131 :     $self->app->session->user->has_right(undef, 'view', 'genome', $job->genome_id, 1)) {
132 :     $content .= '<p> &raquo; <a href="?page=JobShare&job='.$job->id.
133 :     '">Share this genome with selected users</a> ';
134 :     }
135 :    
136 :     $content .= "<p> &raquo <a href='?page=Jobs'>Back to the Jobs Overview</a></p>";
137 :    
138 :     # upload
139 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.uploaded'),
140 :     'Genome Upload');
141 :     $content .= "<table>";
142 :     $content .= "<tr><th>Genome ID - Name:</th><td>".$job->genome_id." - ".$job->genome_name."</td></tr>";
143 :     $content .= "<tr><th>Job:</th><td> #".$job->id."</td></tr>";
144 :     $content .= "<tr><th>User:</th><td>".$job->owner->login."</td></tr>";
145 :     $content .= "<tr><th>Date:</th><td>".localtime($job->metaxml->get_metadata('upload.timestamp'))."</td></tr>";
146 :    
147 :     $content .= "<tr><td colspan=2></td></tr>";
148 :    
149 :     $content .= "<tr><th>Sequencing method:</th><td>".$job->metaxml->get_metadata('genome.sequencing_method')."</td></tr>";
150 :     $content .= "<tr><th>Coverage:</th><td>".$job->metaxml->get_metadata('genome.coverage')."</td></tr>";
151 :     $content .= "<tr><th>Number of contigs:</th><td>".$job->metaxml->get_metadata('genome.contigs')."</td></tr>";
152 :     $content .= "<tr><th>Read length:</th><td>".($job->metaxml->get_metadata('genome.read_length') || '')."</td></tr>";
153 :     $content .= "<tr><th>Genetic code:</th><td>".$job->metaxml->get_metadata('genome.genetic_code')."</td></tr>";
154 :    
155 :     $content .= "<tr><td colspan=2></td></tr>";
156 :    
157 :     my $text = $job->metaxml->get_metadata('submit_suggested')? 'yes' : 'no';
158 :     $content .= "<tr><th>Include into SEED:</th><td>".$text."</td></tr>";
159 :    
160 :     $text = $job->metaxml->get_metadata('keep_genecalls')? 'yes' : 'no';
161 :     $content .= "<tr><th>Preserve gene calls:</th><td>".$text."</td></tr>";
162 :    
163 :     $text = $job->metaxml->get_metadata('correction.automatic')? 'yes' : 'no';
164 :     $content .= "<tr><th>Automatically fix errors:</th><td>".$text."</td></tr>";
165 :    
166 :     $text = $job->metaxml->get_metadata('correction.frameshifts')? 'yes' : 'no';
167 :     $content .= "<tr><th>Fix frameshifts:</th><td>".$text."</td></tr>";
168 :    
169 :     $text = $job->metaxml->get_metadata('correction.backfill_gaps')? 'yes' : 'no';
170 :     $content .= "<tr><th>Backfill gaps:</th><td>".$text."</td></tr>";
171 :    
172 :     $content .= "</table>";
173 :    
174 :     # rapid propagation
175 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.rp'),
176 :     'Rapid Propagation');
177 :    
178 :     # quality check
179 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.qc'),
180 :     'Quality Check');
181 :    
182 :     # build table with quality statistics data
183 :     my $QCs = [[ 'qc.Num_features', 'Number of features' ],
184 :     [ 'qc.Num_warn', 'Number of warnings' ],
185 :     [ 'qc.Num_fatal', 'Number of fatal problems' ],
186 :     [ 'qc.Possible_missing', 'Possibly missing genes' ],
187 :     [ 'qc.RNA_overlaps', 'RNA overlaps' ],
188 :     [ 'qc.Bad_STARTs', 'Genes with bad starts' ],
189 :     [ 'qc.Bad_STOPs', 'Genes with bad stops' ],
190 :     [ 'qc.Same_STOP', 'Genes with identical stop' ],
191 :     [ 'qc.Embedded', 'Embedded genes' ],
192 :     [ 'qc.Impossible_overlaps', 'Critical quality check errors' ],
193 :     [ 'qc.Too_short', 'Genes which are too short (< 90 bases)' ],
194 :     [ 'qc.Convergent', 'Convergent overlaps' ],
195 :     [ 'qc.Divergent', 'Divergent overlaps' ],
196 :     [ 'qc.Same_strand', 'Same strand overlaps' ],
197 :     ];
198 :    
199 :     my $statistics = '';
200 :     foreach my $qc (@$QCs) {
201 :     if ($job->metaxml->get_metadata($qc->[0])) {
202 :     my ($type, $value) = @{$job->metaxml->get_metadata($qc->[0])};
203 :     if ($value or ($type and $type eq 'SCORE')) {
204 :     my $info = ($type eq 'SCORE') ? '' : ucfirst(lc($type));
205 :     $statistics .= "<tr><th>".$qc->[1].":</th><td>".$value."</td><td>".$info."</td></tr>";
206 :     }
207 :     }
208 :     }
209 :    
210 :     if ($statistics) {
211 :     $content .= "<p>For detailed explanations of the terms used in our quality report, please refer to <a href='http://www.theseed.org/wiki/RAST_Quality_Report' target='_blank'>our wiki</a>.</p>";
212 :     $content .= "<table> $statistics </table>";
213 :     }
214 :    
215 :    
216 :     # correction phase
217 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.correction'),
218 :     'Quality Revision');
219 :    
220 :     # correction request form
221 :     if ($job->metaxml->get_metadata('status.correction') and
222 :     $job->metaxml->get_metadata('status.correction') eq 'requires_intervention') {
223 :    
224 :     $content .= '<p id="section_content">Please select the correction procedures you would like to run on your genome and press the <em>Correct selected quality problems</em> button. If you do want to keep the all information despite failure to meet the quality check requirements, accept the genome as it is.</p>';
225 :     $content .= '<p id="section_content">Please refer to our documentation to find a <a href="http://www.theseed.org/wiki/SponkeyQualityRevision" target="_blank">detailed explanation of the quality revision</a>.</p>';
226 :    
227 :     my $corrections = { 'remove_embedded_pegs' => 'Remove embedded genes',
228 :     'remove_rna_overlaps' => 'Remove RNA overlaps', };
229 :    
230 :     my $possible = $job->metaxml->get_metadata("correction.possible");
231 :    
232 :     $content .= '<p>'.$self->start_form(undef, { 'job' => $job->id });
233 :     $content .= join('', $self->app->cgi->checkbox_group( -name => 'corrections',
234 :     -values => $possible,
235 :     -linebreak => 'true',
236 :     -labels => $corrections,
237 :     )
238 :     );
239 :     $content .= "</p><p>".$self->app->cgi->submit(-name => 'action', -value => 'Correct selected quality problems');
240 :     $content .= " &laquo; or &raquo; ";
241 :     $content .= $self->app->cgi->submit(-name => 'action', -value => 'Accept quality and proceed');
242 :     $content .= $self->end_form.'</p>';
243 :    
244 :     }
245 :    
246 :     # show info if quality revision is running
247 :     if ($job->metaxml->get_metadata('correction.request') and
248 :     $job->metaxml->get_metadata('status.correction') and
249 :     $job->metaxml->get_metadata('status.correction') ne 'complete' ) {
250 :     $content .= "<p>Quality revision has been requested for this job.</p>";
251 :     }
252 :    
253 :     # show info if quality revision is complete
254 :     if ($job->metaxml->get_metadata('status.correction') and
255 :     $job->metaxml->get_metadata('status.correction') eq 'complete') {
256 :     if ($job->metaxml->get_metadata('correction.timestamp') and
257 :     $job->metaxml->get_metadata('correction.acceptedby')) {
258 :     $content .= "<table>";
259 :     $content .= "<tr><th>Accepted by:</th><td>".$job->metaxml->get_metadata('correction.acceptedby')."</td></tr>";
260 :     $content .= "<tr><th>Date:</th><td>".localtime($job->metaxml->get_metadata('correction.timestamp'))."</td></tr>";
261 :     $content .= "</table>";
262 :     }
263 :     else {
264 :     $content .= "<p>No quality revision was necessary.</p>";
265 :     }
266 :     }
267 :    
268 :    
269 :     # similarity computation
270 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.sims'),
271 :     'Similarity Computation');
272 :    
273 :     # auto assignement
274 :     $content .= $self->get_section_bar($job->metaxml->get_metadata('status.auto_assign'),
275 :     'Auto Assignment');
276 :    
277 :     return $content;
278 :    
279 :     }
280 :    
281 :    
282 :     =item * B<set_correction_requests> ()
283 :    
284 :     Action method that will set the requested quality corrections.
285 :    
286 :     =cut
287 :    
288 :     sub set_correction_requests {
289 :     my ($self) = @_;
290 :    
291 :     my @corrections = $self->application->cgi->param('corrections');
292 :     my $job = $self->data('job');
293 :    
294 :     if (scalar(@corrections)) {
295 :     $self->application->add_message('info', 'Quality revision(s) requested.');
296 :     $job->metaxml->set_metadata('status.correction', 'not_started');
297 :     $job->metaxml->set_metadata('correction.request', \@corrections);
298 :     $job->metaxml->set_metadata('correction.acceptedby', $self->application->session->user->login);
299 :     $job->metaxml->set_metadata('correction.timestamp', time());
300 :     }
301 :     else {
302 :     $self->application->add_message('info', 'You did not select any quality revision. Nothing changed.');
303 :     }
304 :    
305 :     }
306 :    
307 :    
308 :     =item * B<accept_genome_quality> ()
309 :    
310 :     Action method that will set the quality revision to accepted
311 :    
312 :     =cut
313 :    
314 :     sub accept_genome_quality {
315 :     my ($self) = @_;
316 :    
317 :     $self->application->add_message('info', 'Genome quality accepted.');
318 :    
319 :     my $job = $self->data('job');
320 :     if ($job->metaxml->get_metadata('status.uploaded') eq 'complete' and
321 :     $job->metaxml->get_metadata('status.rp') eq 'complete' and
322 :     $job->metaxml->get_metadata('status.qc') eq 'complete' and
323 :     $job->metaxml->get_metadata('status.correction') ne 'complete') {
324 :    
325 :     $job->metaxml->set_metadata('status.correction', 'complete');
326 :     $job->metaxml->set_metadata('correction.timestamp', time());
327 :     $job->metaxml->set_metadata('correction.acceptedby', $self->application->session->user->login);
328 :    
329 :     }
330 :     else {
331 :     $self->application->error('Illegal call of proceed genome quality.');
332 :     }
333 :    
334 :     }
335 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3