[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.7, Tue Jul 8 01:39:58 2008 UTC revision 1.8, Tue Jul 8 19:28:47 2008 UTC
# 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 63  Line 81 
81  my $user      = $cgi->param('user');           #  Current user  my $user      = $cgi->param('user');           #  Current user
82  my $curator   = $cgi->param('curator') || '';  #  Filter roles by subsystem curator  my $curator   = $cgi->param('curator') || '';  #  Filter roles by subsystem curator
83  my $genomeD   = $cgi->param('genomeD');        #  Find lit by genome  my $genomeD   = $cgi->param('genomeD');        #  Find lit by genome
84    my $ref_id    = $cgi->param('ref_id');         #  Show data by reference
85  my $role      = $cgi->param('role');           #  Find lit by role  my $role      = $cgi->param('role');           #  Find lit by role
86  my $show_just = $cgi->param('show_just');      #  Filter lit by status  my $show_just = $cgi->param('show_just');      #  Filter lit by status
87     $show_just = ($show_just eq "all") ? '' : $show_just;     $show_just = ($show_just eq "all") ? '' : $show_just;
# Line 71  Line 90 
90    
91  my ( $submit1, $submit2, $submit3, $submit4, $submit5 );  my ( $submit1, $submit2, $submit3, $submit4, $submit5 );
92  if    ( $cgi->param( 'Process Changes' )          ) { $submit5 = 1 }  if    ( $cgi->param( 'Process Changes' )          ) { $submit5 = 1 }
93  if    ( $cgi->param( 'Change subsystem curator' ) ) {}  if    ( $ref_id                                   ) {}
94    elsif ( $cgi->param( 'Change subsystem curator' ) ) {}
95  elsif ( $cgi->param( 'Show Genomes' )             ) { $submit1 = 1 }  elsif ( $cgi->param( 'Show Genomes' )             ) { $submit1 = 1 }
96  elsif ( $cgi->param( 'Show Roles' )               ) { $submit2 = 1 }  elsif ( $cgi->param( 'Show Roles' )               ) { $submit2 = 1 }
97  elsif ( $cgi->param( 'Show Genome' )              ) { $submit3 = 1 }  elsif ( $cgi->param( 'Show Genome' )              ) { $submit3 = 1 }
# Line 115  Line 135 
135    
136  if ( $done ) { }  if ( $done ) { }
137    
138    #  All sequences in a reference ------------------------------------------------
139    
140    elsif ( $ref_id )
141    {
142        my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
143        my $tuples = $rdbH->SQL( "SELECT DISTINCT status,md5_hash
144                                  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        &display_set( $fig, $cgi, $html, \@to_display, "Genes linked to Reference: $ref_id", 'Show Reference' ) ;
160    }
161    
162  #  Literature selected by role -------------------------------------------------  #  Literature selected by role -------------------------------------------------
163    
164  elsif ( $submit4 && $role )  elsif ( $submit4 && $role )
165  {  {
166      my $roleQ = quotemeta $role;      my $roleQ = quotemeta $role;
167      my $where = $show_just ? " AND (dlits.status = '$show_just')" : '';      my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
168      my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed      my $tuples = $rdbH->SQL( "SELECT DISTINCT dlits.status,dlits.md5_hash,dlits.pubmed
169                                FROM hash_role,dlits,pubmed_titles                                FROM hash_role,dlits
170                                WHERE hash_role.role = '$roleQ' AND hash_role.md5_hash = dlits.md5_hash $where"                                WHERE hash_role.role = '$roleQ' AND hash_role.md5_hash = dlits.md5_hash"
171                                  . $and_status
172                             );                             );
173      my @to_display = ();      my @to_display = ();
174      foreach my $x (@$tuples)      foreach my $x (@$tuples)
# Line 135  Line 180 
180              push(@to_display,[$status,$pegs[0],$pubmed]);              push(@to_display,[$status,$pegs[0],$pubmed]);
181          }          }
182      }      }
183    
184      &display_set($fig,$cgi,$html,\@to_display,"Genes for Role: $role",'Show Role');      &display_set($fig,$cgi,$html,\@to_display,"Genes for Role: $role",'Show Role');
185  }  }
186    
# Line 323  Line 369 
369      my $total_tuples = @tuples;      my $total_tuples = @tuples;
370    
371      my $from;                    #  Offset to first item displayed      my $from;                    #  Offset to first item displayed
372      my $lines_left = 100;        #  Really the lines per page      my $n_per_page = 100;        #  Really the lines per page
373    
374      if ( $cgi->param( 'Go to item numbers' ) )      if ( $cgi->param( 'Go to item numbers' ) )
375      {      {
# Line 332  Line 378 
378      else      else
379      {      {
380          $from  = $cgi->param( 'from_line' ) || 0;          $from  = $cgi->param( 'from_line' ) || 0;
381          $from -= $lines_left if $cgi->param( 'Previous page' );          $from -= $n_per_page if $cgi->param( 'Previous page' );
382          $from += $lines_left if $cgi->param( 'Next page' );          $from += $n_per_page if $cgi->param( 'Next page' );
383      }      }
384    
385      #  Cut down the array to that to be displayed      #  Cut down the array to that to be displayed
# Line 343  Line 389 
389          if ( $from < 0 ) { $from = 0 }          if ( $from < 0 ) { $from = 0 }
390          if ( $from > $total_tuples )          if ( $from > $total_tuples )
391          {          {
392              $from = $lines_left * int( ( $total_tuples - 1 ) / $lines_left );              $from = $n_per_page * int( ( $total_tuples - 1 ) / $n_per_page );
393          }          }
394          splice( @tuples, 0, $from );          splice( @tuples, 0, $from );
395          splice( @tuples, $lines_left );          splice( @tuples, $n_per_page );
396      }      }
397      else      else
398      {      {
# Line 366  Line 412 
412      push( @$html, $cgi->hidden( -name => 'user', -value => $user, -override => 1 ) );      push( @$html, $cgi->hidden( -name => 'user', -value => $user, -override => 1 ) );
413    
414      #  Filter roles by subsystem curator      #  Filter roles by subsystem curator
415      my $curator = $cgi->param('curator') || '';      my $curator = $cgi->param('curator');
416      push( @$html, $cgi->hidden( -name => 'curator', -value => $curator, -override => 1 ) ) if $curator;      push( @$html, $cgi->hidden( -name => 'curator', -value => $curator, -override => 1 ) ) if $curator;
417    
418      #  Find lit by genome      #  Find lit by genome
419      my $genomeD = $cgi->param('genomeD');      my $genomeD = $cgi->param('genomeD');
420      push( @$html, $cgi->hidden( -name => 'genomeD', -value => $genomeD, -override => 1 ) ) if $genomeD;      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      #  Find lit by role
427      my $role = $cgi->param('role');      my $role = $cgi->param('role');
428      push( @$html, $cgi->hidden( -name => 'role', -value => $role, -override => 1 ) ) if $role;      push( @$html, $cgi->hidden( -name => 'role', -value => $role, -override => 1 ) ) if $role;
# Line 385  Line 435 
435    
436      push( @$html, $cgi->br );      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      #  Build the status selection table
455    
456      my $col_hdrs = [' ','G','N','R','D','PEG','Function','Genus/Species','PubMed','Title'];      my $col_hdrs = [' ','G','N','R','D','PEG','Function','Genus/Species','PubMed','Title'];
# Line 405  Line 471 
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, $gs, pubmed_link($pubmed), $title ] );          push( @$tab, [ @codes, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ] );
485      }      }
486    
487      push( @$html,&HTML::make_table( $col_hdrs, $tab, $tab_title ) );      push( @$html,&HTML::make_table( $col_hdrs, $tab, $tab_title ) );
# Line 415  Line 490 
490    
491      #  Navigation controls through long lists      #  Navigation controls through long lists
492    
493      if ( defined( $from ) && ( $total_tuples > $lines_left ) )      if ( defined( $from ) && ( $total_tuples > $n_per_page ) )
494      {      {
495          my $i1 = $from + 1;          my $i1 = $from + 1;
496          my $i2 = $from + $lines_left;          my $i2 = $from + $n_per_page;
497          $i2 = $total_tuples if $i2 > $total_tuples;          $i2 = $total_tuples if $i2 > $total_tuples;
498          push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );          push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );
499          push( @$html, $cgi->br, "Currently displaying items $i1 - $i2 of $total_tuples.", $cgi->br );          push( @$html, $cgi->br, "Currently displaying items $i1 - $i2 of $total_tuples.", $cgi->br );
# Line 427  Line 502 
502    
503          my @offsets;          my @offsets;
504          my %labels;          my %labels;
505          for ( my $i = 0; $i < $total_tuples; $i += $lines_left )          for ( my $i = 0; $i < $total_tuples; $i += $n_per_page )
506          {          {
507              push @offsets, $i;              push @offsets, $i;
508              my $imax = $i + $lines_left;              my $imax = $i + $n_per_page;
509              $imax = $total_tuples if $imax > $total_tuples;              $imax = $total_tuples if $imax > $total_tuples;
510              $labels{ $i } = ( $i+1 ) . " - $imax";              $labels{ $i } = ( $i+1 ) . " - $imax";
511          }          }
# Line 449  Line 524 
524    
525      push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );      push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );
526    
527      push( @$html, $cgi->br, $cgi->submit( 'Show Genomes' ), "discarding any changes made on this page." );      #  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 )      if ( $curator )
534      {      {
535          push( @$html, $cgi->br, $cgi->submit( 'Show Roles' ),          push( @$html, $cgi->br, $cgi->submit( 'Show Roles' ),
536                                  "for subsystem curator '$curator', discarding any changes made on this page." );                                  "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." );      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 {  sub desc {
562      my( $html ) = @_;      my( $html ) = @_;
563    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3