[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.8, Wed Oct 4 16:03:35 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 1114  Line 1082 
1082  Number of rows to display. If omitted, the default is 1 for a single-select list  Number of rows to display. If omitted, the default is 1 for a single-select list
1083  and 10 for a multi-select list.  and 10 for a multi-select list.
1084    
1085    =item crossMenu (optional)
1086    
1087    If specified, is presumed to be the name of another genome menu whose contents
1088    are to be mutually exclusive with the contents of this menu. As a result, instead
1089    of the standard onChange event, the onChange event will deselect any entries in
1090    the other menu.
1091    
1092  =item RETURN  =item RETURN
1093    
1094  Returns the HTML text to generate a C<SELECT> menu inside a form.  Returns the HTML text to generate a C<SELECT> menu inside a form.
# Line 1124  Line 1099 
1099    
1100  sub NmpdrGenomeMenu {  sub NmpdrGenomeMenu {
1101      # Get the parameters.      # Get the parameters.
1102      my ($self, $menuName, $multiple, $selected, $rows) = @_;      my ($self, $menuName, $multiple, $selected, $rows, $cross) = @_;
1103      # Get the Sprout and CGI objects.      # Get the Sprout and CGI objects.
1104      my $sprout = $self->DB();      my $sprout = $self->DB();
1105      my $cgi = $self->Q();      my $cgi = $self->Q();
# Line 1189  Line 1164 
1164      my $showSelect = "showSelected($menuName, '$divID', 1000);";      my $showSelect = "showSelected($menuName, '$divID', 1000);";
1165      # If multiple selection is supported, create an onChange event.      # If multiple selection is supported, create an onChange event.
1166      my $onChange = "";      my $onChange = "";
1167      if ($multiple) {      if ($cross) {
1168            $onChange = " onChange=\"crossUnSelect($menuName, '$divID', $cross, '${formName}_${cross}_status', 1000)\"";
1169        } elsif ($multiple) {
1170          $onChange = " onChange=\"$showSelect\"";          $onChange = " onChange=\"$showSelect\"";
1171      }      }
1172      # Create the SELECT tag and stuff it into the output array.      # Create the SELECT tag and stuff it into the output array.
# Line 1370  Line 1347 
1347      # Create the row.      # Create the row.
1348      my $retVal = $cgi->Tr($cgi->td("Results/Page"),      my $retVal = $cgi->Tr($cgi->td("Results/Page"),
1349                            $cgi->td($cgi->popup_menu(-name => 'PageSize',                            $cgi->td($cgi->popup_menu(-name => 'PageSize',
1350                                                      -values => [10, 25, 45, 100, 1000],                                                      -values => [10, 25, 50, 100, 1000],
1351                                                      -default => $pageSize) . " " .                                                      -default => $pageSize) . " " .
                                    $cgi->checkbox(-name => 'ShowAliases',  
                                                   -value => 1,  
                                                   -label => 'Show Alias Links',  
                                                   -default => $aliases),  
1352                                     $cgi->checkbox(-name => 'ShowURL',                                     $cgi->checkbox(-name => 'ShowURL',
1353                                                    -value => 1,                                                    -value => 1,
1354                                                    -label => 'Show URL')),                                                    -label => 'Show URL')),
# Line 1442  Line 1415 
1415          # Get the feature location string.          # Get the feature location string.
1416          my $loc = $sprout->FeatureLocation($feat);          my $loc = $sprout->FeatureLocation($feat);
1417          # Compute the contig, start, and stop points.          # Compute the contig, start, and stop points.
1418          my($start, $stop, $contig) = BasicLocation::Parse($loc);          my($contig, $start, $stop) = BasicLocation::Parse($loc);
1419            Trace("Start and stop are ($start,$stop) on contig $contig.") if T(3);
1420          # 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
1421          # big and that we get some surrounding stuff.          # big and that we get some surrounding stuff.
1422          my $mid = int(($start + $stop) / 2);          my $mid = int(($start + $stop) / 2);
# Line 1472  Line 1446 
1446          }          }
1447          my $seg_id = $contig;          my $seg_id = $contig;
1448          $seg_id =~ s/:/--/g;          $seg_id =~ s/:/--/g;
1449            Trace("Show limits are ($show_start,$show_stop) in genome $genomeID with ref $seg_id.") if T(3);
1450          # Assemble all the pieces.          # Assemble all the pieces.
1451          $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";
1452      }      }
# Line 1715  Line 1690 
1690      # Get the parameters.      # Get the parameters.
1691      my ($self) = @_;      my ($self) = @_;
1692      # Return the result.      # Return the result.
1693      return ['orgName', 'function', 'gblink', 'protlink'];      return ['orgName', 'function', 'gblink', 'protlink',
1694                FeatureQuery::AdditionalColumns($self)];
1695  }  }
1696    
1697  =head3 FeatureColumnTitle  =head3 FeatureColumnTitle
# Line 1909  Line 1885 
1885      return $retVal;      return $retVal;
1886  }  }
1887    
1888    =head2 Virtual Methods
1889    
1890    =head3 Form
1891    
1892    C<< my $html = $shelp->Form(); >>
1893    
1894    Generate the HTML for a form to request a new search.
1895    
1896    =head3 Find
1897    
1898    C<< my $resultCount = $shelp->Find(); >>
1899    
1900    Conduct a search based on the current CGI query parameters. The search results will
1901    be written to the session cache file and the number of results will be
1902    returned. If the search parameters are invalid, a result count of C<undef> will be
1903    returned and a result message will be stored in this object describing the problem.
1904    
1905    =head3 Description
1906    
1907    C<< my $htmlText = $shelp->Description(); >>
1908    
1909    Return a description of this search. The description is used for the table of contents
1910    on the main search tools page. It may contain HTML, but it should be character-level,
1911    not block-level, since the description is going to appear in a list.
1912    
1913    =head3 SortKey
1914    
1915    C<< my $key = $shelp->SortKey($record); >>
1916    
1917    Return the sort key for the specified record. The default is to sort by feature name,
1918    floating NMPDR organisms to the top. This sort may be overridden by the search class
1919    to provide fancier functionality. This method is called by B<PutFeature>, so it
1920    is only used for feature searches. A non-feature search would presumably have its
1921    own sort logic.
1922    
1923    =over 4
1924    
1925    =item record
1926    
1927    The C<DBObject> from which the current row of data is derived.
1928    
1929    =item RETURN
1930    
1931    Returns a key field that can be used to sort this row in among the results.
1932    
1933    =back
1934    
1935    =cut
1936    
1937    sub SortKey {
1938        # Get the parameters.
1939        my ($self, $record) = @_;
1940        # Get the feature ID from the record.
1941        my ($fid) = $record->Value('Feature(id)');
1942        # Get the group from the feature ID.
1943        my $group = $self->FeatureGroup($fid);
1944        # Ask the feature query object to form the sort key.
1945        my $retVal = FeatureQuery::SortKey($self, $group, $record);
1946        # Return the result.
1947        return $retVal;
1948    }
1949  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3