[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.101, Mon Aug 20 23:29:24 2007 UTC revision 1.106, Wed Feb 6 23:21:02 2008 UTC
# Line 1  Line 1 
1  package Sprout;  package Sprout;
2    
     require Exporter;  
     use ERDB;  
     @ISA = qw(Exporter ERDB);  
3      use Data::Dumper;      use Data::Dumper;
4      use strict;      use strict;
5      use DBKernel;      use DBKernel;
# Line 17  Line 14 
14      use BasicLocation;      use BasicLocation;
15      use CustomAttributes;      use CustomAttributes;
16      use RemoteCustomAttributes;      use RemoteCustomAttributes;
17        use base qw(ERDB);
18    
19  =head1 Sprout Database Manipulation Object  =head1 Sprout Database Manipulation Object
20    
# Line 29  Line 27 
27  on the constructor. For example, the following invocation specifies a PostgreSQL database named I<GenDB>  on the constructor. For example, the following invocation specifies a PostgreSQL database named I<GenDB>
28  whose definition and data files are in a co-directory named F<Data>.  whose definition and data files are in a co-directory named F<Data>.
29    
30  C<< my $sprout = Sprout->new('GenDB', { dbType => 'pg', dataDir => '../Data', xmlFileName => '../Data/SproutDBD.xml' }); >>      my $sprout = Sprout->new('GenDB', { dbType => 'pg', dataDir => '../Data', xmlFileName => '../Data/SproutDBD.xml' });
31    
32  Once you have a sprout object, you may use it to re-create the database, load the tables from  Once you have a sprout object, you may use it to re-create the database, load the tables from
33  tab-delimited flat files and perform queries. Several special methods are provided for common  tab-delimited flat files and perform queries. Several special methods are provided for common
34  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
35  L</dna_seq> returns the DNA sequence for a specified genome location.  L</DNASeq> returns the DNA sequence for a specified genome location.
36    
37  The Sprout object is a subclass of the ERDB object and inherits all its properties and methods.  The Sprout object is a subclass of the ERDB object and inherits all its properties and methods.
38    
# Line 46  Line 44 
44    
45  =head3 new  =head3 new
46    
47  C<< my $sprout = Sprout->new($dbName, \%options); >>      my $sprout = Sprout->new($dbName, \%options);
48    
49  This is the constructor for a sprout object. It connects to the database and loads the  This is the constructor for a sprout object. It connects to the database and loads the
50  database definition into memory. The positional first parameter specifies the name of the  database definition into memory. The positional first parameter specifies the name of the
# Line 80  Line 78 
78    
79  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE
80    
81    * B<host> name of the database host
82    
83  =back  =back
84    
85  For example, the following constructor call specifies a database named I<Sprout> and a user name of  For example, the following constructor call specifies a database named I<Sprout> and a user name of
86  I<fig> with a password of I<admin>. The database load files are in the directory  I<fig> with a password of I<admin>. The database load files are in the directory
87  F</usr/fig/SproutData>.  F</usr/fig/SproutData>.
88    
89  C<< my $sprout = Sprout->new('Sprout', { userData =>; 'fig/admin', dataDir => '/usr/fig/SproutData' }); >>      my $sprout = Sprout->new('Sprout', { userData => 'fig/admin', dataDir => '/usr/fig/SproutData' });
90    
91  =cut  =cut
92    
# Line 110  Line 110 
110                         port         => $FIG_Config::dbport,                         port         => $FIG_Config::dbport,
111                                                          # database connection port                                                          # database connection port
112                         sock         => $FIG_Config::dbsock,                         sock         => $FIG_Config::dbsock,
113                         host         => $FIG_Config::dbhost,                         host         => $FIG_Config::sprout_host,
114                         maxSegmentLength => 4500,        # maximum feature segment length                         maxSegmentLength => 4500,        # maximum feature segment length
115                         maxSequenceLength => 8000,       # maximum contig sequence length                         maxSequenceLength => 8000,       # maximum contig sequence length
116                         noDBOpen     => 0,               # 1 to suppress the database open                         noDBOpen     => 0,               # 1 to suppress the database open
# Line 123  Line 123 
123      # Connect to the database.      # Connect to the database.
124      my $dbh;      my $dbh;
125      if (! $optionTable->{noDBOpen}) {      if (! $optionTable->{noDBOpen}) {
126            Trace("Connect data: host = $optionTable->{host}, port = $optionTable->{port}.") if T(3);
127          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,
128                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});
129      }      }
# Line 149  Line 150 
150      return $retVal;      return $retVal;
151  }  }
152    
153    =head3 RealCoreGenomes
154    
155        my @genomes = $sprout->RealCoreGenomes();
156    
157    Return the IDs of the original core NMPDR genomes. These are the ones
158    in the major groups indicated in the C<@realCoreGroups> member of the
159    B<FIG_Config> file.
160    
161    =cut
162    
163    sub RealCoreGenomes {
164        # Get the parameters.
165        my ($self) = @_;
166        # Declare the return variable.
167        my @retVal = ();
168        # Get the hash of all the genome groups.
169        my %groups = $self->GetGroups();
170        # Loop through the groups, keeping the ones that belong to real core
171        # organisms.
172        for my $group (keys %groups) {
173            if (grep { $group =~ /$_/ } @FIG_Config::realCoreGroups) {
174                push @retVal, @{$groups{$group}};
175            }
176        }
177        # Return the result.
178        return @retVal;
179    }
180    
181  =head3 MaxSegment  =head3 MaxSegment
182    
183  C<< my $length = $sprout->MaxSegment(); >>      my $length = $sprout->MaxSegment();
184    
185  This method returns the maximum permissible length of a feature segment. The length is important  This method returns the maximum permissible length of a feature segment. The length is important
186  because it enables us to make reasonable guesses at how to find features inside a particular  because it enables us to make reasonable guesses at how to find features inside a particular
# Line 168  Line 197 
197    
198  =head3 MaxSequence  =head3 MaxSequence
199    
200  C<< my $length = $sprout->MaxSequence(); >>      my $length = $sprout->MaxSequence();
201    
202  This method returns the maximum permissible length of a contig sequence. A contig is broken  This method returns the maximum permissible length of a contig sequence. A contig is broken
203  into sequences in order to save memory resources. In particular, when manipulating features,  into sequences in order to save memory resources. In particular, when manipulating features,
# Line 183  Line 212 
212    
213  =head3 Load  =head3 Load
214    
215  C<< $sprout->Load($rebuild); >>;      $sprout->Load($rebuild);;
216    
217  Load the database from files in the data directory, optionally re-creating the tables.  Load the database from files in the data directory, optionally re-creating the tables.
218    
# Line 223  Line 252 
252    
253  =head3 LoadUpdate  =head3 LoadUpdate
254    
255  C<< my $stats = $sprout->LoadUpdate($truncateFlag, \@tableList); >>      my $stats = $sprout->LoadUpdate($truncateFlag, \@tableList);
256    
257  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
258  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 269  Line 298 
298              Trace("No load file found for $tableName in $dataDir.") if T(0);              Trace("No load file found for $tableName in $dataDir.") if T(0);
299          } else {          } else {
300              # Attempt to load this table.              # Attempt to load this table.
301              my $result = $self->LoadTable($fileName, $tableName, $truncateFlag);              my $result = $self->LoadTable($fileName, $tableName, truncate => $truncateFlag);
302              # Accumulate the resulting statistics.              # Accumulate the resulting statistics.
303              $retVal->Accumulate($result);              $retVal->Accumulate($result);
304          }          }
# Line 280  Line 309 
309    
310  =head3 GenomeCounts  =head3 GenomeCounts
311    
312  C<< my ($arch, $bact, $euk, $vir, $env, $unk) = $sprout->GenomeCounts($complete); >>      my ($arch, $bact, $euk, $vir, $env, $unk) = $sprout->GenomeCounts($complete);
313    
314  Count the number of genomes in each domain. If I<$complete> is TRUE, only complete  Count the number of genomes in each domain. If I<$complete> is TRUE, only complete
315  genomes will be included in the counts.  genomes will be included in the counts.
# Line 325  Line 354 
354    
355  =head3 ContigCount  =head3 ContigCount
356    
357  C<< my $count = $sprout->ContigCount($genomeID); >>      my $count = $sprout->ContigCount($genomeID);
358    
359  Return the number of contigs for the specified genome ID.  Return the number of contigs for the specified genome ID.
360    
# Line 354  Line 383 
383    
384  =head3 GeneMenu  =head3 GeneMenu
385    
386  C<< my $selectHtml = $sprout->GeneMenu(\%attributes, $filterString, \@params, $selected); >>      my $selectHtml = $sprout->GeneMenu(\%attributes, $filterString, \@params, $selected);
387    
388  Return an HTML select menu of genomes. Each genome will be an option in the menu,  Return an HTML select menu of genomes. Each genome will be an option in the menu,
389  and will be displayed by name with the ID and a contig count attached. The selection  and will be displayed by name with the ID and a contig count attached. The selection
# Line 435  Line 464 
464    
465  =head3 Build  =head3 Build
466    
467  C<< $sprout->Build(); >>      $sprout->Build();
468    
469  Build the database. The database will be cleared and the tables re-created from the metadata.  Build the database. The database will be cleared and the tables re-created from the metadata.
470  This method is useful when a database is brand new or when the database definition has  This method is useful when a database is brand new or when the database definition has
# Line 452  Line 481 
481    
482  =head3 Genomes  =head3 Genomes
483    
484  C<< my @genomes = $sprout->Genomes(); >>      my @genomes = $sprout->Genomes();
485    
486  Return a list of all the genome IDs.  Return a list of all the genome IDs.
487    
# Line 469  Line 498 
498    
499  =head3 GenusSpecies  =head3 GenusSpecies
500    
501  C<< my $infoString = $sprout->GenusSpecies($genomeID); >>      my $infoString = $sprout->GenusSpecies($genomeID);
502    
503  Return the genus, species, and unique characterization for a genome.  Return the genus, species, and unique characterization for a genome.
504    
# Line 501  Line 530 
530    
531  =head3 FeaturesOf  =head3 FeaturesOf
532    
533  C<< my @features = $sprout->FeaturesOf($genomeID, $ftype); >>      my @features = $sprout->FeaturesOf($genomeID, $ftype);
534    
535  Return a list of the features relevant to a specified genome.  Return a list of the features relevant to a specified genome.
536    
# Line 546  Line 575 
575    
576  =head3 FeatureLocation  =head3 FeatureLocation
577    
578  C<< my @locations = $sprout->FeatureLocation($featureID); >>      my @locations = $sprout->FeatureLocation($featureID);
579    
580  Return the location of a feature in its genome's contig segments. In a list context, this method  Return the location of a feature in its genome's contig segments. In a list context, this method
581  will return a list of the locations. In a scalar context, it will return the locations as a space-  will return a list of the locations. In a scalar context, it will return the locations as a space-
# Line 592  Line 621 
621    
622  =head3 ParseLocation  =head3 ParseLocation
623    
624  C<< my ($contigID, $start, $dir, $len) = Sprout::ParseLocation($location); >>      my ($contigID, $start, $dir, $len) = Sprout::ParseLocation($location);
625    
626  Split a location specifier into the contig ID, the starting point, the direction, and the  Split a location specifier into the contig ID, the starting point, the direction, and the
627  length.  length.
# Line 638  Line 667 
667    
668  =head3 PointLocation  =head3 PointLocation
669    
670  C<< my $found = Sprout::PointLocation($location, $point); >>      my $found = Sprout::PointLocation($location, $point);
671    
672  Return the offset into the specified location of the specified point on the contig. If  Return the offset into the specified location of the specified point on the contig. If
673  the specified point is before the location, a negative value will be returned. If it is  the specified point is before the location, a negative value will be returned. If it is
# Line 690  Line 719 
719    
720  =head3 DNASeq  =head3 DNASeq
721    
722  C<< my $sequence = $sprout->DNASeq(\@locationList); >>      my $sequence = $sprout->DNASeq(\@locationList);
723    
724  This method returns the DNA sequence represented by a list of locations. The list of locations  This method returns the DNA sequence represented by a list of locations. The list of locations
725  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,
# Line 774  Line 803 
803    
804  =head3 AllContigs  =head3 AllContigs
805    
806  C<< my @idList = $sprout->AllContigs($genomeID); >>      my @idList = $sprout->AllContigs($genomeID);
807    
808  Return a list of all the contigs for a genome.  Return a list of all the contigs for a genome.
809    
# Line 804  Line 833 
833    
834  =head3 GenomeLength  =head3 GenomeLength
835    
836  C<< my $length = $sprout->GenomeLength($genomeID); >>      my $length = $sprout->GenomeLength($genomeID);
837    
838  Return the length of the specified genome in base pairs.  Return the length of the specified genome in base pairs.
839    
# Line 839  Line 868 
868    
869  =head3 FeatureCount  =head3 FeatureCount
870    
871  C<< my $count = $sprout->FeatureCount($genomeID, $type); >>      my $count = $sprout->FeatureCount($genomeID, $type);
872    
873  Return the number of features of the specified type in the specified genome.  Return the number of features of the specified type in the specified genome.
874    
# Line 874  Line 903 
903    
904  =head3 GenomeAssignments  =head3 GenomeAssignments
905    
906  C<< my $fidHash = $sprout->GenomeAssignments($genomeID); >>      my $fidHash = $sprout->GenomeAssignments($genomeID);
907    
908  Return a list of a genome's assigned features. The return hash will contain each  Return a list of a genome's assigned features. The return hash will contain each
909  assigned feature of the genome mapped to the text of its most recent functional  assigned feature of the genome mapped to the text of its most recent functional
# Line 917  Line 946 
946    
947  =head3 ContigLength  =head3 ContigLength
948    
949  C<< my $length = $sprout->ContigLength($contigID); >>      my $length = $sprout->ContigLength($contigID);
950    
951  Compute the length of a contig.  Compute the length of a contig.
952    
# Line 956  Line 985 
985    
986  =head3 ClusterPEGs  =head3 ClusterPEGs
987    
988  C<< my $clusteredList = $sprout->ClusterPEGs($sub, \@pegs); >>      my $clusteredList = $sprout->ClusterPEGs($sub, \@pegs);
989    
990  Cluster the PEGs in a list according to the cluster coding scheme of the specified  Cluster the PEGs in a list according to the cluster coding scheme of the specified
991  subsystem. In order for this to work properly, the subsystem object must have  subsystem. In order for this to work properly, the subsystem object must have
992  been used recently to retrieve the PEGs using the B<get_pegs_from_cell> method.  been used recently to retrieve the PEGs using the B<get_pegs_from_cell> or
993  This causes the cluster numbers to be pulled into the subsystem's color hash.  B<get_row> methods. This causes the cluster numbers to be pulled into the
994  If a PEG is not found in the color hash, it will not appear in the output  subsystem's color hash. If a PEG is not found in the color hash, it will not
995  sequence.  appear in the output sequence.
996    
997  =over 4  =over 4
998    
# Line 1004  Line 1033 
1033    
1034  =head3 GenesInRegion  =head3 GenesInRegion
1035    
1036  C<< my (\@featureIDList, $beg, $end) = $sprout->GenesInRegion($contigID, $start, $stop); >>      my (\@featureIDList, $beg, $end) = $sprout->GenesInRegion($contigID, $start, $stop);
1037    
1038  List the features which overlap a specified region in a contig.  List the features which overlap a specified region in a contig.
1039    
# Line 1085  Line 1114 
1114    
1115  =head3 GeneDataInRegion  =head3 GeneDataInRegion
1116    
1117  C<< my @featureList = $sprout->GenesInRegion($contigID, $start, $stop); >>      my @featureList = $sprout->GenesInRegion($contigID, $start, $stop);
1118    
1119  List the features which overlap a specified region in a contig.  List the features which overlap a specified region in a contig.
1120    
# Line 1156  Line 1185 
1185    
1186  =head3 FType  =head3 FType
1187    
1188  C<< my $ftype = $sprout->FType($featureID); >>      my $ftype = $sprout->FType($featureID);
1189    
1190  Return the type of a feature.  Return the type of a feature.
1191    
# Line 1186  Line 1215 
1215    
1216  =head3 FeatureAnnotations  =head3 FeatureAnnotations
1217    
1218  C<< my @descriptors = $sprout->FeatureAnnotations($featureID, $rawFlag); >>      my @descriptors = $sprout->FeatureAnnotations($featureID, $rawFlag);
1219    
1220  Return the annotations of a feature.  Return the annotations of a feature.
1221    
# Line 1249  Line 1278 
1278    
1279  =head3 AllFunctionsOf  =head3 AllFunctionsOf
1280    
1281  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>      my %functions = $sprout->AllFunctionsOf($featureID);
1282    
1283  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
1284  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,
# Line 1304  Line 1333 
1333    
1334  =head3 FunctionOf  =head3 FunctionOf
1335    
1336  C<< my $functionText = $sprout->FunctionOf($featureID, $userID); >>      my $functionText = $sprout->FunctionOf($featureID, $userID);
1337    
1338  Return the most recently-determined functional assignment of a particular feature.  Return the most recently-determined functional assignment of a particular feature.
1339    
# Line 1408  Line 1437 
1437    
1438  =head3 FunctionsOf  =head3 FunctionsOf
1439    
1440  C<< my @functionList = $sprout->FunctionOf($featureID, $userID); >>      my @functionList = $sprout->FunctionOf($featureID, $userID);
1441    
1442  Return the functional assignments of a particular feature.  Return the functional assignments of a particular feature.
1443    
# Line 1480  Line 1509 
1509    
1510  =head3 BBHList  =head3 BBHList
1511    
1512  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>      my $bbhHash = $sprout->BBHList($genomeID, \@featureList);
1513    
1514  Return a hash mapping the features in a specified list to their bidirectional best hits  Return a hash mapping the features in a specified list to their bidirectional best hits
1515  on a specified target genome.  on a specified target genome.
# Line 1530  Line 1559 
1559    
1560  =head3 SimList  =head3 SimList
1561    
1562  C<< my %similarities = $sprout->SimList($featureID, $count); >>      my %similarities = $sprout->SimList($featureID, $count);
1563    
1564  Return a list of the similarities to the specified feature.  Return a list of the similarities to the specified feature.
1565    
# Line 1566  Line 1595 
1595    
1596  =head3 IsComplete  =head3 IsComplete
1597    
1598  C<< my $flag = $sprout->IsComplete($genomeID); >>      my $flag = $sprout->IsComplete($genomeID);
1599    
1600  Return TRUE if the specified genome is complete, else FALSE.  Return TRUE if the specified genome is complete, else FALSE.
1601    
# Line 1602  Line 1631 
1631    
1632  =head3 FeatureAliases  =head3 FeatureAliases
1633    
1634  C<< my @aliasList = $sprout->FeatureAliases($featureID); >>      my @aliasList = $sprout->FeatureAliases($featureID);
1635    
1636  Return a list of the aliases for a specified feature.  Return a list of the aliases for a specified feature.
1637    
# Line 1632  Line 1661 
1661    
1662  =head3 GenomeOf  =head3 GenomeOf
1663    
1664  C<< my $genomeID = $sprout->GenomeOf($featureID); >>      my $genomeID = $sprout->GenomeOf($featureID);
1665    
1666  Return the genome that contains a specified feature or contig.  Return the genome that contains a specified feature or contig.
1667    
# Line 1668  Line 1697 
1697    
1698  =head3 CoupledFeatures  =head3 CoupledFeatures
1699    
1700  C<< my %coupleHash = $sprout->CoupledFeatures($featureID); >>      my %coupleHash = $sprout->CoupledFeatures($featureID);
1701    
1702  Return the features functionally coupled with a specified feature. Features are considered  Return the features functionally coupled with a specified feature. Features are considered
1703  functionally coupled if they tend to be clustered on the same chromosome.  functionally coupled if they tend to be clustered on the same chromosome.
# Line 1715  Line 1744 
1744    
1745  =head3 CouplingEvidence  =head3 CouplingEvidence
1746    
1747  C<< my @evidence = $sprout->CouplingEvidence($peg1, $peg2); >>      my @evidence = $sprout->CouplingEvidence($peg1, $peg2);
1748    
1749  Return the evidence for a functional coupling.  Return the evidence for a functional coupling.
1750    
# Line 1777  Line 1806 
1806    
1807  =head3 GetSynonymGroup  =head3 GetSynonymGroup
1808    
1809  C<< my $id = $sprout->GetSynonymGroup($fid); >>      my $id = $sprout->GetSynonymGroup($fid);
1810    
1811  Return the synonym group name for the specified feature.  Return the synonym group name for the specified feature.
1812    
# Line 1816  Line 1845 
1845    
1846  =head3 GetBoundaries  =head3 GetBoundaries
1847    
1848  C<< my ($contig, $beg, $end) = $sprout->GetBoundaries(@locList); >>      my ($contig, $beg, $end) = $sprout->GetBoundaries(@locList);
1849    
1850  Determine the begin and end boundaries for the locations in a list. All of the  Determine the begin and end boundaries for the locations in a list. All of the
1851  locations must belong to the same contig and have mostly the same direction in  locations must belong to the same contig and have mostly the same direction in
# Line 1880  Line 1909 
1909    
1910  =head3 ReadFasta  =head3 ReadFasta
1911    
1912  C<< my %sequenceData = Sprout::ReadFasta($fileName, $prefix); >>      my %sequenceData = Sprout::ReadFasta($fileName, $prefix);
1913    
1914  Read sequence data from a FASTA-format file. Each sequence in a FASTA file is represented by  Read sequence data from a FASTA-format file. Each sequence in a FASTA file is represented by
1915  one or more lines of data. The first line begins with a > character and contains an ID.  one or more lines of data. The first line begins with a > character and contains an ID.
# Line 1946  Line 1975 
1975    
1976  =head3 FormatLocations  =head3 FormatLocations
1977    
1978  C<< my @locations = $sprout->FormatLocations($prefix, \@locations, $oldFormat); >>      my @locations = $sprout->FormatLocations($prefix, \@locations, $oldFormat);
1979    
1980  Insure that a list of feature locations is in the Sprout format. The Sprout feature location  Insure that a list of feature locations is in the Sprout format. The Sprout feature location
1981  format is I<contig>_I<beg*len> where I<*> is C<+> for a forward gene and C<-> for a backward  format is I<contig>_I<beg*len> where I<*> is C<+> for a forward gene and C<-> for a backward
# Line 2011  Line 2040 
2040    
2041  =head3 DumpData  =head3 DumpData
2042    
2043  C<< $sprout->DumpData(); >>      $sprout->DumpData();
2044    
2045  Dump all the tables to tab-delimited DTX files. The files will be stored in the data directory.  Dump all the tables to tab-delimited DTX files. The files will be stored in the data directory.
2046    
# Line 2028  Line 2057 
2057    
2058  =head3 XMLFileName  =head3 XMLFileName
2059    
2060  C<< my $fileName = $sprout->XMLFileName(); >>      my $fileName = $sprout->XMLFileName();
2061    
2062  Return the name of this database's XML definition file.  Return the name of this database's XML definition file.
2063    
# Line 2039  Line 2068 
2068      return $self->{_xmlName};      return $self->{_xmlName};
2069  }  }
2070    
2071    =head3 GetGenomeNameData
2072    
2073        my ($genus, $species, $strain) = $sprout->GenomeNameData($genomeID);
2074    
2075    Return the genus, species, and unique characterization for a genome. This
2076    is similar to L</GenusSpecies>, with the exception that it returns the
2077    values in three seperate fields.
2078    
2079    =over 4
2080    
2081    =item genomeID
2082    
2083    ID of the genome whose name data is desired.
2084    
2085    =item RETURN
2086    
2087    Returns a three-element list, consisting of the genus, species, and strain
2088    of the specified genome. If the genome is not found, an error occurs.
2089    
2090    =back
2091    
2092    =cut
2093    
2094    sub GetGenomeNameData {
2095        # Get the parameters.
2096        my ($self, $genomeID) = @_;
2097        # Get the desired values.
2098        my ($genus, $species, $strain) = $self->GetEntityValues('Genome', $genomeID =>
2099                                                                [qw(Genome(genus) Genome(species) Genome(unique-characterization))]);
2100        # Throw an error if they were not found.
2101        if (! defined $genus) {
2102            Confess("Genome $genomeID not found in database.");
2103        }
2104        # Return the results.
2105        return ($genus, $species, $strain);
2106    }
2107    
2108    =head3 GetGenomeByNameData
2109    
2110        my @genomes = $sprout->GetGenomeByNameData($genus, $species, $strain);
2111    
2112    Return a list of the IDs of the genomes with the specified genus,
2113    species, and strain. In almost every case, there will be either zero or
2114    one IDs returned; however, two or more IDs could be returned if there are
2115    multiple versions of the genome in the database.
2116    
2117    =over 4
2118    
2119    =item genus
2120    
2121    Genus of the desired genome.
2122    
2123    =item species
2124    
2125    Species of the desired genome.
2126    
2127    =item strain
2128    
2129    Strain (unique characterization) of the desired genome. This may be an empty
2130    string, in which case it is presumed that the desired genome has no strain
2131    specified.
2132    
2133    =item RETURN
2134    
2135    Returns a list of the IDs of the genomes having the specified genus, species, and
2136    strain.
2137    
2138    =back
2139    
2140    =cut
2141    
2142    sub GetGenomeByNameData {
2143        # Get the parameters.
2144        my ($self, $genus, $species, $strain) = @_;
2145        # Try to find the genomes.
2146        my @retVal = $self->GetFlat(['Genome'], "Genome(genus) = ? AND Genome(species) = ? AND Genome(unique-characterization) = ?",
2147                                    [$genus, $species, $strain], 'Genome(id)');
2148        # Return the result.
2149        return @retVal;
2150    }
2151    
2152  =head3 Insert  =head3 Insert
2153    
2154  C<< $sprout->Insert($objectType, \%fieldHash); >>      $sprout->Insert($objectType, \%fieldHash);
2155    
2156  Insert an entity or relationship instance into the database. The entity or relationship of interest  Insert an entity or relationship instance into the database. The entity or relationship of interest
2157  is defined by a type name and then a hash of field names to values. Field values in the primary  is defined by a type name and then a hash of field names to values. Field values in the primary
# Line 2050  Line 2160 
2160  list references. For example, the following line inserts an inactive PEG feature named  list references. For example, the following line inserts an inactive PEG feature named
2161  C<fig|188.1.peg.1> with aliases C<ZP_00210270.1> and C<gi|46206278>.  C<fig|188.1.peg.1> with aliases C<ZP_00210270.1> and C<gi|46206278>.
2162    
2163  C<< $sprout->Insert('Feature', { id => 'fig|188.1.peg.1', active => 0, feature-type => 'peg', alias => ['ZP_00210270.1', 'gi|46206278']}); >>      $sprout->Insert('Feature', { id => 'fig|188.1.peg.1', active => 0, feature-type => 'peg', alias => ['ZP_00210270.1', 'gi|46206278']});
2164    
2165  The next statement inserts a C<HasProperty> relationship between feature C<fig|158879.1.peg.1> and  The next statement inserts a C<HasProperty> relationship between feature C<fig|158879.1.peg.1> and
2166  property C<4> with an evidence URL of C<http://seedu.uchicago.edu/query.cgi?article_id=142>.  property C<4> with an evidence URL of C<http://seedu.uchicago.edu/query.cgi?article_id=142>.
2167    
2168  C<< $sprout->InsertObject('HasProperty', { 'from-link' => 'fig|158879.1.peg.1', 'to-link' => 4, evidence => 'http://seedu.uchicago.edu/query.cgi?article_id=142'}); >>      $sprout->InsertObject('HasProperty', { 'from-link' => 'fig|158879.1.peg.1', 'to-link' => 4, evidence => 'http://seedu.uchicago.edu/query.cgi?article_id=142'});
2169    
2170  =over 4  =over 4
2171    
# Line 2080  Line 2190 
2190    
2191  =head3 Annotate  =head3 Annotate
2192    
2193  C<< my $ok = $sprout->Annotate($fid, $timestamp, $user, $text); >>      my $ok = $sprout->Annotate($fid, $timestamp, $user, $text);
2194    
2195  Annotate a feature. This inserts an Annotation record into the database and links it to the  Annotate a feature. This inserts an Annotation record into the database and links it to the
2196  specified feature and user.  specified feature and user.
# Line 2134  Line 2244 
2244    
2245  =head3 AssignFunction  =head3 AssignFunction
2246    
2247  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser); >>      my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser);
2248    
2249  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
2250  format is described in L</ParseAssignment>.  format is described in L</ParseAssignment>.
# Line 2194  Line 2304 
2304    
2305  =head3 FeaturesByAlias  =head3 FeaturesByAlias
2306    
2307  C<< my @features = $sprout->FeaturesByAlias($alias); >>      my @features = $sprout->FeaturesByAlias($alias);
2308    
2309  Returns a list of features with the specified alias. The alias is parsed to determine  Returns a list of features with the specified alias. The alias is parsed to determine
2310  the type of the alias. A string of digits is a GenBack ID and a string of exactly 6  the type of the alias. A string of digits is a GenBack ID and a string of exactly 6
# Line 2236  Line 2346 
2346    
2347  =head3 FeatureTranslation  =head3 FeatureTranslation
2348    
2349  C<< my $translation = $sprout->FeatureTranslation($featureID); >>      my $translation = $sprout->FeatureTranslation($featureID);
2350    
2351  Return the translation of a feature.  Return the translation of a feature.
2352    
# Line 2264  Line 2374 
2374    
2375  =head3 Taxonomy  =head3 Taxonomy
2376    
2377  C<< my @taxonomyList = $sprout->Taxonomy($genome); >>      my @taxonomyList = $sprout->Taxonomy($genome);
2378    
2379  Return the taxonomy of the specified genome. This will be in the form of a list  Return the taxonomy of the specified genome. This will be in the form of a list
2380  containing the various classifications in order from domain (eg. C<Bacteria>, C<Archaea>,  containing the various classifications in order from domain (eg. C<Bacteria>, C<Archaea>,
2381  or C<Eukaryote>) to sub-species. For example,  or C<Eukaryote>) to sub-species. For example,
2382    
2383  C<< (Bacteria, Proteobacteria, Gammaproteobacteria, Enterobacteriales, Enterobacteriaceae, Escherichia, Escherichia coli, Escherichia coli K12) >>      (Bacteria, Proteobacteria, Gammaproteobacteria, Enterobacteriales, Enterobacteriaceae, Escherichia, Escherichia coli, Escherichia coli K12)
2384    
2385  =over 4  =over 4
2386    
# Line 2305  Line 2415 
2415    
2416  =head3 CrudeDistance  =head3 CrudeDistance
2417    
2418  C<< my $distance = $sprout->CrudeDistance($genome1, $genome2); >>      my $distance = $sprout->CrudeDistance($genome1, $genome2);
2419    
2420  Returns a crude estimate of the distance between two genomes. The distance is construed so  Returns a crude estimate of the distance between two genomes. The distance is construed so
2421  that it will be 0 for genomes with identical taxonomies and 1 for genomes from different domains.  that it will be 0 for genomes with identical taxonomies and 1 for genomes from different domains.
# Line 2357  Line 2467 
2467    
2468  =head3 RoleName  =head3 RoleName
2469    
2470  C<< my $roleName = $sprout->RoleName($roleID); >>      my $roleName = $sprout->RoleName($roleID);
2471    
2472  Return the descriptive name of the role with the specified ID. In general, a role  Return the descriptive name of the role with the specified ID. In general, a role
2473  will only have a descriptive name if it is coded as an EC number.  will only have a descriptive name if it is coded as an EC number.
# Line 2391  Line 2501 
2501    
2502  =head3 RoleDiagrams  =head3 RoleDiagrams
2503    
2504  C<< my @diagrams = $sprout->RoleDiagrams($roleID); >>      my @diagrams = $sprout->RoleDiagrams($roleID);
2505    
2506  Return a list of the diagrams containing a specified functional role.  Return a list of the diagrams containing a specified functional role.
2507    
# Line 2421  Line 2531 
2531    
2532  =head3 GetProperties  =head3 GetProperties
2533    
2534  C<< my @list = $sprout->GetProperties($fid, $key, $value, $url); >>      my @list = $sprout->GetProperties($fid, $key, $value, $url);
2535    
2536  Return a list of the properties with the specified characteristics.  Return a list of the properties with the specified characteristics.
2537    
# Line 2507  Line 2617 
2617    
2618  =head3 FeatureProperties  =head3 FeatureProperties
2619    
2620  C<< my @properties = $sprout->FeatureProperties($featureID); >>      my @properties = $sprout->FeatureProperties($featureID);
2621    
2622  Return a list of the properties for the specified feature. Properties are key-value pairs  Return a list of the properties for the specified feature. Properties are key-value pairs
2623  that specify special characteristics of the feature. For example, a property could indicate  that specify special characteristics of the feature. For example, a property could indicate
# Line 2546  Line 2656 
2656    
2657  =head3 DiagramName  =head3 DiagramName
2658    
2659  C<< my $diagramName = $sprout->DiagramName($diagramID); >>      my $diagramName = $sprout->DiagramName($diagramID);
2660    
2661  Return the descriptive name of a diagram.  Return the descriptive name of a diagram.
2662    
# Line 2574  Line 2684 
2684    
2685  =head3 PropertyID  =head3 PropertyID
2686    
2687  C<< my $id = $sprout->PropertyID($propName, $propValue); >>      my $id = $sprout->PropertyID($propName, $propValue);
2688    
2689  Return the ID of the specified property name and value pair, if the  Return the ID of the specified property name and value pair, if the
2690  pair exists. Only a small subset of the FIG attributes are stored as  pair exists. Only a small subset of the FIG attributes are stored as
# Line 2611  Line 2721 
2721    
2722  =head3 MergedAnnotations  =head3 MergedAnnotations
2723    
2724  C<< my @annotationList = $sprout->MergedAnnotations(\@list); >>      my @annotationList = $sprout->MergedAnnotations(\@list);
2725    
2726  Returns a merged list of the annotations for the features in a list. Each annotation is  Returns a merged list of the annotations for the features in a list. Each annotation is
2727  represented by a 4-tuple of the form C<($fid, $timestamp, $userID, $annotation)>, where  represented by a 4-tuple of the form C<($fid, $timestamp, $userID, $annotation)>, where
# Line 2660  Line 2770 
2770    
2771  =head3 RoleNeighbors  =head3 RoleNeighbors
2772    
2773  C<< my @roleList = $sprout->RoleNeighbors($roleID); >>      my @roleList = $sprout->RoleNeighbors($roleID);
2774    
2775  Returns a list of the roles that occur in the same diagram as the specified role. Because  Returns a list of the roles that occur in the same diagram as the specified role. Because
2776  diagrams and roles are in a many-to-many relationship with each other, the list is  diagrams and roles are in a many-to-many relationship with each other, the list is
# Line 2703  Line 2813 
2813    
2814  =head3 FeatureLinks  =head3 FeatureLinks
2815    
2816  C<< my @links = $sprout->FeatureLinks($featureID); >>      my @links = $sprout->FeatureLinks($featureID);
2817    
2818  Return a list of the web hyperlinks associated with a feature. The web hyperlinks are  Return a list of the web hyperlinks associated with a feature. The web hyperlinks are
2819  to external websites describing either the feature itself or the organism containing it  to external websites describing either the feature itself or the organism containing it
# Line 2734  Line 2844 
2844    
2845  =head3 SubsystemsOf  =head3 SubsystemsOf
2846    
2847  C<< my %subsystems = $sprout->SubsystemsOf($featureID); >>      my %subsystems = $sprout->SubsystemsOf($featureID);
2848    
2849  Return a hash describing all the subsystems in which a feature participates. Each subsystem is mapped  Return a hash describing all the subsystems in which a feature participates. Each subsystem is mapped
2850  to the roles the feature performs.  to the roles the feature performs.
# Line 2782  Line 2892 
2892    
2893  =head3 SubsystemList  =head3 SubsystemList
2894    
2895  C<< my @subsystems = $sprout->SubsystemList($featureID); >>      my @subsystems = $sprout->SubsystemList($featureID);
2896    
2897  Return a list containing the names of the subsystems in which the specified  Return a list containing the names of the subsystems in which the specified
2898  feature participates. Unlike L</SubsystemsOf>, this method only returns the  feature participates. Unlike L</SubsystemsOf>, this method only returns the
# Line 2814  Line 2924 
2924    
2925  =head3 GenomeSubsystemData  =head3 GenomeSubsystemData
2926    
2927  C<< my %featureData = $sprout->GenomeSubsystemData($genomeID); >>      my %featureData = $sprout->GenomeSubsystemData($genomeID);
2928    
2929  Return a hash mapping genome features to their subsystem roles.  Return a hash mapping genome features to their subsystem roles.
2930    
# Line 2874  Line 2984 
2984    
2985  =head3 RelatedFeatures  =head3 RelatedFeatures
2986    
2987  C<< my @relatedList = $sprout->RelatedFeatures($featureID, $function, $userID); >>      my @relatedList = $sprout->RelatedFeatures($featureID, $function, $userID);
2988    
2989  Return a list of the features which are bi-directional best hits of the specified feature and  Return a list of the features which are bi-directional best hits of the specified feature and
2990  have been assigned the specified function by the specified user. If no such features exists,  have been assigned the specified function by the specified user. If no such features exists,
# Line 2925  Line 3035 
3035    
3036  =head3 TaxonomySort  =head3 TaxonomySort
3037    
3038  C<< my @sortedFeatureIDs = $sprout->TaxonomySort(\@featureIDs); >>      my @sortedFeatureIDs = $sprout->TaxonomySort(\@featureIDs);
3039    
3040  Return a list formed by sorting the specified features by the taxonomy of the containing  Return a list formed by sorting the specified features by the taxonomy of the containing
3041  genome. This will cause genomes from similar organisms to float close to each other.  genome. This will cause genomes from similar organisms to float close to each other.
# Line 2960  Line 3070 
3070          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",
3071                                          [$fid], 'Genome(taxonomy)');                                          [$fid], 'Genome(taxonomy)');
3072          # Add this feature to the hash buffer.          # Add this feature to the hash buffer.
3073          Tracer::AddToListMap(\%hashBuffer, $taxonomy, $fid);          push @{$hashBuffer{$taxonomy}}, $fid;
3074      }      }
3075      # Sort the keys and get the elements.      # Sort the keys and get the elements.
3076      my @retVal = ();      my @retVal = ();
# Line 2973  Line 3083 
3083    
3084  =head3 Protein  =head3 Protein
3085    
3086  C<< my $protein = Sprout::Protein($sequence, $table); >>      my $protein = Sprout::Protein($sequence, $table);
3087    
3088  Translate a DNA sequence into a protein sequence.  Translate a DNA sequence into a protein sequence.
3089    
# Line 3059  Line 3169 
3169    
3170  =head3 LoadInfo  =head3 LoadInfo
3171    
3172  C<< my ($dirName, @relNames) = $sprout->LoadInfo(); >>      my ($dirName, @relNames) = $sprout->LoadInfo();
3173    
3174  Return the name of the directory from which data is to be loaded and a list of the relation  Return the name of the directory from which data is to be loaded and a list of the relation
3175  names. This information is useful when trying to analyze what needs to be put where in order  names. This information is useful when trying to analyze what needs to be put where in order
# Line 3080  Line 3190 
3190    
3191  =head3 BBHMatrix  =head3 BBHMatrix
3192    
3193  C<< my %bbhMap = $sprout->BBHMatrix($genomeID, $cutoff, @targets); >>      my %bbhMap = $sprout->BBHMatrix($genomeID, $cutoff, @targets);
3194    
3195  Find all the bidirectional best hits for the features of a genome in a  Find all the bidirectional best hits for the features of a genome in a
3196  specified list of target genomes. The return value will be a hash mapping  specified list of target genomes. The return value will be a hash mapping
# Line 3134  Line 3244 
3244    
3245  =head3 SimMatrix  =head3 SimMatrix
3246    
3247  C<< my %simMap = $sprout->SimMatrix($genomeID, $cutoff, @targets); >>      my %simMap = $sprout->SimMatrix($genomeID, $cutoff, @targets);
3248    
3249  Find all the similarities for the features of a genome in a  Find all the similarities for the features of a genome in a
3250  specified list of target genomes. The return value will be a hash mapping  specified list of target genomes. The return value will be a hash mapping
# Line 3204  Line 3314 
3314    
3315  =head3 LowBBHs  =head3 LowBBHs
3316    
3317  C<< my %bbhMap = $sprout->LowBBHs($featureID, $cutoff); >>      my %bbhMap = $sprout->LowBBHs($featureID, $cutoff);
3318    
3319  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
3320  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 3248  Line 3358 
3358    
3359  =head3 Sims  =head3 Sims
3360    
3361  C<< my $simList = $sprout->Sims($fid, $maxN, $maxP, $select, $max_expand, $filters); >>      my $simList = $sprout->Sims($fid, $maxN, $maxP, $select, $max_expand, $filters);
3362    
3363  Get a list of similarities for a specified feature. Similarity information is not kept in the  Get a list of similarities for a specified feature. Similarity information is not kept in the
3364  Sprout database; rather, they are retrieved from a network server. The similarities are  Sprout database; rather, they are retrieved from a network server. The similarities are
# Line 3314  Line 3424 
3424    
3425  =head3 IsAllGenomes  =head3 IsAllGenomes
3426    
3427  C<< my $flag = $sprout->IsAllGenomes(\@list, \@checkList); >>      my $flag = $sprout->IsAllGenomes(\@list, \@checkList);
3428    
3429  Return TRUE if all genomes in the second list are represented in the first list at  Return TRUE if all genomes in the second list are represented in the first list at
3430  least one. Otherwise, return FALSE. If the second list is omitted, the first list is  least one. Otherwise, return FALSE. If the second list is omitted, the first list is
# Line 3363  Line 3473 
3473    
3474  =head3 GetGroups  =head3 GetGroups
3475    
3476  C<< my %groups = $sprout->GetGroups(\@groupList); >>      my %groups = $sprout->GetGroups(\@groupList);
3477    
3478  Return a hash mapping each group to the IDs of the genomes in the group.  Return a hash mapping each group to the IDs of the genomes in the group.
3479  A list of groups may be specified, in which case only those groups will be  A list of groups may be specified, in which case only those groups will be
# Line 3395  Line 3505 
3505                                      [$FIG_Config::otherGroup], ['Genome(id)', 'Genome(primary-group)']);                                      [$FIG_Config::otherGroup], ['Genome(id)', 'Genome(primary-group)']);
3506          # Loop through the genomes found.          # Loop through the genomes found.
3507          for my $genome (@genomes) {          for my $genome (@genomes) {
3508              # Pop this genome's ID off the current list.              # Get the genome ID and group, and add this genome to the group's list.
3509              my @groups = @{$genome};              my ($genomeID, $group) = @{$genome};
3510              my $genomeID = shift @groups;              push @{$retVal{$group}}, $genomeID;
             # Loop through the groups, adding the genome ID to each group's  
             # list.  
             for my $group (@groups) {  
                 Tracer::AddToListMap(\%retVal, $group, $genomeID);  
             }  
3511          }          }
3512      }      }
3513      # Return the hash we just built.      # Return the hash we just built.
# Line 3411  Line 3516 
3516    
3517  =head3 MyGenomes  =head3 MyGenomes
3518    
3519  C<< my @genomes = Sprout::MyGenomes($dataDir); >>      my @genomes = Sprout::MyGenomes($dataDir);
3520    
3521  Return a list of the genomes to be included in the Sprout.  Return a list of the genomes to be included in the Sprout.
3522    
# Line 3443  Line 3548 
3548    
3549  =head3 LoadFileName  =head3 LoadFileName
3550    
3551  C<< my $fileName = Sprout::LoadFileName($dataDir, $tableName); >>      my $fileName = Sprout::LoadFileName($dataDir, $tableName);
3552    
3553  Return the name of the load file for the specified table in the specified data  Return the name of the load file for the specified table in the specified data
3554  directory.  directory.
# Line 3484  Line 3589 
3589    
3590  =head3 DeleteGenome  =head3 DeleteGenome
3591    
3592  C<< my $stats = $sprout->DeleteGenome($genomeID, $testFlag); >>      my $stats = $sprout->DeleteGenome($genomeID, $testFlag);
3593    
3594  Delete a genome from the database.  Delete a genome from the database.
3595    
# Line 3520  Line 3625 
3625    
3626  =head3 Fix  =head3 Fix
3627    
3628  C<< my %fixedHash = Sprout::Fix(%groupHash); >>      my %fixedHash = $sprout->Fix(%groupHash);
3629    
3630  Prepare a genome group hash (like that returned by L</GetGroups>) for processing.  Prepare a genome group hash (like that returned by L</GetGroups>) for processing.
3631  Groups with the same primary name will be combined. The primary name is the  The groups will be combined into the appropriate super-groups.
 first capitalized word in the group name.  
