[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.41, Tue Oct 18 02:24:23 2005 UTC revision 1.46, Thu Oct 20 11:52:36 2005 UTC
# Line 389  Line 389 
389    
390  =head3 LoadUpdate  =head3 LoadUpdate
391    
392  C<< my %stats = $sprout->LoadUpdate($truncateFlag, \@tableList); >>  C<< my $stats = $sprout->LoadUpdate($truncateFlag, \@tableList); >>
393    
394  Load updates to one or more database tables. This method enables the client to make changes to one  Load updates to one or more database tables. This method enables the client to make changes to one
395  or two tables without reloading the whole database. For each table, there must be a corresponding  or two tables without reloading the whole database. For each table, there must be a corresponding
# Line 1153  Line 1153 
1153    
1154  =item RETURN  =item RETURN
1155    
1156  Returns a hash mapping the functional assignment IDs to user IDs.  Returns a hash mapping the user IDs to functional assignment IDs.
1157    
1158  =back  =back
1159    
# Line 1168  Line 1168 
1168                              [$featureID], ['Annotation(time)', 'Annotation(annotation)']);                              [$featureID], ['Annotation(time)', 'Annotation(annotation)']);
1169      # Declare the return hash.      # Declare the return hash.
1170      my %retVal;      my %retVal;
     # Declare a hash for insuring we only make one assignment per user.  
     my %timeHash = ();  
