[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.45, Thu Oct 20 10:20:27 2005 UTC revision 1.73, Sun Jun 25 02:44:43 2006 UTC
# Line 1  Line 1 
1  package Sprout;  package Sprout;
2    
3        require Exporter;
4        use ERDB;
5        @ISA = qw(Exporter ERDB);
6      use Data::Dumper;      use Data::Dumper;
7      use strict;      use strict;
8      use Carp;      use Carp;
# Line 7  Line 10 
10      use XML::Simple;      use XML::Simple;
11      use DBQuery;      use DBQuery;
12      use DBObject;      use DBObject;
     use ERDB;  
13      use Tracer;      use Tracer;
14      use FIGRules;      use FIGRules;
15        use FidCheck;
16      use Stats;      use Stats;
17      use POSIX qw(strftime);      use POSIX qw(strftime);
18    
# Line 32  Line 35 
35  query tasks. For example, L</genomes> lists the IDs of all the genomes in the database and  query tasks. For example, L</genomes> lists the IDs of all the genomes in the database and
36  L</dna_seq> returns the DNA sequence for a specified genome location.  L</dna_seq> returns the DNA sequence for a specified genome location.
37    
38    The Sprout object is a subclass of the ERDB object and inherits all its properties and methods.
39    
40  =cut  =cut
41    
42  #: Constructor SFXlate->new_sprout_only();  #: Constructor SFXlate->new_sprout_only();
# Line 62  Line 67 
67    
68  * B<xmlFileName> name of the XML file containing the database definition (default C<SproutDBD.xml>)  * B<xmlFileName> name of the XML file containing the database definition (default C<SproutDBD.xml>)
69    
70  * B<userData> user name and password, delimited by a slash (default C<root/>)  * B<userData> user name and password, delimited by a slash (default same as SEED)
71    
72  * B<port> connection port (default C<0>)  * B<port> connection port (default C<0>)
73    
74    * B<sock> connection socket (default same as SEED)
75    
76  * B<maxSegmentLength> maximum number of residues per feature segment, (default C<4500>)  * B<maxSegmentLength> maximum number of residues per feature segment, (default C<4500>)
77    
78  * B<maxSequenceLength> maximum number of residues per sequence, (default C<8000>)  * B<maxSequenceLength> maximum number of residues per sequence, (default C<8000>)
# Line 92  Line 99 
99                                                          # database type                                                          # database type
100                         dataDir      => $FIG_Config::sproutData,                         dataDir      => $FIG_Config::sproutData,
101                                                          # data file directory                                                          # data file directory
102                         xmlFileName  => "$FIG_Config::sproutData/SproutDBD.xml",                         xmlFileName  => "$FIG_Config::fig/SproutDBD.xml",
103                                                          # database definition file name                                                          # database definition file name
104                         userData     => "$FIG_Config::dbuser/$FIG_Config::dbpass",                         userData     => "$FIG_Config::dbuser/$FIG_Config::dbpass",
105                                                          # user name and password                                                          # user name and password
106                         port         => $FIG_Config::dbport,                         port         => $FIG_Config::dbport,
107                                                          # database connection port                                                          # database connection port
108                           sock         => $FIG_Config::dbsock,
109                         maxSegmentLength => 4500,        # maximum feature segment length                         maxSegmentLength => 4500,        # maximum feature segment length
110                         maxSequenceLength => 8000,       # maximum contig sequence length                         maxSequenceLength => 8000,       # maximum contig sequence length
111                         noDBOpen     => 0,               # 1 to suppress the database open                         noDBOpen     => 0,               # 1 to suppress the database open
# Line 111  Line 119 
119      my $dbh;      my $dbh;
120      if (! $optionTable->{noDBOpen}) {      if (! $optionTable->{noDBOpen}) {
121          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,
122                                  $password, $optionTable->{port});                                  $password, $optionTable->{port}, undef, $optionTable->{sock});
123      }      }
124      # Create the ERDB object.      # Create the ERDB object.
125      my $xmlFileName = "$optionTable->{xmlFileName}";      my $xmlFileName = "$optionTable->{xmlFileName}";
126      my $erdb = ERDB->new($dbh, $xmlFileName);      my $retVal = ERDB::new($class, $dbh, $xmlFileName);
127      # Create this object.      # Add the option table and XML file name.
128      my $self = { _erdb => $erdb, _options => $optionTable, _xmlName => $xmlFileName };      $retVal->{_options} = $optionTable;
129      # Bless and return it.      $retVal->{_xmlName} = $xmlFileName;
130      bless $self;      # Return it.
131      return $self;      return $retVal;
132  }  }
133    
134  =head3 MaxSegment  =head3 MaxSegment
# Line 155  Line 163 
163      return $self->{_options}->{maxSequenceLength};      return $self->{_options}->{maxSequenceLength};
164  }  }
165    
 =head3 Get  
   
 C<< my $query = $sprout->Get(\@objectNames, $filterClause, \@parameterList); >>  
   
 This method allows a general query against the Sprout data using a specified filter clause.  
   
 The filter is a standard WHERE/ORDER BY clause with question marks as parameter markers and each  
 field name represented in the form B<I<objectName>(I<fieldName>)>. For example, the  
 following call requests all B<Genome> objects for the genus specified in the variable  
 $genus.  
   
 C<< $query = $sprout->Get(['Genome'], "Genome(genus) = ?", [$genus]); >>  
   
 The WHERE clause contains a single question mark, so there is a single additional  
 parameter representing the parameter value. It would also be possible to code  
   
 C<< $query = $sprout->Get(['Genome'], "Genome(genus) = \'$genus\'"); >>  
   
 however, this version of the call would generate a syntax error if there were any quote  
 characters inside the variable C<$genus>.  
   
 The use of the strange parenthesized notation for field names enables us to distinguish  
 hyphens contained within field names from minus signs that participate in the computation  
 of the WHERE clause. All of the methods that manipulate fields will use this same notation.  
   
 It is possible to specify multiple entity and relationship names in order to retrieve more than  
 one object's data at the same time, which allows highly complex joined queries. For example,  
   
 C<< $query = $sprout->Get(['Genome', 'ComesFrom', 'Source'], "Genome(genus) = ?", [$genus]); >>  
   
 This query returns all the genomes for a particular genus and allows access to the  
 sources from which they came. The join clauses to go from Genome to Source are generated  
 automatically.  
   
 Finally, the filter clause can contain sort information. To do this, simply put an C<ORDER BY>  
 clause at the end of the filter. Field references in the ORDER BY section follow the same rules  
 as they do in the filter itself; in other words, each one must be of the form B<I<objectName>(I<fieldName>)>.  
 For example, the following filter string gets all genomes for a particular genus and sorts  
 them by species name.  
   
 C<< $query = $sprout->Get(['Genome'], "Genome(genus) = ? ORDER BY Genome(species)", [$genus]); >>  
   
 It is also permissible to specify I<only> an ORDER BY clause. For example, the following invocation gets  
 all genomes ordered by genus and species.  
   
 C<< $query = $sprout->Get(['Genome'], "ORDER BY Genome(genus), Genome(species)"); >>  
   
 Odd things may happen if one of the ORDER BY fields is in a secondary relation. So, for example, an  
 attempt to order B<Feature>s by alias may (depending on the underlying database engine used) cause  
 a single feature to appear more than once.  
   
 If multiple names are specified, then the query processor will automatically determine a  
 join path between the entities and relationships. The algorithm used is very simplistic.  
 In particular, you can't specify any entity or relationship more than once, and if a  
 relationship is recursive, the path is determined by the order in which the entity  
 and the relationship appear. For example, consider a recursive relationship B<IsParentOf>  
 which relates B<People> objects to other B<People> objects. If the join path is  
 coded as C<['People', 'IsParentOf']>, then the people returned will be parents. If, however,  
 the join path is C<['IsParentOf', 'People']>, then the people returned will be children.  
   
 =over 4  
   
 =item objectNames  
   
 List containing the names of the entity and relationship objects to be retrieved.  
   
 =item filterClause  
   
 WHERE/ORDER BY clause (without the WHERE) to be used to filter and sort the query. The WHERE clause can  
 be parameterized with parameter markers (C<?>). Each field used must be specified in the standard form  
 B<I<objectName>(I<fieldName>)>. Any parameters specified in the filter clause should be added to the  
 parameter list as additional parameters. The fields in a filter clause can come from primary  
 entity relations, relationship relations, or secondary entity relations; however, all of the  
 entities and relationships involved must be included in the list of object names.  
   
 =item parameterList  
   
 List of the parameters to be substituted in for the parameters marks in the filter clause.  
   
 =item RETURN  
   
 Returns a B<DBQuery> that can be used to iterate through all of the results.  
   
 =back  
   
 =cut  
   
 sub Get {  
     # Get the parameters.  
     my ($self, $objectNames, $filterClause, $parameterList) = @_;  
     # We differ from the ERDB Get method in that the parameter list is passed in as a list reference  
     # rather than a list of parameters. The next step is to convert the parameters from a reference  
     # to a real list. We can only do this if the parameters have been specified.  
     my @parameters;  
     if ($parameterList) { @parameters = @{$parameterList}; }  
     return $self->{_erdb}->Get($objectNames, $filterClause, @parameters);  
 }  
   
 =head3 GetEntity  
   
 C<< my $entityObject = $sprout->GetEntity($entityType, $ID); >>  
   
 Return an object describing the entity instance with a specified ID.  
   
 =over 4  
   
 =item entityType  
   
 Entity type name.  
   
 =item ID  
   
 ID of the desired entity.  
   
 =item RETURN  
   
 Returns a B<DBObject> representing the desired entity instance, or an undefined value if no  
 instance is found with the specified key.  
   
 =back  
   
 =cut  
   
 sub GetEntity {  
     # Get the parameters.  
     my ($self, $entityType, $ID) = @_;  
     # Call the ERDB method.  
     return $self->{_erdb}->GetEntity($entityType, $ID);  
 }  
   
 =head3 GetEntityValues  
   
 C<< my @values = GetEntityValues($entityType, $ID, \@fields); >>  
   
 Return a list of values from a specified entity instance.  
   
 =over 4  
   
 =item entityType  
   
 Entity type name.  
   
 =item ID  
   
 ID of the desired entity.  
   
 =item fields  
   
 List of field names, each of the form I<objectName>C<(>I<fieldName>C<)>.  
   
 =item RETURN  
   
 Returns a flattened list of the values of the specified fields for the specified entity.  
   
 =back  
   
 =cut  
 #: Return Type @;  
 sub GetEntityValues {  
     # Get the parameters.  
     my ($self, $entityType, $ID, $fields) = @_;  
     # Call the ERDB method.  
     return $self->{_erdb}->GetEntityValues($entityType, $ID, $fields);  
 }  
   
 =head3 ShowMetaData  
   
 C<< $sprout->ShowMetaData($fileName); >>  
   
 This method outputs a description of the database to an HTML file in the data directory.  
   
 =over 4  
   
 =item fileName  
   
 Fully-qualified name to give to the output file.  
   
 =back  
   
 =cut  
   
 sub ShowMetaData {  
     # Get the parameters.  
     my ($self, $fileName) = @_;  
     # Compute the file name.  
     my $options = $self->{_options};  
     # Call the show method on the underlying ERDB object.  
     $self->{_erdb}->ShowMetaData($fileName);  
 }  
   
