[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.3, Fri Sep 29 15:10:05 2006 UTC revision 1.6, Mon Oct 2 07:31:46 2006 UTC
# Line 237  Line 237 
237  by calling L</SetMessage>. If the parameters are valid, then the method must return  by calling L</SetMessage>. If the parameters are valid, then the method must return
238  the number of items found.  the number of items found.
239    
 =head2 Virtual Methods  
   
 =head3 Form  
   
 C<< my $html = $shelp->Form(); >>  
   
 Generate the HTML for a form to request a new search.  
   
 =head3 Find  
   
 C<< my $resultCount = $shelp->Find(); >>  
   
 Conduct a search based on the current CGI query parameters. The search results will  
 be written to the session cache file and the number of results will be  
 returned. If the search parameters are invalid, a result count of C<undef> will be  
 returned and a result message will be stored in this object describing the problem.  
   
 =head3 Description  
   
 C<< my $htmlText = $shelp->Description(); >>  
   
 Return a description of this search. The description is used for the table of contents  
 on the main search tools page. It may contain HTML, but it should be character-level,  
 not block-level, since the description is going to appear in a list.  
   
240  =cut  =cut
241    
242  # This counter is used to insure every form on the page has a unique name.  # This counter is used to insure every form on the page has a unique name.
# Line 700  Line 675 
675      }      }
676      # Compute the sort key. The sort key floats NMPDR organism features to the      # Compute the sort key. The sort key floats NMPDR organism features to the
677      # top of the return list.      # top of the return list.
678      my $group = $self->FeatureGroup($fid);      my $key = $self->SortKey($record);
     my $key = ($group ? "A$group" : "ZZ");  
679      # Write the feature data.      # Write the feature data.
680      $self->WriteColumnData($key, @output);      $self->WriteColumnData($key, @output);
681  }  }
# Line 799  Line 773 
773      my $retVal;      my $retVal;
774      # Get a digest encoder.      # Get a digest encoder.
775      my $md5 = Digest::MD5->new();      my $md5 = Digest::MD5->new();
776      # If we have a randomization file, use it to seed the digester.      # Add the PID, the IP, and the time stamp. Note that the time stamp is
777      if (open(R, "/dev/urandom")) {      # actually two numbers, and we get them both because we're in list
778          my $b;      # context.
779          read(R, $b, 1024);      $md5->add($$, $ENV{REMOTE_ADDR}, $ENV{REMOTE_PORT}, gettimeofday());
780          $md5->add($b);      # Hash up all this identifying data.
781      }      $retVal = $md5->hexdigest();
782      # Add the PID and the time stamp.      # Return the result.
     $md5->add($$, gettimeofday);  
     # Hash it up and clean the result so that it works as a file name.  
     $retVal = $md5->b64digest();  
     $retVal =~ s,/,\$,g;  
     $retVal =~ s,\+,@,g;  
     # Return it.  
