[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.9, Sat Oct 7 13:18:11 2006 UTC revision 1.10, Fri Oct 13 21:45:11 2006 UTC
# Line 826  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 1136  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 1924  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 1954  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 1986  Line 2042 
2042      return $retVal;      return $retVal;
2043  }  }
2044    
   
2045  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3