166  =head3 Load  =head3 Load
167    
168  C<< $sprout->Load($rebuild); >>;  C<< $sprout->Load($rebuild); >>;
# Line 379  Line 197 
197  sub Load {  sub Load {
198      # Get the parameters.      # Get the parameters.
199      my ($self, $rebuild) = @_;      my ($self, $rebuild) = @_;
     # Get the database object.  
     my $erdb = $self->{_erdb};  
200      # Load the tables from the data directory.      # Load the tables from the data directory.
201      my $retVal = $erdb->LoadTables($self->{_options}->{dataDir}, $rebuild);      my $retVal = $self->LoadTables($self->{_options}->{dataDir}, $rebuild);
202      # Return the statistics.      # Return the statistics.
203      return $retVal;      return $retVal;
204  }  }
# Line 422  Line 238 
238  sub LoadUpdate {  sub LoadUpdate {
239      # Get the parameters.      # Get the parameters.
240      my ($self, $truncateFlag, $tableList) = @_;      my ($self, $truncateFlag, $tableList) = @_;
     # Get the database object.  
     my $erdb = $self->{_erdb};  
241      # Declare the return value.      # Declare the return value.
242      my $retVal = Stats->new();      my $retVal = Stats->new();
243      # Get the data directory.      # Get the data directory.
# Line 437  Line 251 
251              Trace("No load file found for $tableName in $dataDir.") if T(0);              Trace("No load file found for $tableName in $dataDir.") if T(0);
252          } else {          } else {
253              # Attempt to load this table.              # Attempt to load this table.
254              my $result = $erdb->LoadTable($fileName, $tableName, $truncateFlag);              my $result = $self->LoadTable($fileName, $tableName, $truncateFlag);
255              # Accumulate the resulting statistics.              # Accumulate the resulting statistics.
256              $retVal->Accumulate($result);              $retVal->Accumulate($result);
257          }          }
# Line 446  Line 260 
260      return $retVal;      return $retVal;
261  }  }
262    
263    =head3 GenomeCounts
264    
265    C<< my ($arch, $bact, $euk, $vir, $env, $unk) = $sprout->GenomeCounts($complete); >>
266    
267    Count the number of genomes in each domain. If I<$complete> is TRUE, only complete
268    genomes will be included in the counts.
269    
270    =over 4
271    
272    =item complete
273    
274    TRUE if only complete genomes are to be counted, FALSE if all genomes are to be
275    counted
276    
277    =item RETURN
278    
279    A six-element list containing the number of genomes in each of six categories--
280    Archaea, Bacteria, Eukaryota, Viral, Environmental, and Unknown, respectively.
281    
282    =back
283    
284    =cut
285    
286    sub GenomeCounts {
287        # Get the parameters.
288        my ($self, $complete) = @_;
289        # Set the filter based on the completeness flag.
290        my $filter = ($complete ? "Genome(complete) = 1" : "");
291        # Get all the genomes and the related taxonomy information.
292        my @genomes = $self->GetAll(['Genome'], $filter, [], ['Genome(id)', 'Genome(taxonomy)']);
293        # Clear the counters.
294        my ($arch, $bact, $euk, $vir, $env, $unk) = (0, 0, 0, 0, 0, 0);
295        # Loop through, counting the domains.
296        for my $genome (@genomes) {
297            if    ($genome->[1] =~ /^archaea/i)  { ++$arch }
298            elsif ($genome->[1] =~ /^bacter/i)   { ++$bact }
299            elsif ($genome->[1] =~ /^eukar/i)    { ++$euk }
300            elsif ($genome->[1] =~ /^vir/i)      { ++$vir }
301            elsif ($genome->[1] =~ /^env/i)      { ++$env }
302            else  { ++$unk }
303        }
304        # Return the counts.
305        return ($arch, $bact, $euk, $vir, $env, $unk);
306    }
307    
308    =head3 ContigCount
309    
310    C<< my $count = $sprout->ContigCount($genomeID); >>
311    
312    Return the number of contigs for the specified genome ID.
313    
314    =over 4
315    
316    =item genomeID
317    
318    ID of the genome whose contig count is desired.
319    
320    =item RETURN
321    
322    Returns the number of contigs for the specified genome.
323    
324    =back
325    
326    =cut
327    
328    sub ContigCount {
329        # Get the parameters.
330        my ($self, $genomeID) = @_;
331        # Get the contig count.
332        my $retVal = $self->GetCount(['Contig', 'HasContig'], "HasContig(from-link) = ?", [$genomeID]);
333        # Return the result.
334        return $retVal;
335    }
336    
337    =head3 GeneMenu
338    
339    C<< my $selectHtml = $sprout->GeneMenu(\%attributes, $filterString, \@params); >>
340    
341    Return an HTML select menu of genomes. Each genome will be an option in the menu,
342    and will be displayed by name with the ID and a contig count attached. The selection
343    value will be the genome ID. The genomes will be sorted by genus/species name.
344    
345    =over 4
346    
347    =item attributes
348    
349    Reference to a hash mapping attributes to values for the SELECT tag generated.
350    
351    =item filterString
352    
353    A filter string for use in selecting the genomes. The filter string must conform
354    to the rules for the C<< ERDB->Get >> method.
355    
356    =item params
357    
358    Reference to a list of values to be substituted in for the parameter marks in
359    the filter string.
360    
361    =item RETURN
362    
363    Returns an HTML select menu with the specified genomes as selectable options.
364    
365    =back
366    
367    =cut
368    
369    sub GeneMenu {
370        # Get the parameters.
371        my ($self, $attributes, $filterString, $params) = @_;
372        # Start the menu.
373        my $retVal = "<select " .
374            join(" ", map { "$_=\"$attributes->{$_}\"" } keys %{$attributes}) .
375            ">\n";
376        # Get the genomes.
377        my @genomes = $self->GetAll(['Genome'], $filterString, $params, ['Genome(id)',
378                                                                         'Genome(genus)',
379                                                                         'Genome(species)',
380                                                                         'Genome(unique-characterization)']);
381        # Sort them by name.
382        my @sorted = sort { lc("$a->[1] $a->[2]") cmp lc("$b->[1] $b->[2]") } @genomes;
383        # Loop through the genomes, creating the option tags.
384        for my $genomeData (@sorted) {
385            # Get the data for this genome.
386            my ($genomeID, $genus, $species, $strain) = @{$genomeData};
387            # Get the contig count.
388            my $count = $self->ContigCount($genomeID);
389            my $counting = ($count == 1 ? "contig" : "contigs");
390            # Build the option tag.
391            $retVal .= "<option value=\"$genomeID\">$genus $species $strain ($genomeID) [$count $counting]</option>\n";
392            Trace("Option tag built for $genomeID: $genus $species $strain.") if T(3);
393        }
394        # Close the SELECT tag.
395        $retVal .= "</select>\n";
396        # Return the result.
397        return $retVal;
398    }
399  =head3 Build  =head3 Build
400    
401  C<< $sprout->Build(); >>  C<< $sprout->Build(); >>
# Line 460  Line 410 
410      # Get the parameters.      # Get the parameters.
411      my ($self) = @_;      my ($self) = @_;
412      # Create the tables.      # Create the tables.
413      $self->{_erdb}->CreateTables;      $self->CreateTables();
414  }  }
415    
416  =head3 Genomes  =head3 Genomes
# Line 740  Line 690 
690  should be of the form returned by L</featureLocation> when in a list context. In other words,  should be of the form returned by L</featureLocation> when in a list context. In other words,
691  each location is of the form I<contigID>C<_>I<begin>I<dir>I<end>.  each location is of the form I<contigID>C<_>I<begin>I<dir>I<end>.
692    
693    For example, the following would return the DNA sequence for contig C<83333.1:NC_000913>
694    between positions 1401 and 1532, inclusive.
695    
696        my $sequence = $sprout->DNASeq('83333.1:NC_000913_1401_1532');
697    
698  =over 4  =over 4
699    
700  =item locationList  =item locationList
701    
702  List of location specifiers, each in the form I<contigID>C<_>I<begin>I<dir>I<end> (see  List of location specifiers, each in the form I<contigID>C<_>I<begin>I<dir>I<len> or
703  L</FeatureLocation> for more about this format).  I<contigID>C<_>I<begin>C<_>I<end> (see L</FeatureLocation> for more about this format).
704    
705  =item RETURN  =item RETURN
706    
# Line 841  Line 796 
796      return @retVal;      return @retVal;
797  }  }
798    
799    =head3 GenomeLength
800    
801    C<< my $length = $sprout->GenomeLength($genomeID); >>
802    
803    Return the length of the specified genome in base pairs.
804    
805    =over 4
806    
807    =item genomeID
808    
809    ID of the genome whose base pair count is desired.
810    
811    =item RETURN
812    
813    Returns the number of base pairs in all the contigs of the specified
814    genome.
815    
816    =back
817    
818    =cut
819    
820    sub GenomeLength {
821        # Get the parameters.
822        my ($self, $genomeID) = @_;
823        # Declare the return variable.
824        my $retVal = 0;
825        # Get the genome's contig sequence lengths.
826        my @lens = $self->GetFlat(['HasContig', 'IsMadeUpOf'], 'HasContig(from-link) = ?',
827                           [$genomeID], 'IsMadeUpOf(len)');
828        # Sum the lengths.
829        map { $retVal += $_ } @lens;
830        # Return the result.
831        return $retVal;
832    }
833    
834    =head3 FeatureCount
835    
836    C<< my $count = $sprout->FeatureCount($genomeID, $type); >>
837    
838    Return the number of features of the specified type in the specified genome.
839    
840    =over 4
841    
842    =item genomeID
843    
844    ID of the genome whose feature count is desired.
845    
846    =item type
847    
848    Type of feature to count (eg. C<peg>, C<rna>, etc.).
849    
850    =item RETURN
851    
852    Returns the number of features of the specified type for the specified genome.
853    
854    =back
855    
856    =cut
857    
858    sub FeatureCount {
859        # Get the parameters.
860        my ($self, $genomeID, $type) = @_;
861        # Compute the count.
862        my $retVal = $self->GetCount(['HasFeature', 'Feature'],
863                                    "HasFeature(from-link) = ? AND Feature(feature-type) = ?",
864                                    [$genomeID, $type]);
865        # Return the result.
866        return $retVal;
867    }
868    
869    =head3 GenomeAssignments
870    
871    C<< my $fidHash = $sprout->GenomeAssignments($genomeID); >>
872    
873    Return a list of a genome's assigned features. The return hash will contain each
874    assigned feature of the genome mapped to the text of its most recent functional
875    assignment.
876    
877    =over 4
878    
879    =item genomeID
880    
881    ID of the genome whose functional assignments are desired.
882    
883    =item RETURN
884    
885    Returns a reference to a hash which maps each feature to its most recent
886    functional assignment.
887    
888    =back
889    
890    =cut
891    
892    sub GenomeAssignments {
893        # Get the parameters.
894        my ($self, $genomeID) = @_;
895        # Declare the return variable.
896        my $retVal = {};
897        # Query the genome's features and annotations. We'll put the oldest annotations
898        # first so that the last assignment to go into the hash will be the correct one.
899        my $query = $self->Get(['HasFeature', 'IsTargetOfAnnotation', 'Annotation'],
900                               "HasFeature(from-link) = ? ORDER BY Annotation(time)",
901                               [$genomeID]);
902        # Loop through the annotations.
903        while (my $data = $query->Fetch) {
904            # Get the feature ID and annotation text.
905            my ($fid, $annotation) = $data->Values(['HasFeature(to-link)',
906                                                    'Annotation(annotation)']);
907            # Check to see if this is an assignment. Note that the user really
908            # doesn't matter to us, other than we use it to determine whether or
909            # not this is an assignment.
910            my ($user, $assignment) = _ParseAssignment('fig', $annotation);
911            if ($user) {
912                # Here it's an assignment. We put it in the return hash, overwriting
913                # any older assignment that might be present.
914                $retVal->{$fid} = $assignment;
915            }
916        }
917        # Return the result.
918        return $retVal;
919    }
920    
921  =head3 ContigLength  =head3 ContigLength
922    
923  C<< my $length = $sprout->ContigLength($contigID); >>  C<< my $length = $sprout->ContigLength($contigID); >>
# Line 1153  Line 1230 
1230    
1231  =item RETURN  =item RETURN
1232    
1233  Returns a hash mapping the functional assignment IDs to user IDs.  Returns a hash mapping the user IDs to functional assignment IDs.
1234    
1235  =back  =back
1236    
# Line 1163  Line 1240 
1240      # Get the parameters.      # Get the parameters.
1241      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
1242      # Get all of the feature's annotations.      # Get all of the feature's annotations.
1243      my @query = $self->GetAll(['IsTargetOfAnnotation', 'Annotation'],      my @query = $self->GetAll(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],
1244                              "IsTargetOfAnnotation(from-link) = ?",                              "IsTargetOfAnnotation(from-link) = ?",
1245                              [$featureID], ['Annotation(time)', 'Annotation(annotation)']);                              [$featureID], ['Annotation(time)', 'Annotation(annotation)',
1246                                               'MadeAnnotation(from-link)']);
1247      # Declare the return hash.      # Declare the return hash.
1248      my %retVal;      my %retVal;
     # Declare a hash for insuring we only make one assignment per user.  
     my %timeHash = ();  
