[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.100, Mon Jul 16 19:59:50 2007 UTC revision 1.113, Tue Aug 12 06:01:49 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 CGI;
18        use WikiTools;
19        use base qw(ERDB);
20    
21  =head1 Sprout Database Manipulation Object  =head1 Sprout Database Manipulation Object
22    
# Line 29  Line 29 
29  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>
30  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>.
31    
32  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' });
33    
34  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
35  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
36  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
37  L</dna_seq> returns the DNA sequence for a specified genome location.  L</DNASeq> returns the DNA sequence for a specified genome location.
38    
39  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.
40    
# Line 46  Line 46 
46    
47  =head3 new  =head3 new
48    
49  C<< my $sprout = Sprout->new($dbName, \%options); >>      my $sprout = Sprout->new($dbName, \%options);
50    
51  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
52  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 80 
80    
81  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE
82    
83    * B<host> name of the database host
84    
85  =back  =back
86    
87  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
88  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
89  F</usr/fig/SproutData>.  F</usr/fig/SproutData>.
90    
91  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' });
92    
93  =cut  =cut
94    
# Line 110  Line 112 
112                         port         => $FIG_Config::dbport,                         port         => $FIG_Config::dbport,
113                                                          # database connection port                                                          # database connection port
114                         sock         => $FIG_Config::dbsock,                         sock         => $FIG_Config::dbsock,
115                         host         => $FIG_Config::dbhost,                         host         => $FIG_Config::sprout_host,
116                         maxSegmentLength => 4500,        # maximum feature segment length                         maxSegmentLength => 4500,        # maximum feature segment length
117                         maxSequenceLength => 8000,       # maximum contig sequence length                         maxSequenceLength => 8000,       # maximum contig sequence length
118                         noDBOpen     => 0,               # 1 to suppress the database open                         noDBOpen     => 0,               # 1 to suppress the database open
# Line 123  Line 125 
125      # Connect to the database.      # Connect to the database.
126      my $dbh;      my $dbh;
127      if (! $optionTable->{noDBOpen}) {      if (! $optionTable->{noDBOpen}) {
128            Trace("Connect data: host = $optionTable->{host}, port = $optionTable->{port}.") if T(3);
129          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,
130                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});
131      }      }
# Line 145  Line 148 
148          my $user = ($FIG_Config::arch eq 'win' ? 'self' : scalar(getpwent()));          my $user = ($FIG_Config::arch eq 'win' ? 'self' : scalar(getpwent()));
149          $retVal->{_ca} = CustomAttributes->new(user => $user);          $retVal->{_ca} = CustomAttributes->new(user => $user);
150      }      }
151        # Insure we have access to the stem module.
152        WikiUse('Lingua::Stem');
153        $retVal->{stemmer} = Lingua::Stem->new();
154        $retVal->{stemmer}->stem_caching({ -level => 2 });
155      # Return it.      # Return it.
156      return $retVal;      return $retVal;
157  }  }
158    
159    =head3 CoreGenomes
160    
161        my @genomes = $sprout->CoreGenomes($scope);
162    
163    Return the IDs of NMPDR genomes in the specified scope.
164    
165    =over 4
166    
167    =item scope
168    
169    Scope of the desired genomes. C<core> covers the original core genomes,
170    C<nmpdr> covers all genomes in NMPDR groups, and C<all> covers all
171    genomes in the system.
172    
173    =item RETURN
174    
175    Returns a list of the IDs for the genomes in the specified scope.
176    
177    =back
178    
179    =cut
180    
181    sub CoreGenomes {
182        # Get the parameters.
183        my ($self, $scope) = @_;
184        # Declare the return variable.
185        my @retVal = ();
186        # If we want all genomes, then this is easy.
187        if ($scope eq 'all') {
188            @retVal = $self->Genomes();
189        } else {
190            # Here we're dealing with groups. Get the hash of all the
191            # genome groups.
192            my %groups = $self->GetGroups();
193            # Loop through the groups, keeping the ones that we want.
194            for my $group (keys %groups) {
195                # Decide if we want to keep this group.
196                my $keepGroup = 0;
197                if ($scope eq 'nmpdr') {
198                    # NMPDR mode: keep all groups.
199                    $keepGroup = 1;
200                } elsif ($scope eq 'core') {
201                    # CORE mode. Only keep real core groups.
202                    if (grep { $group =~ /$_/ } @{$FIG_Config::realCoreGroups}) {
203                        $keepGroup = 1;
204                    }
205                }
206                # Add this group if we're keeping it.
207                if ($keepGroup) {
208                    push @retVal, @{$groups{$group}};
209                }
210            }
211        }
212        # Return the result.
213        return @retVal;
214    }
215    
216    =head3 SuperGroup
217    
218        my $superGroup = $sprout->SuperGroup($groupName);
219    
220    Return the name of the super-group containing the specified NMPDR genome
221    group. If no appropriate super-group can be found, an error will be
222    thrown.
223    
224    =over 4
225    
226    =item groupName
227    
228    Name of the group whose super-group is desired.
229    
230    =item RETURN
231    
232    Returns the name of the super-group containing the incoming group.
233    
234    =back
235    
236    =cut
237    
238    sub SuperGroup {
239        # Get the parameters.
240        my ($self, $groupName) = @_;
241        # Declare the return variable.
242        my $retVal;
243        # Get the group hash.
244        my %groupHash = $self->CheckGroupFile();
245        # Find the super-group genus.
246        $groupName =~ /([A-Z]\w+)/;
247        my $nameThing = $1;
248        # See if it's directly in the group hash.
249        if (exists $groupHash{$nameThing}) {
250            # Yes, then it's our result.
251            $retVal = $nameThing;
252        } else {
253            # No, so we have to search.
254            for my $superGroup (keys %groupHash) {
255                # Get this super-group's item list.
256                my $list = $groupHash{$superGroup}->{contents};
257                # Search it.
258                if (grep { $_->[0] eq $nameThing } @{$list}) {
259                    $retVal = $superGroup;
260                }
261            }
262            # Make sure we found something.
263            if (! $retVal) {
264                Confess("No super-group found for \"$groupName\".");
265            }
266        }
267        # Return the result.
268        return $retVal;
269    }
270    
271  =head3 MaxSegment  =head3 MaxSegment
272    
273  C<< my $length = $sprout->MaxSegment(); >>      my $length = $sprout->MaxSegment();
274    
275  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
276  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 287 
287    
288  =head3 MaxSequence  =head3 MaxSequence
289    
290  C<< my $length = $sprout->MaxSequence(); >>      my $length = $sprout->MaxSequence();
291    
292  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
293  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 302 
302    
303  =head3 Load  =head3 Load
304    
305  C<< $sprout->Load($rebuild); >>;      $sprout->Load($rebuild);;
306    
307  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.
308    
# Line 223  Line 342 
342    
343  =head3 LoadUpdate  =head3 LoadUpdate
344    
345  C<< my $stats = $sprout->LoadUpdate($truncateFlag, \@tableList); >>      my $stats = $sprout->LoadUpdate($truncateFlag, \@tableList);
346    
347  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
348  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 388 
388              Trace("No load file found for $tableName in $dataDir.") if T(0);              Trace("No load file found for $tableName in $dataDir.") if T(0);
389          } else {          } else {
390              # Attempt to load this table.              # Attempt to load this table.
391              my $result = $self->LoadTable($fileName, $tableName, $truncateFlag);              my $result = $self->LoadTable($fileName, $tableName, truncate => $truncateFlag);
392              # Accumulate the resulting statistics.              # Accumulate the resulting statistics.
393              $retVal->Accumulate($result);              $retVal->Accumulate($result);
394          }          }
# Line 280  Line 399 
399    
400  =head3 GenomeCounts  =head3 GenomeCounts
401    
402  C<< my ($arch, $bact, $euk, $vir, $env, $unk) = $sprout->GenomeCounts($complete); >>      my ($arch, $bact, $euk, $vir, $env, $unk) = $sprout->GenomeCounts($complete);
403    
404  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
405  genomes will be included in the counts.  genomes will be included in the counts.
# Line 325  Line 444 
444    
445  =head3 ContigCount  =head3 ContigCount
446    
447  C<< my $count = $sprout->ContigCount($genomeID); >>      my $count = $sprout->ContigCount($genomeID);
448    
449  Return the number of contigs for the specified genome ID.  Return the number of contigs for the specified genome ID.
450    
# Line 352  Line 471 
471      return $retVal;      return $retVal;
472  }  }
473    
474  =head3 GeneMenu  =head3 GenomeMenu
475    
476        my $html = $sprout->GenomeMenu(%options);
477    
478    Generate a genome selection control with the specified name and options.
479    This control is almost but not quite the same as the genome control in the
480    B<SearchHelper> class. Eventually, the two will be combined.
481    
482  C<< my $selectHtml = $sprout->GeneMenu(\%attributes, $filterString, \@params, $selected); >>  =over 4
483    
484    =item options
485    
486    Optional parameters for the control (see below).
487    
488    =item RETURN
489    
490    Returns the HTML for a genome selection control on a form (sometimes called a popup menu).
491    
492  Return an HTML select menu of genomes. Each genome will be an option in the menu,  =back
493  and will be displayed by name with the ID and a contig count attached. The selection  
494  value will be the genome ID. The genomes will be sorted by genus/species name.  The valid options are as follows.
495    
496  =over 4  =over 4
497    
498  =item attributes  =item name
499    
500    Name to give this control for use in passing it to the form. The default is C<myGenomeControl>.
501    Terrible things will happen if you have two controls with the same name on the same page.
502    
503    =item filter
504    
505    If specified, a filter for the list of genomes to display. The filter should be in the form of a
506    list reference. The first element of the list should be the filter string, and the remaining elements
507    the filter parameters.
508    
509    =item multiSelect
510    
511    If TRUE, then the user can select multiple genomes. If FALSE, the user can only select one genome.
512    
513    =item size
514    
515    Number of rows to display in the control. The default is C<10>
516    
517    =item id
518    
519    ID to give this control. The default is the value of the C<name> option. Nothing will work correctly
520    unless this ID is unique.
521    
522    =item selected
523    
524    A comma-delimited list of selected genomes, or a reference to a list of selected genomes. The
525    default is none.
526    
527    =item class
528    
529    If specified, a style class to assign to the genome control.
530    
531    =back
532    
533  Reference to a hash mapping attributes to values for the SELECT tag generated.  =cut
534    
535  =item filterString  sub GenomeMenu {
536        # Get the parameters.
537        my ($self, %options) = @_;
538        # Get the control's name and ID.
539        my $menuName = $options{name} || 'myGenomeControl';
540        my $menuID = $options{id} || $menuName;
541        # Compute the IDs for the status display.
542        my $divID = "${menuID}_status";
543        my $urlID = "${menuID}_url";
544        # Compute the code to show selected genomes in the status area.
545        my $showSelect = "showSelected('$menuID', '$divID', '$urlID', 1000)";
546        # Check for single-select or multi-select.
547        my $multiSelect = $options{multiSelect} || 0;
548        # Get the style data.
549        my $class = $options{class} || '';
550        # Get the list of pre-selected items.
551        my $selections = $options{selected} || [];
552        if (ref $selections ne 'ARRAY') {
553            $selections = [ split /\s*,\s*/, $selections ];
554        }
555        my %selected = map { $_ => 1 } @{$selections};
556        # Extract the filter information. The default is no filtering. It can be passed as a tab-delimited
557        # string or a list reference.
558        my $filterParms = $options{filter} || "";
559        if (! ref $filterParms) {
560            $filterParms = [split /\t|\\t/, $filterParms];
561        }
562        my $filterString = shift @{$filterParms};
563        # Get a list of all the genomes in group order. In fact, we only need them ordered
564        # by name (genus,species,strain), but putting primary-group in front enables us to
565        # take advantage of an existing index.
566        my @genomeList = $self->GetAll(['Genome'], "$filterString ORDER BY Genome(primary-group), Genome(genus), Genome(species), Genome(unique-characterization)",
567                                       $filterParms,
568                                       [qw(Genome(primary-group) Genome(id) Genome(genus) Genome(species) Genome(unique-characterization) Genome(taxonomy) Genome(contigs))]);
569        # Create a hash to organize the genomes by group. Each group will contain a list of
570        # 2-tuples, the first element being the genome ID and the second being the genome
571        # name.
572        my %gHash = ();
573        for my $genome (@genomeList) {
574            # Get the genome data.
575            my ($group, $genomeID, $genus, $species, $strain, $taxonomy, $contigs) = @{$genome};
576            # Compute its name. This is the genus, species, strain (if any), and the contig count.
577            my $name = "$genus $species ";
578            $name .= "$strain " if $strain;
579            my $contigCount = ($contigs == 1 ? "" : ", $contigs contigs");
580            # Now we get the domain. The domain tells us the display style of the organism.
581            my ($domain) = split /\s*;\s*/, $taxonomy, 2;
582            # Now compute the display group. This is normally the primary group, but if the
583            # organism is supporting, we blank it out.
584            my $displayGroup = ($group eq $FIG_Config::otherGroup ? "" : $group);
585            # Push the genome into the group's list. Note that we use the real group
586            # name for the hash key here, not the display group name.
587            push @{$gHash{$group}}, [$genomeID, $name, $contigCount, $domain];
588        }
589        # We are almost ready to unroll the menu out of the group hash. The final step is to separate
590        # the supporting genomes by domain. First, we extract the NMPDR groups and sort them. They
591        # are sorted by the first capitalized word. Groups with "other" are sorted after groups
592        # that aren't "other". At some point, we will want to make this less complicated.
593        my %sortGroups = map { $_ =~ /(other)?(.*)([A-Z].+)/; "$3$1$2" => $_ }
594                             grep { $_ ne $FIG_Config::otherGroup } keys %gHash;
595        my @groups = map { $sortGroups{$_} } sort keys %sortGroups;
596        # Remember the number of NMPDR groups.
597        my $nmpdrGroupCount = scalar @groups;
598        # Loop through the supporting genomes, classifying them by domain. We'll also keep a list
599        # of the domains found.
600        my @otherGenomes = @{$gHash{$FIG_Config::otherGroup}};
601        my @domains = ();
602        for my $genomeData (@otherGenomes) {
603            my ($genomeID, $name, $contigCount, $domain) = @{$genomeData};
604            if (exists $gHash{$domain}) {
605                push @{$gHash{$domain}}, $genomeData;
606            } else {
607                $gHash{$domain} = [$genomeData];
608                push @domains, $domain;
609            }
610        }
611        # Add the domain groups at the end of the main group list. The main group list will now
612        # contain all the categories we need to display the genomes.
613        push @groups, sort @domains;
614        # Delete the supporting group.
615        delete $gHash{$FIG_Config::otherGroup};
616        # Now it gets complicated. We need a way to mark all the NMPDR genomes. We take advantage
617        # of the fact they come first in the list. We'll accumulate a count of the NMPDR genomes
618        # and use that to make the selections.
619        my $nmpdrCount = 0;
620        # Create the type counters.
621        my $groupCount = 1;
622        # Get the number of rows to display.
623        my $rows = $options{size} || 10;
624        # If we're multi-row, create an onChange event.
625        my $onChangeTag = ( $rows > 1 ? " onChange=\"$showSelect;\" onFocus=\"$showSelect;\"" : "" );
626        # Set up the multiple-select flag.
627        my $multipleTag = ($multiSelect ? " multiple" : "" );
628        # Set up the style class.
629        my $classTag = ($class ? " class=\"$class\"" : "" );
630        # Create the SELECT tag and stuff it into the output array.
631        my @lines = ("<SELECT name=\"$menuID\" id=\"$menuID\" $onChangeTag$multipleTag$classTag size=\"$rows\">");
632        # Loop through the groups.
633        for my $group (@groups) {
634            # Get the genomes in the group.
635            for my $genome (@{$gHash{$group}}) {
636                # If this is an NMPDR organism, we add an extra style and count it.
637                my $nmpdrStyle = "";
638                if ($nmpdrGroupCount > 0) {
639                    $nmpdrCount++;
640                    $nmpdrStyle = " Core";
641                }
642                # Get the organism ID, name, contig count, and domain.
643                my ($genomeID, $name, $contigCount, $domain) = @{$genome};
644                # See if we're pre-selected.
645                my $selectTag = ($selected{$genomeID} ? " SELECTED" : "");
646                # Compute the display name.
647                my $nameString = "$name ($genomeID$contigCount)";
648                # Generate the option tag.
649                my $optionTag = "<OPTION class=\"$domain$nmpdrStyle\" title=\"$group\" value=\"$genomeID\"$selectTag>$nameString</OPTION>";
650                push @lines, "    $optionTag";
651            }
652            # Record this group in the nmpdrGroup count. When that gets to 0, we've finished the NMPDR
653            # groups.
654            $nmpdrGroupCount--;
655        }
656        # Close the SELECT tag.
657        push @lines, "</SELECT>";
658        if ($rows > 1) {
659            # We're in a non-compact mode, so we need to add some selection helpers. First is
660            # the search box. This allows the user to type text and change which genomes are
661            # displayed. For multiple-select mode, we include a button that selects the displayed
662            # genes. For single-select mode, we use a plain label instead.
663            my $searchThingName = "${menuID}_SearchThing";
664            my $searchThingLabel = ($multiSelect ? "<INPUT type=\"button\" name=\"MacroSearch\" class=\"button\" value=\"Select genomes containing\" onClick=\"selectShowing('$menuID', '$searchThingName'); $showSelect;\" />"
665                                                 : "Show genomes containing");
666            push @lines, "<br />$searchThingLabel&nbsp;" .
667                         "<INPUT type=\"text\" id=\"$searchThingName\" name=\"$searchThingName\" size=\"30\" onKeyup=\"showTyped('$menuID', '$searchThingName');\" />";
668            # For multi-select mode, we also have buttons to set and clear selections.
669            if ($multiSelect) {
670                push @lines, "<INPUT type=\"button\" name=\"ClearAll\" class=\"bigButton\"  value=\"Clear All\" onClick=\"clearAll('$menuID'); $showSelect\" />";
671                push @lines, "<INPUT type=\"button\" name=\"SelectAll\" class=\"bigButton\" value=\"Select All\" onClick=\"selectAll('$menuID'); $showSelect\" />";
672                push @lines, "<INPUT type=\"button\" name=\"NMPDROnly\" class=\"bigButton\"  value=\"Select NMPDR\" onClick=\"selectSome('$menuID', $nmpdrCount, true); $showSelect;\" />";
673            }
674            # Add a hidden field we can use to generate organism page hyperlinks.
675            push @lines, "<INPUT type=\"hidden\" id=\"$urlID\" value=\"$FIG_Config::cgi_url/seedviewer.cgi?page=Organism;organism=\" />";
676            # Add the status display. This tells the user what's selected no matter where the list is scrolled.
677            push @lines, "<DIV id=\"$divID\" class=\"Panel\"></DIV>";
678        }
679        # Assemble all the lines into a string.
680        my $retVal = join("\n", @lines, "");
681        # Return the result.
682        return $retVal;
683    }
684    
 A filter string for use in selecting the genomes. The filter string must conform  
 to the rules for the C<< ERDB->Get >> method.  
