[Bio] / Sprout / Sprout.pm Repository:
ViewVC logotype

Diff of /Sprout/Sprout.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.113, Tue Aug 12 06:01:49 2008 UTC revision 1.116, Tue Sep 9 21:02:10 2008 UTC
# Line 107  Line 107 
107                                                          # data file directory                                                          # data file directory
108                         xmlFileName  => "$dbd_dir/SproutDBD.xml",                         xmlFileName  => "$dbd_dir/SproutDBD.xml",
109                                                          # database definition file name                                                          # database definition file name
110                         userData     => "$FIG_Config::dbuser/$FIG_Config::dbpass",                         userData     => "$FIG_Config::sproutUser/$FIG_Config::sproutPass",
111                                                          # user name and password                                                          # user name and password
112                         port         => $FIG_Config::dbport,                         port         => $FIG_Config::sproutPort,
113                                                          # database connection port                                                          # database connection port
114                         sock         => $FIG_Config::dbsock,                         sock         => $FIG_Config::sproutSock,
115                         host         => $FIG_Config::sprout_host,                         host         => $FIG_Config::sprout_host,
116                         maxSegmentLength => 4500,        # maximum feature segment length                         maxSegmentLength => 4500,        # maximum feature segment length
117                         maxSequenceLength => 8000,       # maximum contig sequence length                         maxSequenceLength => 8000,       # maximum contig sequence length
# Line 148  Line 148 
148          my $user = ($FIG_Config::arch eq 'win' ? 'self' : scalar(getpwent()));          my $user = ($FIG_Config::arch eq 'win' ? 'self' : scalar(getpwent()));
149          $retVal->{_ca} = CustomAttributes->new(user => $user);          $retVal->{_ca} = CustomAttributes->new(user => $user);
150      }      }
     # Insure we have access to the stem module.  
     WikiUse('Lingua::Stem');  
     $retVal->{stemmer} = Lingua::Stem->new();  
     $retVal->{stemmer}->stem_caching({ -level => 2 });  