1249      # Now we sort the assignments by timestamp in reverse.      # Now we sort the assignments by timestamp in reverse.
1250      my @sortedQuery = sort { -($a->[0] <=> $b->[0]) } @query;      my @sortedQuery = sort { -($a->[0] <=> $b->[0]) } @query;
1251      # Loop until we run out of annotations.      # Loop until we run out of annotations.
1252      for my $annotation (@sortedQuery) {      for my $annotation (@sortedQuery) {
1253          # Get the annotation fields.          # Get the annotation fields.
1254          my ($timeStamp, $text) = @{$annotation};          my ($timeStamp, $text, $user) = @{$annotation};
1255          # Check to see if this is a functional assignment.          # Check to see if this is a functional assignment.
1256          my ($user, $function) = _ParseAssignment($text);          my ($actualUser, $function) = _ParseAssignment($user, $text);
1257          if ($user && ! exists $timeHash{$user}) {          if ($actualUser && ! exists $retVal{$actualUser}) {
1258              # Here it is a functional assignment and there has been no              # Here it is a functional assignment and there has been no
1259              # previous assignment for this user, so we stuff it in the              # previous assignment for this user, so we stuff it in the
1260              # return hash.              # return hash.
1261              $retVal{$function} = $user;              $retVal{$actualUser} = $function;
             # Insure we don't assign to this user again.  
             $timeHash{$user} = 1;  
1262          }          }
1263      }      }
1264      # Return the hash of assignments found.      # Return the hash of assignments found.
# Line 1262  Line 1336 
1336              }              }
1337          }          }
1338          # Build a query for all of the feature's annotations, sorted by date.          # Build a query for all of the feature's annotations, sorted by date.
1339          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation'],          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],
1340                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1341                                 [$featureID]);                                 [$featureID]);
1342          my $timeSelected = 0;          my $timeSelected = 0;
1343          # Loop until we run out of annotations.          # Loop until we run out of annotations.
1344          while (my $annotation = $query->Fetch()) {          while (my $annotation = $query->Fetch()) {
1345              # Get the annotation text.              # Get the annotation text.
1346              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);              my ($text, $time, $user) = $annotation->Values(['Annotation(annotation)',
1347                                                         'Annotation(time)', 'MadeAnnotation(from-link)']);
1348              # 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.
1349              my ($user, $function) = _ParseAssignment($text);              my ($actualUser, $function) = _ParseAssignment($user, $text);
1350              if ($user) {              Trace("Assignment user is $actualUser, text is $function.") if T(4);
1351                if ($actualUser) {
1352                  # Here it is a functional assignment. Check the time and the user                  # Here it is a functional assignment. Check the time and the user
1353                  # name. The time must be recent and the user must be trusted.                  # name. The time must be recent and the user must be trusted.
1354                  if ((exists $trusteeTable{$user}) && ($time > $timeSelected)) {                  if ((exists $trusteeTable{$actualUser}) && ($time > $timeSelected)) {
1355                      $retVal = $function;                      $retVal = $function;
1356                      $timeSelected = $time;                      $timeSelected = $time;
1357                  }                  }
# Line 1334  Line 1410 
1410          # users.          # users.
1411          my %trusteeTable = ();          my %trusteeTable = ();
1412          # Build a query for all of the feature's annotations, sorted by date.          # Build a query for all of the feature's annotations, sorted by date.
1413          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation'],          my $query = $self->Get(['IsTargetOfAnnotation', 'Annotation', 'MadeAnnotation'],
1414                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",                                 "IsTargetOfAnnotation(from-link) = ? ORDER BY Annotation(time) DESC",
1415                                 [$featureID]);                                 [$featureID]);
1416          my $timeSelected = 0;          my $timeSelected = 0;
1417          # Loop until we run out of annotations.          # Loop until we run out of annotations.
1418          while (my $annotation = $query->Fetch()) {          while (my $annotation = $query->Fetch()) {
1419              # Get the annotation text.              # Get the annotation text.
1420              my ($text, $time) = $annotation->Values(['Annotation(annotation)','Annotation(time)']);              my ($text, $time, $user) = $annotation->Values(['Annotation(annotation)',
1421                                                                'Annotation(time)',
1422                                                                'MadeAnnotation(user)']);
1423              # 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.
1424              my ($user, $function) = _ParseAssignment($text);              my ($actualUser, $function) = _ParseAssignment($user, $text);
1425              if ($user) {              if ($actualUser) {
1426                  # Here it is a functional assignment.                  # Here it is a functional assignment.
1427                  push @retVal, [$user, $function];                  push @retVal, [$actualUser, $function];
1428              }              }
1429          }          }
1430      } else {      } else {
1431          # Here we have a non-FIG feature ID. In this case the user ID does not          # Here we have a non-FIG feature ID. In this case the user ID does not
1432          # matter. We simply get the information from the External Alias Function          # matter. We simply get the information from the External Alias Function
1433          # table.          # table.
1434          push @retVal, $self->GetEntityValues('ExternalAliasFunc', $featureID, ['ExternalAliasFunc(func)']);          my @assignments = $self->GetEntityValues('ExternalAliasFunc', $featureID,
1435                                                     ['ExternalAliasFunc(func)']);
1436            push @retVal, map { ['master', $_] } @assignments;
1437      }      }
1438      # Return the assignments found.      # Return the assignments found.
1439      return @retVal;      return @retVal;
# Line 1479  Line 1559 
1559      my $genomeData = $self->GetEntity('Genome', $genomeID);      my $genomeData = $self->GetEntity('Genome', $genomeID);
1560      if ($genomeData) {      if ($genomeData) {
1561          # The genome exists, so get the completeness flag.          # The genome exists, so get the completeness flag.
1562          ($retVal) = $genomeData->Value('complete');          ($retVal) = $genomeData->Value('Genome(complete)');
1563      }      }
1564      # Return the result.      # Return the result.
1565      return $retVal;      return $retVal;
# Line 1519  Line 1599 
1599    
1600  C<< my $genomeID = $sprout->GenomeOf($featureID); >>  C<< my $genomeID = $sprout->GenomeOf($featureID); >>
1601    
1602  Return the genome that contains a specified feature.  Return the genome that contains a specified feature or contig.
1603    
1604  =over 4  =over 4
1605    
1606  =item featureID  =item featureID
1607    
1608  ID of the feature whose genome is desired.  ID of the feature or contig whose genome is desired.
1609    
1610  =item RETURN  =item RETURN
1611    
1612  Returns the ID of the genome for the specified feature. If the feature is not found, returns  Returns the ID of the genome for the specified feature or contig. If the feature or contig is not
1613  an undefined value.  found, returns an undefined value.
1614    
1615  =back  =back
1616    
# Line 1539  Line 1619 
1619  sub GenomeOf {  sub GenomeOf {
1620      # Get the parameters.      # Get the parameters.
1621      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
1622      # Create a query to find the genome associated with the feature.      # Create a query to find the genome associated with the incoming ID.
1623      my $query = $self->Get(['IsLocatedIn', 'HasContig'], "IsLocatedIn(from-link) = ?", [$featureID]);      my $query = $self->Get(['IsLocatedIn', 'HasContig'], "IsLocatedIn(from-link) = ? OR HasContig(to-link) = ?",
1624                               [$featureID, $featureID]);
1625      # Declare the return value.      # Declare the return value.
1626      my $retVal;      my $retVal;
1627      # Get the genome ID.      # Get the genome ID.
# Line 1587  Line 1668 
1668          # Get the ID and score of the coupling.          # Get the ID and score of the coupling.
1669          my ($couplingID, $score) = $clustering->Values(['Coupling(id)',          my ($couplingID, $score) = $clustering->Values(['Coupling(id)',
1670                                                          'Coupling(score)']);                                                          'Coupling(score)']);
1671          # The coupling ID contains the two feature IDs separated by a space. We use          # Get the other feature that participates in the coupling.
1672          # this information to find the ID of the other feature.          my ($otherFeatureID) = $self->GetFlat(['ParticipatesInCoupling'],
1673          my ($fid1, $fid2) = split / /, $couplingID;                                             "ParticipatesInCoupling(to-link) = ? AND ParticipatesInCoupling(from-link) <> ?",
1674          my $otherFeatureID = ($featureID eq $fid1 ? $fid2 : $fid1);                                             [$couplingID, $featureID], 'ParticipatesInCoupling(from-link)');
1675          # Attach the other feature's score to its ID.          # Attach the other feature's score to its ID.
1676          $retVal{$otherFeatureID} = $score;          $retVal{$otherFeatureID} = $score;
1677          $found = 1;          $found = 1;
# Line 1723  Line 1804 
1804      my ($self, $peg1, $peg2) = @_;      my ($self, $peg1, $peg2) = @_;
1805      # Declare the return values. We'll start with the coupling ID and undefine the      # Declare the return values. We'll start with the coupling ID and undefine the
1806      # flag and score until we have more information.      # flag and score until we have more information.
1807      my ($retVal, $inverted, $score) = (CouplingID($peg1, $peg2), undef, undef);      my ($retVal, $inverted, $score) = ($self->CouplingID($peg1, $peg2), undef, undef);
1808      # Find the coupling data.      # Find the coupling data.
1809      my @pegs = $self->GetAll(['Coupling', 'ParticipatesInCoupling'],      my @pegs = $self->GetAll(['Coupling', 'ParticipatesInCoupling'],
1810                                   "Coupling(id) = ? ORDER BY ParticipatesInCoupling(pos)",                                   "Coupling(id) = ? ORDER BY ParticipatesInCoupling(pos)",
# Line 1746  Line 1827 
1827    
1828  =head3 CouplingID  =head3 CouplingID
1829    
1830  C<< my $couplingID = Sprout::CouplingID($peg1, $peg2); >>  C<< my $couplingID = $sprout->CouplingID($peg1, $peg2); >>
1831    
1832  Return the coupling ID for a pair of feature IDs.  Return the coupling ID for a pair of feature IDs.
1833    
# Line 1779  Line 1860 
1860  =cut  =cut
1861  #: Return Type $;  #: Return Type $;
1862  sub CouplingID {  sub CouplingID {
1863      return join " ", sort @_;      my ($self, @pegs) = @_;
1864  }      return $self->DigestKey(join " ", sort @pegs);
   
 =head3 GetEntityTypes  
   
 C<< my @entityList = $sprout->GetEntityTypes(); >>  
   
 Return the list of supported entity types.  
   
 =cut  
 #: Return Type @;  
 sub GetEntityTypes {  
     # Get the parameters.  
     my ($self) = @_;  
     # Get the underlying database object.  
     my $erdb = $self->{_erdb};  
     # Get its entity type list.  
     my @retVal = $erdb->GetEntityTypes();  
1865  }  }
1866    
1867  =head3 ReadFasta  =head3 ReadFasta
# Line 1944  Line 2009 
2009      # Get the data directory name.      # Get the data directory name.
2010      my $outputDirectory = $self->{_options}->{dataDir};      my $outputDirectory = $self->{_options}->{dataDir};
2011      # Dump the relations.      # Dump the relations.
2012      $self->{_erdb}->DumpRelations($outputDirectory);      $self->DumpRelations($outputDirectory);
2013  }  }
2014    
2015  =head3 XMLFileName  =head3 XMLFileName
# Line 1996  Line 2061 
2061      # Get the parameters.      # Get the parameters.
2062      my ($self, $objectType, $fieldHash) = @_;      my ($self, $objectType, $fieldHash) = @_;
2063      # Call the underlying method.      # Call the underlying method.
2064      $self->{_erdb}->InsertObject($objectType, $fieldHash);      $self->InsertObject($objectType, $fieldHash);
2065  }  }
2066    
2067  =head3 Annotate  =head3 Annotate
# Line 2155  Line 2220 
2220      return @retVal;      return @retVal;
2221  }  }
2222    
 =head3 Exists  
   
 C<< my $found = $sprout->Exists($entityName, $entityID); >>  
   
 Return TRUE if an entity exists, else FALSE.  
   
 =over 4  
   
 =item entityName  
   
 Name of the entity type (e.g. C<Feature>) relevant to the existence check.  
   
 =item entityID  
   
 ID of the entity instance whose existence is to be checked.  
   
 =item RETURN  
   
 Returns TRUE if the entity instance exists, else FALSE.  
   
 =back  
   
 =cut  
 #: Return Type $;  
 sub Exists {  
     # Get the parameters.  
     my ($self, $entityName, $entityID) = @_;  
     # Check for the entity instance.  
     Trace("Checking existence of $entityName with ID=$entityID.") if T(4);  
     my $testInstance = $self->GetEntity($entityName, $entityID);  
     # Return an existence indicator.  
     my $retVal = ($testInstance ? 1 : 0);  
     return $retVal;  
 }  
   
