[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.5, Tue Jan 25 03:02:07 2005 UTC revision 1.8, Thu Jan 27 00:30:20 2005 UTC
# Line 36  Line 36 
36    
37  #: Constructor SFXlate->new_sprout_only();  #: Constructor SFXlate->new_sprout_only();
38    
   
39  =head2 Public Methods  =head2 Public Methods
40    
41  =head3 new  =head3 new
# Line 424  Line 423 
423  =back  =back
424    
425  =cut  =cut
426  #: Return Type %;  #: Return Type $%;
427  sub LoadUpdate {  sub LoadUpdate {
428          # Get the parameters.          # Get the parameters.
429          my $self = shift @_;          my $self = shift @_;
# Line 2550  Line 2549 
2549          return %retVal;          return %retVal;
2550  }  }
2551    
2552    =head3 GetGroups
2553    
2554    C<< my %groups = $sprout->GetGroups(\@groupList); >>
2555    
2556    Return a hash mapping each group to the IDs of the genomes in the group.
2557    A list of groups may be specified, in which case only those groups will be
2558    shown. Alternatively, if no parameter is supplied, all groups will be
2559    included. Genomes that are not in any group are omitted.
2560    
2561    =cut
2562    #: Return Type %@;
2563    sub GetGroups {
2564        # Get the parameters.
2565        my $self = shift @_;
2566        my ($groupList) = @_;
2567        # Declare the return value.
2568        my %retVal = ();
2569        # Determine whether we are getting all the groups or just some.
2570        if (defined $groupList) {
2571            # Here we have a group list. Loop through them individually,
2572            # getting a list of the relevant genomes.
2573            for my $group (@{$groupList}) {
2574                my @genomeIDs = $self->GetFlat(['Genome'], "Genome(group-name) = ?",
2575                    [$group], "Genome(id)");
2576                $retVal{$group} = \@genomeIDs;
2577            }
2578        } else {
2579            # Here we need all of the groups. In this case, we run through all
2580            # of the genome records, putting each one found into the appropriate
2581            # group. Note that we use a filter clause to insure that only genomes
2582            # in groups are included in the return set.
2583            my @genomes = $self->GetAll(['Genome'], "Genome(group-name) > ' '", [],
2584                                        ['Genome(id)', 'Genome(group-name)']);
2585            # Loop through the genomes found.
2586            for my $genome (@genomes) {
2587                # Pop this genome's ID off the current list.
2588                my @groups = @{$genome};
2589                my $genomeID = shift @groups;
2590                # Loop through the groups, adding the genome ID to each group's
2591                # list.
2592                for my $group (@groups) {
2593                    if (exists $retVal{$group}) {
2594                        push @{$retVal{$group}}, $genomeID;
2595                    } else {
2596                        $retVal{$group} = [$genomeID];
2597                    }
2598                }
2599            }
2600        }
2601        # Return the hash we just built.
2602        return %retVal;
2603    }
2604    
2605  =head2 Internal Utility Methods  =head2 Internal Utility Methods
2606    
2607  =head3 ParseAssignment  =head3 ParseAssignment

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3