[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.12, Wed May 4 03:24:43 2005 UTC
# Line 269  Line 269 
269  sub GetEntity {  sub GetEntity {
270          # Get the parameters.          # Get the parameters.
271          my ($self, $entityType, $ID) = @_;          my ($self, $entityType, $ID) = @_;
272          # Create a query.          # Call the ERDB method.
273          my $query = $self->Get([$entityType], "$entityType(id) = ?", [$ID]);          return $self->{_erdb}->GetEntity($entityType, $ID);
         # Get the first (and only) object.  
         my $retVal = $query->Fetch();  
         # Return the result.  
         return $retVal;  
274  }  }
275    
276  =head3 GetEntityValues  =head3 GetEntityValues
# Line 308  Line 304 
304  sub GetEntityValues {  sub GetEntityValues {
305          # Get the parameters.          # Get the parameters.
306          my ($self, $entityType, $ID, $fields) = @_;          my ($self, $entityType, $ID, $fields) = @_;
307          # Get the specified entity.          # Call the ERDB method.
308          my $entity = $self->GetEntity($entityType, $ID);          return $self->{_erdb}->GetEntityValues($entityType, $ID, $fields);
         # Declare the return list.  
         my @retVal = ();  
         # If we found the entity, push the values into the return list.  
         if ($entity) {  
                 push @retVal, $entity->Values($fields);  
         }  
         # Return the result.  
         return @retVal;  
309  }  }
310    
311  =head3 ShowMetaData  =head3 ShowMetaData
# Line 1070  Line 1058 
1058  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>
1059    
1060  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
1061  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,
1062  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
1063  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,
1064  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.
1065  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
1066  functional assignments, we will only keep the most recent one.  recent one.
1067    
1068  =over 4  =over 4
1069    
# Line 1109  Line 1097 
1097          # Get the annotation fields.          # Get the annotation fields.
1098          my ($timeStamp, $text) = @{$annotation};          my ($timeStamp, $text) = @{$annotation};
1099                  # Check to see if this is a functional assignment.                  # Check to see if this is a functional assignment.
1100                  my ($user, $function) = ParseAssignment($text);                  my ($user, $function) = _ParseAssignment($text);
1101          if ($user && ! exists $timeHash{$user}) {          if ($user && ! exists $timeHash{$user}) {
1102              # Here it is a functional assignment and there has been no              # Here it is a functional assignment and there has been no
1103              # 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 1119 
1119    
1120  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
1121  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
1122  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
1123  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
1124  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
1125  is not a big problem because most features only have a small number of annotations.  most features only have a small number of annotations.
1126    
1127  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
1128  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 1191 
1191              # Get the annotation text.              # Get the annotation text.
1192              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);
1193              # 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.
1194              my ($user, $type, $function) = split(/\n/, $text);              my ($user, $function) = _ParseAssignment($text);
1195              if ($type =~ m/^set $user function to$/i) {              if ($user) {
1196                  # Here it is a functional assignment. Check the time and the user                  # Here it is a functional assignment. Check the time and the user
1197                  # name. The time must be recent and the user must be trusted.                  # name. The time must be recent and the user must be trusted.
1198                  if ((exists $trusteeTable{$user}) && ($time > $timeSelected)) {                  if ((exists $trusteeTable{$user}) && ($time > $timeSelected)) {
# Line 1447  Line 1435 
1435                  if ($line =~ m/^>\s*(.+?)(\s|\n)/) {                  if ($line =~ m/^>\s*(.+?)(\s|\n)/) {
1436                          # Here we have a new header. Store the current sequence if we have one.                          # Here we have a new header. Store the current sequence if we have one.
1437                          if ($id) {                          if ($id) {
1438                                  $retVal{$id} = $sequence;                                  $retVal{$id} = uc $sequence;
1439                          }                          }
1440                          # Clear the sequence accumulator and save the new ID.                          # Clear the sequence accumulator and save the new ID.
1441                          ($id, $sequence) = ("$prefix$1", "");                          ($id, $sequence) = ("$prefix$1", "");
1442                  } else {                  } else {
1443                          # Here we have a data line, so we add it to the sequence accumulator.                          # Here we have a data line, so we add it to the sequence accumulator.
1444                          # First, we get the actual data out.                          # First, we get the actual data out. Note that we normalize to upper
1445                            # case.
1446                          $line =~ /^\s*(.*?)(\s|\n)/;                          $line =~ /^\s*(.*?)(\s|\n)/;
1447                          $sequence .= $1;                          $sequence .= $1;
1448                  }                  }
1449          }          }
1450          # Flush out the last sequence (if any).          # Flush out the last sequence (if any).
1451          if ($sequence) {          if ($sequence) {
1452                  $retVal {$id} = $sequence;                  $retVal{$id} = uc $sequence;
1453          }          }
1454            # Close the file.
1455            close FASTAFILE;
1456          # Return the hash constructed from the file.          # Return the hash constructed from the file.
1457          return %retVal;          return %retVal;
1458  }  }
# Line 1656  Line 1647 
1647    
1648  =head3 AssignFunction  =head3 AssignFunction
1649    
1650  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function); >>  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser); >>
1651    
1652  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
1653  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.  
1654    
1655  =over 4  =over 4
1656    
# Line 1670  Line 1660 
1660    
1661  =item user  =item user
1662    
1663  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>.
1664    
1665  =item function  =item function
1666    
1667  Text of the function being assigned.  Text of the function being assigned.
1668    
1669    =item assigningUser (optional)
1670    
1671    Name of the individual user making the assignment. If omitted, defaults to the user group.
1672    
1673  =item RETURN  =item RETURN
1674    
1675  Returns 1 if successful, 0 if an error occurred.  Returns 1 if successful, 0 if an error occurred.
# Line 1686  Line 1680 
1680  #: Return Type $;  #: Return Type $;
1681  sub AssignFunction {  sub AssignFunction {
1682          # Get the parameters.          # Get the parameters.
1683          my ($self, $featureID, $user, $function) = @_;          my ($self, $featureID, $user, $function, $assigningUser) = @_;
1684        # Default the assigning user.
1685        if (! $assigningUser) {
1686            $assigningUser = $user;
1687        }
1688          # Create an annotation string from the parameters.          # Create an annotation string from the parameters.
1689          my $annotationText = "$user\nset $user function to\n$function";          my $annotationText = "$assigningUser\nset $user function to\n$function";
1690          # Get the current time.          # Get the current time.
1691          my $now = time;          my $now = time;
1692          # Declare the return variable.          # Declare the return variable.
# Line 2631  Line 2629 
2629  =head3 ParseAssignment  =head3 ParseAssignment
2630    
2631  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,
2632  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
2633  will be returned.  isn't, an empty list will be returned.
2634    
2635    A functional assignment is always of the form
2636    
2637        I<XXXX>C<\nset >I<YYYY>C< function to\n>I<ZZZZZ>
2638    
2639    where I<XXXX> is the B<assigning user>, I<YYYY> is the B<user>, and I<ZZZZ> is the
2640    actual functional role. In most cases, the user and the assigning user will be the
2641    same, but that is not always the case.
2642    
2643  This is a static method.  This is a static method.
2644    
# Line 2651  Line 2657 
2657    
2658  =cut  =cut
2659    
2660  sub ParseAssignment {  sub _ParseAssignment {
2661          # Get the parameters.          # Get the parameters.
2662          my ($text) = @_;          my ($text) = @_;
2663          # Declare the return value.          # Declare the return value.
2664          my @retVal = ();          my @retVal = ();
2665          # Check to see if this is a functional assignment.          # Check to see if this is a functional assignment.
2666          my ($user, $type, $function) = split(/\n/, $text);          my ($user, $type, $function) = split(/\n/, $text);
2667          if ($type =~ m/^set $user function to$/i) {          if ($type =~ m/^set ([^ ]+) function to$/i) {
2668                  # 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,
2669                  @retVal = ($user, $function);          # and the assigning user.
2670                    @retVal = ($1, $function, $user);
2671          }          }
2672          # Return the result list.          # Return the result list.
2673          return @retVal;          return @retVal;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3