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

Diff of /FigWebServices/get_dlits.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3