151      # Return it.      # Return it.
152      return $retVal;      return $retVal;
153  }  }
# Line 536  Line 532 
532      # Get the parameters.      # Get the parameters.
533      my ($self, %options) = @_;      my ($self, %options) = @_;
534      # Get the control's name and ID.      # Get the control's name and ID.
535      my $menuName = $options{name} || 'myGenomeControl';      my $menuName = $options{name} || $options{id} || 'myGenomeControl';
536      my $menuID = $options{id} || $menuName;      my $menuID = $options{id} || $menuName;
537        Trace("Genome menu name = $menuName with ID $menuID.") if T(3);
538      # Compute the IDs for the status display.      # Compute the IDs for the status display.
539      my $divID = "${menuID}_status";      my $divID = "${menuID}_status";
540      my $urlID = "${menuID}_url";      my $urlID = "${menuID}_url";
# Line 628  Line 625 
625      # Set up the style class.      # Set up the style class.
626      my $classTag = ($class ? " class=\"$class\"" : "" );      my $classTag = ($class ? " class=\"$class\"" : "" );
627      # Create the SELECT tag and stuff it into the output array.      # Create the SELECT tag and stuff it into the output array.
628      my @lines = ("<SELECT name=\"$menuID\" id=\"$menuID\" $onChangeTag$multipleTag$classTag size=\"$rows\">");      my @lines = ("<SELECT name=\"$menuName\" id=\"$menuID\" $onChangeTag$multipleTag$classTag size=\"$rows\">");
629      # Loop through the groups.      # Loop through the groups.
630      for my $group (@groups) {      for my $group (@groups) {
631          # Get the genomes in the group.          # Get the genomes in the group.
# Line 664  Line 661 
661          my $searchThingLabel = ($multiSelect ? "<INPUT type=\"button\" name=\"MacroSearch\" class=\"button\" value=\"Select genomes containing\" onClick=\"selectShowing('$menuID', '$searchThingName'); $showSelect;\" />"          my $searchThingLabel = ($multiSelect ? "<INPUT type=\"button\" name=\"MacroSearch\" class=\"button\" value=\"Select genomes containing\" onClick=\"selectShowing('$menuID', '$searchThingName'); $showSelect;\" />"
662                                               : "Show genomes containing");                                               : "Show genomes containing");
663          push @lines, "<br />$searchThingLabel&nbsp;" .          push @lines, "<br />$searchThingLabel&nbsp;" .
664                       "<INPUT type=\"text\" id=\"$searchThingName\" name=\"$searchThingName\" size=\"30\" onKeyup=\"showTyped('$menuID', '$searchThingName');\" />";                       "<INPUT type=\"text\" id=\"$searchThingName\" name=\"$searchThingName\" size=\"30\" onKeyup=\"showTyped('$menuID', '$searchThingName');\" />" .
665                         Hint("GenomeControl", "Type here to filter the genomes displayed.") . "<br />";
666          # For multi-select mode, we also have buttons to set and clear selections.          # For multi-select mode, we also have buttons to set and clear selections.
667          if ($multiSelect) {          if ($multiSelect) {
668              push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll('$menuID'); $showSelect\" />";              push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll('$menuID'); $showSelect\" />";
# Line 672  Line 670 
670              push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome('$menuID', $nmpdrCount, true); $showSelect;\" />";              push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome('$menuID', $nmpdrCount, true); $showSelect;\" />";
671          }          }
672          # Add a hidden field we can use to generate organism page hyperlinks.          # Add a hidden field we can use to generate organism page hyperlinks.
673          push @lines, "<INPUT type=\"hidden\" id=\"$urlID\" value=\"$FIG_Config::cgi_url/seedviewer.cgi?page=Organism;organism=\" />";          push @lines, "<INPUT type=\"hidden\" id=\"$urlID\" value=\"$FIG_Config::cgi_url/wiki/rest.cgi/NmpdrPlugin/SeedViewer?page=Organism;organism=\" />";
674          # Add the status display. This tells the user what's selected no matter where the list is scrolled.          # Add the status display. This tells the user what's selected no matter where the list is scrolled.
675          push @lines, "<DIV id=\"$divID\" class=\"Panel\"></DIV>";          push @lines, "<DIV id=\"$divID\" class=\"Panel\"></DIV>";
676      }      }
# Line 713  Line 711 
711      my $retVal;      my $retVal;
712      # See if it's stemmable.      # See if it's stemmable.
713      if ($word =~ /^[A-Za-z]+$/) {      if ($word =~ /^[A-Za-z]+$/) {
714          # Compute the stem.          # Compute the stem. Currently, it's just the word.
715          my $stemList = $self->{stemmer}->stem($word);          my $stem = $word;
         my $stem = $stemList->[0];  
716          # Check to see if it's long enough.          # Check to see if it's long enough.
717          if (length $stem >= 3) {          if (length $stem >= 3) {
718              # Yes, keep it.              # Yes, keep it.
# Line 2815  Line 2812 
2812      return @retVal;      return @retVal;
2813  }  }
2814    
 =head3 GetProperties  
   
     my @list = $sprout->GetProperties($fid, $key, $value, $url);  
   
 Return a list of the properties with the specified characteristics.  
   
 Properties are the Sprout analog of the FIG attributes. The call is  
 passed directly to the CustomAttributes or RemoteCustomAttributes object  
 contained in this object.  
   
 This method returns a series of tuples that match the specified criteria. Each tuple  
 will contain an object ID, a key, and one or more values. The parameters to this  
 method therefore correspond structurally to the values expected in each tuple. In  
 addition, you can ask for a generic search by suffixing a percent sign (C<%>) to any  
 of the parameters. So, for example,  
   
     my @attributeList = $sprout->GetProperties('fig|100226.1.peg.1004', 'structure%', 1, 2);  
   
 would return something like  
   
     ['fig}100226.1.peg.1004', 'structure', 1, 2]  
     ['fig}100226.1.peg.1004', 'structure1', 1, 2]  
     ['fig}100226.1.peg.1004', 'structure2', 1, 2]  
     ['fig}100226.1.peg.1004', 'structureA', 1, 2]  
   
 Use of C<undef> in any position acts as a wild card (all values). You can also specify  
 a list reference in the ID column. Thus,  
   
     my @attributeList = $sprout->GetProperties(['100226.1', 'fig|100226.1.%'], 'PUBMED');  
   
 would get the PUBMED attribute data for Streptomyces coelicolor A3(2) and all its  
 features.  
   
 In addition to values in multiple sections, a single attribute key can have multiple  
 values, so even  
   
     my @attributeList = $sprout->GetProperties($peg, 'virulent');  
   
 which has no wildcard in the key or the object ID, may return multiple tuples.  
   
 =over 4  
   
 =item objectID  
   
 ID of object whose attributes are desired. If the attributes are desired for multiple  
 objects, this parameter can be specified as a list reference. If the attributes are  
 desired for all objects, specify C<undef> or an empty string. Finally, you can specify  
 attributes for a range of object IDs by putting a percent sign (C<%>) at the end.  
   
 =item key  
   
 Attribute key name. A value of C<undef> or an empty string will match all  
 attribute keys. If the values are desired for multiple keys, this parameter can be  
 specified as a list reference. Finally, you can specify attributes for a range of  
 keys by putting a percent sign (C<%>) at the end.  
   
 =item values  
   
 List of the desired attribute values, section by section. If C<undef>  
 or an empty string is specified, all values in that section will match. A  
 generic match can be requested by placing a percent sign (C<%>) at the end.  
 In that case, all values that match up to and not including the percent sign  
 will match. You may also specify a regular expression enclosed  
 in slashes. All values that match the regular expression will be returned. For  
 performance reasons, only values have this extra capability.  
   
 =item RETURN  
   
 Returns a list of tuples. The first element in the tuple is an object ID, the  
 second is an attribute key, and the remaining elements are the sections of  
 the attribute value. All of the tuples will match the criteria set forth in  
 the parameter list.  
   
 =back  
   
 =cut  
   
 sub GetProperties {  
     # Get the parameters.  
     my ($self, @parms) = @_;  
     # Declare the return variable.  
     my @retVal = $self->{_ca}->GetAttributes(@parms);  
     # Return the result.  
     return @retVal;  
 }  
   
2815  =head3 FeatureProperties  =head3 FeatureProperties
2816    
2817      my @properties = $sprout->FeatureProperties($featureID);      my @properties = $sprout->FeatureProperties($featureID);
# Line 3202  Line 3113 
3113      # Get the parameters.      # Get the parameters.
3114      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
3115      # Get the list of names.      # Get the list of names.
3116      my @retVal = $self->GetFlat(['HasRoleInSubsystem'], "HasRoleInSubsystem(from-link) = ?",      ##HACK: we do a join to the Subsystem table because we have missing subsystems in
3117        ## the Sprout database!
3118        my @retVal = $self->GetFlat(['HasRoleInSubsystem', 'Subsystem'], "HasRoleInSubsystem(from-link) = ?",
3119                                  [$featureID], 'HasRoleInSubsystem(to-link)');                                  [$featureID], 'HasRoleInSubsystem(to-link)');
3120      # Return the result, sorted.      # Return the result, sorted.
3121      return sort @retVal;      return sort @retVal;
# Line 4250  Line 4163 
4163  }  }
4164    
4165    
4166    =head3 Hint
4167    
4168        my $htmlText = SearchHelper::Hint($wikiPage, $hintText);
4169    
4170    Return the HTML for a small question mark that displays the specified hint text when it is clicked.
4171    This HTML can be put in forms to provide a useful hinting mechanism.
4172    
4173    =over 4
4174    
4175    =item wikiPage
4176    
4177    Name of the wiki page to be popped up when the hint mark is clicked.
4178    
4179    =item hintText
4180    
4181    Text to display for the hint. It is raw html, but may not contain any double quotes.
4182    
4183    =item RETURN
4184    
4185    Returns the html for the hint facility. The resulting html shows a small button-like thing that
4186    uses the standard FIG popup technology.
4187    
4188    =back
4189    
4190    =cut
4191    
4192    sub Hint {
4193        # Get the parameters.
4194        my ($wikiPage, $hintText) = @_;
4195        # Escape the single quotes in the hint text.
4196        my $quotedText = $hintText;
4197        $quotedText =~ s/'/\\'/g;
4198        # Convert the wiki page name to a URL.
4199        my $wikiURL = join("", map { ucfirst $_ } split /\s+/, $wikiPage);
4200        $wikiURL = "$FIG_Config::cgi_url/wiki/view.cgi/FIG/$wikiURL";
4201        # Compute the mouseover script.
4202        my $mouseOver = "doTooltip(this, '$quotedText')";
4203        # Create the html.
4204        my $retVal = "&nbsp;<a href=\"$wikiURL\"><img src=\"$FIG_Config::cgi_url/Html/button-h.png\" class=\"helpicon\" onmouseover=\"$mouseOver\"/></a>";
4205        # Return it.
4206        return $retVal;
4207    }
4208    
4209  1;  1;

Legend:
Removed from v.1.113  
changed lines
  Added in v.1.116

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3