[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.9, Tue Jul 8 21:26:13 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    my $who_says  = $cgi->param('who_says');       #  Show the responsible party
89    
90    #  Requested actions:
91    
92    my ( $submit1, $submit2, $submit3, $submit4, $submit5 );
93    if    ( $cgi->param( 'Process Changes' )          ) { $submit5 = 1 }
94    if    ( $ref_id                                   ) {}
95    elsif ( $cgi->param( 'Change subsystem curator' ) ) {}
96    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    
 my $genomeD   = $cgi->param('genomeD');  
 my $submit5   = $cgi->param('Process Changes');  
103  my $rdbH  = $fig->db_handle;  my $rdbH  = $fig->db_handle;
104    
105  if (! $user)  if (! -d "$FIG_Config::data/Dlits")
106  {  {
107      push(@$html,$cgi->h1('you need to set user= in the URL'));      push( @$html, $cgi->h1("dlit data are not installed") );
108        $done = 1;
109  }  }
110  elsif (! -d "$FIG_Config::data/Dlits")  elsif ( ! $user )
111  {  {
112      push(@$html,$cgi->h1("dlit data not installed"));      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  }  }
122  elsif ($submit5)  
123    #  Process a page of curated literature ----------------------------------------
124    
125    if ( $submit5 && ! $done )
126  {  {
127      &process_changes($fig,$cgi,$html);      &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  }  }
132  elsif ($submit1)  
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    #  All sequences in a reference ------------------------------------------------
140    
141    elsif ( $ref_id )
142  {  {
143      my $where   = $show_just ? "AND (dlits.status = '$show_just ') " : "";      my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
144      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,curator
145      my @genomes = sort map { &compute_genome_label($fig,$_->[0]) } @$genomes;                                FROM dlits
146                                  WHERE ( pubmed = '$ref_id' )"
147                                  . $and_status
148                               );
149        my @to_display = ();
150        foreach my $x ( @$tuples )
151        {
152            my( $status, $hash, $cur ) = @$x;
153            my @pegs = $fig->pegs_with_md5( $hash );
154            if ( @pegs > 0 )
155            {
156                push( @to_display, [ $status, $pegs[0], $ref_id, $cur ] );
157            }
158        }
159    
160      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' ) ;
161                   $cgi->hidden(-name => 'user', -value=>$user),  }
162                   $cgi->hidden(-name => 'show_just', -value=>$show_just),  
163                   $cgi->hidden(-name => 'curator', -value=> $curator),  #  Literature selected by role -------------------------------------------------
164                   $cgi->scrolling_list( -name   => 'genomeD',  
165                                         -values => [@genomes],  elsif ( $submit4 && $role )
166                                         -size   => 30  {
167                                       ),      my $roleQ = quotemeta $role;
168                   $cgi->br,      my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
169                   $cgi->submit( 'Show Genome' ),      my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed,dlits.curator
170                   $cgi->end_form                                FROM hash_role,dlits
171                                  WHERE hash_role.role = '$roleQ' AND hash_role.md5_hash = dlits.md5_hash"
172                                  . $and_status
173           );           );
174        my @to_display = ();
175        foreach my $x ( @$tuples )
176        {
177            my( $status, $hash, $pubmed, $cur ) = @$x;
178            my @pegs = $fig->pegs_with_md5( $hash );
179            if ( @pegs > 0 )
180            {
181                push( @to_display, [ $status, $pegs[0], $pubmed, $cur ] );
182            }
183  }  }
184  elsif ($submit2)  
185        &display_set( $fig, $cgi, $html, \@to_display, "Genes for Role: $role", 'Show Role' );
186    }
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 ') " : "";      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) " : "";      my $where2   = $curator ? "AND (curr_role.curator = '$curator' AND curr_role.role = hash_role.role) " : "";
197    
198      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
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'),      push(@$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
205                   $cgi->hidden(-name => 'user', -value=>$user),                   $cgi->hidden(-name => 'user', -value=>$user),
                  $cgi->hidden(-name => 'show_just', -value=>$show_just),  
