[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.45, Thu Oct 20 10:20:27 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 1200  Line 1200 
1200  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
1201  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
1202  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
1203  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
1204  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
1205  most features only have a small number of annotations.  most features only have a small number of annotations.
1206    
# Line 1291  Line 1291 
1291      return $retVal;      return $retVal;
1292  }  }
1293    
1294    =head3 FunctionsOf
1295    
1296    C<< my @functionList = $sprout->FunctionOf($featureID, $userID); >>
1297    
1298    Return the functional assignments of a particular feature.
1299    
1300    The functional assignment is handled differently depending on the type of feature. If
1301    the feature is identified by a FIG ID (begins with the string C<fig|>), then a functional
1302    assignment is a type of annotation. The format of an assignment is described in
1303    L</ParseAssignment>. Its worth noting that we cannot filter on the content of the
1304    annotation itself because it's a text field; however, this is not a big problem because
1305    most features only have a small number of annotations.
1306    
1307    If the feature is B<not> identified by a FIG ID, then the functional assignment
1308    information is taken from the B<ExternalAliasFunc> table. If the table does
1309    not contain an entry for the feature, an empty list is returned.
1310    
1311    =over 4
1312    
1313    =item featureID
1314    
1315    ID of the feature whose functional assignments are desired.
1316    
1317    =item RETURN
1318    
1319    Returns a list of 2-tuples, each consisting of a user ID and the text of an assignment by
1320    that user.
1321    
1322    =back
1323    
1324    =cut
1325    #: Return Type @@;
1326    sub FunctionsOf {
1327        # Get the parameters.
1328        my ($self, $featureID) = @_;
1329        # Declare the return value.
1330        my @retVal = ();
1331        # Determine the ID type.
1332        if ($featureID =~ m/^fig\|/) {
1333            # Here we have a FIG feature ID. We must build the list of trusted
1334            # users.
1335            my %trusteeTable = ();
1336            # Build a query for all of the feature's annotations, sorted by date.
1337            my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation'],
1338                                   "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1339                                   [$featureID]);
1340            my $timeSelected = 0;
1341            # Loop until we run out of annotations.
1342            while (my $annotation = $query->Fetch()) {
1343                # Get the annotation text.
1344                my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);
1345                # Check to see if this is a functional assignment for a trusted user.
1346                my ($user, $function) = _ParseAssignment($text);
1347                if ($user) {
1348                    # Here it is a functional assignment.
1349                    push @retVal, [$user, $function];
1350                }
1351            }
1352        } else {
1353            # Here we have a non-FIG feature ID. In this case the user ID does not
1354            # matter. We simply get the information from the External Alias Function
1355            # table.
1356            push @retVal, $self->GetEntityValues('ExternalAliasFunc', $featureID, ['ExternalAliasFunc(func)']);
1357        }
1358        # Return the assignments found.
1359        return @retVal;
1360    }
1361    
1362  =head3 BBHList  =head3 BBHList
1363    
1364  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>
# Line 2609  Line 2677 
2677                                      ['HasSSCell(from-link)', 'IsRoleOf(from-link)']);                                      ['HasSSCell(from-link)', 'IsRoleOf(from-link)']);
2678      # Create the return value.      # Create the return value.
2679      my %retVal = ();      my %retVal = ();
2680        # Build a hash to weed out duplicates. Sometimes the same PEG and role appears
2681        # in two spreadsheet cells.
2682        my %dupHash = ();
2683      # Loop through the results, adding them to the hash.      # Loop through the results, adding them to the hash.
2684      for my $record (@subsystems) {      for my $record (@subsystems) {
2685            # Get this subsystem and role.
2686          my ($subsys, $role) = @{$record};          my ($subsys, $role) = @{$record};
2687          if (exists $retVal{$subsys}) {          # Insure it's the first time for both.
2688            my $dupKey = "$subsys\n$role";
2689            if (! exists $dupHash{"$subsys\n$role"}) {
2690                $dupHash{$dupKey} = 1;
2691              push @{$retVal{$subsys}}, $role;              push @{$retVal{$subsys}}, $role;
         } else {  
             $retVal{$subsys} = [$role];  
2692          }          }
2693      }      }
2694      # Return the hash.      # Return the hash.
# Line 3184  Line 3257 
3257      # Declare the return value.      # Declare the return value.
3258      my @retVal = ();      my @retVal = ();
3259      # Check to see if this is a functional assignment.      # Check to see if this is a functional assignment.
3260      my ($user, $type, $function) = split(/\n/, $text);      my ($type, $function) = split(/\n/, $text);
3261      if ($type =~ m/^set ([^ ]+) function to$/i) {      if ($type =~ m/^set ([^ ]+) function to$/i) {
3262          # 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,
3263          # and the assigning user.          # and the assigning user.
3264          @retVal = ($1, $function, $user);          @retVal = ($1, $function);
3265      }      }
3266      # Return the result list.      # Return the result list.
3267      return @retVal;      return @retVal;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3