[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.116, Tue Sep 9 21:02:10 2008 UTC revision 1.117, Tue Sep 16 18:57:59 2008 UTC
# Line 16  Line 16 
16      use RemoteCustomAttributes;      use RemoteCustomAttributes;
17      use CGI;      use CGI;
18      use WikiTools;      use WikiTools;
19        use BioWords;
20      use base qw(ERDB);      use base qw(ERDB);
21    
22  =head1 Sprout Database Manipulation Object  =head1 Sprout Database Manipulation Object
# Line 707  Line 708 
708  sub Stem {  sub Stem {
709      # Get the parameters.      # Get the parameters.
710      my ($self, $word) = @_;      my ($self, $word) = @_;
711      # Declare the return variable.      # Get the stemmer object.
712      my $retVal;      my $stemmer = $self->{stemmer};
713      # See if it's stemmable.      if (! defined $stemmer) {
714      if ($word =~ /^[A-Za-z]+$/) {          # We don't have one pre-built, so we build and save it now.
715          # Compute the stem. Currently, it's just the word.          $stemmer = BioWords->new(exceptions => "$FIG_Config::sproutData/Exceptions.txt",
716          my $stem = $word;                                   stops => "$FIG_Config::sproutData/StopWords.txt",
717          # Check to see if it's long enough.                                   cache => 1);
718          if (length $stem >= 3) {          $self->{stemmer} = $stemmer;
             # Yes, keep it.  
             $retVal = $stem;  
         } else {  
             # No, use the original word.  
             $retVal = $word;  
         }  
719      }      }
720        # Try to stem the word.
721        my $retVal = $stemmer->Process($word);
722      # Return the result.      # Return the result.
723      return $retVal;      return $retVal;
724  }  }
# Line 1616  Line 1613 
1613  the specified user and FIG are considered trusted. If the user ID is omitted, only FIG  the specified user and FIG are considered trusted. If the user ID is omitted, only FIG
1614  is trusted.  is trusted.
1615    
1616  If the feature is B<not> identified by a FIG ID, then the functional assignment  If the feature is B<not> identified by a FIG ID, then we search the aliases for it.
1617  information is taken from the B<ExternalAliasFunc> table. If the table does  If no matching alias is found, we return an undefined value.
 not contain an entry for the feature, an undefined value is returned.  
1618    
1619  =over 4  =over 4
1620    
# Line 1644  Line 1640 
1640      my ($self, $featureID, $userID) = @_;      my ($self, $featureID, $userID) = @_;
1641      # Declare the return value.      # Declare the return value.
1642      my $retVal;      my $retVal;
1643      # Determine the ID type.      # Find a FIG ID for this feature.
1644      if ($featureID =~ m/^fig\|/) {      my ($fid) = $self->FeaturesByAlias($featureID);
1645        # Only proceed if we have an ID.
1646        if ($fid) {
1647          # Here we have a FIG feature ID.          # Here we have a FIG feature ID.
1648          if (!$userID) {          if (!$userID) {
1649              # Use the primary assignment.              # Use the primary assignment.
1650              ($retVal) = $self->GetEntityValues('Feature', $featureID, ['Feature(assignment)']);              ($retVal) = $self->GetEntityValues('Feature', $fid, ['Feature(assignment)']);
1651          } else {          } else {
1652              # We must build the list of trusted users.              # We must build the list of trusted users.
1653              my %trusteeTable = ();              my %trusteeTable = ();
# Line 1675  Line 1673 
1673              # Build a query for all of the feature's annotations, sorted by date.              # Build a query for all of the feature's annotations, sorted by date.
1674              my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],              my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],
1675                                     "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",                                     "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1676                                     [$featureID]);                                     [$fid]);
1677              my $timeSelected = 0;              my $timeSelected = 0;
1678              # Loop until we run out of annotations.              # Loop until we run out of annotations.
1679              while (my $annotation = $query->Fetch()) {              while (my $annotation = $query->Fetch()) {
# Line 1695  Line 1693 
1693                  }                  }
1694              }              }
1695          }          }
     } else {  
         # Here we have a non-FIG feature ID. In this case the user ID does not  
         # matter. We simply get the information from the External Alias Function  
         # table.  
         ($retVal) = $self->GetEntityValues('ExternalAliasFunc', $featureID, ['ExternalAliasFunc(func)']);  
1696      }      }
1697      # Return the assignment found.      # Return the assignment found.
1698      return $retVal;      return $retVal;
# Line 1718  Line 1711 
1711  annotation itself because it's a text field; however, this is not a big problem because  annotation itself because it's a text field; however, this is not a big problem because
1712  most features only have a small number of annotations.  most features only have a small number of annotations.
1713    
 If the feature is B<not> identified by a FIG ID, then the functional assignment  
 information is taken from the B<ExternalAliasFunc> table. If the table does  
 not contain an entry for the feature, an empty list is returned.  
   
