[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.37, Mon Aug 20 23:22:42 2007 UTC revision 1.42, Fri Oct 17 16:41:47 2008 UTC
# Line 241  Line 241 
241    
242  =head3 new  =head3 new
243    
244  C<< my $shelp = SearchHelper->new($cgi); >>      my $shelp = SearchHelper->new($cgi);
245    
246  Construct a new SearchHelper object.  Construct a new SearchHelper object.
247    
# Line 311  Line 311 
311    
312  =head3 Q  =head3 Q
313    
314  C<< my $query = $shelp->Q(); >>      my $query = $shelp->Q();
315    
316  Return the CGI query object.  Return the CGI query object.
317    
# Line 328  Line 328 
328    
329  =head3 DB  =head3 DB
330    
331  C<< my $sprout = $shelp->DB(); >>      my $sprout = $shelp->DB();
332    
333  Return the Sprout database object.  Return the Sprout database object.
334    
# Line 349  Line 349 
349    
350  =head3 IsNew  =head3 IsNew
351    
352  C<< my $flag = $shelp->IsNew(); >>      my $flag = $shelp->IsNew();
353    
354  Return TRUE if this is a new session, FALSE if this is an old session. An old  Return TRUE if this is a new session, FALSE if this is an old session. An old
355  session already has search results ready to process.  session already has search results ready to process.
# Line 365  Line 365 
365    
366  =head3 ID  =head3 ID
367    
368  C<< my $sessionID = $shelp->ID(); >>      my $sessionID = $shelp->ID();
369    
370  Return the current session ID.  Return the current session ID.
371    
# Line 380  Line 380 
380    
381  =head3 FormName  =head3 FormName
382    
383  C<< my $name = $shelp->FormName(); >>      my $name = $shelp->FormName();
384    
385  Return the name of the form this helper object will generate.  Return the name of the form this helper object will generate.
386    
# Line 395  Line 395 
395    
396  =head3 QueueFormScript  =head3 QueueFormScript
397    
398  C<< $shelp->QueueFormScript($statement); >>      $shelp->QueueFormScript($statement);
399    
400  Add the specified statement to the queue of JavaScript statements that are to be  Add the specified statement to the queue of JavaScript statements that are to be
401  executed when the form has been fully defined. This is necessary because until  executed when the form has been fully defined. This is necessary because until
# Line 430  Line 430 
430    
431  =head3 FormStart  =head3 FormStart
432    
433  C<< my $html = $shelp->FormStart($title); >>      my $html = $shelp->FormStart($title);
434    
435  Return the initial section of a form designed to perform another search of the  Return the initial section of a form designed to perform another search of the
436  same type. The form header is included along with hidden fields to persist the  same type. The form header is included along with hidden fields to persist the
# Line 461  Line 461 
461      # case the Advanced button was used.      # case the Advanced button was used.
462      my $retVal = "<div class=\"search\">\n" .      my $retVal = "<div class=\"search\">\n" .
463                   $cgi->start_form(-method => 'POST',                   $cgi->start_form(-method => 'POST',
464                                    -action => $cgi->url(-relative => 1),                                    -action => "$FIG_Config::cgi_url/SearchSkeleton.cgi",
465                                    -name => $self->FormName()) .                                    -name => $self->FormName()) .
466                   $cgi->hidden(-name => 'Class',                   $cgi->hidden(-name => 'Class',
467                                -value => $self->{class},                                -value => $self->{class},
# Line 478  Line 478 
478    
479  =head3 FormEnd  =head3 FormEnd
480    
481  C<< my $htmlText = $shelp->FormEnd(); >>      my $htmlText = $shelp->FormEnd();
482    
483  Return the HTML text for closing a search form. This closes both the C<form> and  Return the HTML text for closing a search form. This closes both the C<form> and
484  C<div> tags.  C<div> tags.
# Line 510  Line 510 
510    
511  =head3 SetMessage  =head3 SetMessage
512    
513  C<< $shelp->SetMessage($msg); >>      $shelp->SetMessage($msg);
514    
515  Store the specified text as the result message. The result message is displayed  Store the specified text as the result message. The result message is displayed
516  if an invalid parameter value is specified.  if an invalid parameter value is specified.
# Line 534  Line 534 
534    
535  =head3 Message  =head3 Message
536    
537  C<< my $text = $shelp->Message(); >>      my $text = $shelp->Message();
538    
539  Return the result message. The result message is displayed if an invalid parameter  Return the result message. The result message is displayed if an invalid parameter
540  value is specified.  value is specified.
# Line 550  Line 550 
550    
551  =head3 OpenSession  =head3 OpenSession
552    
553  C<< $shelp->OpenSession($rhelp); >>      $shelp->OpenSession($rhelp);
554    
555  Set up the session cache file and write out the column headers.  Set up the session cache file and write out the column headers.
556  This method should not be called until all the columns have  This method should not be called until all the columns have
# Line 585  Line 585 
585    
586  =head3 GetCacheFileName  =head3 GetCacheFileName
587    
588  C<< my $fileName = $shelp->GetCacheFileName(); >>      my $fileName = $shelp->GetCacheFileName();
589    
590  Return the name to be used for this session's cache file.  Return the name to be used for this session's cache file.
591    
# Line 600  Line 600 
600    
601  =head3 GetTempFileName  =head3 GetTempFileName
602    
603  C<< my $fileName = $shelp->GetTempFileName($type); >>      my $fileName = $shelp->GetTempFileName($type);
604    
605  Return the name to be used for a temporary file of the specified type. The  Return the name to be used for a temporary file of the specified type. The
606  name is computed from the session name with the type as a suffix.  name is computed from the session name with the type as a suffix.
# Line 631  Line 631 
631    
632  =head3 WriteColumnHeaders  =head3 WriteColumnHeaders
633    
634  C<< $shelp->WriteColumnHeaders(@colNames); >>      $shelp->WriteColumnHeaders(@colNames);
635    
636  Write out the column headers for the current search session. The column headers  Write out the column headers for the current search session. The column headers
637  are sent to the cache file, and then the cache is re-opened as a sort pipe and  are sent to the cache file, and then the cache is re-opened as a sort pipe and
# Line 668  Line 668 
668    
669  =head3 ReadColumnHeaders  =head3 ReadColumnHeaders
670    
671  C<< my @colHdrs = $shelp->ReadColumnHeaders($fh); >>      my @colHdrs = $shelp->ReadColumnHeaders($fh);
672    
673  Read the column headers from the specified file handle. The column headers are  Read the column headers from the specified file handle. The column headers are
674  frozen strings intermixed with frozen hash references. The strings represent  frozen strings intermixed with frozen hash references. The strings represent
# Line 700  Line 700 
700    
701  =head3 WriteColumnData  =head3 WriteColumnData
702    
703  C<< $shelp->WriteColumnData($key, @colValues); >>      $shelp->WriteColumnData($key, @colValues);
704    
705  Write a row of column values to the current search session. It is assumed that  Write a row of column values to the current search session. It is assumed that
706  the session file is already open for output.  the session file is already open for output.
# Line 729  Line 729 
729    
730  =head3 CloseSession  =head3 CloseSession
731    
732  C<< $shelp->CloseSession(); >>      $shelp->CloseSession();
733    
734  Close the session file.  Close the session file.
735    
# Line 751  Line 751 
751    
752  =head3 OrganismData  =head3 OrganismData
753    
754  C<< my ($orgName, $group) = $shelp->Organism($genomeID); >>      my ($orgName, $group) = $shelp->Organism($genomeID);
755    
756  Return the name and status of the organism corresponding to the specified genome ID.  Return the name and status of the organism corresponding to the specified genome ID.
757  For performance reasons, this information is cached in a special hash table, so we  For performance reasons, this information is cached in a special hash table, so we
# Line 803  Line 803 
803    
804  =head3 Organism  =head3 Organism
805    
806  C<< my $orgName = $shelp->Organism($genomeID); >>      my $orgName = $shelp->Organism($genomeID);
807    
808  Return the name of the relevant organism. The name is computed from the genus,  Return the name of the relevant organism. The name is computed from the genus,
809  species, and unique characterization. A cache is used to improve performance.  species, and unique characterization. A cache is used to improve performance.
# Line 833  Line 833 
833    
834  =head3 ComputeFASTA  =head3 ComputeFASTA
835    
836  C<< my $fasta = $shelp->ComputeFASTA($desiredType, $sequence, $flankingWidth); >>      my $fasta = $shelp->ComputeFASTA($desiredType, $sequence, $flankingWidth, $comments);
837    
838  Parse a sequence input and convert it into a FASTA string of the desired type with  Parse a sequence input and convert it into a FASTA string of the desired type with
839  the desired flanking width.  the desired flanking width.
# Line 860  Line 860 
860  protein translation of a feature doesn't always match the DNA and is taken directly  protein translation of a feature doesn't always match the DNA and is taken directly
861  from the database.  from the database.
862    
863    =item comments
864    
865    Comment string to be added to the FASTA header.
866    
867  =item RETURN  =item RETURN
868    
869  Returns a string in FASTA format representing the content of the desired sequence with  Returns a string in FASTA format representing the content of the desired sequence with
# Line 872  Line 876 
876    
877  sub ComputeFASTA {  sub ComputeFASTA {
878      # Get the parameters.      # Get the parameters.
879      my ($self, $desiredType, $sequence, $flankingWidth) = @_;      my ($self, $desiredType, $sequence, $flankingWidth, $comment) = @_;
880      # Declare the return variable. If an error occurs, it will remain undefined.      # Declare the return variable. If an error occurs, it will remain undefined.
881      my $retVal;      my $retVal;
882      # This variable will be cleared if an error is detected.      # This variable will be cleared if an error is detected.
# Line 903  Line 907 
907                  # In an emergency, fall back to the original ID.                  # In an emergency, fall back to the original ID.
908                  $fastaLabel = $fid;                  $fastaLabel = $fid;
909              }              }
910                # Add any specified comments.
911                if ($comment) {
912                    $fastaLabel .= " $comment";
913                }
914              # Now proceed according to the sequence type.              # Now proceed according to the sequence type.
915              if ($desiredType =~ /prot/) {              if ($desiredType =~ /prot/) {
916                  # We want protein, so get the translation.                  # We want protein, so get the translation.
# Line 994  Line 1002 
1002    
1003  =head3 SubsystemTree  =head3 SubsystemTree
1004    
1005  C<< my $tree = SearchHelper::SubsystemTree($sprout, %options); >>      my $tree = SearchHelper::SubsystemTree($sprout, %options);
1006    
1007  This method creates a subsystem selection tree suitable for passing to  This method creates a subsystem selection tree suitable for passing to
1008  L</SelectionTree>. Each leaf node in the tree will have a link to the  L</SelectionTree>. Each leaf node in the tree will have a link to the
# Line 1052  Line 1060 
1060              push @subs, $classLess;              push @subs, $classLess;
1061          }          }
1062      }      }
1063        # Get the seedviewer URL.
1064        my $svURL = $FIG_Config::linkinSV || "$FIG_Config::cgi_url/seedviewer.cgi";
1065        Trace("Seed Viewer URL is $svURL.") if T(3);
1066      # Declare the return variable.      # Declare the return variable.
1067      my @retVal = ();      my @retVal = ();
1068      # Each element in @subs represents a leaf node, so as we loop through it we will be      # Each element in @subs represents a leaf node, so as we loop through it we will be
# Line 1126  Line 1137 
1137              if ($optionThing->{links}) {              if ($optionThing->{links}) {
1138                  # Compute the link value.                  # Compute the link value.
1139                  my $linkable = uri_escape($id);                  my $linkable = uri_escape($id);
1140                  $nodeContent->{link} = "../FIG/display_subsys.cgi?ssa_name=$linkable;request=show_ssa;sort=by_phylo;show_clusters=1;SPROUT=1";                  $nodeContent->{link} = "$svURL?page=Subsystems;subsystem=$linkable";
1141              }              }
1142              if ($optionThing->{radio}) {              if ($optionThing->{radio}) {
1143                  # Compute the radio value.                  # Compute the radio value.
# Line 1144  Line 1155 
1155    
1156  =head3 NmpdrGenomeMenu  =head3 NmpdrGenomeMenu
1157    
1158  C<< my $htmlText = $shelp->NmpdrGenomeMenu($menuName, $multiple, \@selected, $rows); >>      my $htmlText = $shelp->NmpdrGenomeMenu($menuName, $multiple, \@selected, $rows);
1159    
1160  This method creates a hierarchical HTML menu for NMPDR genomes organized by category. The  This method creates a hierarchical HTML menu for NMPDR genomes organized by category. The
1161  category indicates the low-level NMPDR group. Organizing the genomes in this way makes it  category indicates the low-level NMPDR group. Organizing the genomes in this way makes it
# Line 1173  Line 1184 
1184    
1185  =item crossMenu (optional)  =item crossMenu (optional)
1186    
1187  If specified, is presumed to be the name of another genome menu whose contents  This is currently not supported.
 are to be mutually exclusive with the contents of this menu. As a result, instead  
 of the standard onChange event, the onChange event will deselect any entries in  
 the other menu.  
1188    
1189  =item RETURN  =item RETURN
1190    
# Line 1196  Line 1204 
1204      if (! defined $rows) {      if (! defined $rows) {
1205          $rows = ($multiple ? 10 : 1);          $rows = ($multiple ? 10 : 1);
1206      }      }
1207      # Create the multiple tag.      # Get a comma-delimited list of the preselected genomes.
1208      my $multipleTag = ($multiple ? " multiple" : "");      my $preselected = "";
1209      # Get the form name.      if ($selected) {
1210      my $formName = $self->FormName();          $preselected = join(", ", @$selected);
1211      # Check to see if we already have a genome list in memory.      }
1212      my $groupHash;      # Ask Sprout for a genome menu.
1213      my @groups;      my $retVal = $sprout->GenomeMenu(name => $menuName,
1214      my $nmpdrGroupCount;                                       multiSelect => $multiple,
1215      my $genomes = $self->{genomeList};                                       selected => $preselected,
1216      if (defined $genomes) {                                       size => $rows);
         # We have a list ready to use.  
         $groupHash = $genomes;  
         @groups = @{$self->{groupList}};  
         $nmpdrGroupCount = $self->{groupCount};  
     } else {  
         # Get a list of all the genomes in group order. In fact, we only need them ordered  
         # by name (genus,species,strain), but putting primary-group in front enables us to  
         # take advantage of an existing index.  
         my @genomeList = $sprout->GetAll(['Genome'],  
                                          "ORDER BY Genome(primary-group), Genome(genus), Genome(species), Genome(unique-characterization)",  
                                          [], ['Genome(primary-group)', 'Genome(id)',  
                                               'Genome(genus)', 'Genome(species)',  
                                               'Genome(unique-characterization)',  
                                               'Genome(taxonomy)']);  
         # Create a hash to organize the genomes by group. Each group will contain a list of  
         # 2-tuples, the first element being the genome ID and the second being the genome  
         # name.  
         my %gHash = ();  
         for my $genome (@genomeList) {  
             # Get the genome data.  
             my ($group, $genomeID, $genus, $species, $strain, $taxonomy) = @{$genome};  
             # Compute and cache its name and display group.  
             my ($name, $displayGroup, $domain) = $self->SaveOrganismData($group, $genomeID, $genus, $species,  
                                                                          $strain, $taxonomy);  
             # Push the genome into the group's list. Note that we use the real group  
             # name here, not the display group name.  
             push @{$gHash{$group}}, [$genomeID, $name, $domain];  
         }  
         # We are almost ready to unroll the menu out of the group hash. The final step is to separate  
         # the supporting genomes by domain. First, we sort the NMPDR groups.  
         @groups = sort grep { $_ ne $FIG_Config::otherGroup } keys %gHash;  
         # Remember the number of NMPDR groups.  
         $nmpdrGroupCount = scalar @groups;  
         # Loop through the supporting genomes, classifying them by domain. We'll also keep a list  
         # of the domains found.  
         my @otherGenomes = @{$gHash{$FIG_Config::otherGroup}};  
         my @domains = ();  
         for my $genomeData (@otherGenomes) {  
             my ($genomeID, $name, $domain) = @{$genomeData};  
             if (exists $gHash{$domain}) {  
                 push @{$gHash{$domain}}, $genomeData;  
             } else {  
                 $gHash{$domain} = [$genomeData];  
                 push @domains, $domain;  
             }  
         }  
         # Add the domain groups at the end of the main group list. The main group list will now  
         # contain all the categories we need to display the genomes.  
         push @groups, sort @domains;  
         # Delete the supporting group.  
         delete $gHash{$FIG_Config::otherGroup};  
         # Save the genome list for future use.  
         $self->{genomeList} = \%gHash;  
         $self->{groupList} = \@groups;  
         $self->{groupCount} = $nmpdrGroupCount;  
         $groupHash = \%gHash;  
     }  
     # Next, create a hash that specifies the pre-selected entries. Note that we need to deal  
     # with the possibility of undefined values in the incoming list.  
     my %selectedHash = ();  
     if (defined $selected) {  
         %selectedHash = map { $_ => 1 } grep { defined($_) } @{$selected};  
     }  
     # Now it gets complicated. We need a way to mark all the NMPDR genomes. We take advantage  
     # of the fact they come first in the list. We'll accumulate a count of the NMPDR genomes  
     # and use that to make the selections.  
     my $nmpdrCount = 0;  
     # Create the type counters.  
     my $groupCount = 1;  
     # Compute the ID for the status display.  
     my $divID = "${formName}_${menuName}_status";  
     # Compute the JavaScript call for updating the status.  
     my $showSelect = "showSelected($menuName, '$divID', 1000);";  
     # If multiple selection is supported, create an onChange event.  
     my $onChange = "";  
     if ($cross) {  
         # Here we have a paired menu. Selecting something in our menu unselects it in the  
         # other and redisplays the status of both.  
         $onChange = " onChange=\"crossUnSelect($menuName, '$divID', $cross, '${formName}_${cross}_status', 1000)\"";  
     } elsif ($multiple) {  
         # This is an unpaired menu, so all we do is redisplay our status.  
         $onChange = " onChange=\"$showSelect\"";  
     }  
     # Create the SELECT tag and stuff it into the output array.  
     my @lines = ("<SELECT name=\"$menuName\"$onChange$multipleTag size=\"$rows\">");  
     # Loop through the groups.  
     for my $group (@groups) {  
         # Create the option group tag.  
         my $tag = "<OPTGROUP label=\"$group\">";  
         push @lines, "  $tag";  
         # Get the genomes in the group.  
         for my $genome (@{$groupHash->{$group}}) {  
             # Count this organism if it's NMPDR.  
             if ($nmpdrGroupCount > 0) {  
                 $nmpdrCount++;  
             }  
             # Get the organism ID, name, and domain.  
             my ($genomeID, $name, $domain) = @{$genome};  
             # See if it's selected.  
             my $select = ($selectedHash{$genomeID} ? " selected" : "");  
             # Generate the option tag.  
             my $optionTag = "<OPTION class=\"$domain\" value=\"$genomeID\"$select>$name <em>($genomeID)</em></OPTION>";  
             push @lines, "    $optionTag";  
         }  
         # Close the option group.  
         push @lines, "  </OPTGROUP>";  
         # Record this group in the nmpdrGroup count. When that gets to 0, we've finished the NMPDR  
         # groups.  
         $nmpdrGroupCount--;  
     }  
     # Close the SELECT tag.  
     push @lines, "</SELECT>";  
     # Check for multiple selection.  
     if ($multiple) {  
         # Multi-select is on, so we need to add some selection helpers. First is  
         # the search box. This allows the user to type text and have all genomes containing  
         # the text selected automatically.  
         my $searchThingName = "${menuName}_SearchThing";  
         push @lines, "<br />" .  
                      "<INPUT type=\"button\" name=\"MacroSearch\" class=\"button\" value=\"Select genomes containing\" onClick=\"selectViaSearch($menuName, $searchThingName); $showSelect\" />&nbsp;" .  
                      "<INPUT type=\"text\" name=\"$searchThingName\" size=\"30\" />" . Hint("Genome Control",  
                                                                                             "Enter a genome number, then click the button to the left " .  
                                                                                             "in order to select the genome with that number. " .  
                                                                                             "Enter a genus, species, or strain and click the " .  
                                                                                             "button to select all genomes with that genus, species, " .  
                                                                                             "or strain name.");  
         # Next are the buttons to set and clear selections.  
         push @lines, "<br />";  
         push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll($menuName); $showSelect\" />";  
         push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll($menuName); $showSelect\" />";  
         push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome($menuName, $nmpdrCount, true); $showSelect\" />";  
         # push @lines, "<INPUT type=\"button\" name=\"OtherOnly\" class=\"bigButton\" value=\"Select Supporting\" onClick=\"selectSome($menuName, $nmpdrCount, false); $showSelect\" />";  
         # Add the status display, too.  
         push @lines, "<DIV id=\"$divID\" class=\"selectStatus\"></DIV>";  
         # Queue to update the status display when the form loads. We need to modify the show statement  
         # slightly because the queued statements are executed outside the form. This may seem like a lot of  
         # trouble, but we want all of the show statement calls to be generated from a single line of code,  
         # in case we decide to twiddle the parameters.  
         $showSelect =~ s/showSelected\(/showSelected\(thisForm\./;  
         $self->QueueFormScript($showSelect);  
         # Finally, add this parameter to the list of genome parameters. This enables us to  
         # easily find all the parameters used to select one or more genomes.  
         push @{$self->{genomeParms}}, $menuName;  
     }  
     # Assemble all the lines into a string.  
     my $retVal = join("\n", @lines, "");  
1217      # Return the result.      # Return the result.
1218      return $retVal;      return $retVal;
1219  }  }
1220    
1221  =head3 PropertyMenu  =head3 PropertyMenu
1222    
1223  C<< my $htmlText = $shelp->PropertyMenu($menuName, $selected, $force); >>      my $htmlText = $shelp->PropertyMenu($menuName, $selected, $force);
1224    
1225  Generate a property name dropdown menu.  Generate a property name dropdown menu.
1226    
# Line 1408  Line 1270 
1270    
1271  =head3 MakeTable  =head3 MakeTable
1272    
1273  C<< my $htmlText = $shelp->MakeTable(\@rows); >>      my $htmlText = $shelp->MakeTable(\@rows);
1274    
1275  Create a table from a group of table rows. The table rows must be fully pre-formatted: in  Create a table from a group of table rows. The table rows must be fully pre-formatted: in
1276  other words, each must have the TR and TD tags included.  other words, each must have the TR and TD tags included.
# Line 1471  Line 1333 
1333    
1334  =head3 SubmitRow  =head3 SubmitRow
1335    
1336  C<< my $htmlText = $shelp->SubmitRow($caption); >>      my $htmlText = $shelp->SubmitRow($caption);
1337    
1338  Returns the HTML text for the row containing the page size control  Returns the HTML text for the row containing the page size control
1339  and the submit button. All searches should have this row somewhere  and the submit button. All searches should have this row somewhere
# Line 1508  Line 1370 
1370                                     $cgi->popup_menu(-name => 'AliasType',                                     $cgi->popup_menu(-name => 'AliasType',
1371                                                      -values => ['FIG', AliasAnalysis::AliasTypes() ],                                                      -values => ['FIG', AliasAnalysis::AliasTypes() ],
1372                                                      -default => $aliasType) .                                                      -default => $aliasType) .
1373                                     Hint("Identifier type", "Specify how you want gene names to be displayed."))) .                                     Hint("Identifier Type", "Specify how you want gene names to be displayed."))) .
1374                   "\n" .                   "\n" .
1375                   $cgi->Tr($cgi->td("Results/Page"),                   $cgi->Tr($cgi->td("Results/Page"),
1376                            $cgi->td($cgi->popup_menu(-name => 'PageSize',                            $cgi->td($cgi->popup_menu(-name => 'PageSize',
# Line 1523  Line 1385 
1385    
1386  =head3 GetGenomes  =head3 GetGenomes
1387    
1388  C<< my @genomeList = $shelp->GetGenomes($parmName); >>      my @genomeList = $shelp->GetGenomes($parmName);
1389    
1390  Return the list of genomes specified by the specified CGI query parameter.  Return the list of genomes specified by the specified CGI query parameter.
1391  If the request method is POST, then the list of genome IDs is returned  If the request method is POST, then the list of genome IDs is returned
# Line 1565  Line 1427 
1427      return @retVal;      return @retVal;
1428  }  }
1429    
 =head3 GetHelpText  
   
 C<< my $htmlText = $shelp->GetHelpText(); >>  
   
 Get the help text for this search. The help text is stored in files on the template  
 server. The help text for a specific search is taken from a file named  
 C<SearchHelp_>I<class>C<.inc> in the template directory C<$FIG_Config::template_url>.  
 There are also three standard help files: C<SearchHelp1_Filtering.inc> describes the  
 feature filtering performed by the B<RHFeatures> object, C<SearchHelp1_GenomeControl.inc>  
 describes how to use a multiple-selection genome control, and C<SearchHelp1_Standard.inc>  
 describes the standard controls for a search, such as page size, URL display, and  
 external alias display.  
   
 =cut  
   
 sub GetHelpText {  
     # Get the parameters.  
     my ($self) = @_;  
     # Create a list to hold the pieces of the help.  
     my @helps = ();  
     # Get the template directory URL.  
     my $urlBase = $FIG_Config::template_url;  
     # Start with the specific help.  
     my $class = $self->{class};  
     push @helps, PageBuilder::GetPage("$urlBase/SearchHelp_$class.inc");  
     # Add the genome control help if needed.  
     if (scalar @{$self->{genomeParms}}) {  
         push @helps, PageBuilder::GetPage("$urlBase/SearchHelp1_GenomeControl.inc");  
     }  
     # Next the filter help.  
     if ($self->{filtered}) {  
         push @helps, PageBuilder::GetPage("$urlBase/SearchHelp1_Filtering.inc");  
     }  
     # Finally, the standard help.  
     push @helps, PageBuilder::GetPage("$urlBase/SearchHelp1_Standard.inc");  
     # Assemble the pieces.  
     my $retVal = join("\n<p>&nbsp;</p>\n", @helps);  
     # Return the result.  
     return $retVal;  
 }  
   
1430  =head3 ComputeSearchURL  =head3 ComputeSearchURL
1431    
1432  C<< my $url = $shelp->ComputeSearchURL(%overrides); >>      my $url = $shelp->ComputeSearchURL(%overrides);
1433    
1434  Compute the GET-style URL for the current search. In order for this to work, there  Compute the GET-style URL for the current search. In order for this to work, there
1435  must be a copy of the search form on the current page. This will always be the  must be a copy of the search form on the current page. This will always be the
# Line 1641  Line 1462 
1462      my $cgi = $self->Q();      my $cgi = $self->Q();
1463      my $sprout = $self->DB();      my $sprout = $self->DB();
1464      # Start with the full URL.      # Start with the full URL.
1465      my $retVal = $cgi->url(-full => 1);      my $retVal = "$FIG_Config::cgi_url/SearchSkeleton.cgi";
1466      # Get all the query parameters in a hash.      # Get all the query parameters in a hash.
1467      my %parms = $cgi->Vars();      my %parms = $cgi->Vars();
1468      # Now we need to do some fixing. Each multi-valued parameter is encoded as a string with null      # Now we need to do some fixing. Each multi-valued parameter is encoded as a string with null
# Line 1701  Line 1522 
1522    
1523  =head3 AdvancedClassList  =head3 AdvancedClassList
1524    
1525  C<< my @classes = SearchHelper::AdvancedClassList(); >>      my @classes = SearchHelper::AdvancedClassList();
1526    
1527  Return a list of advanced class names. This list is used to generate the directory  Return a list of advanced class names. This list is used to generate the directory
1528  of available searches on the search page.  of available searches on the search page.
# Line 1724  Line 1545 
1545    
1546  =head3 SelectionTree  =head3 SelectionTree
1547    
1548  C<< my $htmlText = SearchHelper::SelectionTree($cgi, \%tree, %options); >>      my $htmlText = SearchHelper::SelectionTree($cgi, \%tree, %options);
1549    
1550  Display a selection tree.  Display a selection tree.
1551    
# Line 1833  Line 1654 
1654  =item nodeImageClosed  =item nodeImageClosed
1655    
1656  URL of the image to display next to the tree nodes when they are collapsed. Clicking  URL of the image to display next to the tree nodes when they are collapsed. Clicking
1657  on the image will expand a section of the tree. The default is C<../FIG/Html/plus.gif>.  on the image will expand a section of the tree. The default is C<plus.gif>.
1658    
1659  =item nodeImageOpen  =item nodeImageOpen
1660    
1661  URL of the image to display next to the tree nodes when they are expanded. Clicking  URL of the image to display next to the tree nodes when they are expanded. Clicking
1662  on the image will collapse a section of the tree. The default is C<../FIG/Html/minus.gif>.  on the image will collapse a section of the tree. The default is C<minus.gif>.
1663    
1664  =item style  =item style
1665    
# Line 1878  Line 1699 
1699      my ($cgi, $tree, %options) = @_;      my ($cgi, $tree, %options) = @_;
1700      # Get the options.      # Get the options.
1701      my $optionThing = Tracer::GetOptions({ name => 'selection',      my $optionThing = Tracer::GetOptions({ name => 'selection',
1702                                             nodeImageClosed => '../FIG/Html/plus.gif',                                             nodeImageClosed => "$FIG_Config::cgi_url/Html/plus.gif",
1703                                             nodeImageOpen => '../FIG/Html/minus.gif',                                             nodeImageOpen => "$FIG_Config::cgi_url/Html/minus.gif",
1704                                             style => 'tree',                                             style => 'tree',
1705                                             target => '_self',                                             target => '_self',
1706                                             selected => undef},                                             selected => undef},
# Line 1913  Line 1734 
1734    
1735  =head3 ShowBranch  =head3 ShowBranch
1736    
1737  C<< my @htmlLines = SearchHelper::ShowBranch($cgi, $label, $id, $branch, $options, $displayType); >>      my @htmlLines = SearchHelper::ShowBranch($cgi, $label, $id, $branch, $options, $displayType);
1738    
1739  This is a recursive method that displays a branch of the tree.  This is a recursive method that displays a branch of the tree.
1740    
# Line 2008  Line 1829 
1829                      # If we have children, create the child list with a recursive call.                      # If we have children, create the child list with a recursive call.
1830                      if ($hasChildren) {                      if ($hasChildren) {
1831                          Trace("Processing children of $myLabel.") if T(4);                          Trace("Processing children of $myLabel.") if T(4);
1832                          push @childHtml, ShowBranch($cgi, $myLabel, $myID, $myContent, $options, 'none');                          push @childHtml, ShowBranch($cgi, $myLabel, $myID, $myContent, $options, 'block');
1833                          Trace("Children of $myLabel finished.") if T(4);                          Trace("Children of $myLabel finished.") if T(4);
1834                      }                      }
1835                  }                  }
# Line 2065  Line 1886 
1886    
1887  =head3 GetDivID  =head3 GetDivID
1888    
1889  C<< my $idString = SearchHelper::GetDivID($name); >>      my $idString = SearchHelper::GetDivID($name);
1890    
1891  Return a new HTML ID string.  Return a new HTML ID string.
1892    
# Line 2096  Line 1917 
1917    
1918  =head3 PrintLine  =head3 PrintLine
1919    
1920  C<< $shelp->PrintLine($message); >>      $shelp->PrintLine($message);
1921    
1922  Print a line of CGI output. This is used during the operation of the B<Find> method while  Print a line of CGI output. This is used during the operation of the B<Find> method while
1923  searching, so the user sees progress in real-time.  searching, so the user sees progress in real-time.
# Line 2120  Line 1941 
1941    
1942  =head3 GetHelper  =head3 GetHelper
1943    
1944  C<< my $shelp = SearchHelper::GetHelper($parm, $type => $className); >>      my $shelp = SearchHelper::GetHelper($parm, $type => $className);
1945    
1946  Return a helper object with the given class name. If no such class exists, an  Return a helper object with the given class name. If no such class exists, an
1947  error will be thrown.  error will be thrown.
# Line 2178  Line 1999 
1999    
2000  =head3 SaveOrganismData  =head3 SaveOrganismData
2001    
2002  C<< my ($name, $displayGroup, $domain) = $shelp->SaveOrganismData($group, $genomeID, $genus, $species, $strain, $taxonomy); >>      my ($name, $displayGroup, $domain) = $shelp->SaveOrganismData($group, $genomeID, $genus, $species, $strain, $taxonomy);
2003    
2004  Format the name of an organism and the display version of its group name. The incoming  Format the name of an organism and the display version of its group name. The incoming
2005  data should be the relevant fields from the B<Genome> record in the database. The  data should be the relevant fields from the B<Genome> record in the database. The
# Line 2252  Line 2073 
2073    
2074  =head3 ValidateKeywords  =head3 ValidateKeywords
2075    
2076  C<< my $okFlag = $shelp->ValidateKeywords($keywordString, $required); >>      my $okFlag = $shelp->ValidateKeywords($keywordString, $required);
2077    
2078  Insure that a keyword string is reasonably valid. If it is invalid, a message will be  Insure that a keyword string is reasonably valid. If it is invalid, a message will be
2079  set.  set.
# Line 2302  Line 2123 
2123    
2124  =head3 TuningParameters  =head3 TuningParameters
2125    
2126  C<< my $options = $shelp->TuningParameters(%parmHash); >>      my $options = $shelp->TuningParameters(%parmHash);
2127    
2128  Retrieve tuning parameters from the CGI query object. The parameter is a hash that maps parameter names  Retrieve tuning parameters from the CGI query object. The parameter is a hash that maps parameter names
2129  to their default values. The parameters and their values will be returned as a hash reference.  to their default values. The parameters and their values will be returned as a hash reference.
# Line 2345  Line 2166 
2166    
2167  =head3 GetPreferredAliasType  =head3 GetPreferredAliasType
2168    
2169  C<< my $type = $shelp->GetPreferredAliasType(); >>      my $type = $shelp->GetPreferredAliasType();
2170    
2171  Return the preferred alias type for the current session. This information is stored  Return the preferred alias type for the current session. This information is stored
2172  in the C<AliasType> parameter of the CGI query object, and the default is C<FIG>  in the C<AliasType> parameter of the CGI query object, and the default is C<FIG>
# Line 2367  Line 2188 
2188    
2189  =head3 Form  =head3 Form
2190    
2191  C<< my $html = $shelp->Form(); >>      my $html = $shelp->Form();
2192    
2193  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
2194    
2195  =head3 Find  =head3 Find
2196    
2197  C<< my $resultCount = $shelp->Find(); >>      my $resultCount = $shelp->Find();
2198    
2199  Conduct a search based on the current CGI query parameters. The search results will  Conduct a search based on the current CGI query parameters. The search results will
2200  be written to the session cache file and the number of results will be  be written to the session cache file and the number of results will be
# Line 2391  Line 2212 
2212    
2213  =head3 Description  =head3 Description
2214    
2215  C<< my $htmlText = $shelp->Description(); >>      my $htmlText = $shelp->Description();
2216    
2217  Return a description of this search. The description is used for the table of contents  Return a description of this search. The description is used for the table of contents
2218  on the main search tools page. It may contain HTML, but it should be character-level,  on the main search tools page. It may contain HTML, but it should be character-level,
# Line 2408  Line 2229 
2229    
2230  =head3 SearchTitle  =head3 SearchTitle
2231    
2232  C<< my $titleHtml = $shelp->SearchTitle(); >>      my $titleHtml = $shelp->SearchTitle();
2233    
2234  Return the display title for this search. The display title appears above the search results.  Return the display title for this search. The display title appears above the search results.
2235  If no result is returned, no title will be displayed. The result should be an html string  If no result is returned, no title will be displayed. The result should be an html string
# Line 2427  Line 2248 
2248    
2249  =head3 DefaultColumns  =head3 DefaultColumns
2250    
2251  C<< $shelp->DefaultColumns($rhelp); >>      $shelp->DefaultColumns($rhelp);
2252    
2253  Store the default columns in the result helper. The default action is just to ask  Store the default columns in the result helper. The default action is just to ask
2254  the result helper for its default columns, but this may be changed by overriding  the result helper for its default columns, but this may be changed by overriding
# Line 2454  Line 2275 
2275    
2276  =head3 Hint  =head3 Hint
2277    
2278  C<< my $htmlText = SearchHelper::Hint($wikiPage, $hintText); >>      my $htmlText = SearchHelper::Hint($wikiPage, $hintText);
2279    
2280  Return the HTML for a small question mark that displays the specified hint text when it is clicked.  Return the HTML for a small question mark that displays the specified hint text when it is clicked.
2281  This HTML can be put in forms to provide a useful hinting mechanism.  This HTML can be put in forms to provide a useful hinting mechanism.
# Line 2463  Line 2284 
2284    
2285  =item wikiPage  =item wikiPage
2286    
2287  Name of the wiki page to be popped up when the hint maek is clicked.  Name of the wiki page to be popped up when the hint mark is clicked.
2288    
2289  =item hintText  =item hintText
2290    
# Line 2481  Line 2302 
2302  sub Hint {  sub Hint {
2303      # Get the parameters.      # Get the parameters.
2304      my ($wikiPage, $hintText) = @_;      my ($wikiPage, $hintText) = @_;
2305      # Escape the single quotes in the hint text.      # Ask Sprout to draw the hint button for us.
2306      my $quotedText = $hintText;      return Sprout::Hint($wikiPage, $hintText);
     $quotedText =~ s/'/\\'/g;  
     # Convert the wiki page name to a URL.  
     my $wikiURL = ucfirst $wikiPage;  
     $wikiURL =~ s/ /_/g;  
     $wikiURL = "../wiki/index.php/$wikiURL";  
     # Create the html.  
     my $retVal = "&nbsp;<input type=\"button\" class=\"hintbutton\" onMouseOver=\"javascript:if (!this.tooltip) { " .  
                  "this.tooltip = new Popup_Tooltip(this, 'Search Hint', '$quotedText', '', 1); this.tooltip.addHandler(); } " .  
                  "return false;\" value=\"?\" onClick=\"javascript:window.open('$wikiURL', 'nmpdrHelp');\" />";  
     # Return it.  
     return $retVal;  
2307  }  }
2308    
2309    

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.42

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3