2223  =head3 FeatureTranslation  =head3 FeatureTranslation
2224    
2225  C<< my $translation = $sprout->FeatureTranslation($featureID); >>  C<< my $translation = $sprout->FeatureTranslation($featureID); >>
# Line 2828  Line 2858 
2858      return @retVal;      return @retVal;
2859  }  }
2860    
 =head3 GetAll  
   
 C<< my @list = $sprout->GetAll(\@objectNames, $filterClause, \@parameters, \@fields, $count); >>  
   
 Return a list of values taken from the objects returned by a query. The first three  
 parameters correspond to the parameters of the L</Get> method. The final parameter is  
 a list of the fields desired from each record found by the query. The field name  
 syntax is the standard syntax used for fields in the B<ERDB> system--  
 B<I<objectName>(I<fieldName>)>-- where I<objectName> is the name of the relevant entity  
 or relationship and I<fieldName> is the name of the field.  
   
 The list returned will be a list of lists. Each element of the list will contain  
 the values returned for the fields specified in the fourth parameter. If one of the  
 fields specified returns multiple values, they are flattened in with the rest. For  
 example, the following call will return a list of the features in a particular  
 spreadsheet cell, and each feature will be represented by a list containing the  
 feature ID followed by all of its aliases.  
   
 C<< $query = $sprout->Get(['ContainsFeature', 'Feature'], "ContainsFeature(from-link) = ?", [$ssCellID], ['Feature(id)', 'Feature(alias)']); >>  
   
 =over 4  
   
 =item objectNames  
   
 List containing the names of the entity and relationship objects to be retrieved.  
   
 =item filterClause  
   
 WHERE/ORDER BY clause (without the WHERE) to be used to filter and sort the query. The WHERE clause can  
 be parameterized with parameter markers (C<?>). Each field used must be specified in the standard form  
 B<I<objectName>(I<fieldName>)>. Any parameters specified in the filter clause should be added to the  
 parameter list as additional parameters. The fields in a filter clause can come from primary  
 entity relations, relationship relations, or secondary entity relations; however, all of the  
 entities and relationships involved must be included in the list of object names.  
   
 =item parameterList  
   
 List of the parameters to be substituted in for the parameters marks in the filter clause.  
   
 =item fields  
   
 List of the fields to be returned in each element of the list returned.  
   
 =item count  
   
 Maximum number of records to return. If omitted or 0, all available records will be returned.  
   
 =item RETURN  
   
 Returns a list of list references. Each element of the return list contains the values for the  
 fields specified in the B<fields> parameter.  
   
 =back  
   
 =cut  
 #: Return Type @@;  
 sub GetAll {  
     # Get the parameters.  
     my ($self, $objectNames, $filterClause, $parameterList, $fields, $count) = @_;  
     # Call the ERDB method.  
     my @retVal = $self->{_erdb}->GetAll($objectNames, $filterClause, $parameterList,  
                                         $fields, $count);  
     # Return the resulting list.  
     return @retVal;  
 }  
   
 =head3 GetFlat  
   
 C<< my @list = $sprout->GetFlat(\@objectNames, $filterClause, $parameterList, $field); >>  
   
 This is a variation of L</GetAll> that asks for only a single field per record and  
 returns a single flattened list.  
   
 =over 4  
   
 =item objectNames  
   
 List containing the names of the entity and relationship objects to be retrieved.  
   
 =item filterClause  
   
 WHERE/ORDER BY clause (without the WHERE) to be used to filter and sort the query. The WHERE clause can  
 be parameterized with parameter markers (C<?>). Each field used must be specified in the standard form  
 B<I<objectName>(I<fieldName>)>. Any parameters specified in the filter clause should be added to the  
 parameter list as additional parameters. The fields in a filter clause can come from primary  
 entity relations, relationship relations, or secondary entity relations; however, all of the  
 entities and relationships involved must be included in the list of object names.  
   
 =item parameterList  
   
 List of the parameters to be substituted in for the parameters marks in the filter clause.  
   
 =item field  
   
 Name of the field to be used to get the elements of the list returned.  
   
 =item RETURN  
   
 Returns a list of values.  
   
 =back  
   
 =cut  
 #: Return Type @;  
 sub GetFlat {  
     # Get the parameters.  
     my ($self, $objectNames, $filterClause, $parameterList, $field) = @_;  
     # Construct the query.  
     my $query = $self->Get($objectNames, $filterClause, $parameterList);  
     # Create the result list.  
     my @retVal = ();  
     # Loop through the records, adding the field values found to the result list.  
     while (my $row = $query->Fetch()) {  
         push @retVal, $row->Value($field);  
     }  
     # Return the list created.  
     return @retVal;  
 }  
   