206                   $cgi->hidden(-name => 'curator', -value=> $curator),                   $cgi->hidden(-name => 'curator', -value=> $curator),
207                   $cgi->scrolling_list( -name   => 'role',                    $cgi->hidden( -name => 'who_says', -value => $who_says )
208            );
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],                                         -values => [@roles],
216                                         -size   => 30                                         -size   => 30
217                                       ),                                       ),
218                   $cgi->br,                    $cgi->br, &show_just_selector( $cgi ),
219                   $cgi->submit( 'Show Role' ),                    $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                   $cgi->end_form
223           );           );
224  }  }
225  elsif ($submit3 && $genomeD && ($genomeD =~ /\((\d+\.\d+)\)/))  
226    #  Literature selected by genome -----------------------------------------------
227    
228    elsif ( $submit3 && $genomeD && ( $genomeD =~ /\((\d+\.\d+)\)$/ ) )
229  {  {
     my $where = $show_just ? " AND dlits.status = '$show_just'" : '';  
230      my $genome = $1;      my $genome = $1;
231      my $tuples = $rdbH->SQL("select DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed      my $where  = $show_just ? " AND (dlits.status = '$show_just')" : '';
232        my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed,dlits.curator
233                                FROM genome_hash,dlits                                FROM genome_hash,dlits
234                                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"
235                               );
236      my @to_display = ();      my @to_display = ();
237      foreach my $x (@$tuples)      foreach my $x (@$tuples)
238      {      {
239          my($status,$hash,$pubmed) = @$x;          my ( $status, $hash, $pubmed, $cur ) = @$x;
240          foreach my $peg ($fig->pegs_with_md5($hash))          foreach my $peg ($fig->pegs_with_md5($hash))
241          {          {
242              if (&FIG::genome_of($peg) eq $genome)              if (&FIG::genome_of($peg) eq $genome)
243              {              {
244                  push(@to_display,[$status,$peg,$pubmed]);                  push(@to_display,[ $status, $peg, $pubmed, $cur ]);
245              }              }
246          }          }
247      }      }
248      &display_set($fig,$cgi,$html,\@to_display,'Genes for $genomeD','Show Genome');      &display_set( $fig, $cgi, $html, \@to_display, "Genes for $genomeD", 'Show Genome' );
249  }  }
250  elsif ($submit4)  
251  {  #  Show genome list ------------------------------------------------------------
252      my $where = $show_just ? " AND dlits.status = '$show_just'" : '';  
253      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)  
254          {          {
255              push(@to_display,[$status,$pegs[0],$pubmed]);      #  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      &display_set($fig,$cgi,$html,\@to_display,'Genes for Role: $role','Show Role');      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                      $cgi->hidden( -name => 'user',     -value => $user ),
270                      $cgi->hidden( -name => 'curator',  -value => $curator ),
271                      $cgi->hidden( -name => 'who_says', -value => $who_says ),
272                      $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  }  }
283    
284    #  Default = display subsystem curators ----------------------------------------
285    
286  else  else
287  {  {
288      my @cur  = map { $_->[0]} @{$rdbH->SQL( "SELECT DISTINCT curator FROM dlits" )};      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;      my $curN = @cur;
297    
     my $show_just_opt =  $cgi->scrolling_list( -name   => 'show_just',  
                                                -values => ['all',' ','D','R','N','G'],  
                                                -default => 'all',  
                                                -override => 1,  
                                                -size   => 1  
                                      ),  
   
298      push(@$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),      push(@$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),
299                   $cgi->hidden(-name => 'user', -value=>$user),                   $cgi->hidden(-name => 'user', -value=>$user),
300                      $cgi->hidden( -name => 'who_says', -value => $who_says ),
301                   $cgi->scrolling_list( -name   => 'curator',                   $cgi->scrolling_list( -name   => 'curator',
302                                         -values => [ @cur ],                                         -values => [ @cur ],
303                                              -size   => $curN                                              -size   => $curN
304                                              ),                                              ),
                  $cgi->scrolling_list( -name   => 'show_just',  
                                        -values => ['all',' ','D','R','N','G'],  
                                        -default => 'all',  
                                        -override => 1,  
                                        -size   => 1  
                                        ),  
305                   $cgi->br,                   $cgi->br,
306                      &show_just_selector( $cgi ),
307                   $cgi->submit( 'Show Roles' ),                   $cgi->submit( 'Show Roles' ),
308                   $cgi->br,                   $cgi->br,
309                   $cgi->submit( 'Show Genomes' ),                   $cgi->submit( 'Show Genomes' ),
310                   $cgi->end_form                   $cgi->end_form
311           );           );
312  }  }
   