3632    
3633  =over 4  =over 4
3634    
# Line 3542  Line 3646 
3646    
3647  sub Fix {  sub Fix {
3648      # Get the parameters.      # Get the parameters.
3649      my (%groupHash) = @_;      my ($self, %groupHash) = @_;
3650      # Create the result hash.      # Create the result hash.
3651      my %retVal = ();      my %retVal = ();
3652        # Get the super-group table.
3653        my %superTable = $self->CheckGroupFile();
3654      # Copy over the genomes.      # Copy over the genomes.
3655      for my $groupID (keys %groupHash) {      for my $groupID (keys %groupHash) {
3656          # Make a safety copy of the group ID.          # Get the super-group name.
3657          my $realGroupID = $groupID;          my $realGroupID;
         # Yank the primary name.  
3658          if ($groupID =~ /([A-Z]\w+)/) {          if ($groupID =~ /([A-Z]\w+)/) {
3659                if (! defined($superTable{$1})) {
3660                    Confess("Super-group name not found for group $groupID.");
3661                } else {
3662              $realGroupID = $1;              $realGroupID = $1;
3663          }          }
3664            } else {
3665                Confess("Invalid group name $groupID.");
3666            }
3667          # Append this group's genomes into the result hash.          # Append this group's genomes into the result hash.
3668          Tracer::AddToListMap(\%retVal, $realGroupID, @{$groupHash{$groupID}});          push @{$retVal{$realGroupID}}, @{$groupHash{$groupID}};
3669      }      }
3670      # Return the result hash.      # Return the result hash.
3671      return %retVal;      return %retVal;
# Line 3562  Line 3673 
3673    
3674  =head3 GroupPageName  =head3 GroupPageName
3675    
3676  C<< my $name = $sprout->GroupPageName($group); >>      my $name = $sprout->GroupPageName($group);
3677    
3678  Return the name of the page for the specified NMPDR group.  Return the name of the page for the specified NMPDR group.
3679    
# Line 3587  Line 3698 
3698      # Declare the return variable.      # Declare the return variable.
3699      my $retVal;      my $retVal;
3700      # Check for the group file data.      # Check for the group file data.
3701      if (! defined $self->{groupHash}) {      my %superTable = $self->CheckGroupFile();
         # Read the group file.  
         my %groupData = Sprout::ReadGroupFile($self->{_options}->{dataDir} . "/groups.tbl");  
         # Store it in our object.  
         $self->{groupHash} = \%groupData;  
     }  
3702      # Compute the real group name.      # Compute the real group name.
     my $realGroup = $group;  
3703      if ($group =~ /([A-Z]\w+)/) {      if ($group =~ /([A-Z]\w+)/) {
3704          $realGroup = $1;          my $realGroup = $1;
3705            if (! defined($superTable{$1})) {
3706                Confess("No super-group found for \"$group\".");
3707            } else {
3708                $retVal = "../content/$superTable{$1}->{page}";
3709            }
3710        } else {
3711            Confess("\"group\" is not a valid group name.");
3712      }      }
     # Return the page name.  
     $retVal = "../content/" . $self->{groupHash}->{$realGroup}->[1];  
3713      # Return the result.      # Return the result.
3714      return $retVal;      return $retVal;
3715  }  }
3716    
 =head3 ReadGroupFile  
   
 C<< my %groupData = Sprout::ReadGroupFile($groupFileName); >>  
   
 Read in the data from the specified group file. The group file contains information  
 about each of the NMPDR groups.  
   
 =over 4  
   
 =item name  
