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

Diff of /Sprout/SHSubSearch.pm

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

revision 1.3, Sat Dec 2 09:46:01 2006 UTC revision 1.9, Tue Apr 29 20:53:35 2008 UTC
# Line 4  Line 4 
4    
5      use strict;      use strict;
6      use Tracer;      use Tracer;
     use SearchHelper;  
7      use CGI;      use CGI;
8      use HTML;      use HTML;
9      use Sprout;      use Sprout;
10      use FeatureData;      use RHFeatures;
11      use FeatureQuery;      use base 'SearchHelper';
   
     our @ISA = qw(SearchHelper);  
12    
13  =head1 Subsystem Feature Search Helper  =head1 Subsystem Feature Search Helper
14    
# Line 39  Line 36 
36    
37  =head3 Form  =head3 Form
38    
39  C<< my $html = $shelp->Form(); >>      my $html = $shelp->Form();
40    
41  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
42    
# Line 52  Line 49 
49      my $cgi = $self->Q();      my $cgi = $self->Q();
50      my $sprout = $self->DB();      my $sprout = $self->DB();
51      # Start the form.      # Start the form.
52      my $retVal = $self->FormStart("Open Subsystem OR Search for Genes by Subsystem or Class");      my $retVal = $self->FormStart("Search for Genes by Subsystem or Class");
53      # Create a subsystem tree.      # Create a subsystem tree.
54      my $tree = SearchHelper::SubsystemTree($sprout, radio => 1, links => 1);      my $tree = SearchHelper::SubsystemTree($sprout, radio => 1, links => 1);
55      # Build a form field out of it.      # Build a form field out of it.
# Line 65  Line 62 
62      # Start with the subsystem tree.      # Start with the subsystem tree.
63      push @rows, $cgi->Tr($cgi->th({ colspan => 3, align => "center" }, "Subsystem Tree")),      push @rows, $cgi->Tr($cgi->th({ colspan => 3, align => "center" }, "Subsystem Tree")),
64                  $cgi->Tr($cgi->td({ colspan => 3 }, $treeField));                  $cgi->Tr($cgi->td({ colspan => 3 }, $treeField));
65      # Start with a keyword search box.      # Put in the keyword search box.
66      my $expressionString = $cgi->param('keywords') || "";      my $expressionString = $cgi->param('keywords') || "";
67      push @rows, $cgi->Tr($cgi->th("Search Words"),      push @rows, RHFeatures::WordSearchRow($self);
                          $cgi->td({ colspan => 2 },  
                                   $cgi->textfield(-name => 'keywords',  
                                                   -value => $expressionString,  
                                                   -size => 60)));  
68      # Add the special options.      # Add the special options.
69      push @rows, FeatureQuery::SpecialOptions($self);      push @rows, RHFeatures::FeatureFilterFormRows($self, 'options');
70      # Finish it off with the submit row.      # Finish it off with the submit row.
71      push @rows, $self->SubmitRow();      push @rows, $self->SubmitRow();
72      # Convert the form rows into a table.      # Convert the form rows into a table.
# Line 86  Line 79 
79    
80  =head3 Find  =head3 Find
81    
82  C<< my $resultCount = $shelp->Find(); >>      my $resultCount = $shelp->Find();
83    
84  Conduct a search based on the current CGI query parameters. The search results will  Conduct a search based on the current CGI query parameters. The search results will
85  be written to the session cache file and the number of results will be  be written to the session cache file and the number of results will be
# Line 108  Line 101 
101      if (! $spec) {      if (! $spec) {
102          $self->SetMessage("No subsystem or class selected.");          $self->SetMessage("No subsystem or class selected.");
103      } else {      } else {
104          # Create a feature data object to store our results.          # We need to build a query to get our features. This involves building
105          my $fd = FeatureData->new($self);          # a filter clause and a parameter list.
         # We need to build a query to get our features. We need to remember  
         # the filter clause format and the parameter.  
106          my ($filterClause, $parameter);          my ($filterClause, $parameter);
107          if ($spec =~ /^id=(.+)$/) {          if ($spec =~ /^id=(.+)$/) {
108              # Here we're filtering for a single subsystem.              # Here we're filtering for a single subsystem.
# Line 134  Line 125 
125              # any keywords were specified.              # any keywords were specified.
126              my $query;              my $query;
127              if ($keywords) {              if ($keywords) {
128                    $self->PrintLine("Word search query submitted.<br />");
129                  $query = $sprout->Search($keywords, 2, @majorParms);                  $query = $sprout->Search($keywords, 2, @majorParms);
130              } else {              } else {
131                    $self->PrintLine("Standard search query submitted.<br />");
132                  $query = $sprout->Get(@majorParms);                  $query = $sprout->Get(@majorParms);
133              }              }
134                # Get the result helper for a feature search.
135                my $rhelp = RHFeatures->new($self);
136                # Compute the default columns. This is a very simple search which
137                # has no extra columns.
138                $self->DefaultColumns($rhelp);
139              # Initialize the session file.              # Initialize the session file.
140              $self->OpenSession();              $self->OpenSession($rhelp);
141              # Initialize the result counter.              # Clear the result counter.
142              $retVal = 0;              $retVal = 0;
143              # Loop through the selected features.              # Process the query results.
144              while (my $record = $query->Fetch()) {              while (my $record = $query->Fetch()) {
145                  $fd->Store($record);                  # Compute the sort key.
146                  $self->PutFeature($fd);                  my $sort = $rhelp->SortKey($record);
147                    # Store this feature.
148                    $rhelp->PutData($sort, $record->PrimaryValue('Feature(id)'), $record);
149                    # Increment the result counter.
150                  $retVal++;                  $retVal++;
151              }              }
152              # Close the session file.              # Close the session file.
# Line 158  Line 159 
159    
160  =head3 Description  =head3 Description
161    
162  C<< my $htmlText = $shelp->Description(); >>      my $htmlText = $shelp->Description();
163    
164  Return a description of this search. The description is used for the table of contents  Return a description of this search. The description is used for the table of contents
165  on the main search tools page. It may contain HTML, but it should be character-level,  on the main search tools page. It may contain HTML, but it should be character-level,

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3