685    
686  =item params  =head3 Stem
687    
688  Reference to a list of values to be substituted in for the parameter marks in      my $stem = $sprout->Stem($word);
 the filter string.  
689    
690  =item selected (optional)  Return the stem of the specified word, or C<undef> if the word is not
691    stemmable. Note that even if the word is stemmable, the stem may be
692    the same as the original word.
693    
694  ID of the genome to be initially selected.  =over 4
695    
696  =item fast (optional)  =item word
697    
698  If specified and TRUE, the contig counts will be omitted to improve performance.  Word to convert into a stem.
699    
700  =item RETURN  =item RETURN
701    
702  Returns an HTML select menu with the specified genomes as selectable options.  Returns a stem of the word (which may be the word itself), or C<undef> if
703    the word is not stemmable.
704    
705  =back  =back
706    
707  =cut  =cut
708    
709  sub GeneMenu {  sub Stem {
710      # Get the parameters.      # Get the parameters.
711      my ($self, $attributes, $filterString, $params, $selected, $fast) = @_;      my ($self, $word) = @_;
712      my $slowMode = ! $fast;      # Declare the return variable.
713      # Default to nothing selected. This prevents an execution warning if "$selected"      my $retVal;
714      # is undefined.      # See if it's stemmable.
715      $selected = "" unless defined $selected;      if ($word =~ /^[A-Za-z]+$/) {
716      Trace("Gene Menu called with slow mode \"$slowMode\" and selection \"$selected\".") if T(3);          # Compute the stem.
717      # Start the menu.          my $stemList = $self->{stemmer}->stem($word);
718      my $retVal = "<select " .          my $stem = $stemList->[0];
719          join(" ", map { "$_=\"$attributes->{$_}\"" } keys %{$attributes}) .          # Check to see if it's long enough.
720          ">\n";          if (length $stem >= 3) {
721      # Get the genomes.              # Yes, keep it.
722      my @genomes = $self->GetAll(['Genome'], $filterString, $params, ['Genome(id)',              $retVal = $stem;
723                                                                       'Genome(genus)',          } else {
724                                                                       'Genome(species)',              # No, use the original word.
725                                                                       'Genome(unique-characterization)']);              $retVal = $word;
726      # Sort them by name.          }
     my @sorted = sort { lc("$a->[1] $a->[2]") cmp lc("$b->[1] $b->[2]") } @genomes;  
     # Loop through the genomes, creating the option tags.  
     for my $genomeData (@sorted) {  
         # Get the data for this genome.  
         my ($genomeID, $genus, $species, $strain) = @{$genomeData};  
         # Get the contig count.  
         my $contigInfo = "";  
         if ($slowMode) {  
             my $count = $self->ContigCount($genomeID);  
             my $counting = ($count == 1 ? "contig" : "contigs");  
             $contigInfo = "[$count $counting]";  
         }  
         # Find out if we're selected.  
         my $selectOption = ($selected eq $genomeID ? " selected" : "");  
         # Build the option tag.  
         $retVal .= "<option value=\"$genomeID\"$selectOption>$genus $species $strain ($genomeID)$contigInfo</option>\n";  
727      }      }
     # Close the SELECT tag.  
     $retVal .= "</select>\n";  
728      # Return the result.      # Return the result.
729      return $retVal;      return $retVal;
730  }  }
731    
732    
733  =head3 Build  =head3 Build
734    
735  C<< $sprout->Build(); >>      $sprout->Build();
736    
737  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.
738  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 749 
749    
750  =head3 Genomes  =head3 Genomes
751    
752  C<< my @genomes = $sprout->Genomes(); >>      my @genomes = $sprout->Genomes();
753    
754  Return a list of all the genome IDs.  Return a list of all the genome IDs.
755    
# Line 469  Line 766 
766    
767  =head3 GenusSpecies  =head3 GenusSpecies
768    
769  C<< my $infoString = $sprout->GenusSpecies($genomeID); >>      my $infoString = $sprout->GenusSpecies($genomeID);
770    
771  Return the genus, species, and unique characterization for a genome.  Return the genus, species, and unique characterization for a genome.
772    
# Line 501  Line 798 
798    
799  =head3 FeaturesOf  =head3 FeaturesOf
800    
801  C<< my @features = $sprout->FeaturesOf($genomeID, $ftype); >>      my @features = $sprout->FeaturesOf($genomeID, $ftype);
802    
803  Return a list of the features relevant to a specified genome.  Return a list of the features relevant to a specified genome.
804    
# Line 546  Line 843 
843    
844  =head3 FeatureLocation  =head3 FeatureLocation
845    
846  C<< my @locations = $sprout->FeatureLocation($featureID); >>      my @locations = $sprout->FeatureLocation($featureID);
847    
848  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
849  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 570  Line 867 
867  =item RETURN  =item RETURN
868    
869  Returns a list of the feature's contig segments. The locations are returned as a list in a list  Returns a list of the feature's contig segments. The locations are returned as a list in a list
870  context and as a comma-delimited string in a scalar context.  context and as a comma-delimited string in a scalar context. An empty list means the feature
871    wasn't found.
872    
873  =back  =back
874    
# Line 579  Line 877 
877  sub FeatureLocation {  sub FeatureLocation {
878      # Get the parameters.      # Get the parameters.
879      my ($self, $featureID) = @_;      my ($self, $featureID) = @_;
880        # Declare the return variable.
881        my @retVal = ();
882      # Get the feature record.      # Get the feature record.
883      my $object = $self->GetEntity('Feature', $featureID);      my $object = $self->GetEntity('Feature', $featureID);
884      Confess("Feature $featureID not found.") if ! defined($object);      # Only proceed if we found it.
885        if (defined $object) {
886      # Get the location string.      # Get the location string.
887      my $locString = $object->PrimaryValue('Feature(location-string)');      my $locString = $object->PrimaryValue('Feature(location-string)');
888      # Create the return list.      # Create the return list.
889      my @retVal = split /\s*,\s*/, $locString;          @retVal = split /\s*,\s*/, $locString;
890        }
891      # Return the list in the format indicated by the context.      # Return the list in the format indicated by the context.
892      return (wantarray ? @retVal : join(',', @retVal));      return (wantarray ? @retVal : join(',', @retVal));
893  }  }
894    
895  =head3 ParseLocation  =head3 ParseLocation
896    
897  C<< my ($contigID, $start, $dir, $len) = Sprout::ParseLocation($location); >>      my ($contigID, $start, $dir, $len) = Sprout::ParseLocation($location);
898    
899  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
900  length.  length.
# Line 638  Line 940 
940    
941  =head3 PointLocation  =head3 PointLocation
942    
943  C<< my $found = Sprout::PointLocation($location, $point); >>      my $found = Sprout::PointLocation($location, $point);
944    
945  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
946  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 992 
992    
993  =head3 DNASeq  =head3 DNASeq
994    
995  C<< my $sequence = $sprout->DNASeq(\@locationList); >>      my $sequence = $sprout->DNASeq(\@locationList);
996    
997  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
998  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 1076 
1076    
1077  =head3 AllContigs  =head3 AllContigs
1078    
1079  C<< my @idList = $sprout->AllContigs($genomeID); >>      my @idList = $sprout->AllContigs($genomeID);
1080    
1081  Return a list of all the contigs for a genome.  Return a list of all the contigs for a genome.
1082    
# Line 804  Line 1106 
1106    
1107  =head3 GenomeLength  =head3 GenomeLength
1108    
1109  C<< my $length = $sprout->GenomeLength($genomeID); >>      my $length = $sprout->GenomeLength($genomeID);
1110    
1111  Return the length of the specified genome in base pairs.  Return the length of the specified genome in base pairs.
1112    
# Line 839  Line 1141 
1141    
1142  =head3 FeatureCount  =head3 FeatureCount
1143    
1144  C<< my $count = $sprout->FeatureCount($genomeID, $type); >>      my $count = $sprout->FeatureCount($genomeID, $type);
1145    
1146  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.
1147    
# Line 874  Line 1176 
1176    
1177  =head3 GenomeAssignments  =head3 GenomeAssignments
1178    
1179  C<< my $fidHash = $sprout->GenomeAssignments($genomeID); >>      my $fidHash = $sprout->GenomeAssignments($genomeID);
1180    
1181  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
1182  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 1219 
1219    
1220  =head3 ContigLength  =head3 ContigLength
1221    
1222  C<< my $length = $sprout->ContigLength($contigID); >>      my $length = $sprout->ContigLength($contigID);
1223    
1224  Compute the length of a contig.  Compute the length of a contig.
1225    
# Line 956  Line 1258 
1258    
1259  =head3 ClusterPEGs  =head3 ClusterPEGs
1260    
1261  C<< my $clusteredList = $sprout->ClusterPEGs($sub, \@pegs); >>      my $clusteredList = $sprout->ClusterPEGs($sub, \@pegs);
1262    
1263  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
1264  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
1265  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
1266  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
1267  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
1268  sequence.  appear in the output sequence.
1269    
1270  =over 4  =over 4
1271    
# Line 1004  Line 1306 
1306    
1307  =head3 GenesInRegion  =head3 GenesInRegion
1308    
1309  C<< my (\@featureIDList, $beg, $end) = $sprout->GenesInRegion($contigID, $start, $stop); >>      my (\@featureIDList, $beg, $end) = $sprout->GenesInRegion($contigID, $start, $stop);
1310    
1311  List the features which overlap a specified region in a contig.  List the features which overlap a specified region in a contig.
1312    
# Line 1085  Line 1387 
1387    
1388  =head3 GeneDataInRegion  =head3 GeneDataInRegion
1389    
1390  C<< my @featureList = $sprout->GenesInRegion($contigID, $start, $stop); >>      my @featureList = $sprout->GenesInRegion($contigID, $start, $stop);
1391    
1392  List the features which overlap a specified region in a contig.  List the features which overlap a specified region in a contig.
1393    
# Line 1156  Line 1458 
1458    
1459  =head3 FType  =head3 FType
1460    
1461  C<< my $ftype = $sprout->FType($featureID); >>      my $ftype = $sprout->FType($featureID);
1462    
1463  Return the type of a feature.  Return the type of a feature.
1464    
# Line 1186  Line 1488 
1488    
1489  =head3 FeatureAnnotations  =head3 FeatureAnnotations
1490    
1491  C<< my @descriptors = $sprout->FeatureAnnotations($featureID, $rawFlag); >>      my @descriptors = $sprout->FeatureAnnotations($featureID, $rawFlag);
1492    
1493  Return the annotations of a feature.  Return the annotations of a feature.
1494    
# Line 1249  Line 1551 
1551    
1552  =head3 AllFunctionsOf  =head3 AllFunctionsOf
1553    
1554  C<< my %functions = $sprout->AllFunctionsOf($featureID); >>      my %functions = $sprout->AllFunctionsOf($featureID);
1555    
1556  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
1557  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 1606 
1606    
1607  =head3 FunctionOf  =head3 FunctionOf
1608    
1609  C<< my $functionText = $sprout->FunctionOf($featureID, $userID); >>      my $functionText = $sprout->FunctionOf($featureID, $userID);
1610    
1611  Return the most recently-determined functional assignment of a particular feature.  Return the most recently-determined functional assignment of a particular feature.
1612    
# Line 1408  Line 1710 
1710    
1711  =head3 FunctionsOf  =head3 FunctionsOf
1712    
1713  C<< my @functionList = $sprout->FunctionOf($featureID, $userID); >>      my @functionList = $sprout->FunctionOf($featureID, $userID);
1714    
1715  Return the functional assignments of a particular feature.  Return the functional assignments of a particular feature.
1716    
# Line 1480  Line 1782 
1782    
1783  =head3 BBHList  =head3 BBHList
1784    
1785  C<< my $bbhHash = $sprout->BBHList($genomeID, \@featureList); >>      my $bbhHash = $sprout->BBHList($genomeID, \@featureList);
1786    
1787  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
1788  on a specified target genome.  on a specified target genome.
# Line 1530  Line 1832 
1832    
1833  =head3 SimList  =head3 SimList
1834    
1835  C<< my %similarities = $sprout->SimList($featureID, $count); >>      my %similarities = $sprout->SimList($featureID, $count);
1836    
1837  Return a list of the similarities to the specified feature.  Return a list of the similarities to the specified feature.
1838    
# Line 1566  Line 1868 
1868    
1869  =head3 IsComplete  =head3 IsComplete
1870    
1871  C<< my $flag = $sprout->IsComplete($genomeID); >>      my $flag = $sprout->IsComplete($genomeID);
1872    
1873  Return TRUE if the specified genome is complete, else FALSE.  Return TRUE if the specified genome is complete, else FALSE.
1874    
# Line 1602  Line 1904 
1904    
1905  =head3 FeatureAliases  =head3 FeatureAliases
1906    
1907  C<< my @aliasList = $sprout->FeatureAliases($featureID); >>      my @aliasList = $sprout->FeatureAliases($featureID);
1908    
1909  Return a list of the aliases for a specified feature.  Return a list of the aliases for a specified feature.
1910    
# Line 1632  Line 1934 
1934    
1935  =head3 GenomeOf  =head3 GenomeOf
1936    
1937  C<< my $genomeID = $sprout->GenomeOf($featureID); >>      my $genomeID = $sprout->GenomeOf($featureID);
1938    
1939  Return the genome that contains a specified feature or contig.  Return the genome that contains a specified feature or contig.
1940    
# Line 1660  Line 1962 
1962      if ($featureID =~ /^fig\|(\d+\.\d+)/) {      if ($featureID =~ /^fig\|(\d+\.\d+)/) {
1963          $retVal = $1;          $retVal = $1;
1964      } else {      } else {
1965            # Find the feature by alias.
1966            my ($realFeatureID) = $self->FeaturesByAlias($featureID);
1967            if ($realFeatureID && $realFeatureID =~ /^fig\|(\d+\.\d+)/) {
1968                $retVal = $1;
1969            } else {
1970                # Use the external table.
1971                my ($org) = $self->GetFlat(['ExternalAliasOrg'], "ExternalAliasOrg(id) = ?",
1972                                           [$featureID], "ExternalAliasOrg(org)");
1973                if ($org) {
1974                    $retVal = $org;
1975                } else {
1976          Confess("Invalid feature ID $featureID.");          Confess("Invalid feature ID $featureID.");
1977      }      }
1978            }
1979        }
1980      # Return the value found.      # Return the value found.
1981      return $retVal;      return $retVal;
1982  }  }
1983    
1984  =head3 CoupledFeatures  =head3 CoupledFeatures
1985    
1986  C<< my %coupleHash = $sprout->CoupledFeatures($featureID); >>      my %coupleHash = $sprout->CoupledFeatures($featureID);
1987    
1988  Return the features functionally coupled with a specified feature. Features are considered  Return the features functionally coupled with a specified feature. Features are considered
1989  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 2030 
2030    
2031  =head3 CouplingEvidence  =head3 CouplingEvidence
2032    
2033  C<< my @evidence = $sprout->CouplingEvidence($peg1, $peg2); >>      my @evidence = $sprout->CouplingEvidence($peg1, $peg2);
2034    
2035  Return the evidence for a functional coupling.  Return the evidence for a functional coupling.
2036    
# Line 1777  Line 2092 
2092    
2093  =head3 GetSynonymGroup  =head3 GetSynonymGroup
2094    
2095  C<< my $id = $sprout->GetSynonymGroup($fid); >>      my $id = $sprout->GetSynonymGroup($fid);
2096    
2097  Return the synonym group name for the specified feature.  Return the synonym group name for the specified feature.
2098    
# Line 1816  Line 2131 
2131    
2132  =head3 GetBoundaries  =head3 GetBoundaries
2133    
2134  C<< my ($contig, $beg, $end) = $sprout->GetBoundaries(@locList); >>      my ($contig, $beg, $end) = $sprout->GetBoundaries(@locList);
2135    
2136  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
2137  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 2195 
2195    
2196  =head3 ReadFasta  =head3 ReadFasta
2197    
2198  C<< my %sequenceData = Sprout::ReadFasta($fileName, $prefix); >>      my %sequenceData = Sprout::ReadFasta($fileName, $prefix);
2199    
2200  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
2201  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 2261 
2261    
2262  =head3 FormatLocations  =head3 FormatLocations
2263    
2264  C<< my @locations = $sprout->FormatLocations($prefix, \@locations, $oldFormat); >>      my @locations = $sprout->FormatLocations($prefix, \@locations, $oldFormat);
2265    
2266  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
2267  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 2326 
2326    
2327  =head3 DumpData  =head3 DumpData
2328    
2329  C<< $sprout->DumpData(); >>      $sprout->DumpData();
2330    
2331  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.
2332    
# Line 2028  Line 2343 
2343    
2344  =head3 XMLFileName  =head3 XMLFileName
2345    
2346  C<< my $fileName = $sprout->XMLFileName(); >>      my $fileName = $sprout->XMLFileName();
2347    
2348  Return the name of this database's XML definition file.  Return the name of this database's XML definition file.
2349    
# Line 2039  Line 2354 
2354      return $self->{_xmlName};      return $self->{_xmlName};
2355  }  }
2356    
2357    =head3 GetGenomeNameData
2358    
2359        my ($genus, $species, $strain) = $sprout->GenomeNameData($genomeID);
2360    
2361    Return the genus, species, and unique characterization for a genome. This
2362    is similar to L</GenusSpecies>, with the exception that it returns the
2363    values in three seperate fields.
2364    
2365    =over 4
2366    
2367    =item genomeID
2368    
2369    ID of the genome whose name data is desired.
2370    
2371    =item RETURN
2372    
2373    Returns a three-element list, consisting of the genus, species, and strain
2374    of the specified genome. If the genome is not found, an error occurs.
2375    
2376    =back
2377    
2378    =cut
2379    
2380    sub GetGenomeNameData {
2381        # Get the parameters.
2382        my ($self, $genomeID) = @_;
2383        # Get the desired values.
2384        my ($genus, $species, $strain) = $self->GetEntityValues('Genome', $genomeID =>
2385                                                                [qw(Genome(genus) Genome(species) Genome(unique-characterization))]);
2386        # Throw an error if they were not found.
2387        if (! defined $genus) {
2388            Confess("Genome $genomeID not found in database.");
2389        }
2390        # Return the results.
2391        return ($genus, $species, $strain);
2392    }
2393    
2394    =head3 GetGenomeByNameData
2395    
2396        my @genomes = $sprout->GetGenomeByNameData($genus, $species, $strain);
2397    
2398    Return a list of the IDs of the genomes with the specified genus,
2399    species, and strain. In almost every case, there will be either zero or
2400    one IDs returned; however, two or more IDs could be returned if there are
2401    multiple versions of the genome in the database.
2402    
2403    =over 4
2404    
2405    =item genus
2406    
2407    Genus of the desired genome.
2408    
2409    =item species
2410    
2411    Species of the desired genome.
2412    
2413    =item strain
2414    
2415    Strain (unique characterization) of the desired genome. This may be an empty
2416    string, in which case it is presumed that the desired genome has no strain
2417    specified.
2418    
2419    =item RETURN
2420    
2421    Returns a list of the IDs of the genomes having the specified genus, species, and
2422    strain.
2423    
2424    =back
2425    
2426    =cut
2427    
2428    sub GetGenomeByNameData {
2429        # Get the parameters.
2430        my ($self, $genus, $species, $strain) = @_;
2431        # Try to find the genomes.
2432        my @retVal = $self->GetFlat(['Genome'], "Genome(genus) = ? AND Genome(species) = ? AND Genome(unique-characterization) = ?",
2433                                    [$genus, $species, $strain], 'Genome(id)');
2434        # Return the result.
2435        return @retVal;
2436    }
2437    
2438  =head3 Insert  =head3 Insert
2439    
2440  C<< $sprout->Insert($objectType, \%fieldHash); >>      $sprout->Insert($objectType, \%fieldHash);
2441    
2442  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
2443  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 2446 
2446  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
2447  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>.
2448    
2449  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']});
2450    
2451  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
2452  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>.
2453    
2454  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'});
2455    
2456  =over 4  =over 4
2457    
# Line 2080  Line 2476 
2476    
2477  =head3 Annotate  =head3 Annotate
2478    
2479  C<< my $ok = $sprout->Annotate($fid, $timestamp, $user, $text); >>      my $ok = $sprout->Annotate($fid, $timestamp, $user, $text);
2480    
2481  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
2482  specified feature and user.  specified feature and user.
# Line 2134  Line 2530 
2530    
2531  =head3 AssignFunction  =head3 AssignFunction
2532    
2533  C<< my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser); >>      my $ok = $sprout->AssignFunction($featureID, $user, $function, $assigningUser);
2534    
2535  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
2536  format is described in L</ParseAssignment>.  format is described in L</ParseAssignment>.
# Line 2194  Line 2590 
2590    
2591  =head3 FeaturesByAlias  =head3 FeaturesByAlias
2592    
2593  C<< my @features = $sprout->FeaturesByAlias($alias); >>      my @features = $sprout->FeaturesByAlias($alias);
2594    
2595  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
2596  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 2632 
2632    
2633  =head3 FeatureTranslation  =head3 FeatureTranslation
2634    
2635  C<< my $translation = $sprout->FeatureTranslation($featureID); >>      my $translation = $sprout->FeatureTranslation($featureID);
2636    
2637  Return the translation of a feature.  Return the translation of a feature.
2638    
# Line 2264  Line 2660 
2660    
2661  =head3 Taxonomy  =head3 Taxonomy
2662    
2663  C<< my @taxonomyList = $sprout->Taxonomy($genome); >>      my @taxonomyList = $sprout->Taxonomy($genome);
2664    
2665  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
2666  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>,
2667  or C<Eukaryote>) to sub-species. For example,  or C<Eukaryote>) to sub-species. For example,
2668    
2669  C<< (Bacteria, Proteobacteria, Gammaproteobacteria, Enterobacteriales, Enterobacteriaceae, Escherichia, Escherichia coli, Escherichia coli K12) >>      (Bacteria, Proteobacteria, Gammaproteobacteria, Enterobacteriales, Enterobacteriaceae, Escherichia, Escherichia coli, Escherichia coli K12)
2670    
2671  =over 4  =over 4
2672    
# Line 2305  Line 2701 
2701    
2702  =head3 CrudeDistance  =head3 CrudeDistance
2703    
2704  C<< my $distance = $sprout->CrudeDistance($genome1, $genome2); >>      my $distance = $sprout->CrudeDistance($genome1, $genome2);
2705    
2706  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
2707  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 2753 
2753    
2754  =head3 RoleName  =head3 RoleName
2755    
2756  C<< my $roleName = $sprout->RoleName($roleID); >>      my $roleName = $sprout->RoleName($roleID);
2757    
2758  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
2759  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 2787 
2787    
2788  =head3 RoleDiagrams  =head3 RoleDiagrams
2789    
2790  C<< my @diagrams = $sprout->RoleDiagrams($roleID); >>      my @diagrams = $sprout->RoleDiagrams($roleID);
2791    
2792  Return a list of the diagrams containing a specified functional role.  Return a list of the diagrams containing a specified functional role.
2793    
# Line 2421  Line 2817 
2817    
2818  =head3 GetProperties  =head3 GetProperties
2819    
2820  C<< my @list = $sprout->GetProperties($fid, $key, $value, $url); >>      my @list = $sprout->GetProperties($fid, $key, $value, $url);
2821    
2822  Return a list of the properties with the specified characteristics.  Return a list of the properties with the specified characteristics.
2823    
# Line 2507  Line 2903 
2903    
2904  =head3 FeatureProperties  =head3 FeatureProperties
2905    
2906  C<< my @properties = $sprout->FeatureProperties($featureID); >>      my @properties = $sprout->FeatureProperties($featureID);
2907    
2908  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
2909  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 2942 
2942    
2943  =head3 DiagramName  =head3 DiagramName
2944    
2945  C<< my $diagramName = $sprout->DiagramName($diagramID); >>      my $diagramName = $sprout->DiagramName($diagramID);
2946    
2947  Return the descriptive name of a diagram.  Return the descriptive name of a diagram.
2948    
# Line 2574  Line 2970 
2970    
2971  =head3 PropertyID  =head3 PropertyID
2972    
2973  C<< my $id = $sprout->PropertyID($propName, $propValue); >>      my $id = $sprout->PropertyID($propName, $propValue);
2974    
2975  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
2976  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 3007 
3007    
3008  =head3 MergedAnnotations  =head3 MergedAnnotations
3009    
3010  C<< my @annotationList = $sprout->MergedAnnotations(\@list); >>      my @annotationList = $sprout->MergedAnnotations(\@list);
3011    
3012  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
3013  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 3056 
3056    
3057  =head3 RoleNeighbors  =head3 RoleNeighbors
3058    
3059  C<< my @roleList = $sprout->RoleNeighbors($roleID); >>      my @roleList = $sprout->RoleNeighbors($roleID);
3060    
3061  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
3062  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 3099 
3099    
3100  =head3 FeatureLinks  =head3 FeatureLinks
3101    
3102  C<< my @links = $sprout->FeatureLinks($featureID); >>      my @links = $sprout->FeatureLinks($featureID);
3103    
3104  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
3105  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 3130 
3130    
3131  =head3 SubsystemsOf  =head3 SubsystemsOf
3132    
3133  C<< my %subsystems = $sprout->SubsystemsOf($featureID); >>      my %subsystems = $sprout->SubsystemsOf($featureID);
3134    
3135  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
3136  to the roles the feature performs.  to the roles the feature performs.
# Line 2782  Line 3178 
3178    
3179  =head3 SubsystemList  =head3 SubsystemList
3180    
3181  C<< my @subsystems = $sprout->SubsystemList($featureID); >>      my @subsystems = $sprout->SubsystemList($featureID);
3182    
3183  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
3184  feature participates. Unlike L</SubsystemsOf>, this method only returns the  feature participates. Unlike L</SubsystemsOf>, this method only returns the
# Line 2814  Line 3210 
3210    
3211  =head3 GenomeSubsystemData  =head3 GenomeSubsystemData
3212    
3213  C<< my %featureData = $sprout->GenomeSubsystemData($genomeID); >>      my %featureData = $sprout->GenomeSubsystemData($genomeID);
3214    
3215  Return a hash mapping genome features to their subsystem roles.  Return a hash mapping genome features to their subsystem roles.
3216    
# Line 2874  Line 3270 
3270    
3271  =head3 RelatedFeatures  =head3 RelatedFeatures
3272    
3273  C<< my @relatedList = $sprout->RelatedFeatures($featureID, $function, $userID); >>      my @relatedList = $sprout->RelatedFeatures($featureID, $function, $userID);
3274    
3275  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
3276  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 3321 
3321    
3322  =head3 TaxonomySort  =head3 TaxonomySort
3323    
3324  C<< my @sortedFeatureIDs = $sprout->TaxonomySort(\@featureIDs); >>      my @sortedFeatureIDs = $sprout->TaxonomySort(\@featureIDs);
3325    
3326  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
3327  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 3356 
3356          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",
3357                                          [$fid], 'Genome(taxonomy)');                                          [$fid], 'Genome(taxonomy)');
3358          # Add this feature to the hash buffer.          # Add this feature to the hash buffer.
3359          Tracer::AddToListMap(\%hashBuffer, $taxonomy, $fid);          push @{$hashBuffer{$taxonomy}}, $fid;
3360      }      }
3361      # Sort the keys and get the elements.      # Sort the keys and get the elements.
3362      my @retVal = ();      my @retVal = ();
# Line 2973  Line 3369 
3369    
3370  =head3 Protein  =head3 Protein
3371    
3372  C<< my $protein = Sprout::Protein($sequence, $table); >>      my $protein = Sprout::Protein($sequence, $table);
3373    
3374  Translate a DNA sequence into a protein sequence.  Translate a DNA sequence into a protein sequence.
3375    
# Line 3059  Line 3455 
3455    
3456  =head3 LoadInfo  =head3 LoadInfo
3457    
3458  C<< my ($dirName, @relNames) = $sprout->LoadInfo(); >>      my ($dirName, @relNames) = $sprout->LoadInfo();
3459    
3460  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
3461  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 3476 
3476    
3477  =head3 BBHMatrix  =head3 BBHMatrix
3478    
3479  C<< my %bbhMap = $sprout->BBHMatrix($genomeID, $cutoff, @targets); >>      my %bbhMap = $sprout->BBHMatrix($genomeID, $cutoff, @targets);
3480    
3481  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
3482  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 3530 
3530    
3531  =head3 SimMatrix  =head3 SimMatrix
3532    
3533  C<< my %simMap = $sprout->SimMatrix($genomeID, $cutoff, @targets); >>      my %simMap = $sprout->SimMatrix($genomeID, $cutoff, @targets);
3534    
3535  Find all the similarities for the features of a genome in a  Find all the similarities for the features of a genome in a
3536  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 3600 
3600    
3601  =head3 LowBBHs  =head3 LowBBHs
3602    
3603  C<< my %bbhMap = $sprout->LowBBHs($featureID, $cutoff); >>      my %bbhMap = $sprout->LowBBHs($featureID, $cutoff);
3604    
3605  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
3606  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 3644 
3644    
3645  =head3 Sims  =head3 Sims
3646    
3647  C<< my $simList = $sprout->Sims($fid, $maxN, $maxP, $select, $max_expand, $filters); >>      my $simList = $sprout->Sims($fid, $maxN, $maxP, $select, $max_expand, $filters);
3648    
3649  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
3650  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 3710 
3710    
3711  =head3 IsAllGenomes  =head3 IsAllGenomes
3712    
3713  C<< my $flag = $sprout->IsAllGenomes(\@list, \@checkList); >>      my $flag = $sprout->IsAllGenomes(\@list, \@checkList);
3714    
3715  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
3716  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 3759 
3759    
3760  =head3 GetGroups  =head3 GetGroups
3761    
3762  C<< my %groups = $sprout->GetGroups(\@groupList); >>      my %groups = $sprout->GetGroups(\@groupList);
3763    
3764  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.
3765  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 3791 
3791                                      [$FIG_Config::otherGroup], ['Genome(id)', 'Genome(primary-group)']);                                      [$FIG_Config::otherGroup], ['Genome(id)', 'Genome(primary-group)']);
3792          # Loop through the genomes found.          # Loop through the genomes found.
3793          for my $genome (@genomes) {          for my $genome (@genomes) {
3794              # Pop this genome's ID off the current list.              # Get the genome ID and group, and add this genome to the group's list.
3795              my @groups = @{$genome};              my ($genomeID, $group) = @{$genome};
3796              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);  
             }  