1171      # Now we sort the assignments by timestamp in reverse.      # Now we sort the assignments by timestamp in reverse.
1172      my @sortedQuery = sort { -($a->[0] <=> $b->[0]) } @query;      my @sortedQuery = sort { -($a->[0] <=> $b->[0]) } @query;
1173      # Loop until we run out of annotations.      # Loop until we run out of annotations.
# Line 1178  Line 1176 
1176          my ($timeStamp, $text) = @{$annotation};          my ($timeStamp, $text) = @{$annotation};
1177          # Check to see if this is a functional assignment.          # Check to see if this is a functional assignment.
1178          my ($user, $function) = _ParseAssignment($text);          my ($user, $function) = _ParseAssignment($text);
1179          if ($user && ! exists $timeHash{$user}) {          if ($user && ! exists $retVal{$user}) {
1180              # Here it is a functional assignment and there has been no              # Here it is a functional assignment and there has been no
1181              # previous assignment for this user, so we stuff it in the              # previous assignment for this user, so we stuff it in the
1182              # return hash.              # return hash.
1183              $retVal{$function} = $user;              $retVal{$user} = $function;
             # Insure we don't assign to this user again.  
             $timeHash{$user} = 1;  
1184          }          }
1185      }      }
1186      # Return the hash of assignments found.      # Return the hash of assignments found.
# Line 1200  Line 1196 
1196  The functional assignment is handled differently depending on the type of feature. If  The functional assignment is handled differently depending on the type of feature. If
1197  the feature is identified by a FIG ID (begins with the string C<fig|>), then a functional  the feature is identified by a FIG ID (begins with the string C<fig|>), then a functional
1198  assignment is a type of annotation. The format of an assignment is described in  assignment is a type of annotation. The format of an assignment is described in
1199  L</ParseLocation>. Its worth noting that we cannot filter on the content of the  L</ParseAssignment>. Its worth noting that we cannot filter on the content of the
1200  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
1201  most features only have a small number of annotations.  most features only have a small number of annotations.
1202    
# Line 1291  Line 1287 
1287      return $retVal;      return $retVal;
1288  }  }
1289    
1290    =head3 FunctionsOf
1291    
1292    C<< my @functionList = $sprout->FunctionOf($featureID, $userID); >>
1293    
1294    Return the functional assignments of a particular feature.
1295    
1296    The functional assignment is handled differently depending on the type of feature. If
1297    the feature is identified by a FIG ID (begins with the string C<fig|>), then a functional
1298    assignment is a type of annotation. The format of an assignment is described in
1299    L</ParseAssignment>. Its worth noting that we cannot filter on the content of the
1300    annotation itself because it's a text field; however, this is not a big problem because
1301    most features only have a small number of annotations.
1302    
1303    If the feature is B<not> identified by a FIG ID, then the functional assignment
1304    information is taken from the B<ExternalAliasFunc> table. If the table does
1305    not contain an entry for the feature, an empty list is returned.
1306    
1307    =over 4
1308    
1309    =item featureID
1310    
1311    ID of the feature whose functional assignments are desired.
1312    
1313    =item RETURN
1314    
1315    Returns a list of 2-tuples, each consisting of a user ID and the text of an assignment by
1316    that user.
1317    
1318    =back
1319    
1320    =cut
1321    #: Return Type @@;
1322    sub FunctionsOf {
1323        # Get the parameters.
1324        my ($self, $featureID) = @_;
1325        # Declare the return value.
1326        my @retVal = ();
1327        # Determine the ID type.
1328        if ($featureID =~ m/^fig\|/) {
1329            # Here we have a FIG feature ID. We must build the list of trusted
1330            # users.
1331            my %trusteeTable = ();
1332            # Build a query for all of the feature's annotations, sorted by date.
1333            my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation'],
1334                                   "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1335                                   [$featureID]);
1336            my $timeSelected = 0;
1337            # Loop until we run out of annotations.
1338            while (my $annotation = $query->Fetch()) {
1339                # Get the annotation text.
1340                my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);
1341                # Check to see if this is a functional assignment for a trusted user.
1342                my ($user, $function) = _ParseAssignment($text);
1343                if ($user) {
1344                    # Here it is a functional assignment.
1345                    push @retVal, [$user, $function];
1346                }
1347            }
1348        } else {
1349            # Here we have a non-FIG feature ID. In this case the user ID does not
1350            # matter. We simply get the information from the External Alias Function
1351            # table.
1352            push @retVal, $self->GetEntityValues('ExternalAliasFunc', $featureID, ['ExternalAliasFunc(func)']);
1353        }
1354        # Return the assignments found.
1355        return @retVal;
1356    }
1357    
1358  =head3 BBHList  =head3 BBHList
1359    
1360  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>
# Line 2609  Line 2673 
2673                                      ['HasSSCell(from-link)', 'IsRoleOf(from-link)']);                                      ['HasSSCell(from-link)', 'IsRoleOf(from-link)']);
2674      # Create the return value.      # Create the return value.
2675      my %retVal = ();      my %retVal = ();
2676        # Build a hash to weed out duplicates. Sometimes the same PEG and role appears
2677        # in two spreadsheet cells.
2678        my %dupHash = ();
2679      # Loop through the results, adding them to the hash.      # Loop through the results, adding them to the hash.
2680      for my $record (@subsystems) {      for my $record (@subsystems) {
2681            # Get this subsystem and role.
2682          my ($subsys, $role) = @{$record};          my ($subsys, $role) = @{$record};
2683          if (exists $retVal{$subsys}) {          # Insure it's the first time for both.
2684            my $dupKey = "$subsys\n$role";
2685            if (! exists $dupHash{"$subsys\n$role"}) {
2686                $dupHash{$dupKey} = 1;
2687              push @{$retVal{$subsys}}, $role;              push @{$retVal{$subsys}}, $role;
         } else {  
             $retVal{$subsys} = [$role];  
2688          }          }
2689      }      }
2690      # Return the hash.      # Return the hash.
# Line 3184  Line 3253 
3253      # Declare the return value.      # Declare the return value.
3254      my @retVal = ();      my @retVal = ();
3255      # Check to see if this is a functional assignment.      # Check to see if this is a functional assignment.
3256      my ($user, $type, $function) = split(/\n/, $text);      my ($type, $function) = split(/\n/, $text);
3257      if ($type =~ m/^set ([^ ]+) function to$/i) {      if ($type =~ m/^set ([^ ]+) function to$/i) {
3258          # Here it is, so we return the user name (which is in $1), the functional role text,          # Here it is, so we return the user name (which is in $1), the functional role text,
3259          # and the assigning user.          # and the assigning user.
3260          @retVal = ($1, $function, $user);          @retVal = ($1, $function);
3261      }      }
3262      # Return the result list.      # Return the result list.
3263      return @retVal;      return @retVal;

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.46

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3