[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.4, Wed Nov 15 22:34:50 2006 UTC revision 1.5, Mon Jul 16 20:04:51 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 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;
154              # Create a feature data object for tracking the results.              # Create a feature data object for tracking the results.
# Line 160  Line 164 
164                                       [$genomeID]);                                       [$genomeID]);
165              # Loop through the query results. The same feature may appear multiple times,              # Loop through the query results. The same feature may appear multiple times,
166              # but all the multiples will be grouped together.              # but all the multiples will be grouped together.
167                my $savedRow;
168              while (my $row = $query->Fetch()) {              while (my $row = $query->Fetch()) {
169                  # Get the feature ID;                  # Get the feature ID;
170                  my ($newFid) = $row->Value('Feature(id)');                  my $newFid = $row->PrimaryValue('Feature(id)');
171                  # 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
172                  # to avoid a run-time warning.                  # to avoid a run-time warning.
173                  if (! defined($fid) || $newFid ne $fid) {                  if (! defined($fid) || $newFid ne $fid) {
174                      if (defined($fid)) {                      if (defined($fid)) {
175                          # Here we have an old feature to output.                          # Here we have an old feature to output.
176                          $self->DumpFeature($fd, \@extraCols);                          $self->DumpFeature($rhelp, $savedRow, \@extraCols);
177                          $retVal++;                          $retVal++;
178                      }                      }
179                      # Now we can store the new feature.                      # Clear the property value list.
                     $fd->Store($row);  
180                      @extraCols = ();                      @extraCols = ();
181                        # Save this as the currently-active feature.
182                        $savedRow = $row;
183                      $fid = $newFid;                      $fid = $newFid;
184                  }                  }
185                  # Get this row's property data for the extra column.                  # Get this row's property data for the extra column.
# Line 189  Line 195 
195              }              }
196              # If there's a feature still in the buffer, write it here.              # If there's a feature still in the buffer, write it here.
197              if (defined $fid) {              if (defined $fid) {
198                  $self->DumpFeature($fd, \@extraCols);                  $self->DumpFeature($rhelp, $savedRow, \@extraCols);
199                  $retVal++;                  $retVal++;
200              }              }
201              # Close the session file.              # Close the session file.
# Line 202  Line 208 
208    
209  =head3 DumpFeature  =head3 DumpFeature
210    
211  C<< $shelp->DumpFeature($fd, \@extraCols); >>  C<< $shelp->DumpFeature($rhelp, $record, \@extraCols); >>
212    
213  Write the data for the current feature to the output.  Write the data for the current feature to the output.
214    
215  =over 4  =over 4
216    
217  =item fd  =item rhelp
218    
219    Feature result helper.
220    
221    =item record
222    
223  B<FeatureData> object for the feature.  B<ERDBObject> containing the feature.
224    
225  =item extraCols  =item extraCols
226    
# Line 222  Line 232 
232    
233  sub DumpFeature {  sub DumpFeature {
234      # Get the parameters.      # Get the parameters.
235      my ($self, $fd, $extraCols) = @_;      my ($self, $rhelp, $record, $extraCols) = @_;
236      # Format the extra column data.      # Format the extra column data.
237      my $extraColumn = join(", ", @{$extraCols});      my $extraColumn = join(", ", @{$extraCols});
238      # Add the extra column data.      # Add the extra column data.
239      $fd->AddExtraColumns(values => $extraColumn);      $rhelp->PutExtraColumns(values => $extraColumn);
240        # Compute the sort key and the feature ID.
241        my $sortKey = $rhelp->SortKey($record);
242        my $fid = $record->PrimaryValue('Feature(id)');
243      # Put everything to the output.      # Put everything to the output.
244      $self->PutFeature($fd);      $rhelp->PutData($sortKey, $fid, $record);
245  }  }
246    
247  =head3 Description  =head3 Description

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3