[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.10, Fri Feb 25 18:41:45 2005 UTC revision 1.11, Tue Mar 8 09:17:40 2005 UTC
# Line 1070  Line 1070 
1070  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>
1071    
1072  Return all of the functional assignments for a particular feature. The data is returned as a  Return all of the functional assignments for a particular feature. The data is returned as a
1073  hash of functional assignments to user IDs. A functional assignment is a type of annotation.  hash of functional assignments to user IDs. A functional assignment is a type of annotation,
1074  It has the format "XXXX\nset XXXX function to\nYYYYY". In this instance, XXXX is the user ID  Functional assignments are described in the L</ParseAssignment> function. Its worth noting that
1075  and YYYYY is the functional assignment text. Its worth noting that we cannot filter on the content  we cannot filter on the content of the annotation itself because it's a text field; however,
1076  of the annotation itself because it's a text field; however, this is not a big problem because most  this is not a big problem because most features only have a small number of annotations.
1077  features only have a small number of annotations. Finally, if a single user has multiple  Finally, if a single user has multiple functional assignments, we will only keep the most
1078  functional assignments, we will only keep the most recent one.  recent one.
1079    
1080  =over 4  =over 4
1081    
# Line 1109  Line 1109 
1109          # Get the annotation fields.          # Get the annotation fields.
1110          my ($timeStamp, $text) = @{$annotation};          my ($timeStamp, $text) = @{$annotation};
1111                  # Check to see if this is a functional assignment.                  # Check to see if this is a functional assignment.
1112                  my ($user, $function) = ParseAssignment($text);                  my ($user, $function) = _ParseAssignment($text);
1113          if ($user && ! exists $timeHash{$user}) {          if ($user && ! exists $timeHash{$user}) {
1114              # Here it is a functional assignment and there has been no              # Here it is a functional assignment and there has been no
1115              # previous assignment for this user, so we stuff it in the              # previous assignment for this user, so we stuff it in the
# Line 1131  Line 1131 
1131    
1132  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
1133  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
1134  assignment is a type of annotation. It has the format "XXXX\nset XXXX function to\nYYYYY". In this  assignment is a type of annotation. The format of an assignment is described in
1135  instance, XXXX is the user ID and YYYYY is the functional assignment text. Its worth noting that  L</ParseLocation>. Its worth noting that we cannot filter on the content of the
1136  we cannot filter on the content of the annotation itself because it's a text field; however, this  annotation itself because it's a text field; however, this is not a big problem because
1137  is not a big problem because most features only have a small number of annotations.  most features only have a small number of annotations.
1138    
1139  Each user has an associated list of trusted users. The assignment returned will be the most  Each user has an associated list of trusted users. The assignment returned will be the most
1140  recent one by at least one of the trusted users. If no trusted user list is available, then  recent one by at least one of the trusted users. If no trusted user list is available, then
# Line 1203  Line 1203 
1203              # Get the annotation text.              # Get the annotation text.
1204              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);
1205              # Check to see if this is a functional assignment for a trusted user.              # Check to see if this is a functional assignment for a trusted user.
1206              my ($user, $type, $function) = split(/\n/, $text);              my ($user, $function) = _ParseAssignment($text);
1207              if ($type =~ m/^set $user function to$/i) {              if ($user) {
1208                  # Here it is a functional assignment. Check the time and the user                  # Here it is a functional assignment. Check the time and the user
1209                  # name. The time must be recent and the user must be trusted.                  # name. The time must be recent and the user must be trusted.
1210                  if ((exists $trusteeTable{$user}) && ($time > $timeSelected)) {                  if ((exists $trusteeTable{$user}) && ($time > $timeSelected)) {
# Line 1656  Line 1656 
1656    
1657  =head3 AssignFunction  =head3 AssignFunction
1658    
1659  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function); >>  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser); >>
1660    
1661  This method assigns a function to a feature. Functions are a special type of annotation. The general  This method assigns a function to a feature. Functions are a special type of annotation. The general
1662  format is "XXXX\nset XXXX function to\nYYYYY" where XXXX is the feature type and YYYY is the functional  format is described in L</ParseAssignment>.
 assignment text.  
1663    
1664  =over 4  =over 4
1665    
# Line 1670  Line 1669 
1669    
1670  =item user  =item user
1671    
1672  Name of the user making the assignment. This is frequently a group name, like C<kegg> or C<fig>.  Name of the user group making the assignment, such as C<kegg> or C<fig>.
1673    
1674  =item function  =item function
1675    
1676  Text of the function being assigned.  Text of the function being assigned.
1677    
1678    =item assigningUser (optional)
1679    
1680    Name of the individual user making the assignment. If omitted, defaults to the user group.
1681    
1682  =item RETURN  =item RETURN
1683    
1684  Returns 1 if successful, 0 if an error occurred.  Returns 1 if successful, 0 if an error occurred.
# Line 1686  Line 1689 
1689  #: Return Type $;  #: Return Type $;
1690  sub AssignFunction {  sub AssignFunction {
1691          # Get the parameters.          # Get the parameters.
1692          my ($self, $featureID, $user, $function) = @_;          my ($self, $featureID, $user, $function, $assigningUser) = @_;
1693        # Default the assigning user.
1694        if (! $assigningUser) {
1695            $assigningUser = $user;
1696        }
1697          # Create an annotation string from the parameters.          # Create an annotation string from the parameters.
1698          my $annotationText = "$user\nset $user function to\n$function";          my $annotationText = "$assigningUser\nset $user function to\n$function";
1699          # Get the current time.          # Get the current time.
1700          my $now = time;          my $now = time;
1701          # Declare the return variable.          # Declare the return variable.
# Line 2631  Line 2638 
2638  =head3 ParseAssignment  =head3 ParseAssignment
2639    
2640  Parse annotation text to determine whether or not it is a functional assignment. If it is,  Parse annotation text to determine whether or not it is a functional assignment. If it is,
2641  the user and function text will be returned as a 2-element list. If it isn't, an empty list  the user, function text, and assigning user will be returned as a 3-element list. If it
2642  will be returned.  isn't, an empty list will be returned.
2643    
2644    A functional assignment is always of the form
2645    
2646        I<XXXX>C<\nset >I<YYYY>C< function to\n>I<ZZZZZ>
2647    
2648    where I<XXXX> is the B<assigning user>, I<YYYY> is the B<user>, and I<ZZZZ> is the
2649    actual functional role. In most cases, the user and the assigning user will be the
2650    same, but that is not always the case.
2651    
2652  This is a static method.  This is a static method.
2653    
# Line 2651  Line 2666 
2666    
2667  =cut  =cut
2668    
2669  sub ParseAssignment {  sub _ParseAssignment {
2670          # Get the parameters.          # Get the parameters.
2671          my ($text) = @_;          my ($text) = @_;
2672          # Declare the return value.          # Declare the return value.
2673          my @retVal = ();          my @retVal = ();
2674          # Check to see if this is a functional assignment.          # Check to see if this is a functional assignment.
2675          my ($user, $type, $function) = split(/\n/, $text);          my ($user, $type, $function) = split(/\n/, $text);
2676          if ($type =~ m/^set $user function to$/i) {          if ($type =~ m/^set ([^ ]+) function to$/i) {
2677                  # Here it is, so we return the user name and function text.                  # Here it is, so we return the user name (which is in $1), the functional role text,
2678                  @retVal = ($user, $function);          # and the assigning user.
2679                    @retVal = ($1, $function, $user);
2680          }          }
2681          # Return the result list.          # Return the result list.
2682          return @retVal;          return @retVal;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3