3797          }          }
3798      }      }
3799      # Return the hash we just built.      # Return the hash we just built.
# Line 3411  Line 3802 
3802    
3803  =head3 MyGenomes  =head3 MyGenomes
3804    
3805  C<< my @genomes = Sprout::MyGenomes($dataDir); >>      my @genomes = Sprout::MyGenomes($dataDir);
3806    
3807  Return a list of the genomes to be included in the Sprout.  Return a list of the genomes to be included in the Sprout.
3808    
# Line 3443  Line 3834 
3834    
3835  =head3 LoadFileName  =head3 LoadFileName
3836    
3837  C<< my $fileName = Sprout::LoadFileName($dataDir, $tableName); >>      my $fileName = Sprout::LoadFileName($dataDir, $tableName);
3838    
3839  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
3840  directory.  directory.
# Line 3484  Line 3875 
3875    
3876  =head3 DeleteGenome  =head3 DeleteGenome
3877    
3878  C<< my $stats = $sprout->DeleteGenome($genomeID, $testFlag); >>      my $stats = $sprout->DeleteGenome($genomeID, $testFlag);
3879    
3880  Delete a genome from the database.  Delete a genome from the database.
3881    
# Line 3520  Line 3911 
3911    
3912  =head3 Fix  =head3 Fix
3913    
3914  C<< my %fixedHash = Sprout::Fix(%groupHash); >>      my %fixedHash = $sprout->Fix(%groupHash);
3915    
3916  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.
3917  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.  
3918    
3919  =over 4  =over 4
3920    
# Line 3542  Line 3932 
3932    
3933  sub Fix {  sub Fix {
3934      # Get the parameters.      # Get the parameters.
3935      my (%groupHash) = @_;      my ($self, %groupHash) = @_;
3936      # Create the result hash.      # Create the result hash.
3937      my %retVal = ();      my %retVal = ();
3938      # Copy over the genomes.      # Copy over the genomes.
3939      for my $groupID (keys %groupHash) {      for my $groupID (keys %groupHash) {
3940          # Make a safety copy of the group ID.          # Get the super-group name.
3941          my $realGroupID = $groupID;          my $realGroupID = $self->SuperGroup($groupID);
3942          # Yank the primary name.          # Append this group's genomes into the result hash
3943          if ($groupID =~ /([A-Z]\w+)/) {          # using the super-group name.
3944              $realGroupID = $1;          push @{$retVal{$realGroupID}}, @{$groupHash{$groupID}};
         }  
         # Append this group's genomes into the result hash.  
         Tracer::AddToListMap(\%retVal, $realGroupID, @{$groupHash{$groupID}});  
3945      }      }
3946      # Return the result hash.      # Return the result hash.
3947      return %retVal;      return %retVal;
# Line 3562  Line 3949 
3949    
3950  =head3 GroupPageName  =head3 GroupPageName
3951    
3952  C<< my $name = $sprout->GroupPageName($group); >>      my $name = $sprout->GroupPageName($group);
3953    
3954  Return the name of the page for the specified NMPDR group.  Return the name of the page for the specified NMPDR group.
3955    
# Line 3584  Line 3971 
3971  sub GroupPageName {  sub GroupPageName {
3972      # Get the parameters.      # Get the parameters.
3973      my ($self, $group) = @_;      my ($self, $group) = @_;
     # Declare the return variable.  
     my $retVal;  
3974      # Check for the group file data.      # Check for the group file data.
3975      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;  
     }  
3976      # Compute the real group name.      # Compute the real group name.
3977      my $realGroup = $group;      my $realGroup = $self->SuperGroup($group);
3978      if ($group =~ /([A-Z]\w+)/) {      # Get the associated page name.
3979          $realGroup = $1;      my $retVal = "../content/$superTable{$realGroup}->{page}";
     }  
     # Return the page name.  
     $retVal = "../content/" . $self->{groupHash}->{$realGroup}->[1];  
3980      # Return the result.      # Return the result.
3981      return $retVal;      return $retVal;
3982  }  }
3983    
 =head3 ReadGroupFile  
3984    
3985  C<< my %groupData = Sprout::ReadGroupFile($groupFileName); >>  =head3 AddProperty
   
 Read in the data from the specified group file. The group file contains information  
 about each of the NMPDR groups.  
   
 =over 4  
   
 =item name  
   
 Name of the group.  
   
 =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  
3986    
3987  =item species      $sprout->AddProperty($featureID, $key, @values);
3988    
3989  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.  
3990    
3991  =back  =over 4
3992    
3993  The parameters to this method are as follows  =item peg
3994    
3995  =over 4  ID of the feature to which the attribute is to be added.
3996    
3997  =item groupFile  =item key
3998    
3999  Name of the file containing the group data.  Name of the attribute (key).
4000    
4001  =item RETURN  =item values
4002    
4003  Returns a hash keyed on group name. The value of each hash  Values of the attribute.
4004    
4005  =back  =back
4006    
4007  =cut  =cut
4008    #: Return Type ;
4009  sub ReadGroupFile {  sub AddProperty {
4010      # Get the parameters.      # Get the parameters.
4011      my ($groupFileName) = @_;      my ($self, $featureID, $key, @values) = @_;
4012      # Declare the return variable.      # Add the property using the attached attributes object.
4013      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;  
4014  }  }
4015    
4016  =head3 AddProperty  =head3 CheckGroupFile
4017    
4018  C<< my  = $sprout->AddProperty($featureID, $key, @values); >>      my %groupData = $sprout->CheckGroupFile();
4019    
4020  Add a new attribute value (Property) to a feature.  Get the group file hash. The group file hash describes the relationship
4021    between a group and the super-group to which it belongs for purposes of
4022    display. The super-group name is computed from the first capitalized word
4023    in the actual group name. For each super-group, the group file contains
4024    the page name and a list of the species expected to be in the group.
4025    Each species is specified by a genus and a species name. A species name
4026    of C<0> implies an entire genus.
4027    
4028  =over 4  This method returns a hash from super-group names to a hash reference. Each
4029    resulting hash reference contains the following fields.
4030    
4031  =item peg  =over 4
   
 ID of the feature to which the attribute is to be added.  
4032    
4033  =item key  =item page
4034    
4035  Name of the attribute (key).  The super-group's web page in the NMPDR.
4036    
4037  =item values  =item contents
4038    
4039  Values of the attribute.  A list of 2-tuples, each containing a genus name followed by a species name
4040    (or 0, indicating all species). This list indicates which organisms belong
4041    in the super-group.
4042    
4043  =back  =back
4044    
4045  =cut  =cut
4046  #: Return Type ;  
4047  sub AddProperty {  sub CheckGroupFile {
4048      # Get the parameters.      # Get the parameters.
4049      my ($self, $featureID, $key, @values) = @_;      my ($self) = @_;
4050      # Add the property using the attached attributes object.      # Check to see if we already have this hash.
4051      $self->{_ca}->AddAttribute($featureID, $key, @values);      if (! defined $self->{groupHash}) {
4052            # We don't, so we need to read it in.
4053            my %groupHash;
4054            # Read the group file.
4055            my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");
4056            # Loop through the list of sort-of groups.
4057            for my $groupLine (@groupLines) {
4058                my ($name, $page, @contents) = split /\t/, $groupLine;
4059                $groupHash{$name} = { page => $page,
4060                                      contents => [ map { [ split /\s*,\s*/, $_ ] } @contents ]
4061                                    };
4062            }
4063            # Save the hash.
4064            $self->{groupHash} = \%groupHash;
4065        }
4066        # Return the result.
4067        return %{$self->{groupHash}};
4068  }  }
4069    
4070  =head2 Virtual Methods  =head2 Virtual Methods
4071    
4072  =head3 CleanKeywords  =head3 CleanKeywords
4073    
4074  C<< my $cleanedString = $sprout->CleanKeywords($searchExpression); >>      my $cleanedString = $sprout->CleanKeywords($searchExpression);
4075    
4076  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
4077  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 3727  Line 4098 
4098      # Get the parameters.      # Get the parameters.
4099      my ($self, $searchExpression) = @_;      my ($self, $searchExpression) = @_;
4100      # Perform the standard cleanup.      # Perform the standard cleanup.
4101      my $retVal = $self->ERDB::CleanKeywords($searchExpression);      my $words = $self->ERDB::CleanKeywords($searchExpression);
4102      # Fix the periods in EC and TC numbers.      # Fix the periods in EC and TC numbers.
4103      $retVal =~ s/(\d+|\-)\.(\d+|-)\.(\d+|-)\.(\d+|-)/$1_$2_$3_$4/g;      $words =~ s/(\d+|\-)\.(\d+|-)\.(\d+|-)\.(\d+|-)/$1_$2_$3_$4/g;
4104      # Fix non-trailing periods.      # Fix non-trailing periods.
4105      $retVal =~ s/\.(\w)/_$1/g;      $words =~ s/\.(\w)/_$1/g;
4106      # Fix non-leading minus signs.      # Fix non-leading minus signs.
4107      $retVal =~ s/(\w)[\-]/$1_/g;      $words =~ s/(\w)[\-]/$1_/g;
4108      # Fix the vertical bars and colons      # Fix the vertical bars and colons
4109      $retVal =~ s/(\w)[|:](\w)/$1'$2/g;      $words =~ s/(\w)[|:](\w)/$1'$2/g;
4110        # Now split up the list so that each keyword is in its own string. We keep the delimiters
4111        # because they may contain boolean expression data.
4112        my @words = split /([^A-Za-z'0-9_]+)/, $words;
4113        # We'll convert the stemmable words into stems and re-assemble the result.
4114        my $retVal = "";
4115        for my $word (@words) {
4116            my $stem = $self->Stem($word);
4117            if (defined $stem) {
4118                $retVal .= $stem;
4119            } else {
4120                $retVal .= $word;
4121            }
4122        }
4123        Trace("Cleaned keyword list for \"$searchExpression\" is \"$retVal\".") if T(3);
4124      # Return the result.      # Return the result.
4125      return $retVal;      return $retVal;
4126  }  }
# Line 3750  Line 4135 
4135    
4136  A functional assignment is always of the form  A functional assignment is always of the form
4137    
4138      C<set >I<YYYY>C< function to\n>I<ZZZZZ>      set YYYY function to
4139        ZZZZ
4140    
4141  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,
4142  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 4191 
4191    
4192  =head3 _CheckFeature  =head3 _CheckFeature
4193    
4194  C<< my $flag = $sprout->_CheckFeature($fid); >>      my $flag = $sprout->_CheckFeature($fid);
4195    
4196  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.
4197    

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.113

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3