313  &HTML::show_page($cgi,$html);  &HTML::show_page($cgi,$html);
314    exit;
315    
316    
317    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    }
331    
332    
333  sub compute_genome_label  sub compute_genome_label
334  {  {
# Line 207  Line 338 
338      return "$gs ($org)";      return "$gs ($org)";
339  }  }
340    
341    
342  sub title_of {  sub title_of {
343      my($fig,$pubmed) = @_;      my($fig,$pubmed) = @_;
344    
345      my $rdbH  = $fig->db_handle;      my $rdbH  = $fig->db_handle;
346      my $retval = $rdbH->SQL( "SELECT title FROM pubmed_titles WHERE (pubmed = $pubmed)");      my $retval = $rdbH->SQL( "SELECT title
347                                  FROM pubmed_titles
348                                  WHERE (pubmed = $pubmed)"
349                               );
350      return (@$retval > 0) ? $retval->[0]->[0] : "";      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    }
358    
359    
360  sub display_set {  sub display_set {
361      my($fig,$cgi,$html,$to_display,$tab_title,$submit) = @_;      my($fig,$cgi,$html,$to_display,$tab_title,$submit) = @_;
362    
     my $from = $cgi->param('from_line');  
     if (! $from) { $from = 0 }  
     my $lines_left = 100;  
   
363      my %status_code = ( 'D' => 1, ' ' => 2, 'N' => 3, 'R' => 4, 'G' => 5);      my %status_code = ( 'D' => 1, ' ' => 2, 'N' => 3, 'R' => 4, 'G' => 5);
364    
365      my $col_hdrs = [' ','G','N','R','D','PEG','Function','PubMed','Title'];      #  @$to_distplay items are [ $status, $peg, $pubmed ]
366      my $tab = [];  
367      foreach $_ (@$to_display) { $_->[0] =~ s/^\s*$/ /; }      foreach $_ ( @$to_display ) { $_->[0] =~ s/^\s*$/ /; }  # fix empty status strings
368      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]} )
369                         or &FIG::by_fig_id( $a->[1], $b->[1] )
370                         or ( $a->[2] <=> $b->[2] )
371                          }
372                     @$to_display;
373      my $total_tuples = @tuples;      my $total_tuples = @tuples;
374    
375      if (@tuples > 0) { splice(@tuples,0,$from); $from = $from + $lines_left; splice(@tuples,$lines_left) }      my $from;                    #  Offset to first item displayed
376        my $n_per_page = 100;        #  Really the lines per page
377    
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            $from -= $n_per_page if $cgi->param( 'Previous page' );
386            $from += $n_per_page if $cgi->param( 'Next page' );
387        }
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                $from = $n_per_page * int( ( $total_tuples - 1 ) / $n_per_page );
397            }
398            splice( @tuples, 0, $from );
399            splice( @tuples, $n_per_page );
400        }
401      else      else
402      {      {
403          undef $from;          undef $from;
404      }      }
405    
406        # 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        my $curator = $cgi->param('curator');
420        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        #  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        #  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        #  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        #  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        #  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        #  Build the status selection table
463    
464        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        my $tab = [];
467      my $i;      my $i;
468      for ($i=0; ($i < @tuples); $i++)      for ($i=0; ($i < @tuples); $i++)
469      {      {
470          my $tuple = $tuples[$i];          my $tuple = $tuples[$i];
471          my($status,$peg,$pubmed) = @$tuple;          my( $status, $peg, $pubmed, $cur ) = @$tuple;
472          next if (! $fig->is_real_feature($peg));          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);          my $title = &title_of($fig,$pubmed);
476          my $func = $fig->function_of($peg);          my $func = $fig->function_of($peg);
477          my @codes = $cgi->radio_group(-name => "tuple:$peg:$pubmed:$status",          my @codes = $cgi->radio_group(-name => "tuple:$peg:$pubmed:$status",
478                                        -values => [' ','G','N','R','D'],                                        -values => [' ','G','N','R','D'],
479                                        -default => "$status",                                        -default => "$status",
480                                        -nolabels => 1);                                         -nolabels => 1
481                                         );
482    
483          if (($i % 15) == 14) { push(@$tab,$col_hdrs) }          my $pub_link = &pubmed_link( $pubmed );
484          push(@$tab,[@codes,&HTML::fid_link($cgi,$peg),$func,  
485                      "<a target=_blank href=http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=search&term=$pubmed>$pubmed</a>",          #  Does this paper cover more than one protein?
486                      $title]);  
487            if ( $genes_in_pub{ $pubmed } > 1 )
488            {
489                #  This link intentionally omits filtering by status
490                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      }      }
494      push(@$html, $cgi->start_form(-action => "get_dlits.cgi", -method => 'post'),          if (($i % 15) == 14) { push(@$tab,$col_hdrs) }
495                   $cgi->hidden(-name => 'user', -value=>$user),          push( @$tab, $who_says ? [ @codes, $cur, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ]
496                   $cgi->br,                                 : [ @codes, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ]
497           );           );
498        }
499    
500      push(@$html,&HTML::make_table($col_hdrs,$tab,$tab_title));      push(@$html,&HTML::make_table($col_hdrs,$tab,$tab_title));
501      if (defined($from))  
502        push( @$html, $cgi->br, &show_just_selector( $cgi ) );
503    
504        #  Navigation controls through long lists
505    
506        if ( defined( $from ) && ( $total_tuples > $n_per_page ) )
507      {      {
508          my $genomeD = $cgi->param('genomeD');          my $i1 = $from + 1;
509          $genomeD = $genomeD ? $genomeD : "none";          my $i2 = $from + $n_per_page;
510          push(@$html,"<br>To get the next 100 (out of $total_tuples)",          $i2 = $total_tuples if $i2 > $total_tuples;
511                      $cgi->hidden(-name => 'from_line', -value => $from, -override => 1),          push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );
512                      $cgi->hidden(-name => 'genomeD', -value => "$genomeD"),          push( @$html, $cgi->br, "Currently displaying items $i1 - $i2 of $total_tuples.", $cgi->br );
513                      $cgi->submit($submit));          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            for ( my $i = 0; $i < $total_tuples; $i += $n_per_page )
519            {
520                push @offsets, $i;
521                my $imax = $i + $n_per_page;
522                $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      }      }
535      push(@$html,$cgi->br,$cgi->submit('Process Changes'));  
536        #  Some action buttons:
537    
538        push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );
539    
540        #  Display some general navigation buttons.  However, these are not
541        #  consistent with the intended use of the publication-based view.
542    
543        if ( ! $ref_id )
544        {
545            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        }
553    
554      push(@$html,$cgi->end_form);      push(@$html,$cgi->end_form);
555  }  }
556    
557    
558    #     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    }
572    
573    
574    sub desc {
575        my( $html ) = @_;
576    
577        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    }
586    
587    
588  sub process_changes {  sub process_changes {
589      my($fig,$cgi,$html) = @_;      my($fig,$cgi,$html) = @_;
590        my $user = $cgi->param('user');
591    
592      my @tuples = grep { $_->[2] ne $_->[3] }      my @tuples = grep { $_->[2] ne $_->[3] }
593                   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($_)] : () }
594                   $cgi->param();                   $cgi->param();
595      my $user = $cgi->param('user');      my $n_change = 0;
596      foreach my $tuple (@tuples)      foreach my $tuple (@tuples)
597      {      {
598          my($peg,$pubmed,$from,$to) = @$tuple;          my($peg,$pubmed,$from,$to) = @$tuple;
# Line 290  Line 602 
602                          -curator  => $user,                          -curator  => $user,
603                          -override => 1                          -override => 1
604                        );                        );
605            $n_change++;
606      }      }
607      push(@$html,$cgi->h2('made the requested changes'));  
608        push( @$html, $cgi->h2( "<FONT Color=green>Made $n_change requested changes.</FONT>" ) );
609  }  }
610    
611    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3