[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.10, Wed Jul 9 15:59:57 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,curator
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, $prev_curator ) = @$x;
152            my @pegs = grep { $fig->is_real_feature($_) }
153                       $fig->pegs_with_md5( $hash );
154            if ( @pegs > 0 )
155            {
156                push( @to_display, [ $status, $pegs[0], $ref_id, $prev_curator ] );
157            }
158        }
159    
160        &display_set( $fig, $cgi, $html, \@to_display, "Genes linked to Reference: $ref_id", 'Show Reference' ) ;
161    }
162    
163  #  Literature selected by role -------------------------------------------------  #  Literature selected by role -------------------------------------------------
164    
165  elsif ( $submit4 && $role )  elsif ( $submit4 && $role )
166  {  {
167      my $roleQ = quotemeta $role;      my $roleQ = quotemeta $role;
168      my $where = $show_just ? " AND (dlits.status = '$show_just')" : '';      my $and_status = $show_just ? " AND ( dlits.status = '$show_just' )" : '';
169      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,dlits.curator
170                                FROM hash_role,dlits,pubmed_titles                                FROM hash_role,dlits
171                                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"
172                                  . $and_status
173                             );                             );
174      my @to_display = ();      my @to_display = ();
175      foreach my $x (@$tuples)      foreach my $x (@$tuples)
176      {      {
177          my($status,$hash,$pubmed) = @$x;          my( $status, $hash, $pubmed, $prev_curator ) = @$x;
178          my @pegs = $fig->pegs_with_md5($hash);          my @pegs = grep { $fig->is_real_feature($_) }
179                       $fig->pegs_with_md5( $hash );
180          if (@pegs > 0)          if (@pegs > 0)
181          {          {
182              push(@to_display,[$status,$pegs[0],$pubmed]);              push( @to_display, [ $status, $pegs[0], $pubmed, $prev_curator ] );
183          }          }
184      }      }
185    
186      &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');
187  }  }
188    
# Line 181  Line 229 
229  {  {
230      my $genome = $1;      my $genome = $1;
231      my $where  = $show_just ? " AND (dlits.status = '$show_just')" : '';      my $where  = $show_just ? " AND (dlits.status = '$show_just')" : '';
232      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,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, $prev_curator ) = @$x;
240          foreach my $peg ( $fig->pegs_with_md5($hash) )          push @to_display, map  { [ $status, $_, $pubmed, $prev_curator ] }
241          {                            grep { &FIG::genome_of($_) eq $genome && $fig->is_real_feature($_) }
242              if ( &FIG::genome_of($peg) eq $genome )                            $fig->pegs_with_md5($hash);
             {  
                 push(@to_display,[ $status, $peg, $pubmed ]);  
             }  
         }  
243      }      }
244    
245      &display_set( $fig, $cgi, $html, \@to_display, "Genes for $genomeD", 'Show Genome' );      &display_set( $fig, $cgi, $html, \@to_display, "Genes for $genomeD", 'Show Genome' );
246  }  }
247    
# Line 317  Line 362 
362      foreach $_ ( @$to_display ) { $_->[0] =~ s/^\s*$/ /; }  # fix empty status strings      foreach $_ ( @$to_display ) { $_->[0] =~ s/^\s*$/ /; }  # fix empty status strings
363      my @tuples = sort { ( $status_code{$a->[0]} <=> $status_code{$b->[0]} )      my @tuples = sort { ( $status_code{$a->[0]} <=> $status_code{$b->[0]} )
364                       or &FIG::by_fig_id( $a->[1], $b->[1] )                       or &FIG::by_fig_id( $a->[1], $b->[1] )
365                       or ( $a->[2] <=> $b->[2] )                       or ( $a->[2] <=> $b->[2] )  # Numeric sort of PMID
366                        }                        }
367                   @$to_display;                   @$to_display;
368      my $total_tuples = @tuples;      my $total_tuples = @tuples;
369    
370      my $from;                    #  Offset to first item displayed      my $from;                    #  Offset to first item displayed
371      my $lines_left = 100;        #  Really the lines per page      my $n_per_page = 100;        #  Really the lines per page
372    
373      if ( $cgi->param( 'Go to item numbers' ) )      if ( $cgi->param( 'Go to item numbers' ) )
374      {      {
# Line 332  Line 377 
377      else      else
378      {      {
379          $from  = $cgi->param( 'from_line' ) || 0;          $from  = $cgi->param( 'from_line' ) || 0;
380          $from -= $lines_left if $cgi->param( 'Previous page' );          $from -= $n_per_page if $cgi->param( 'Previous page' );
381          $from += $lines_left if $cgi->param( 'Next page' );          $from += $n_per_page if $cgi->param( 'Next page' );
382      }      }
383    
384      #  Cut down the array to that to be displayed      #  Cut down the array to that to be displayed
# Line 343  Line 388 
388          if ( $from < 0 ) { $from = 0 }          if ( $from < 0 ) { $from = 0 }
389          if ( $from > $total_tuples )          if ( $from > $total_tuples )
390          {          {
391              $from = $lines_left * int( ( $total_tuples - 1 ) / $lines_left );              $from = $n_per_page * int( ( $total_tuples - 1 ) / $n_per_page );
392          }          }
393          splice( @tuples, 0, $from );          splice( @tuples, 0, $from );
394          splice( @tuples, $lines_left );          splice( @tuples, $n_per_page );
395      }      }
396      else      else
397      {      {
# Line 366  Line 411 
411      push( @$html, $cgi->hidden( -name => 'user', -value => $user, -override => 1 ) );      push( @$html, $cgi->hidden( -name => 'user', -value => $user, -override => 1 ) );
412    
413      #  Filter roles by subsystem curator      #  Filter roles by subsystem curator
414      my $curator = $cgi->param('curator') || '';      my $curator = $cgi->param('curator');
415      push( @$html, $cgi->hidden( -name => 'curator', -value => $curator, -override => 1 ) ) if $curator;      push( @$html, $cgi->hidden( -name => 'curator', -value => $curator, -override => 1 ) ) if $curator;
416    
417      #  Find lit by genome      #  Find lit by genome
418      my $genomeD = $cgi->param('genomeD');      my $genomeD = $cgi->param('genomeD');
419      push( @$html, $cgi->hidden( -name => 'genomeD', -value => $genomeD, -override => 1 ) ) if $genomeD;      push( @$html, $cgi->hidden( -name => 'genomeD', -value => $genomeD, -override => 1 ) ) if $genomeD;
420    
421        #  Show sequences associated with a reference
422        my $ref_id = $cgi->param('ref_id');
423        push( @$html, $cgi->hidden( -name => 'ref_id', -value => $ref_id, -override => 1 ) ) if $ref_id;
424    
425      #  Find lit by role      #  Find lit by role
426      my $role = $cgi->param('role');      my $role = $cgi->param('role');
427      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 434 
434    
435      push( @$html, $cgi->br );      push( @$html, $cgi->br );
436    
437        #  If this is not a table built around one reference, we want to append
438        #  links to all proteins associated with the reference.  We will
439        #  compute this on a unique set of the references:
440    
441        my %genes_in_pub;
442        if ( ! $ref_id )
443        {
444            foreach ( @tuples )
445            {
446                my $pub = $_->[2];
447                next if defined $genes_in_pub{ $pub };
448                #  This count intentionally omits filtering by status
449                $genes_in_pub{ $pub } = scalar ( &all_seqs_in_pub( $fig, $pub ) );
450            }
451        }
452    
453      #  Build the status selection table      #  Build the status selection table
454    
455      my $col_hdrs = [' ','G','N','R','D','PEG','Function','Genus/Species','PubMed','Title'];      my $col_hdrs = [' ','G','N','R','D','Curator','PEG','Function','Genus/Species','PubMed','Title'];
456      my $tab = [];      my $tab = [];
457      my $i;      my $i;
458      for ($i=0; ($i < @tuples); $i++)      for ($i=0; ($i < @tuples); $i++)
459      {      {
460          my $tuple = $tuples[$i];          my $tuple = $tuples[$i];
461          my( $status, $peg, $pubmed ) = @$tuple;          my( $status, $peg, $pubmed, $prev_curator ) = @$tuple;
462          next if (! $fig->is_real_feature($peg));          next if ( ! $fig->is_real_feature($peg) );   # This should never fail
463    
464            $prev_curator =~ s/^master://i;  #  Remove master from displayed curator
465          my $gs = $fig->genus_species( &FIG::genome_of( $peg ) );          my $gs = $fig->genus_species( &FIG::genome_of( $peg ) );
466          $gs =~ s/^(\S+\s+\S+).*$/$1/;          $gs =~ s/^(\S+\s+\S+).*$/$1/;
467          my $title = &title_of( $fig, $pubmed );          my $title = &title_of( $fig, $pubmed );
# Line 405  Line 472 
472                                         -nolabels => 1                                         -nolabels => 1
473                                       );                                       );
474    
475            my $pub_link = &pubmed_link( $pubmed );
476    
477            #  Does this paper cover more than one protein?
478    
479            if ( $genes_in_pub{ $pubmed } > 1 )
480            {
481                #  This link intentionally omits filtering by status
482                my $href = "get_dlits.cgi?user=$user&ref_id=$pubmed";
483                $pub_link .= "<BR />(<A HRef='$href' Target=_blank>$genes_in_pub{$pubmed} seqs</A>)";
484            }
485          if (($i % 15) == 14) { push(@$tab,$col_hdrs) }          if (($i % 15) == 14) { push(@$tab,$col_hdrs) }
486          push( @$tab, [ @codes, &HTML::fid_link($cgi,$peg), $func, $gs, pubmed_link($pubmed), $title ] );          push( @$tab, [ @codes, $prev_curator, &HTML::fid_link( $cgi, $peg ), $func, $gs, $pub_link, $title ] );
487      }      }
488    
489      push( @$html,&HTML::make_table( $col_hdrs, $tab, $tab_title ) );      push( @$html,&HTML::make_table( $col_hdrs, $tab, $tab_title ) );
# Line 415  Line 492 
492    
493      #  Navigation controls through long lists      #  Navigation controls through long lists
494    
495      if ( defined( $from ) && ( $total_tuples > $lines_left ) )      if ( defined( $from ) && ( $total_tuples > $n_per_page ) )
496      {      {
497          my $i1 = $from + 1;          my $i1 = $from + 1;
498          my $i2 = $from + $lines_left;          my $i2 = $from + $n_per_page;
499          $i2 = $total_tuples if $i2 > $total_tuples;          $i2 = $total_tuples if $i2 > $total_tuples;
500          push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );          push( @$html, $cgi->hidden( -name => 'from_line', -value => $from, -override => 1 ) );
501          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 504 
504    
505          my @offsets;          my @offsets;
506          my %labels;          my %labels;
507          for ( my $i = 0; $i < $total_tuples; $i += $lines_left )          for ( my $i = 0; $i < $total_tuples; $i += $n_per_page )
508          {          {
509              push @offsets, $i;              push @offsets, $i;
510              my $imax = $i + $lines_left;              my $imax = $i + $n_per_page;
511              $imax = $total_tuples if $imax > $total_tuples;              $imax = $total_tuples if $imax > $total_tuples;
512              $labels{ $i } = ( $i+1 ) . " - $imax";              $labels{ $i } = ( $i+1 ) . " - $imax";
513          }          }
# Line 449  Line 526 
526    
527      push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );      push( @$html, $cgi->br, $cgi->submit( 'Process Changes' ), "entered on this page." );
528    
529      push( @$html, $cgi->br, $cgi->submit( 'Show Genomes' ), "discarding any changes made on this page." );      #  Display some general navigation buttons.  However, these are not
530        #  consistent with the intended use of the publication-based view.
531    
532        if ( ! $ref_id )
533        {
534            push( @$html, $cgi->br, $cgi->submit( 'Show Genomes' ), "discarding any changes made on this page." );
535      if ( $curator )      if ( $curator )
536      {      {
537          push( @$html, $cgi->br, $cgi->submit( 'Show Roles' ),          push( @$html, $cgi->br, $cgi->submit( 'Show Roles' ),
538                                  "for subsystem curator '$curator', discarding any changes made on this page." );                                  "for subsystem curator '$curator', discarding any changes made on this page." );
539      }      }
   
540      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." );
541        }
542    
543      push( @$html, $cgi->end_form );      push( @$html, $cgi->end_form );
544  }  }
545    
546    
547    #     dlit
548    #     flds => "status char(1), md5_hash varchar(32), pubmed varchar(16), curator varchar(30), go_code varchar(15)"
549    
550    sub all_seqs_in_pub {
551        my ( $fig, $pubmed, $status ) = @_;
552        my $rdbH = $fig->db_handle;
553        my $and_status = $status ? " AND ( status = '$status' )" : "";
554        my $response = $rdbH->SQL( "SELECT DISTINCT md5_hash
555                                    FROM dlits
556                                    WHERE ( pubmed = '$pubmed' )"
557                                        . $and_status
558                                 );
559        return ( ref $response ) ? map { $_->[0] } @$response : ();
560    }
561    
562    
563  sub desc {  sub desc {
564      my( $html ) = @_;      my( $html ) = @_;
565    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3