1714  =over 4  =over 4
1715    
1716  =item featureID  =item featureID
# Line 1742  Line 1731 
1731      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
1732      # Declare the return value.      # Declare the return value.
1733      my @retVal = ();      my @retVal = ();
1734      # Determine the ID type.      # Convert to a FIG ID.
1735      if ($featureID =~ m/^fig\|/) {      my ($fid) = $self->FeaturesByAlias($featureID);
1736        # Only proceed if we found one.
1737        if ($fid) {
1738          # Here we have a FIG feature ID. We must build the list of trusted          # Here we have a FIG feature ID. We must build the list of trusted
1739          # users.          # users.
1740          my %trusteeTable = ();          my %trusteeTable = ();
1741          # Build a query for all of the feature's annotations, sorted by date.          # Build a query for all of the feature's annotations, sorted by date.
1742          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],
1743                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1744                                 [$featureID]);                                 [$fid]);
1745          my $timeSelected = 0;          my $timeSelected = 0;
1746          # Loop until we run out of annotations.          # Loop until we run out of annotations.
1747          while (my $annotation = $query->Fetch()) {          while (my $annotation = $query->Fetch()) {
# Line 1765  Line 1756 
1756                  push @retVal, [$actualUser, $function];                  push @retVal, [$actualUser, $function];
1757              }              }
1758          }          }
     } else {  
         # Here we have a non-FIG feature ID. In this case the user ID does not  
         # matter. We simply get the information from the External Alias Function  
         # table.  
         my @assignments = $self->GetEntityValues('ExternalAliasFunc', $featureID,  
                                                  ['ExternalAliasFunc(func)']);  
         push @retVal, map { ['master', $_] } @assignments;  
1759      }      }
1760      # Return the assignments found.      # Return the assignments found.
1761      return @retVal;      return @retVal;
# Line 1963  Line 1947 
1947          my ($realFeatureID) = $self->FeaturesByAlias($featureID);          my ($realFeatureID) = $self->FeaturesByAlias($featureID);
1948          if ($realFeatureID && $realFeatureID =~ /^fig\|(\d+\.\d+)/) {          if ($realFeatureID && $realFeatureID =~ /^fig\|(\d+\.\d+)/) {
1949              $retVal = $1;              $retVal = $1;
         } else {  
             # Use the external table.  
             my ($org) = $self->GetFlat(['ExternalAliasOrg'], "ExternalAliasOrg(id) = ?",  
                                        [$featureID], "ExternalAliasOrg(org)");  
             if ($org) {  
                 $retVal = $org;  
             } else {  
                 Confess("Invalid feature ID $featureID.");  
             }  
1950          }          }
1951      }      }
1952      # Return the value found.      # Return the value found.
# Line 3112  Line 3087 
3087  sub SubsystemList {  sub SubsystemList {
3088      # Get the parameters.      # Get the parameters.
3089      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
3090      # Get the list of names.      # Get the list of names. We do a join to the Subsystem table because we have missing subsystems in
3091      ##HACK: we do a join to the Subsystem table because we have missing subsystems in      # the Sprout database!
     ## the Sprout database!  
3092      my @retVal = $self->GetFlat(['HasRoleInSubsystem', 'Subsystem'], "HasRoleInSubsystem(from-link) = ?",      my @retVal = $self->GetFlat(['HasRoleInSubsystem', 'Subsystem'], "HasRoleInSubsystem(from-link) = ?",
3093                                  [$featureID], 'HasRoleInSubsystem(to-link)');                                  [$featureID], 'HasRoleInSubsystem(to-link)');
3094      # Return the result, sorted.      # Return the result, sorted.

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3