[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.44, Thu Oct 20 09:32:18 2005 UTC revision 1.46, Thu Oct 20 11:52:36 2005 UTC
# 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); >>

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3