[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.12, Mon Oct 16 22:58:37 2006 UTC revision 1.13, Fri Nov 3 00:40:16 2006 UTC
# Line 1163  Line 1163 
1163      if (defined $selected) {      if (defined $selected) {
1164          %selectedHash = map { $_ => 1 } grep { defined($_) } @{$selected};          %selectedHash = map { $_ => 1 } grep { defined($_) } @{$selected};
1165      }      }
1166      # Now it gets complicated. We need a way to mark all the NMPDR genomes.      # Now it gets complicated. We need a way to mark all the NMPDR genomes. We take advantage
1167        # of the fact they come first in the list. We'll accumulate a count of the NMPDR genomes
1168        # and use that to make the selections.
1169        my $nmpdrCount = 0;
1170      # Create the type counters.      # Create the type counters.
1171      my $groupCount = 1;      my $groupCount = 1;
1172      # Compute the ID for the status display.      # Compute the ID for the status display.
# Line 1173  Line 1176 
1176      # If multiple selection is supported, create an onChange event.      # If multiple selection is supported, create an onChange event.
1177      my $onChange = "";      my $onChange = "";
1178      if ($cross) {      if ($cross) {
1179            # Here we have a paired menu. Selecting something in our menu unselects it in the
1180            # other and redisplays the status of both.
1181          $onChange = " onChange=\"crossUnSelect($menuName, '$divID', $cross, '${formName}_${cross}_status', 1000)\"";          $onChange = " onChange=\"crossUnSelect($menuName, '$divID', $cross, '${formName}_${cross}_status', 1000)\"";
1182      } elsif ($multiple) {      } elsif ($multiple) {
1183            # This is an unpaired menu, so all we do is redisplay our status.
1184          $onChange = " onChange=\"$showSelect\"";          $onChange = " onChange=\"$showSelect\"";
1185      }      }
1186      # Create the SELECT tag and stuff it into the output array.      # Create the SELECT tag and stuff it into the output array.
1187      my $select = "<SELECT name=\"$menuName\"$onChange$multipleTag size=\"$rows\">";      my @lines = ("<SELECT name=\"$menuName\"$onChange$multipleTag size=\"$rows\">");
     my @lines = ($select);  
1188      # Loop through the groups.      # Loop through the groups.
1189      for my $group (@groups) {      for my $group (@groups) {
1190          # Create the option group tag.          # Create the option group tag.
1191          my $tag = "<OPTGROUP label=\"$group\">";          my $tag = "<OPTGROUP label=\"$group\">";
1192          push @lines, "  $tag";          push @lines, "  $tag";
         # Compute the label for this group's options. This is seriously dirty stuff, as the  
         # label option may have functionality in future browsers. If that happens, we'll need  
         # to modify the genome text so that the "selectSome" method can tell which are NMPDR  
         # organisms and which aren't. Sadly, the OPTGROUP tag is invisible in the DOM Javascript  
         # hierarchy, so we can't use it.  
         my $label = ($group eq $FIG_Config::otherGroup ? "other" : "nmpdr");  
1193          # Get the genomes in the group.          # Get the genomes in the group.
1194          for my $genome (@{$groupHash->{$group}}) {          for my $genome (@{$groupHash->{$group}}) {
1195                # Count this organism if it's NMPDR.
1196                if ($group ne $FIG_Config::otherGroup) {
1197                    $nmpdrCount++;
1198                }
1199                # Get the organism ID and name.
1200              my ($genomeID, $name) = @{$genome};              my ($genomeID, $name) = @{$genome};
1201              # See if it's selected.              # See if it's selected.
1202              my $select = ($selectedHash{$genomeID} ? " selected" : "");              my $select = ($selectedHash{$genomeID} ? " selected" : "");
1203              # Generate the option tag.              # Generate the option tag.
1204              my $optionTag = "<OPTION value=\"$genomeID\" label=\"$label\"$select>$name <em>($genomeID)</em></OPTION>";              my $optionTag = "<OPTION value=\"$genomeID\"$select>$name <em>($genomeID)</em></OPTION>";
1205              push @lines, "    $optionTag";              push @lines, "    $optionTag";
1206          }          }
1207          # Close the option group.          # Close the option group.
# Line 1211  Line 1215 
1215          push @lines, "<br />";          push @lines, "<br />";
1216          push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll($menuName); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll($menuName); $showSelect\" />";
1217          push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll($menuName); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll($menuName); $showSelect\" />";
1218          push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome($menuName, 'nmpdr'); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome($menuName, $nmpdrCount, true); $showSelect\" />";
1219          push @lines, "<INPUT type=\"button\" name=\"OtherOnly\" class=\"bigButton\" value=\"Select Supporting\" onClick=\"selectSome($menuName, 'other'); $showSelect\" />";          push @lines, "<INPUT type=\"button\" name=\"OtherOnly\" class=\"bigButton\" value=\"Select Supporting\" onClick=\"selectSome($menuName, $nmpdrCount, false); $showSelect\" />";
1220          # Now add the search box. This allows the user to type text and have all genomes containing          # Now add the search box. This allows the user to type text and have all genomes containing
1221          # the text selected automatically.          # the text selected automatically.
1222          my $searchThingName = "${menuName}_SearchThing";          my $searchThingName = "${menuName}_SearchThing";
# Line 1733  Line 1737 
1737      if ($colName =~ /^X=(.+)$/) {      if ($colName =~ /^X=(.+)$/) {
1738          # Here we have an extra column.          # Here we have an extra column.
1739          $retVal = $1;          $retVal = $1;
     } elsif ($colName eq 'orgName') {  
         $retVal = "Name";  
     } elsif ($colName eq 'fid') {  
         $retVal = "FIG ID";  
1740      } elsif ($colName eq 'alias') {      } elsif ($colName eq 'alias') {
1741          $retVal = "External Aliases";          $retVal = "External Aliases";
1742        } elsif ($colName eq 'fid') {
1743            $retVal = "FIG ID";
1744      } elsif ($colName eq 'function') {      } elsif ($colName eq 'function') {
1745          $retVal = "Functional Assignment";          $retVal = "Functional Assignment";
1746      } elsif ($colName eq 'gblink') {      } elsif ($colName eq 'gblink') {
1747          $retVal = "GBrowse";          $retVal = "GBrowse";
     } elsif ($colName eq 'protlink') {  
         $retVal = "NMPDR Protein Page";  
1748      } elsif ($colName eq 'group') {      } elsif ($colName eq 'group') {
1749          $retVal = "NMDPR Group";          $retVal = "NMDPR Group";
1750        } elsif ($colName =~ /^keyword:(.+)$/) {
1751            $retVal = ucfirst $1;
1752        } elsif ($colName eq 'orgName') {
1753            $retVal = "Name";
1754        } elsif ($colName eq 'protlink') {
1755            $retVal = "NMPDR Protein Page";
1756        } elsif ($colName eq 'subsystem') {
1757            $retVal = "Subsystems";
1758      }      }
1759      # Return the result.      # Return the result.
1760      return $retVal;      return $retVal;
1761  }  }
1762    
1763    
1764  =head3 FeatureColumnValue  =head3 FeatureColumnValue
1765    
1766  C<< my $value = $shelp->FeatureColumnValue($colName, $fid, \%extraCols); >>  C<< my $value = $shelp->FeatureColumnValue($colName, $fid, \%extraCols); >>
# Line 1802  Line 1811 
1811          if (defined $extraCols->{$1}) {          if (defined $extraCols->{$1}) {
1812              $retVal = $extraCols->{$1};              $retVal = $extraCols->{$1};
1813          }          }
     } elsif ($colName eq 'orgName') {  
         # Here we want the formatted organism name and feature number.  
         $retVal = $self->FeatureName($fid);  
     } elsif ($colName eq 'fid') {  
         # Here we have the raw feature ID. We hyperlink it to the protein page.  
         $retVal = HTML::set_prot_links($fid);  
1814      } elsif ($colName eq 'alias') {      } elsif ($colName eq 'alias') {
1815          # In this case, the user wants a list of external aliases for the feature.          # In this case, the user wants a list of external aliases for the feature.
1816          # These are very expensive, so we compute them when the row is displayed.          # These are very expensive, so we compute them when the row is displayed.
1817          $retVal = "%%aliases=$fid";          $retVal = "%%alias=$fid";
1818        } elsif ($colName eq 'fid') {
1819            # Here we have the raw feature ID. We hyperlink it to the protein page.
1820            $retVal = HTML::set_prot_links($fid);
1821      } elsif ($colName eq 'function') {      } elsif ($colName eq 'function') {
1822          # The functional assignment is just a matter of getting some text.          # The functional assignment is just a matter of getting some text.
1823          ($retVal) = $record->Value('Feature(assignment)');          ($retVal) = $record->Value('Feature(assignment)');
# Line 1822  Line 1828 
1828                            $cgi->img({ src => "../images/button-gbrowse.png",                            $cgi->img({ src => "../images/button-gbrowse.png",
1829                                        border => 0 })                                        border => 0 })
1830                           );                           );
     } elsif ($colName eq 'protlink') {  
         # Here we want a link to the protein page using the official NMPDR button.  
         my $hurl = HTML::fid_link($cgi, $fid, 0, 1);  
         $retVal = $cgi->a({ href => $hurl, title => "Protein page for $fid" },  
                           $cgi->img({ src => "../images/button-nmpdr.png",  
                                      border => 0 })  
                          );  
1831      } elsif ($colName eq 'group') {      } elsif ($colName eq 'group') {
1832          # Get the NMPDR group name.          # Get the NMPDR group name.
1833          my (undef, $group) = $self->OrganismData($fid);          my (undef, $group) = $self->OrganismData($fid);
# Line 1836  Line 1835 
1835          my $nurl = $sprout->GroupPageName($group);          my $nurl = $sprout->GroupPageName($group);
1836          $retVal = $cgi->a({ href => $nurl, title => "$group summary" },          $retVal = $cgi->a({ href => $nurl, title => "$group summary" },
1837                            $group);                            $group);
1838        } elsif ($colName =~ /^keyword:(.+)$/) {
1839            # Here we want keyword-related values. This is also expensive, so
1840            # we compute them when the row is displayed.
1841            $retVal = "%%colName=$fid";
1842        } elsif ($colName eq 'orgName') {
1843            # Here we want the formatted organism name and feature number.
1844            $retVal = $self->FeatureName($fid);
1845        } elsif ($colName eq 'protlink') {
1846            # Here we want a link to the protein page using the official NMPDR button.
1847            my $hurl = HTML::fid_link($cgi, $fid, 0, 1);
1848            $retVal = $cgi->a({ href => $hurl, title => "Protein page for $fid" },
1849                              $cgi->img({ src => "../images/button-nmpdr.png",
1850                                         border => 0 })
1851                             );
1852        }elsif ($colName eq 'subsystem') {
1853            # Another run-time column: subsystem list.
1854            $retVal = "%%subsystem=$fid";
1855      }      }
1856      # Return the result.      # Return the result.
1857      return $retVal;      return $retVal;
# Line 1875  Line 1891 
1891      my $sprout = $self->DB();      my $sprout = $self->DB();
1892      my $cgi = $self->Q();      my $cgi = $self->Q();
1893      # Separate the text into a type and data.      # Separate the text into a type and data.
1894      if ($type eq 'aliases') {      if ($type eq 'alias') {
1895          # Here the caller wants external alias links for a feature. The text          # Here the caller wants external alias links for a feature. The text
1896          # is the feature ID.          # is the feature ID.
1897          my $fid = $text;          my $fid = $text;
# Line 1890  Line 1906 
1906              # Ask the HTML processor to hyperlink them.              # Ask the HTML processor to hyperlink them.
1907              $retVal = HTML::set_prot_links($cgi, $aliasList);              $retVal = HTML::set_prot_links($cgi, $aliasList);
1908          }          }
1909        } elsif ($type eq 'subsystem') {
1910            # Here the caller wants the subsystems in which this feature participates.
1911            # The text is the feature ID. We will list the subsystem names with links
1912            # to the subsystem's summary page.
1913            my $fid = $text;
1914            # Get the subsystems.
1915            Trace("Generating subsystems for feature $fid.") if T(4);
1916            my %subs = $sprout->SubsystemsOf($fid);
1917            # Convert them to links.
1918            my @links = map { HTML::sub_link($cgi, $_) } sort keys %subs;
1919            # String them into a list.
1920            $retVal = join(", ", @links);
1921        } elsif ($type =~ /^keyword:(.+)$/) {
1922            # Here the caller wants the value of the named keyword. The text is the
1923            # feature ID.
1924            my $keywordName = $1;
1925            my $fid = $text;
1926            # Get the attribute values.
1927            Trace("Getting $keywordName values for feature $fid.") if T(4);
1928            my @values = $sprout->GetFlat(['Feature'], "Feature(id) = ?", [$fid],
1929                                          "Feature($keywordName)");
1930            # String them into a list.
1931            $retVal = join(", ", @values);
1932      }      }
1933      # Return the result.      # Return the result.
1934      return $retVal;      return $retVal;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3