[Bio] / Sprout / SearchHelper.pm Repository:
ViewVC logotype

Diff of /Sprout/SearchHelper.pm

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

revision 1.3, Fri Sep 29 15:10:05 2006 UTC revision 1.4, Mon Oct 2 03:15:37 2006 UTC
# Line 237  Line 237 
237  by calling L</SetMessage>. If the parameters are valid, then the method must return  by calling L</SetMessage>. If the parameters are valid, then the method must return
238  the number of items found.  the number of items found.
239    
 =head2 Virtual Methods  
   
 =head3 Form  
   
 C<< my $html = $shelp->Form(); >>  
   
 Generate the HTML for a form to request a new search.  
   
 =head3 Find  
   
 C<< my $resultCount = $shelp->Find(); >>  
   
 Conduct a search based on the current CGI query parameters. The search results will  
 be written to the session cache file and the number of results will be  
 returned. If the search parameters are invalid, a result count of C<undef> will be  
 returned and a result message will be stored in this object describing the problem.  
   
 =head3 Description  
   
 C<< my $htmlText = $shelp->Description(); >>  
   
 Return a description of this search. The description is used for the table of contents  
 on the main search tools page. It may contain HTML, but it should be character-level,  
 not block-level, since the description is going to appear in a list.  
   
240  =cut  =cut
241    
242  # This counter is used to insure every form on the page has a unique name.  # This counter is used to insure every form on the page has a unique name.
# Line 700  Line 675 
675      }      }
676      # Compute the sort key. The sort key floats NMPDR organism features to the      # Compute the sort key. The sort key floats NMPDR organism features to the
677      # top of the return list.      # top of the return list.
678      my $group = $self->FeatureGroup($fid);      my $key = $self->SortKey($record);
     my $key = ($group ? "A$group" : "ZZ");  
679      # Write the feature data.      # Write the feature data.
680      $self->WriteColumnData($key, @output);      $self->WriteColumnData($key, @output);
681  }  }
# Line 799  Line 773 
773      my $retVal;      my $retVal;
774      # Get a digest encoder.      # Get a digest encoder.
775      my $md5 = Digest::MD5->new();      my $md5 = Digest::MD5->new();
776      # If we have a randomization file, use it to seed the digester.      # Add the PID, the IP, and the time stamp. Note that the time stamp is
777      if (open(R, "/dev/urandom")) {      # actually two numbers, and we get them both because we're in list
778          my $b;      # context.
779          read(R, $b, 1024);      $md5->add($$, $ENV{REMOTE_ADDR}, $ENV{REMOTE_PORT}, gettimeofday());
780          $md5->add($b);      # Hash up all this identifying data.
781      }      $retVal = $md5->hexdigest();
782      # Add the PID and the time stamp.      # Return the result.
     $md5->add($$, gettimeofday);  
     # Hash it up and clean the result so that it works as a file name.  
     $retVal = $md5->b64digest();  
     $retVal =~ s,/,\$,g;  
     $retVal =~ s,\+,@,g;  
     # Return it.  
783      return $retVal;      return $retVal;
784  }  }
785    
# Line 970  Line 938 
938      } else {      } else {
939          # Here we can get its genome data.          # Here we can get its genome data.
940          $retVal = $self->Organism($genomeID);          $retVal = $self->Organism($genomeID);
941          # Append the type and number.          # Append the FIG ID.
942          $retVal .= " [$type $num]";          $retVal .= " [$fid]";
943      }      }
944      # Return the result.      # Return the result.
945      return $retVal;      return $retVal;
# Line 1372  Line 1340 
1340                            $cgi->td($cgi->popup_menu(-name => 'PageSize',                            $cgi->td($cgi->popup_menu(-name => 'PageSize',
1341                                                      -values => [10, 25, 45, 100, 1000],                                                      -values => [10, 25, 45, 100, 1000],
1342                                                      -default => $pageSize) . " " .                                                      -default => $pageSize) . " " .
                                    $cgi->checkbox(-name => 'ShowAliases',  
                                                   -value => 1,  
                                                   -label => 'Show Alias Links',  
                                                   -default => $aliases),  
1343                                     $cgi->checkbox(-name => 'ShowURL',                                     $cgi->checkbox(-name => 'ShowURL',
1344                                                    -value => 1,                                                    -value => 1,
1345                                                    -label => 'Show URL')),                                                    -label => 'Show URL')),
# Line 1715  Line 1679 
1679      # Get the parameters.      # Get the parameters.
1680      my ($self) = @_;      my ($self) = @_;
1681      # Return the result.      # Return the result.
1682      return ['orgName', 'function', 'gblink', 'protlink'];      return ['orgName', 'function', 'gblink', 'protlink',
1683                FeatureQuery::AdditionalColumns($self)];
1684  }  }
1685    
1686  =head3 FeatureColumnTitle  =head3 FeatureColumnTitle
# Line 1909  Line 1874 
1874      return $retVal;      return $retVal;
1875  }  }
1876    
1877    =head2 Virtual Methods
1878    
1879    =head3 Form
1880    
1881    C<< my $html = $shelp->Form(); >>
1882    
1883    Generate the HTML for a form to request a new search.
1884    
1885    =head3 Find
1886    
1887    C<< my $resultCount = $shelp->Find(); >>
1888    
1889    Conduct a search based on the current CGI query parameters. The search results will
1890    be written to the session cache file and the number of results will be
1891    returned. If the search parameters are invalid, a result count of C<undef> will be
1892    returned and a result message will be stored in this object describing the problem.
1893    
1894    =head3 Description
1895    
1896    C<< my $htmlText = $shelp->Description(); >>
1897    
1898    Return a description of this search. The description is used for the table of contents
1899    on the main search tools page. It may contain HTML, but it should be character-level,
1900    not block-level, since the description is going to appear in a list.
1901    
1902    =head3 SortKey
1903    
1904    C<< my $key = $shelp->SortKey($record); >>
1905    
1906    Return the sort key for the specified record. The default is to sort by feature name,
1907    floating NMPDR organisms to the top. This sort may be overridden by the search class
1908    to provide fancier functionality. This method is called by B<PutFeature>, so it
1909    is only used for feature searches. A non-feature search would presumably have its
1910    own sort logic.
1911    
1912    =over 4
1913    
1914    =item record
1915    
1916    The C<DBObject> from which the current row of data is derived.
1917    
1918    =item RETURN
1919    
1920    Returns a key field that can be used to sort this row in among the results.
1921    
1922    =back
1923    
1924    =cut
1925    
1926    sub SortKey {
1927        # Get the parameters.
1928        my ($self, $record) = @_;
1929        # Get the feature ID from the record.
1930        my ($fid) = $record->Value('Feature(id)');
1931        # Get the group from the feature ID.
1932        my $group = $self->FeatureGroup($fid);
1933        # Ask the feature query object to form the sort key.
1934        my $retVal = FeatureQuery::SortKey($self, $group, $record);
1935        # Return the result.
1936        return $retVal;
1937    }
1938  1;  1;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3