[Bio] / FigWebServices / get_dlits.cgi Repository:
ViewVC logotype

Annotation of /FigWebServices/get_dlits.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (view) (download)

1 : overbeek 1.1 # -*- perl -*-
2 :     #
3 : golsen 1.7 # Copyright (c) 2003-2008 University of Chicago and Fellowship
4 : overbeek 1.1 # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : golsen 1.8 #
20 :     # DBMS tables used:
21 :     #
22 :     # dlit
23 :     # flds => "status char(1), md5_hash varchar(32), pubmed varchar(16), curator varchar(30), go_code varchar(15)"
24 :     #
25 :     # titles
26 :     # flds => "pubmed varchar(16), title varchar(1000)"
27 :     #
28 :     # hash_role
29 :     # flds => "md5_hash char(32), role varchar(1000)"
30 :     #
31 :     # curr_role
32 :     # flds => "curator varchar(30), role varchar(1000)"
33 :     #
34 :     # genome_hash
35 :     # flds => "genome varchar(32), md5_hash char(32)"
36 :     #
37 : overbeek 1.1
38 :     use FIG;
39 :     my $fig = new FIG;
40 :    
41 :     use HTML;
42 :     use strict;
43 :    
44 :     use CGI;
45 :     my $cgi = new CGI;
46 :    
47 :    
48 :     if (0)
49 :     {
50 :     my $VAR1;
51 :     eval(join("",`cat /tmp/get_dlit_parms`));
52 :     $cgi = $VAR1;
53 :     # print STDERR &Dumper($cgi);
54 :     }
55 :    
56 :     if (0)
57 :     {
58 :     print $cgi->header;
59 :     my @params = $cgi->param;
60 :     print "<pre>\n";
61 :     foreach $_ (@params)
62 :     {
63 : golsen 1.7 print "$_\t:",join(",",$cgi->param($_)),":\n";
64 : overbeek 1.1 }
65 :    
66 :     if (0)
67 :     {
68 : golsen 1.7 if (open(TMP,">/tmp/get_dlit_parms"))
69 :     {
70 :     print TMP &Dumper($cgi);
71 :     close(TMP);
72 :     }
73 : overbeek 1.1 }
74 :     exit;
75 :     }
76 :     my($genome);
77 :    
78 :     my $html = [];
79 :     unshift @$html, "<TITLE>Get Dlits</TITLE>\n";
80 :    
81 : golsen 1.7 my $user = $cgi->param('user'); # Current user
82 :     my $curator = $cgi->param('curator') || ''; # Filter roles by subsystem curator
83 :     my $genomeD = $cgi->param('genomeD'); # Find lit by genome
84 : golsen 1.8 my $ref_id = $cgi->param('ref_id'); # Show data by reference
85 : golsen 1.7 my $role = $cgi->param('role'); # Find lit by role
86 :     my $show_just = $cgi->param('show_just'); # Filter lit by status
87 : overbeek 1.1 $show_just = ($show_just eq "all") ? '' : $show_just;
88 : golsen 1.9 my $who_says = $cgi->param('who_says'); # Show the responsible party
89 : overbeek 1.1
90 : golsen 1.7 # Requested actions:
91 :    
92 :     my ( $submit1, $submit2, $submit3, $submit4, $submit5 );
93 :     if ( $cgi->param( 'Process Changes' ) ) { $submit5 = 1 }
94 : golsen 1.8 if ( $ref_id ) {}
95 :     elsif ( $cgi->param( 'Change subsystem curator' ) ) {}
96 : golsen 1.7 elsif ( $cgi->param( 'Show Genomes' ) ) { $submit1 = 1 }
97 :     elsif ( $cgi->param( 'Show Roles' ) ) { $submit2 = 1 }
98 :     elsif ( $cgi->param( 'Show Genome' ) ) { $submit3 = 1 }
99 :     elsif ( $cgi->param( 'Show Role' ) ) { $submit4 = 1 }
100 :    
101 :     my $done = 0;
102 :    
103 : overbeek 1.1 my $rdbH = $fig->db_handle;
104 :    
105 : golsen 1.7 if (! -d "$FIG_Config::data/Dlits")
106 : overbeek 1.1 {
107 : golsen 1.7 push( @$html, $cgi->h1("dlit data are not installed") );
108 :     $done = 1;
109 : overbeek 1.1 }
110 : golsen 1.7 elsif ( ! $user )
111 : overbeek 1.1 {
112 : golsen 1.7 push( @$html, $cgi->h2('To curate literature, please provide a user name') );
113 :     push( @$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
114 :     'Username: ',
115 :     $cgi->textfield( -name=>"user", -size => 20 ),
116 :     $cgi->br,
117 :     $cgi->submit( 'Set user' ),
118 :     $cgi->end_form
119 :     );
120 :     $done = 1;
121 : overbeek 1.1 }
122 : golsen 1.7
123 :     # Process a page of curated literature ----------------------------------------
124 :    
125 :     if ( $submit5 && ! $done )
126 :     {
127 :     &process_changes( $fig, $cgi, $html );
128 :     my $prev_req = $cgi->param( 'prev_req' );
129 :     $submit3 = 1 if $prev_req eq 'Show Genome';
130 :     $submit4 = 1 if $prev_req eq 'Show Role';
131 : overbeek 1.1 }
132 : golsen 1.7
133 :     # If there is a problem, skip the rest of the action tests --------------------
134 :     # This is organized this way so that a useful page can be
135 :     # provided after processing a curated page.
136 :    
137 :     if ( $done ) { }
138 :    
139 : golsen 1.8 # All sequences in a reference ------------------------------------------------
140 :    
141 :     elsif ( $ref_id )
142 :     {
143 :     my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
144 : golsen 1.9 my $tuples = $rdbH->SQL( "SELECT DISTINCT status,md5_hash,curator
145 : golsen 1.8 FROM dlits
146 :     WHERE ( pubmed = '$ref_id' )"
147 :     . $and_status
148 :     );
149 :     my @to_display = ();
150 :     foreach my $x ( @$tuples )
151 :     {
152 : golsen 1.9 my( $status, $hash, $cur ) = @$x;
153 : golsen 1.8 my @pegs = $fig->pegs_with_md5( $hash );
154 :     if ( @pegs > 0 )
155 :     {
156 : golsen 1.9 push( @to_display, [ $status, $pegs[0], $ref_id, $cur ] );
157 : golsen 1.8 }
158 :     }
159 :    
160 :     &display_set( $fig, $cgi, $html, \@to_display, "Genes linked to Reference: $ref_id", 'Show Reference' ) ;
161 :     }
162 :    
163 : golsen 1.7 # Literature selected by role -------------------------------------------------
164 :    
165 :     elsif ( $submit4 && $role )
166 : overbeek 1.1 {
167 : golsen 1.7 my $roleQ = quotemeta $role;
168 : golsen 1.8 my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
169 : golsen 1.9 my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed,dlits.curator
170 : golsen 1.8 FROM hash_role,dlits
171 :     WHERE hash_role.role = '$roleQ' AND hash_role.md5_hash = dlits.md5_hash"
172 :     . $and_status
173 : golsen 1.7 );
174 : overbeek 1.1 my @to_display = ();
175 : golsen 1.8 foreach my $x ( @$tuples )
176 : overbeek 1.1 {
177 : golsen 1.9 my( $status, $hash, $pubmed, $cur ) = @$x;
178 : golsen 1.8 my @pegs = $fig->pegs_with_md5( $hash );
179 :     if ( @pegs > 0 )
180 : golsen 1.7 {
181 : golsen 1.9 push( @to_display, [ $status, $pegs[0], $pubmed, $cur ] );
182 : golsen 1.7 }
183 : overbeek 1.1 }
184 : golsen 1.8
185 :     &display_set( $fig, $cgi, $html, \@to_display, "Genes for Role: $role", 'Show Role' );
186 : golsen 1.7 }
187 :    
188 :     # Show the role list ----------------------------------------------------------
189 :    
190 :     elsif ( $submit2 || $submit4 )
191 :     {
192 :     # Did user request role literature, and not select a role?
193 :     push @$html, $cgi->h3( '<FONT Color=red>Please select a role.</FONT>' ) if $submit4;
194 :    
195 :     my $where1 = $show_just ? " AND (dlits.status = '$show_just')" : "";
196 :     my $where2 = $curator ? " AND (curr_role.curator = '$curator' AND curr_role.role = hash_role.role)" : "";
197 :    
198 :     my @roles = sort { lc $a cmp lc $b } # Make sort case insensitive
199 :     map { $_->[0] }
200 :     @{ $rdbH->SQL( "SELECT DISTINCT hash_role.role
201 :     FROM hash_role,dlits,curr_role
202 :     WHERE hash_role.md5_hash = dlits.md5_hash $where1 $where2"
203 :     ) };
204 :     push( @$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
205 : golsen 1.9 $cgi->hidden( -name => 'user', -value => $user ),
206 :     $cgi->hidden( -name => 'curator', -value => $curator ),
207 :     $cgi->hidden( -name => 'who_says', -value => $who_says )
208 : golsen 1.7 );
209 :    
210 :     my $whom = $curator ? "'$curator'" : "any one";
211 :     my $status = $show_just ? " with literature of status code '$show_just':" : ":";
212 :     push( @$html, $cgi->h3( "Subsystem roles curated by $whom" . $status ) );
213 :    
214 :     push( @$html, $cgi->scrolling_list( -name => 'role',
215 :     -values => [@roles],
216 :     -size => 30
217 :     ),
218 :     $cgi->br, &show_just_selector( $cgi ),
219 :     $cgi->br, $cgi->submit( 'Show Role' ),
220 :     $cgi->br, $cgi->submit( 'Show Genomes' ),
221 :     $cgi->br, $cgi->submit( 'Change subsystem curator' ), " currently '$curator'.",
222 :     $cgi->end_form
223 :     );
224 : overbeek 1.1 }
225 : golsen 1.7
226 :     # Literature selected by genome -----------------------------------------------
227 :    
228 :     elsif ( $submit3 && $genomeD && ( $genomeD =~ /\((\d+\.\d+)\)$/ ) )
229 : overbeek 1.1 {
230 : golsen 1.7 my $genome = $1;
231 :     my $where = $show_just ? " AND (dlits.status = '$show_just')" : '';
232 : golsen 1.9 my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed,dlits.curator
233 : golsen 1.7 FROM genome_hash,dlits
234 :     WHERE genome_hash.genome = '$genome' AND genome_hash.md5_hash = dlits.md5_hash $where"
235 :     );
236 : overbeek 1.1 my @to_display = ();
237 : golsen 1.7 foreach my $x ( @$tuples )
238 : overbeek 1.1 {
239 : golsen 1.9 my ( $status, $hash, $pubmed, $cur ) = @$x;
240 : golsen 1.7 foreach my $peg ( $fig->pegs_with_md5($hash) )
241 :     {
242 :     if ( &FIG::genome_of($peg) eq $genome )
243 :     {
244 : golsen 1.9 push(@to_display,[ $status, $peg, $pubmed, $cur ]);
245 : golsen 1.7 }
246 :     }
247 : overbeek 1.1 }
248 : golsen 1.7 &display_set( $fig, $cgi, $html, \@to_display, "Genes for $genomeD", 'Show Genome' );
249 :     }
250 :    
251 :     # Show genome list ------------------------------------------------------------
252 :    
253 :     elsif ( $submit1 || $submit3 )
254 :     {
255 :     # Did user request genome literature, and not select a genome?
256 :     push @$html, $cgi->h3( '<FONT Color=red>Please select a genome.</FONT>' ) if $submit3;
257 :    
258 :     my $where = $show_just ? " AND (dlits.status = '$show_just')" : "";
259 :    
260 :     my $genomes = $rdbH->SQL( "SELECT DISTINCT genome_hash.genome
261 :     FROM genome_hash,dlits
262 :     WHERE genome_hash.md5_hash = dlits.md5_hash $where"
263 :     );
264 :     my @genomes = sort { lc $a cmp lc $b } # Make sort case insensitive
265 :     map { &compute_genome_label( $fig, $_->[0] ) }
266 :     @$genomes;
267 :    
268 :     push( @$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
269 : golsen 1.9 $cgi->hidden( -name => 'user', -value => $user ),
270 :     $cgi->hidden( -name => 'curator', -value => $curator ),
271 :     $cgi->hidden( -name => 'who_says', -value => $who_says ),
272 : golsen 1.7 $cgi->scrolling_list( -name => 'genomeD',
273 :     -values => [@genomes],
274 :     -size => 30
275 :     ),
276 :     $cgi->br, &show_just_selector( $cgi ),
277 :     $cgi->br, $cgi->submit( 'Show Genome' ),
278 :     $cgi->br, $cgi->submit( 'Show Roles' ),
279 :     $cgi->br, $cgi->submit( 'Change subsystem curator' ), " currently '$curator'.",
280 :     $cgi->end_form
281 :     );
282 : overbeek 1.1 }
283 : golsen 1.7
284 :     # Default = display subsystem curators ----------------------------------------
285 :    
286 : overbeek 1.1 else
287 :     {
288 : golsen 1.7 my @cur = map { $_->[0] }
289 :     sort { $a->[1] cmp $b->[1] || length $a->[0] <=> length $b->[0] }
290 :     map { my $cur = $_->[0];
291 :     my $nam = lc $cur;
292 :     $nam =~ s/^master[:_]?//;
293 :     [ $cur, $nam ]
294 :     }
295 :     @{ $rdbH->SQL( "SELECT DISTINCT curator FROM dlits" ) };
296 :     my $curN = @cur;
297 :    
298 :     push( @$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
299 : golsen 1.9 $cgi->hidden( -name => 'user', -value => $user ),
300 :     $cgi->hidden( -name => 'who_says', -value => $who_says ),
301 : golsen 1.7 $cgi->scrolling_list( -name => 'curator',
302 :     -values => [ @cur ],
303 :     -size => $curN
304 :     ),
305 :     $cgi->br,
306 :     &show_just_selector( $cgi ),
307 :     $cgi->submit( 'Show Roles' ),
308 :     $cgi->br,
309 :     $cgi->submit( 'Show Genomes' ),
310 :     $cgi->end_form
311 :     );
312 :     }
313 :     &HTML::show_page($cgi,$html);
314 :     exit;
315 : overbeek 1.1
316 :    
317 : golsen 1.7 sub show_just_selector
318 :     {
319 :     my ( $cgi, $html ) = @_;
320 :     my $default = $cgi->param( 'show_just' );
321 :     $default =~ /^[ A-Z]$/ or $default = 'all';
322 :     return 'Show literature links with all status codes, or pick a specific one: '
323 :     . $cgi->scrolling_list( -name => 'show_just',
324 :     -values => ['all',' ','D','R','N','G'],
325 :     -default => $default,
326 :     -override => 1,
327 :     -size => 1
328 :     )
329 :     . $cgi->br;
330 : overbeek 1.1 }
331 :    
332 :    
333 :     sub compute_genome_label
334 :     {
335 :     my($fig, $org) = @_;
336 :    
337 :     my $gs = $fig->genus_species($org);
338 :     return "$gs ($org)";
339 :     }
340 :    
341 : golsen 1.7
342 : overbeek 1.1 sub title_of {
343 : golsen 1.8 my( $fig, $pubmed ) = @_;
344 : overbeek 1.1
345 :     my $rdbH = $fig->db_handle;
346 : golsen 1.7 my $retval = $rdbH->SQL( "SELECT title
347 :     FROM pubmed_titles
348 :     WHERE (pubmed = $pubmed)"
349 :     );
350 :     return ( @$retval > 0 ) ? $retval->[0]->[0] : "";
351 :     }
352 :    
353 :    
354 :     sub pubmed_link
355 :     {
356 :     return "<a target=_blank href=http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=search&term=$_[0]>$_[0]</a>";
357 : overbeek 1.1 }
358 : golsen 1.7
359 : overbeek 1.1
360 :     sub display_set {
361 : golsen 1.7 my( $fig, $cgi, $html, $to_display, $tab_title, $submit ) = @_;
362 : overbeek 1.1
363 : golsen 1.7 my %status_code = ( 'D' => 1, ' ' => 2, 'N' => 3, 'R' => 4, 'G' => 5 );
364 : overbeek 1.1
365 : golsen 1.7 # @$to_distplay items are [ $status, $peg, $pubmed ]
366 : overbeek 1.1
367 : golsen 1.7 foreach $_ ( @$to_display ) { $_->[0] =~ s/^\s*$/ /; } # fix empty status strings
368 :     my @tuples = sort { ( $status_code{$a->[0]} <=> $status_code{$b->[0]} )
369 :     or &FIG::by_fig_id( $a->[1], $b->[1] )
370 :     or ( $a->[2] <=> $b->[2] )
371 :     }
372 :     @$to_display;
373 : overbeek 1.1 my $total_tuples = @tuples;
374 :    
375 : golsen 1.7 my $from; # Offset to first item displayed
376 : golsen 1.8 my $n_per_page = 100; # Really the lines per page
377 : golsen 1.7
378 :     if ( $cgi->param( 'Go to item numbers' ) )
379 :     {
380 :     $from = $cgi->param( 'offset_select' );
381 :     }
382 :     else
383 :     {
384 :     $from = $cgi->param( 'from_line' ) || 0;
385 : golsen 1.8 $from -= $n_per_page if $cgi->param( 'Previous page' );
386 :     $from += $n_per_page if $cgi->param( 'Next page' );
387 : golsen 1.7 }
388 :    
389 :     # Cut down the array to that to be displayed
390 :    
391 :     if ( $total_tuples > 0 )
392 :     {
393 :     if ( $from < 0 ) { $from = 0 }
394 :     if ( $from > $total_tuples )
395 :     {
396 : golsen 1.8 $from = $n_per_page * int( ( $total_tuples - 1 ) / $n_per_page );
397 : golsen 1.7 }
398 :     splice( @tuples, 0, $from );
399 : golsen 1.8 splice( @tuples, $n_per_page );
400 : golsen 1.7 }
401 : overbeek 1.1 else
402 :     {
403 : golsen 1.7 undef $from;
404 : overbeek 1.1 }
405 :    
406 : golsen 1.7 # Add status code key at top of page
407 :    
408 :     &desc( $html );
409 :    
410 :     # Build the html form
411 :    
412 :     push( @$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post') );
413 :    
414 :     # Current user
415 :     my $user = $cgi->param('user');
416 :     push( @$html, $cgi->hidden( -name => 'user', -value => $user, -override => 1 ) );
417 :    
418 :     # Filter roles by subsystem curator
419 : golsen 1.8 my $curator = $cgi->param('curator');
420 : golsen 1.7 push( @$html, $cgi->hidden( -name => 'curator', -value => $curator, -override => 1 ) ) if $curator;
421 :    
422 :     # Find lit by genome
423 :     my $genomeD = $cgi->param('genomeD');
424 :     push( @$html, $cgi->hidden( -name => 'genomeD', -value => $genomeD, -override => 1 ) ) if $genomeD;
425 :    
426 : golsen 1.8 # Show sequences associated with a reference
427 :     my $ref_id = $cgi->param('ref_id');
428 :     push( @$html, $cgi->hidden( -name => 'ref_id', -value => $ref_id, -override => 1 ) ) if $ref_id;
429 :    
430 : golsen 1.7 # Find lit by role
431 :     my $role = $cgi->param('role');
432 :     push( @$html, $cgi->hidden( -name => 'role', -value => $role, -override => 1 ) ) if $role;
433 :    
434 : golsen 1.9 # Find lit by role
435 :     my $who_says = $cgi->param('who_says');
436 :     push( @$html, $cgi->hidden( -name => 'who_says', -value => $who_says, -override => 1 ) ) if $who_says;
437 :    
438 : golsen 1.7 # Requested action
439 :     push( @$html, $cgi->hidden( -name => 'prev_req', -value => $submit, -override => 1 ) ) if $submit;
440 :    
441 :     # Used to inherit action
442 :     push( @$html, $cgi->hidden( -name => $submit, -value => 1, -override => 1 ) ) if $submit;
443 :    
444 :     push( @$html, $cgi->br );
445 :    
446 : golsen 1.8 # If this is not a table built around one reference, we want to append
447 :     # links to all proteins associated with the reference. We will
448 :     # compute this on a unique set of the references:
449 :    
450 :     my %genes_in_pub;
451 :     if ( ! $ref_id )
452 :     {
453 :     foreach ( @tuples )
454 :     {
455 :     my $pub = $_->[2];
456 :     next if defined $genes_in_pub{ $pub };
457 :     # This count intentionally omits filtering by status
458 :     $genes_in_pub{ $pub } = scalar ( &all_seqs_in_pub( $fig, $pub ) );
459 :     }
460 :     }
461 :    
462 : golsen 1.7 # Build the status selection table
463 :    
464 : golsen 1.9 my $col_hdrs = $who_says ? [' ','G','N','R','D','Curator','PEG','Function','Genus/Species','PubMed','Title']
465 :     : [' ','G','N','R','D','PEG','Function','Genus/Species','PubMed','Title'];
466 : golsen 1.7 my $tab = [];
467 : overbeek 1.1 my $i;
468 : golsen 1.8 for ( $i = 0; ($i < @tuples); $i++ )
469 : overbeek 1.1 {
470 : golsen 1.7 my $tuple = $tuples[$i];
471 : golsen 1.9 my( $status, $peg, $pubmed, $cur ) = @$tuple;
472 : golsen 1.7 next if (! $fig->is_real_feature($peg));
473 :     my $gs = $fig->genus_species( &FIG::genome_of( $peg ) );
474 :     $gs =~ s/^(\S+\s+\S+).*$/$1/;
475 :     my $title = &title_of( $fig, $pubmed );
476 :     my $func = $fig->function_of($peg);
477 :     my @codes = $cgi->radio_group( -name => "tuple:$peg:$pubmed:$status",
478 :     -values => [' ','G','N','R','D'],
479 :     -default => "$status",
480 :     -nolabels => 1
481 :     );
482 :    
483 : golsen 1.8 my $pub_link = &pubmed_link( $pubmed );
484 :    
485 :     # Does this paper cover more than one protein?
486 :    
487 :     if ( $genes_in_pub{ $pubmed } > 1 )
488 :     {
489 :     # This link intentionally omits filtering by status
490 : golsen 1.9 my $href = "get_dlits.cgi?user=$user&ref_id=$pubmed";
491 :     $href .= '&who_says=1' if $who_says;
492 :     $pub_link .= "<BR />(<A HRef='$href' Target=_blank>$genes_in_pub{$pubmed} seqs</A>)";
493 : golsen 1.8 }
494 : golsen 1.7 if (($i % 15) == 14) { push(@$tab,$col_hdrs) }
495 : golsen 1.9 push( @$tab, $who_says ? [ @codes, $cur, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ]
496 :     : [ @codes, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ]
497 :     );
498 : golsen 1.7 }
499 :    
500 :     push( @$html,&HTML::make_table( $col_hdrs, $tab, $tab_title ) );
501 :    
502 :     push( @$html, $cgi->br, &show_just_selector( $cgi ) );
503 :    
504 :     # Navigation controls through long lists
505 :    
506 : golsen 1.8 if ( defined( $from ) && ( $total_tuples > $n_per_page ) )
507 : golsen 1.7 {
508 :     my $i1 = $from + 1;
509 : golsen 1.8 my $i2 = $from + $n_per_page;
510 : golsen 1.7 $i2 = $total_tuples if $i2 > $total_tuples;
511 :     push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );
512 :     push( @$html, $cgi->br, "Currently displaying items $i1 - $i2 of $total_tuples.", $cgi->br );
513 :     push( @$html, $cgi->submit( 'Previous page' ) ) if $from > 0;
514 :     push( @$html, $cgi->submit( 'Next page' ) ) if $i2 < $total_tuples;
515 :    
516 :     my @offsets;
517 :     my %labels;
518 : golsen 1.8 for ( my $i = 0; $i < $total_tuples; $i += $n_per_page )
519 : golsen 1.7 {
520 :     push @offsets, $i;
521 : golsen 1.8 my $imax = $i + $n_per_page;
522 : golsen 1.7 $imax = $total_tuples if $imax > $total_tuples;
523 :     $labels{ $i } = ( $i+1 ) . " - $imax";
524 :     }
525 :     push( @$html, $cgi->submit( 'Go to item numbers' ),
526 :     $cgi->scrolling_list( -name => 'offset_select',
527 :     -values => \@offsets,
528 :     -labels => \%labels,
529 :     -default => $from,
530 :     -size => 1,
531 :     -override => 1
532 :     ),
533 :     $cgi->br );
534 : overbeek 1.1 }
535 : golsen 1.7
536 :     # Some action buttons:
537 :    
538 :     push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );
539 :    
540 : golsen 1.8 # Display some general navigation buttons. However, these are not
541 :     # consistent with the intended use of the publication-based view.
542 : golsen 1.7
543 : golsen 1.8 if ( ! $ref_id )
544 : golsen 1.7 {
545 : golsen 1.8 push( @$html, $cgi->br, $cgi->submit( 'Show Genomes' ), "discarding any changes made on this page." );
546 :     if ( $curator )
547 :     {
548 :     push( @$html, $cgi->br, $cgi->submit( 'Show Roles' ),
549 :     "for subsystem curator '$curator', discarding any changes made on this page." );
550 :     }
551 :     push( @$html, $cgi->br, $cgi->submit( 'Change subsystem curator' ), " currently '$curator', discarding any changes made on this page." );
552 : golsen 1.7 }
553 :    
554 : golsen 1.8 push( @$html, $cgi->end_form );
555 :     }
556 :    
557 : golsen 1.7
558 : golsen 1.8 # dlit
559 :     # flds => "status char(1), md5_hash varchar(32), pubmed varchar(16), curator varchar(30), go_code varchar(15)"
560 :    
561 :     sub all_seqs_in_pub {
562 :     my ( $fig, $pubmed, $status ) = @_;
563 :     my $rdbH = $fig->db_handle;
564 :     my $and_status = $status ? " AND ( status = '$status' )" : "";
565 :     my $response = $rdbH->SQL( "SELECT DISTINCT md5_hash
566 :     FROM dlits
567 :     WHERE ( pubmed = '$pubmed' )"
568 :     . $and_status
569 :     );
570 :     return ( ref $response ) ? map { $_->[0] } @$response : ();
571 : overbeek 1.1 }
572 :    
573 : golsen 1.7
574 : overbeek 1.4 sub desc {
575 : golsen 1.7 my( $html ) = @_;
576 : overbeek 1.4
577 : golsen 1.7 my $col_hdrs = [ "Code", "Meaning" ];
578 :     my $tab = [ [ [" ","TD Align=center"], "No one has curated this link yet" ],
579 :     [ ["G","TD Align=center"], "Genome paper - marks all uncurated protein links of this paper to 'G' (implicitly irrelevant)" ],
580 :     [ ["N","TD Align=center"], "Not relevant to this protein" ],
581 :     [ ["R","TD Align=center"], "Relevant, but not strong enough to determine function" ],
582 :     [ ["D","TD Align=center"], "Direct reference that can be used to support function assertion" ]
583 :     ];
584 :     push( @$html, &HTML::make_table( $col_hdrs, $tab, "Code Meanings" ), "<hr>" );
585 : overbeek 1.4 }
586 :    
587 : golsen 1.7
588 : overbeek 1.1 sub process_changes {
589 : golsen 1.7 my( $fig, $cgi, $html ) = @_;
590 :     my $user = $cgi->param('user');
591 : overbeek 1.1
592 :     my @tuples = grep { $_->[2] ne $_->[3] }
593 :     map { ($_ =~ /^tuple:(fig\|\d+\.\d+\.peg\.\d+)\s*:\s*(\d+)\s*:([ RDGN])/) ? [$1,$2,$3,$cgi->param($_)] : () }
594 :     $cgi->param();
595 : golsen 1.7 my $n_change = 0;
596 :     foreach my $tuple ( @tuples )
597 : overbeek 1.1 {
598 : golsen 1.7 my( $peg, $pubmed, $from, $to ) = @$tuple;
599 :     $fig->add_dlit( -status => $to,
600 :     -peg => $peg,
601 :     -pubmed => $pubmed,
602 :     -curator => $user,
603 :     -override => 1
604 :     );
605 :     $n_change++;
606 : overbeek 1.1 }
607 : golsen 1.7
608 :     push( @$html, $cgi->h2( "<FONT Color=green>Made $n_change requested changes.</FONT>" ) );
609 : overbeek 1.1 }
610 :    
611 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3