2861  =head3 Protein  =head3 Protein
2862    
2863  C<< my $protein = Sprout::Protein($sequence, $table); >>  C<< my $protein = Sprout::Protein($sequence, $table); >>
# Line 3048  Line 2959 
2959      # Create the return list, priming it with the name of the data directory.      # Create the return list, priming it with the name of the data directory.
2960      my @retVal = ($self->{_options}->{dataDir});      my @retVal = ($self->{_options}->{dataDir});
2961      # Concatenate the table names.      # Concatenate the table names.
2962      push @retVal, $self->{_erdb}->GetTableNames();      push @retVal, $self->GetTableNames();
2963      # Return the result.      # Return the result.
2964      return @retVal;      return @retVal;
2965  }  }
2966    
2967  =head3 LowBBHs  =head3 LowBBHs
2968    
2969  C<< my %bbhMap = $sprout->GoodBBHs($featureID, $cutoff); >>  C<< my %bbhMap = $sprout->LowBBHs($featureID, $cutoff); >>
2970    
2971  Return the bidirectional best hits of a feature whose score is no greater than a  Return the bidirectional best hits of a feature whose score is no greater than a
2972  specified cutoff value. A higher cutoff value will allow inclusion of hits with  specified cutoff value. A higher cutoff value will allow inclusion of hits with
# Line 3097  Line 3008 
3008      return %retVal;      return %retVal;
3009  }  }
3010    
3011    =head3 Sims
3012    
3013    C<< my $simList = $sprout->Sims($fid, $maxN, $maxP, $select, $max_expand, $filters); >>
3014    
3015    Get a list of similarities for a specified feature. Similarity information is not kept in the
3016    Sprout database; rather, they are retrieved from a network server. The similarities are
3017    returned as B<Sim> objects. A Sim object is actually a list reference that has been blessed
3018    so that its elements can be accessed by name.
3019    
3020    Similarities can be either raw or expanded. The raw similarities are basic
3021    hits between features with similar DNA. Expanding a raw similarity drags in any
3022    features considered substantially identical. So, for example, if features B<A1>,
3023    B<A2>, and B<A3> are all substatially identical to B<A>, then a raw similarity
3024    B<[C,A]> would be expanded to B<[C,A] [C,A1] [C,A2] [C,A3]>.
3025    
3026    =over 4
3027    
3028    =item fid
3029    
3030    ID of the feature whose similarities are desired.
3031    
3032    =item maxN
3033    
3034    Maximum number of similarities to return.
3035    
3036    =item maxP
3037    
3038    Minumum allowable similarity score.
3039    
3040    =item select
3041    
3042    Selection criterion: C<raw> means only raw similarities are returned; C<fig>
3043    means only similarities to FIG features are returned; C<all> means all expanded
3044    similarities are returned; and C<figx> means similarities are expanded until the
3045    number of FIG features equals the maximum.
3046    
3047    =item max_expand
3048    
3049    The maximum number of features to expand.
3050    
3051    =item filters
3052    
3053    Reference to a hash containing filter information, or a subroutine that can be
3054    used to filter the sims.
3055    
3056    =item RETURN
3057    
3058    Returns a reference to a list of similarity objects, or C<undef> if an error
3059    occurred.
3060    
3061    =back
3062    
3063    =cut
3064    
3065    sub Sims {
3066        # Get the parameters.
3067        my ($self, $fid, $maxN, $maxP, $select, $max_expand, $filters) = @_;
3068        # Create the shim object to test for deleted FIDs.
3069        my $shim = FidCheck->new($self);
3070        # Ask the network for sims.
3071        my $retVal = FIGRules::GetNetworkSims($shim, $fid, {}, $maxN, $maxP, $select, $max_expand, $filters);
3072        # Return the result.
3073        return $retVal;
3074    }
3075    
3076  =head3 GetGroups  =head3 GetGroups
3077    
3078  C<< my %groups = $sprout->GetGroups(\@groupList); >>  C<< my %groups = $sprout->GetGroups(\@groupList); >>
# Line 3218  Line 3194 
3194      return $retVal;      return $retVal;
3195  }  }
3196    
3197    =head3 DeleteGenome
3198    
3199    C<< my $stats = $sprout->DeleteGenome($genomeID, $testFlag); >>
3200    
3201    Delete a genome from the database.
3202    
3203    =over 4
3204    
3205    =item genomeID
3206    
3207    ID of the genome to delete
3208    
3209    =item testFlag
3210    
3211    If TRUE, then the DELETE statements will be traced, but no deletions will occur.
3212    
3213    =item RETURN
3214    
3215    Returns a statistics object describing the rows deleted.
3216    
3217    =back
3218    
3219    =cut
3220    #: Return Type $%;
3221    sub DeleteGenome {
3222        # Get the parameters.
3223        my ($self, $genomeID, $testFlag) = @_;
3224        # Perform the delete for the genome's features.
3225        my $retVal = $self->Delete('Feature', "fig|$genomeID.%", $testFlag);
3226        # Perform the delete for the primary genome data.
3227        my $stats = $self->Delete('Genome', $genomeID, $testFlag);
3228        $retVal->Accumulate($stats);
3229        # Return the result.
3230        return $retVal;
3231    }
3232    
3233  =head2 Internal Utility Methods  =head2 Internal Utility Methods
3234    
3235  =head3 ParseAssignment  =head3 ParseAssignment
# Line 3228  Line 3240 
3240    
3241  A functional assignment is always of the form  A functional assignment is always of the form
3242    
3243      I<XXXX>C<\nset >I<YYYY>C< function to\n>I<ZZZZZ>      C<set >I<YYYY>C< function to\n>I<ZZZZZ>
3244    
3245    where I<YYYY> is the B<user>, and I<ZZZZ> is the actual functional role. In most cases,
3246    the user and the assigning user (from MadeAnnotation) will be the same, but that is
3247    not always the case.
3248    
3249  where I<XXXX> is the B<assigning user>, I<YYYY> is the B<user>, and I<ZZZZ> is the  In addition, the functional role may contain extra data that is stripped, such as
3250  actual functional role. In most cases, the user and the assigning user will be the  terminating spaces or a comment separated from the rest of the text by a tab.
 same, but that is not always the case.  
