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

Diff of /Sprout/SHWordSearch.pm

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

revision 1.3, Fri Nov 10 22:02:02 2006 UTC revision 1.7, Wed Dec 6 03:37:05 2006 UTC
# Line 69  Line 69 
69    
70  =head3 Form  =head3 Form
71    
72  C<< my $html = $shelp->Include(); >>  C<< my $html = $shelp->Form(); >>
73    
74  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
75    
# Line 95  Line 95 
95                                                 -value => 'Advanced',                                                 -value => 'Advanced',
96                                                 -class => 'button')),                                                 -class => 'button')),
97                          );                          );
98      # The other row is for the submit button.      # The second row is for special options.
99        push @rows, FeatureQuery::SpecialOptions($self);
100        # The last row is for the submit button.
101      push @rows, $self->SubmitRow();      push @rows, $self->SubmitRow();
102      # Finally, if groups are specified, we include them as hidden fields and display      # Finally, if groups are specified, we include them as hidden fields and display
103      # an explanation.      # an explanation.
# Line 142  Line 144 
144      # Declare the return variable. If it remains undefined, the caller will      # Declare the return variable. If it remains undefined, the caller will
145      # know that an error occurred.      # know that an error occurred.
146      my $retVal;      my $retVal;
147      # Get the keyword list. We need to prove that there is at least one keyword      # Get the keyword list and validate it.
     # that does not begin with a "-".  
148      my $keywords = $cgi->param('keywords') || "";      my $keywords = $cgi->param('keywords') || "";
149      my @wordList = split /\s+/, $keywords;      if ($self->ValidateKeywords($keywords, 1)) {
     my @plusWords = grep { $_ =~ /^[^\-]/ } @wordList;  
     if (! @wordList) {  
         $self->SetMessage("No search words specified.");  
     } elsif (! @plusWords) {  
         $self->SetMessage("At least one keyword must be positive. All the keywords entered are preceded by minus signs.");  
     } else {  
150          # We have good keywords. Initialize the session file.          # We have good keywords. Initialize the session file.
151          $self->OpenSession();          $self->OpenSession();
152          # Initialize the result counter.          # Initialize the result counter.
# Line 161  Line 156 
156          if (@groups) {          if (@groups) {
157              # Here we do the search a group at a time.              # Here we do the search a group at a time.
158              for my $group (@groups) {              for my $group (@groups) {
159                    Trace("Starting the search.") if T(3);
160                  my $query = $sprout->Search($keywords, 0, ['Feature', 'HasFeature', 'Genome'],                  my $query = $sprout->Search($keywords, 0, ['Feature', 'HasFeature', 'Genome'],
161                                              "Genome(primary-group) = ?", [$group]);                                              "Genome(primary-group) = ?", [$group]);
162                    Trace("Processing results.") if T(3);
163                  $retVal += $self->ProcessQuery($query);                  $retVal += $self->ProcessQuery($query);
164                    Trace("Results processed.") if T(3);
165              }              }
166          } else {          } else {
167              # Here we do one search just for features.              # Here we do one search just for features.
168                    Trace("Starting the search.") if T(3);
169              my $query = $sprout->Search($keywords, 0, ['Feature']);              my $query = $sprout->Search($keywords, 0, ['Feature']);
170                    Trace("Processing results.") if T(3);
171              $retVal += $self->ProcessQuery($query);              $retVal += $self->ProcessQuery($query);
172                    Trace("Results processed.") if T(3);
173          }          }
174          # Close the session file.          # Close the session file.
175          $self->CloseSession();          $self->CloseSession();
176            Trace("Session closed.") if T(3);
177      }      }
178      # Return the result count.      # Return the result count.
179      return $retVal;      return $retVal;
# Line 191  Line 193 
193      # Get the parameters.      # Get the parameters.
194      my ($self) = @_;      my ($self) = @_;
195      # Return the result.      # Return the result.
196      return "Search for features based on keywords.";      return "Search for genes based on keywords.";
197  }  }
198    
199  =head3 ProcessQuery  =head3 ProcessQuery

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3