[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.6, Mon Oct 2 07:31:46 2006 UTC revision 1.10, Fri Oct 13 21:45:11 2006 UTC
# Line 214  Line 214 
214                      }                      }
215                  }                  }
216              }              }
         }  
217          # Close the session file.          # Close the session file.
218          $self->CloseSession();          $self->CloseSession();
219            }
220          # Return the result count.          # Return the result count.
221          return $retVal;          return $retVal;
222      }      }
# Line 316  Line 316 
316      return $self->{query};      return $self->{query};
317  }  }
318    
319    
320    
321  =head3 DB  =head3 DB
322    
323  C<< my $sprout = $shelp->DB(); >>  C<< my $sprout = $shelp->DB(); >>
# Line 673  Line 675 
675      for my $colName (@{$self->{cols}}) {      for my $colName (@{$self->{cols}}) {
676          push @output, $self->FeatureColumnValue($colName, $record, $extraCols);          push @output, $self->FeatureColumnValue($colName, $record, $extraCols);
677      }      }
678      # Compute the sort key. The sort key floats NMPDR organism features to the      # Compute the sort key. The sort key usually floats NMPDR organism features to the
679      # top of the return list.      # top of the return list.
680      my $key = $self->SortKey($record);      my $key = $self->SortKey($record);
681      # Write the feature data.      # Write the feature data.
# Line 756  Line 758 
758      # Check for an open session file.      # Check for an open session file.
759      if (defined $self->{fileHandle}) {      if (defined $self->{fileHandle}) {
760          # We found one, so close it.          # We found one, so close it.
761            Trace("Closing session file.") if T(2);
762          close $self->{fileHandle};          close $self->{fileHandle};
763      }      }
764  }  }
# Line 823  Line 826 
826                                                      ['Genome(genus)', 'Genome(species)',                                                      ['Genome(genus)', 'Genome(species)',
827                                                       'Genome(unique-characterization)',                                                       'Genome(unique-characterization)',
828                                                       'Genome(primary-group)']);                                                       'Genome(primary-group)']);
829          # Null out the supporting group.          # Format and cache the name and display group.
830          $group = "" if ($group eq $FIG_Config::otherGroup);          ($orgName, $group) = $self->SaveOrganismData($group, $genomeID, $genus, $species,
831          # If the organism does not exist, format an unknown name.                                                              $strain);
         if (! defined($genus)) {  
             $orgName = "Unknown Genome $genomeID";  
         } else {  
             # It does exist, so format the organism name.  
             $orgName = "$genus $species";  
             if ($strain) {  
                 $orgName .= " $strain";  
             }  
         }  
         # Save this organism in the cache.  
         $cache->{$genomeID} = [$orgName, $group];  
832      }      }
833      # Return the result.      # Return the result.
834      return ($orgName, $group);      return ($orgName, $group);
# Line 1082  Line 1074 
1074  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
1075  and 10 for a multi-select list.  and 10 for a multi-select list.
1076    
1077    =item crossMenu (optional)
1078    
1079    If specified, is presumed to be the name of another genome menu whose contents
1080    are to be mutually exclusive with the contents of this menu. As a result, instead
1081    of the standard onChange event, the onChange event will deselect any entries in
1082    the other menu.
1083    
1084  =item RETURN  =item RETURN
1085    
1086  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 1092  Line 1091 
1091    
1092  sub NmpdrGenomeMenu {  sub NmpdrGenomeMenu {
1093      # Get the parameters.      # Get the parameters.
1094      my ($self, $menuName, $multiple, $selected, $rows) = @_;      my ($self, $menuName, $multiple, $selected, $rows, $cross) = @_;
1095      # Get the Sprout and CGI objects.      # Get the Sprout and CGI objects.
1096      my $sprout = $self->DB();      my $sprout = $self->DB();
1097      my $cgi = $self->Q();      my $cgi = $self->Q();
# Line 1126  Line 1125 
1125          for my $genome (@genomeList) {          for my $genome (@genomeList) {
1126              # Get the genome data.              # Get the genome data.
1127              my ($group, $genomeID, $genus, $species, $strain) = @{$genome};              my ($group, $genomeID, $genus, $species, $strain) = @{$genome};
1128              # Form the genome name.              # Compute and cache its name and display group.
1129              my $name = "$genus $species";              my ($name, $displayGroup) = $self->SaveOrganismData($group, $genomeID, $genus, $species,
1130              if ($strain) {                                                                  $strain);
1131                  $name .= " $strain";              # Push the genome into the group's list. Note that we use the real group
1132              }              # name here, not the display group name.
             # Push the genome into the group's list.  
1133              push @{$gHash{$group}}, [$genomeID, $name];              push @{$gHash{$group}}, [$genomeID, $name];
1134          }          }
1135          # Save the genome list for future use.          # Save the genome list for future use.
# Line 1157  Line 1155 
1155      my $showSelect = "showSelected($menuName, '$divID', 1000);";      my $showSelect = "showSelected($menuName, '$divID', 1000);";
1156      # If multiple selection is supported, create an onChange event.      # If multiple selection is supported, create an onChange event.
1157      my $onChange = "";      my $onChange = "";
1158      if ($multiple) {      if ($cross) {
1159            $onChange = " onChange=\"crossUnSelect($menuName, '$divID', $cross, '${formName}_${cross}_status', 1000)\"";
1160        } elsif ($multiple) {
1161          $onChange = " onChange=\"$showSelect\"";          $onChange = " onChange=\"$showSelect\"";
1162      }      }
1163      # Create the SELECT tag and stuff it into the output array.      # Create the SELECT tag and stuff it into the output array.
# Line 1338  Line 1338 
1338      # Create the row.      # Create the row.
1339      my $retVal = $cgi->Tr($cgi->td("Results/Page"),      my $retVal = $cgi->Tr($cgi->td("Results/Page"),
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, 50, 100, 1000],
1342                                                      -default => $pageSize) . " " .                                                      -default => $pageSize) . " " .
1343                                     $cgi->checkbox(-name => 'ShowURL',                                     $cgi->checkbox(-name => 'ShowURL',
1344                                                    -value => 1,                                                    -value => 1,
# Line 1649  Line 1649 
1649      return $retVal;      return $retVal;
1650  }  }
1651    
1652    =head3 FeatureTypeMap
1653    
1654    C<< my %features = SearchHelper::FeatureTypeMap(); >>
1655    
1656    Return a map of feature types to descriptions. The feature type data is stored
1657    in the B<FIG_Config> file. Currently, it only contains a space-delimited list of
1658    feature types. The map returned by this method is a hash mapping the type codes to
1659    descriptive names.
1660    
1661    The reason we have to convert the list from a string is that the B<NMPDRSetup.pl>
1662    script is only able to insert strings into the generated B<FIG_Config> file.
1663    
1664    =cut
1665    
1666    sub FeatureTypeMap {
1667        my @list = split /\s+/, $FIG_Config::feature_types;
1668        my %retVal = map { $_ => $_ } @list;
1669        return %retVal;
1670    }
1671    
1672    =head3 AdvancedClassList
1673    
1674    C<< my @classes = SearchHelper::AdvancedClassList(); >>
1675    
1676    Return a list of advanced class names. This list is used to generate the directory
1677    of available searches on the search page.
1678    
1679    The reason we have to convert the list from a string is that the B<NMPDRSetup.pl>
1680    script is only able to insert strings into the generated B<FIG_Config> file.
1681    
1682    =cut
1683    
1684    sub AdvancedClassList {
1685        return split /\s+/, $FIG_Config::advanced_classes;
1686    }
1687    
1688  =head2 Feature Column Methods  =head2 Feature Column Methods
1689    
1690  The methods in this column manage feature column data. If you want to provide the  The methods in this column manage feature column data. If you want to provide the
# Line 1876  Line 1912 
1912      return $retVal;      return $retVal;
1913  }  }
1914    
1915    =head3 SaveOrganismData
1916    
1917    C<< my ($name, $displayGroup) = $shelp->SaveOrganismData($group, $genomeID, $genus, $species, $strain); >>
1918    
1919    Format the name of an organism and the display version of its group name. The incoming
1920    data should be the relevant fields from the B<Genome> record in the database. The
1921    data will also be stored in the genome cache for later use in posting search results.
1922    
1923    =over 4
1924    
1925    =item group
1926    
1927    Name of the genome's group as it appears in the database.
1928    
1929    =item genomeID
1930    
1931    ID of the relevant genome.
1932    
1933    =item genus
1934    
1935    Genus of the genome's organism. If undefined or null, it will be assumed the genome is not
1936    in the database. In this case, the organism name is derived from the genomeID and the group
1937    is automatically the supporting-genomes group.
1938    
1939    =item species
1940    
1941    Species of the genome's organism.
1942    
1943    =item strain
1944    
1945    Strain of the species represented by the genome.
1946    
1947    =item RETURN
1948    
1949    Returns a two-element list. The first element is the formatted genome name. The second
1950    element is the display name of the genome's group.
1951    
1952    =back
1953    
1954    =cut
1955    
1956    sub SaveOrganismData {
1957        # Get the parameters.
1958        my ($self, $group, $genomeID, $genus, $species, $strain) = @_;
1959        # Declare the return values.
1960        my ($name, $displayGroup);
1961        # If the organism does not exist, format an unknown name and a blank group.
1962        if (! defined($genus)) {
1963            $name = "Unknown Genome $genomeID";
1964            $displayGroup = "";
1965        } else {
1966            # It does exist, so format the organism name.
1967            $name = "$genus $species";
1968            if ($strain) {
1969                $name .= " $strain";
1970            }
1971            # Compute the display group. This is currently the same as the incoming group
1972            # name unless it's the supporting group, which is nulled out.
1973            $displayGroup = ($group eq $FIG_Config::otherGroup ? "" : $group);
1974        }
1975        # Cache the group and organism data.
1976        my $cache = $self->{orgs};
1977        $cache->{$genomeID} = [$name, $displayGroup];
1978        # Return the result.
1979        return ($name, $displayGroup);
1980    }
1981    
1982  =head2 Virtual Methods  =head2 Virtual Methods
1983    
1984  =head3 Form  =head3 Form
# Line 1906  Line 2009 
2009  C<< my $key = $shelp->SortKey($record); >>  C<< my $key = $shelp->SortKey($record); >>
2010    
2011  Return the sort key for the specified record. The default is to sort by feature name,  Return the sort key for the specified record. The default is to sort by feature name,
2012  floating NMPDR organisms to the top. This sort may be overridden by the search class  floating NMPDR organisms to the top. If a full-text search is used, then the default
2013  to provide fancier functionality. This method is called by B<PutFeature>, so it  sort is by relevance followed by feature name. This sort may be overridden by the
2014  is only used for feature searches. A non-feature search would presumably have its  search class to provide fancier functionality. This method is called by
2015  own sort logic.  B<PutFeature>, so it is only used for feature searches. A non-feature search
2016    would presumably have its own sort logic.
2017    
2018  =over 4  =over 4
2019    
# Line 1937  Line 2041 
2041      # Return the result.      # Return the result.
2042      return $retVal;      return $retVal;
2043  }  }
2044    
2045  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3