3251    
3252  This is a static method.  This is a static method.
3253    
3254  =over 4  =over 4
3255    
3256    =item user
3257    
3258    Name of the assigning user.
3259    
3260  =item text  =item text
3261    
3262  Text of the annotation.  Text of the annotation.
# Line 3253  Line 3272 
3272    
3273  sub _ParseAssignment {  sub _ParseAssignment {
3274      # Get the parameters.      # Get the parameters.
3275      my ($text) = @_;      my ($user, $text) = @_;
3276      # Declare the return value.      # Declare the return value.
3277      my @retVal = ();      my @retVal = ();
3278      # Check to see if this is a functional assignment.      # Check to see if this is a functional assignment.
3279      my ($type, $function) = split(/\n/, $text);      my ($type, $function) = split(/\n/, $text);
3280      if ($type =~ m/^set ([^ ]+) function to$/i) {      if ($type =~ m/^set function to$/i) {
3281          # Here it is, so we return the user name (which is in $1), the functional role text,          # Here we have an assignment without a user, so we use the incoming user ID.
3282          # and the assigning user.          @retVal = ($user, $function);
3283        } elsif ($type =~ m/^set (\S+) function to$/i) {
3284            # Here we have an assignment with a user that is passed back to the caller.
3285          @retVal = ($1, $function);          @retVal = ($1, $function);
3286      }      }
3287        # If we have an assignment, we need to clean the function text. There may be
3288        # extra junk at the end added as a note from the user.
3289        if (@retVal) {
3290            $retVal[1] =~ s/(\t\S)?\s*$//;
3291        }
3292      # Return the result list.      # Return the result list.
3293      return @retVal;      return @retVal;
3294  }  }
# Line 3351  Line 3377 
3377  }  }
3378    
3379    
   
3380  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3