3717    
3718  Name of the group.  =head3 AddProperty
   
 =item page  
   
 Name of the group's page on the web site (e.g. C<campy.php> for  
 Campylobacter)  
   
 =item genus  
   
 Genus of the group  
3719    
3720  =item species      $sprout->AddProperty($featureID, $key, @values);
3721    
3722  Species of the group, or an empty string if the group is for an entire  Add a new attribute value (Property) to a feature.
 genus. If the group contains more than one species, the species names  
 should be separated by commas.  
3723    
3724  =back  =over 4
3725    
3726  The parameters to this method are as follows  =item peg
3727    
3728  =over 4  ID of the feature to which the attribute is to be added.
3729    
3730  =item groupFile  =item key
3731    
3732  Name of the file containing the group data.  Name of the attribute (key).
3733    
3734  =item RETURN  =item values
3735    
3736  Returns a hash keyed on group name. The value of each hash  Values of the attribute.
3737    
3738  =back  =back
3739    
3740  =cut  =cut
3741    #: Return Type ;
3742  sub ReadGroupFile {  sub AddProperty {
3743      # Get the parameters.      # Get the parameters.
3744      my ($groupFileName) = @_;      my ($self, $featureID, $key, @values) = @_;
3745      # Declare the return variable.      # Add the property using the attached attributes object.
3746      my %retVal;      $self->{_ca}->AddAttribute($featureID, $key, @values);
     # Read the group file.  
     my @groupLines = Tracer::GetFile($groupFileName);  
     for my $groupLine (@groupLines) {  
         my ($name, $page, $genus, $species) = split(/\t/, $groupLine);  
         $retVal{$name} = [$page, $genus, $species];  
     }  
     # Return the result.  
     return %retVal;  
3747  }  }
3748    
3749  =head3 AddProperty  =head3 CheckGroupFile
3750    
3751  C<< my  = $sprout->AddProperty($featureID, $key, @values); >>      my %groupData = $sprout->CheckGroupFile();
3752    
3753  Add a new attribute value (Property) to a feature.  Get the group file hash. The group file hash describes the relationship
3754    between a group and the super-group to which it belongs for purposes of
3755    display. The super-group name is computed from the first capitalized word
3756    in the actual group name. For each super-group, the group file contains
3757    the page name and a list of the species expected to be in the group.
3758    Each species is specified by a genus and a species name. A species name
3759    of C<0> implies an entire genus.
3760    
3761  =over 4  This method returns a hash from super-group names to a hash reference. Each
3762    resulting hash reference contains the following fields.
3763    
3764  =item peg  =over 4
3765    
3766  ID of the feature to which the attribute is to be added.  =item page
3767    
3768  =item key  The super-group's web page in the NMPDR.
3769    
3770  Name of the attribute (key).  =item contents
3771    
3772  =item values  A list of 2-tuples, each containing a genus name followed by a species name
3773    (or 0, indicating all species). This list indicates which organisms belong
3774  Values of the attribute.  in the super-group.
3775    
3776  =back  =back
3777    
3778  =cut  =cut
3779  #: Return Type ;  
3780  sub AddProperty {  sub CheckGroupFile{
3781      # Get the parameters.      # Get the parameters.
3782      my ($self, $featureID, $key, @values) = @_;      my ($self) = @_;
3783      # Add the property using the attached attributes object.      # Check to see if we already have this hash.
3784      $self->{_ca}->AddAttribute($featureID, $key, @values);      if (! defined $self->{groupHash}) {
3785            # We don't, so we need to read it in.
3786            my %groupHash;
3787            # Read the group file.
3788            my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");
3789            # Loop through the list of sort-of groups.
3790            for my $groupLine (@groupLines) {
3791                my ($name, $page, @contents) = split /\t/, $groupLine;
3792                $groupHash{$name} = { page => $page,
3793                                      contents => [ map { [ split /\s*,\s*/, $_ ] } @contents ]
3794                                    };
3795            }
3796            # Save the hash.
3797            $self->{groupHash} = \%groupHash;
3798        }
3799        # Return the result.
3800        return %{$self->{groupHash}};
3801  }  }
3802    
3803  =head2 Virtual Methods  =head2 Virtual Methods
3804    
3805  =head3 CleanKeywords  =head3 CleanKeywords
3806    
3807  C<< my $cleanedString = $sprout->CleanKeywords($searchExpression); >>      my $cleanedString = $sprout->CleanKeywords($searchExpression);
3808    
3809  Clean up a search expression or keyword list. This involves converting the periods  Clean up a search expression or keyword list. This involves converting the periods
3810  in EC numbers to underscores, converting non-leading minus signs to underscores,  in EC numbers to underscores, converting non-leading minus signs to underscores,
# Line 3750  Line 3854 
3854    
3855  A functional assignment is always of the form  A functional assignment is always of the form
3856    
3857      C<set >I<YYYY>C< function to\n>I<ZZZZZ>      set YYYY function to
3858        ZZZZ
3859    
3860  where I<YYYY> is the B<user>, and I<ZZZZ> is the actual functional role. In most cases,  where I<YYYY> is the B<user>, and I<ZZZZ> is the actual functional role. In most cases,
3861  the user and the assigning user (from MadeAnnotation) will be the same, but that is  the user and the assigning user (from MadeAnnotation) will be the same, but that is
# Line 3805  Line 3910 
3910    
3911  =head3 _CheckFeature  =head3 _CheckFeature
3912    
3913  C<< my $flag = $sprout->_CheckFeature($fid); >>      my $flag = $sprout->_CheckFeature($fid);
3914    
3915  Return TRUE if the specified FID is probably an NMPDR feature ID, else FALSE.  Return TRUE if the specified FID is probably an NMPDR feature ID, else FALSE.
3916    

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.106

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3