783      return $retVal;      return $retVal;
784  }  }
785    
# Line 970  Line 938 
938      } else {      } else {
939          # Here we can get its genome data.          # Here we can get its genome data.
940          $retVal = $self->Organism($genomeID);          $retVal = $self->Organism($genomeID);
941          # Append the type and number.          # Append the FIG ID.
942          $retVal .= " [$type $num]";          $retVal .= " [$fid]";
943      }      }
944      # Return the result.      # Return the result.
945      return $retVal;      return $retVal;
# Line 1372  Line 1340 
1340                            $cgi->td($cgi->popup_menu(-name => 'PageSize',                            $cgi->td($cgi->popup_menu(-name => 'PageSize',
1341                                                      -values => [10, 25, 45, 100, 1000],                                                      -values => [10, 25, 45, 100, 1000],
1342                                                      -default => $pageSize) . " " .                                                      -default => $pageSize) . " " .
                                    $cgi->checkbox(-name => 'ShowAliases',  
                                                   -value => 1,  
                                                   -label => 'Show Alias Links',  
                                                   -default => $aliases),  
1343                                     $cgi->checkbox(-name => 'ShowURL',                                     $cgi->checkbox(-name => 'ShowURL',
1344                                                    -value => 1,                                                    -value => 1,
1345                                                    -label => 'Show URL')),                                                    -label => 'Show URL')),
# Line 1442  Line 1406 
1406          # Get the feature location string.          # Get the feature location string.
1407          my $loc = $sprout->FeatureLocation($feat);          my $loc = $sprout->FeatureLocation($feat);
1408          # Compute the contig, start, and stop points.          # Compute the contig, start, and stop points.
1409          my($start, $stop, $contig) = BasicLocation::Parse($loc);          my($contig, $start, $stop) = BasicLocation::Parse($loc);
1410            Trace("Start and stop are ($start,$stop) on contig $contig.") if T(3);
1411          # Now we need to do some goofiness to insure that the location is not too          # Now we need to do some goofiness to insure that the location is not too
1412          # big and that we get some surrounding stuff.          # big and that we get some surrounding stuff.
1413          my $mid = int(($start + $stop) / 2);          my $mid = int(($start + $stop) / 2);
# Line 1472  Line 1437 
1437          }          }
1438          my $seg_id = $contig;          my $seg_id = $contig;
1439          $seg_id =~ s/:/--/g;          $seg_id =~ s/:/--/g;
1440            Trace("Show limits are ($show_start,$show_stop) in genome $genomeID with ref $seg_id.") if T(3);
1441          # Assemble all the pieces.          # Assemble all the pieces.
1442          $retVal = "gbrowse.cgi/GB_$genomeID?ref=$seg_id&start=$show_start&stop=$show_stop";          $retVal = "gbrowse.cgi/GB_$genomeID?ref=$seg_id&start=$show_start&stop=$show_stop";
1443      }      }
# Line 1715  Line 1681 
1681      # Get the parameters.      # Get the parameters.
1682      my ($self) = @_;      my ($self) = @_;
1683      # Return the result.      # Return the result.
1684      return ['orgName', 'function', 'gblink', 'protlink'];      return ['orgName', 'function', 'gblink', 'protlink',
1685                FeatureQuery::AdditionalColumns($self)];
1686  }  }
1687    
1688  =head3 FeatureColumnTitle  =head3 FeatureColumnTitle
# Line 1909  Line 1876 
1876      return $retVal;      return $retVal;
1877  }  }
1878    
1879    =head2 Virtual Methods
1880    
1881    =head3 Form
1882    
1883    C<< my $html = $shelp->Form(); >>
1884    
1885    Generate the HTML for a form to request a new search.
1886    
1887    =head3 Find
1888    
1889    C<< my $resultCount = $shelp->Find(); >>
1890    
1891    Conduct a search based on the current CGI query parameters. The search results will
1892    be written to the session cache file and the number of results will be
1893    returned. If the search parameters are invalid, a result count of C<undef> will be
1894    returned and a result message will be stored in this object describing the problem.
1895    
1896    =head3 Description
1897    
1898    C<< my $htmlText = $shelp->Description(); >>
1899    
1900    Return a description of this search. The description is used for the table of contents
1901    on the main search tools page. It may contain HTML, but it should be character-level,
1902    not block-level, since the description is going to appear in a list.
1903    
1904    =head3 SortKey
1905    
1906    C<< my $key = $shelp->SortKey($record); >>
1907    
1908    Return the sort key for the specified record. The default is to sort by feature name,
1909    floating NMPDR organisms to the top. This sort may be overridden by the search class
1910    to provide fancier functionality. This method is called by B<PutFeature>, so it
1911    is only used for feature searches. A non-feature search would presumably have its
1912    own sort logic.
1913    
1914    =over 4
1915    
1916    =item record
1917    
1918    The C<DBObject> from which the current row of data is derived.
1919    
1920    =item RETURN
1921    
1922    Returns a key field that can be used to sort this row in among the results.
1923    
1924    =back
1925    
1926    =cut
1927    
1928    sub SortKey {
1929        # Get the parameters.
1930        my ($self, $record) = @_;
1931        # Get the feature ID from the record.
1932        my ($fid) = $record->Value('Feature(id)');
1933        # Get the group from the feature ID.
1934        my $group = $self->FeatureGroup($fid);
1935        # Ask the feature query object to form the sort key.
1936        my $retVal = FeatureQuery::SortKey($self, $group, $record);
1937        # Return the result.
1938        return $retVal;
1939    }
1940  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3