[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.18, Sat Nov 18 20:36:49 2006 UTC revision 1.21, Thu Nov 30 23:04:37 2006 UTC
# Line 257  Line 257 
257    
258  =over 4  =over 4
259    
260  =item query  =item cgi
261    
262  The CGI query object for the current script.  The CGI query object for the current script.
263    
# Line 267  Line 267 
267    
268  sub new {  sub new {
269      # Get the parameters.      # Get the parameters.
270      my ($class, $query) = @_;      my ($class, $cgi) = @_;
271      # Check for a session ID.      # Check for a session ID.
272      my $session_id = $query->param("SessionID");      my $session_id = $cgi->param("SessionID");
273      my $type = "old";      my $type = "old";
274      if (! $session_id) {      if (! $session_id) {
275          # Here we're starting a new session. We create the session ID and          # Here we're starting a new session. We create the session ID and
276          # store it in the query object.          # store it in the query object.
277          $session_id = NewSessionID();          $session_id = NewSessionID();
278          $type = "new";          $type = "new";
279          $query->param(-name => 'SessionID', -value => $session_id);          $cgi->param(-name => 'SessionID', -value => $session_id);
280      }      }
281      # Compute the subclass name.      # Compute the subclass name.
282      $class =~ /SH(.+)$/;      my $subClass;
283      my $subClass = $1;      if ($class =~ /SH(.+)$/) {
284            # Here we have a real search class.
285            $subClass = $1;
286        } else {
287            # Here we have a bare class. The bare class cannot search, but it can
288            # process search results.
289            $subClass = 'SearchHelper';
290        }
291      # Insure everybody knows we're in Sprout mode.      # Insure everybody knows we're in Sprout mode.
292      $query->param(-name => 'SPROUT', -value => 1);      $cgi->param(-name => 'SPROUT', -value => 1);
293      # Generate the form name.      # Generate the form name.
294      my $formName = "$class$formCount";      my $formName = "$class$formCount";
295      $formCount++;      $formCount++;
# Line 290  Line 297 
297      # as well as an indicator as to whether or not the session is new, plus the      # as well as an indicator as to whether or not the session is new, plus the
298      # class name and a placeholder for the Sprout object.      # class name and a placeholder for the Sprout object.
299      my $retVal = {      my $retVal = {
300                    query => $query,                    query => $cgi,
301                    type => $type,                    type => $type,
302                    class => $subClass,                    class => $subClass,
303                    sprout => undef,                    sprout => undef,
# Line 979  Line 986 
986    
987  sub ComputeFASTA {  sub ComputeFASTA {
988      # Get the parameters.      # Get the parameters.
989      my ($self, $incomingType, $desiredType, $sequence) = @_;      my ($self, $desiredType, $sequence) = @_;
990      # Declare the return variable. If an error occurs, it will remain undefined.      # Declare the return variable. If an error occurs, it will remain undefined.
991      my $retVal;      my $retVal;
992      # This variable will be cleared if an error is detected.      # This variable will be cleared if an error is detected.
# Line 1705  Line 1712 
1712    
1713  =head3 ComputeSearchURL  =head3 ComputeSearchURL
1714    
1715  C<< my $url = $shelp->ComputeSearchURL(); >>  C<< my $url = $shelp->ComputeSearchURL(%overrides); >>
1716    
1717  Compute the GET-style URL for the current search. In order for this to work, there  Compute the GET-style URL for the current search. In order for this to work, there
1718  must be a copy of the search form on the current page. This will always be the  must be a copy of the search form on the current page. This will always be the
# Line 1715  Line 1722 
1722  main complication is that if the user specified all genomes, we'll want to  main complication is that if the user specified all genomes, we'll want to
1723  remove the parameter entirely from a get-style URL.  remove the parameter entirely from a get-style URL.
1724    
1725    =over 4
1726    
1727    =item overrides
1728    
1729    Hash containing override values for the parameters, where the parameter name is
1730    the key and the parameter value is the override value. If the override value is
1731    C<undef>, the parameter will be deleted from the result.
1732    
1733    =item RETURN
1734    
1735    Returns a GET-style URL for invoking the search with the specified overrides.
1736    
1737    =back
1738    
1739  =cut  =cut
1740    
1741  sub ComputeSearchURL {  sub ComputeSearchURL {
1742      # Get the parameters.      # Get the parameters.
1743      my ($self) = @_;      my ($self, %overrides) = @_;
1744      # Get the database and CGI query object.      # Get the database and CGI query object.
1745      my $cgi = $self->Q();      my $cgi = $self->Q();
1746      my $sprout = $self->DB();      my $sprout = $self->DB();
# Line 1760  Line 1781 
1781              if ($allFlag) {              if ($allFlag) {
1782                  @values = ();                  @values = ();
1783              }              }
1784            } elsif (exists $overrides{$parmKey}) {
1785                # Here the value is being overridden, so we skip it for now.
1786                @values = ();
1787          }          }
1788          # If we still have values, create the URL parameters.          # If we still have values, create the URL parameters.
1789          if (@values) {          if (@values) {
1790              push @urlList, map { "$parmKey=" . uri_escape($_) } @values;              push @urlList, map { "$parmKey=" . uri_escape($_) } @values;
1791          }          }
1792      }      }
1793        # Now do the overrides.
1794        for my $overKey (keys %overrides) {
1795            # Only use this override if it's not a delete marker.
1796            if (defined $overrides{$overKey}) {
1797                push @urlList, "$overKey=" . uri_escape($overrides{$overKey});
1798            }
1799        }
1800      # Add the parameters to the URL.      # Add the parameters to the URL.
1801      $retVal .= "?" . join(";", @urlList);      $retVal .= "?" . join(";", @urlList);
1802      # Return the result.      # Return the result.
# Line 2197  Line 2228 
2228    
2229  =head2 Feature Column Methods  =head2 Feature Column Methods
2230    
2231  The methods in this column manage feature column data. If you want to provide the  The methods in this section manage feature column data. If you want to provide the
2232  capability to include new types of data in feature columns, then all the changes  capability to include new types of data in feature columns, then all the changes
2233  are made to this section of the source file. Technically, this should be implemented  are made to this section of the source file. Technically, this should be implemented
2234  using object-oriented methods, but this is simpler for non-programmers to maintain.  using object-oriented methods, but this is simpler for non-programmers to maintain.
# Line 2272  Line 2303 
2303      } elsif ($colName =~ /^keyword:(.+)$/) {      } elsif ($colName =~ /^keyword:(.+)$/) {
2304          $retVal = ucfirst $1;          $retVal = ucfirst $1;
2305      } elsif ($colName eq 'orgName') {      } elsif ($colName eq 'orgName') {
2306          $retVal = "Gene Name";          $retVal = "Organism and Gene ID";
2307      } elsif ($colName eq 'protlink') {      } elsif ($colName eq 'protlink') {
2308          $retVal = "NMPDR Protein Page";          $retVal = "NMPDR Protein Page";
2309      } elsif ($colName eq 'subsystem') {      } elsif ($colName eq 'subsystem') {
# Line 2432  Line 2463 
2463          # Get the subsystems.          # Get the subsystems.
2464          Trace("Generating subsystems for feature $fid.") if T(4);          Trace("Generating subsystems for feature $fid.") if T(4);
2465          my %subs = $sprout->SubsystemsOf($fid);          my %subs = $sprout->SubsystemsOf($fid);
2466          # Convert them to links.          # Extract the subsystem names.
2467          my @links = map { HTML::sub_link($cgi, $_) } sort keys %subs;          my @names = map { HTML::sub_link($cgi, $_) } sort keys %subs;
2468          # String them into a list.          # String them into a list.
2469          $retVal = join(", ", @links);          $retVal = join(", ", @names);
2470      } elsif ($type =~ /^keyword:(.+)$/) {      } elsif ($type =~ /^keyword:(.+)$/) {
2471          # Here the caller wants the value of the named keyword. The text is the          # Here the caller wants the value of the named keyword. The text is the
2472          # feature ID.          # feature ID.

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3