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

Diff of /Sprout/SHPropSearch.pm

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

revision 1.1, Thu Oct 19 02:10:06 2006 UTC revision 1.6, Tue Sep 11 23:27:42 2007 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 Property Search Feature Search Helper  =head1 Property Search Feature Search Helper
14    
# Line 43  Line 40 
40    
41  =head3 Form  =head3 Form
42    
43  C<< my $html = $shelp->Include(); >>  C<< my $html = $shelp->Form(); >>
44    
45  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
46    
# Line 56  Line 53 
53      my $cgi = $self->Q();      my $cgi = $self->Q();
54      my $sprout = $self->DB();      my $sprout = $self->DB();
55      # Start the form.      # Start the form.
56      my $retVal = $self->FormStart("Property Search");      my $retVal = $self->FormStart("Attribute Search");
57      my @rows = ();      my @rows = ();
58      # First, we generate the genome menu.      # First, we generate the genome menu.
59      my $genomeMenu = $self->NmpdrGenomeMenu('genome', 0, [$cgi->param('genome')]);      my $genomeMenu = $self->NmpdrGenomeMenu('genome', 0, [$cgi->param('genome')]);
# Line 143  Line 140 
140          } else {          } else {
141              # If we are here, then we have a genome ($genomeID) and a list              # If we are here, then we have a genome ($genomeID) and a list
142              # of desired property IDs (@propIDs). That means we can search.              # of desired property IDs (@propIDs). That means we can search.
143                # Create the result helper.
144                my $rhelp = RHFeatures->new($self);
145                # Set the default columns.
146                $self->DefaultColumns($rhelp);
147                # Add the value columm at the front.
148                $rhelp->AddExtraColumn(values => 0, title => 'Values', download => 'list',
149                                       style => 'leftAlign');
150              # Initialize the session file.              # Initialize the session file.
151              $self->OpenSession();              $self->OpenSession($rhelp);
152              # Initialize the result counter.              # Initialize the result counter.
153              $retVal = 0;              $retVal = 0;
             # Create a feature data object for tracking the results.  
             my $fd = FeatureData->new($self);  
154              # Create a variable to store the property value HTML.              # Create a variable to store the property value HTML.
155              my @extraCols = ();              my @extraCols = ();
156              # Denote that we currently don't have a feature.              # Denote that we currently don't have a feature.
# Line 160  Line 162 
162                                       [$genomeID]);                                       [$genomeID]);
163              # Loop through the query results. The same feature may appear multiple times,              # Loop through the query results. The same feature may appear multiple times,
164              # but all the multiples will be grouped together.              # but all the multiples will be grouped together.
165                my $savedRow;
166              while (my $row = $query->Fetch()) {              while (my $row = $query->Fetch()) {
167                  # Get the feature ID;                  # Get the feature ID;
168                  my ($newFid) = $row->Value('Feature(id)');                  my $newFid = $row->PrimaryValue('Feature(id)');
169                  # Check to see if we have a new feature coming in. Note we check for undef                  # Check to see if we have a new feature coming in. Note we check for undef
170                  # to avoid a run-time warning.                  # to avoid a run-time warning.
171                  if (! defined($fid) || $newFid ne $fid) {                  if (! defined($fid) || $newFid ne $fid) {
172                      if (defined($fid)) {                      if (defined($fid)) {
173                          # Here we have an old feature to output.                          # Here we have an old feature to output.
174                          $self->DumpFeature($fd, \@extraCols);                          $self->DumpFeature($rhelp, $savedRow, \@extraCols);
175                          $retVal++;                          $retVal++;
176                      }                      }
177                      # Now we can store the new feature.                      # Clear the property value list.
                     $fd->Store($row);  
178                      @extraCols = ();                      @extraCols = ();
179                        # Save this as the currently-active feature.
180                        $savedRow = $row;
181                      $fid = $newFid;                      $fid = $newFid;
182                  }                  }
183                  # Get this row's property data for the extra column.                  # Get this row's property data for the extra column.
# Line 189  Line 193 
193              }              }
194              # If there's a feature still in the buffer, write it here.              # If there's a feature still in the buffer, write it here.
195              if (defined $fid) {              if (defined $fid) {
196                  $self->DumpFeature($fd, \@extraCols);                  $self->DumpFeature($rhelp, $savedRow, \@extraCols);
197                  $retVal++;                  $retVal++;
198              }              }
199              # Close the session file.              # Close the session file.
# Line 202  Line 206 
206    
207  =head3 DumpFeature  =head3 DumpFeature
208    
209  C<< $shelp->DumpFeature($fd, \@extraCols); >>  C<< $shelp->DumpFeature($rhelp, $record, \@extraCols); >>
210    
211  Write the data for the current feature to the output.  Write the data for the current feature to the output.
212    
213  =over 4  =over 4
214    
215  =item fd  =item rhelp
216    
217    Feature result helper.
218    
219    =item record
220    
221  B<FeatureData> object for the feature.  B<ERDBObject> containing the feature.
222    
223  =item extraCols  =item extraCols
224    
# Line 222  Line 230 
230    
231  sub DumpFeature {  sub DumpFeature {
232      # Get the parameters.      # Get the parameters.
233      my ($self, $fd, $extraCols) = @_;      my ($self, $rhelp, $record, $extraCols) = @_;
234      # Format the extra column data.      # Format the extra column data.
235      my $extraColumn = join(", ", @{$extraCols});      my $extraColumn = join(", ", @{$extraCols});
236      # Add the extra column data.      # Add the extra column data.
237      $fd->AddExtraColumns(values => $extraColumn);      $rhelp->PutExtraColumns(values => $extraColumn);
238        # Compute the sort key and the feature ID.
239        my $sortKey = $rhelp->SortKey($record);
240        my $fid = $record->PrimaryValue('Feature(id)');
241      # Put everything to the output.      # Put everything to the output.
242      $self->PutFeature($fd);      $rhelp->PutData($sortKey, $fid, $record);
243  }  }
244    
245  =head3 Description  =head3 Description
# Line 245  Line 256 
256      # Get the parameters.      # Get the parameters.
257      my ($self) = @_;      my ($self) = @_;
258      # Return the result.      # Return the result.
259      return "Search for features in a specific genome with specified property values.";      return "Search for genes in a specific genome with specified property values.";
260  }  }
261    
262  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3