[Bio] / Sprout / GenomeSaplingLoader.pm Repository:
ViewVC logotype

Diff of /Sprout/GenomeSaplingLoader.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5, Wed Sep 9 16:30:22 2009 UTC revision 1.6, Wed Nov 25 20:38:13 2009 UTC
# Line 128  Line 128 
128          # Is this a new set?          # Is this a new set?
129          if ($newSetID != $setID) {          if ($newSetID != $setID) {
130              # Yes. Output the old set.              # Yes. Output the old set.
131              $self->OutputGenomeSet(\%names, \%setNames, \@genomes);              $self->OutputGenomeSet(\%names, $setID, \@genomes);
132              # Clear the set data.              # Clear the set data.
133              %names = ();              %names = ();
134              @genomes = ();              @genomes = ();
# Line 149  Line 149 
149      # Close the input file.      # Close the input file.
150      close $ih;      close $ih;
151      # Output the last set.      # Output the last set.
152      $self->OutputGenomeSet(\%names, \%setNames, \@genomes);      $self->OutputGenomeSet(\%names, $setID, \@genomes);
153  }  }
154    
155  =head3 OutputGenomeSet  =head3 OutputGenomeSet
156    
157      $sl->OutputGenomeSet(\%names, \%setNames, \@genomes);      $sl->OutputGenomeSet(\%names, $setID, \@genomes);
158    
159  Output the data for a genome set. A name will be computed from the genus  Output the data for a genome set. The appropriate GenomeSet and IsCollectionOf
160  information and the appropriate GenomeSet and IsCollectionOf records will  records will be generated for the genomes in the set.
 be generated for the genomes in the set.  
161    
162  =over 4  =over 4
163    
# Line 167  Line 166 
166  Reference to a hash of the genus names used in the set. The hash maps each name  Reference to a hash of the genus names used in the set. The hash maps each name
167  to the number of times it appeared.  to the number of times it appeared.
168    
169  =item setNames  =item setID
170    
171  Reference to a hash of set names already used. This hash will be updated to include  The ID to use for this set.
 the set name chosen.  
172    
173  =item genomes  =item genomes
174    
# Line 182  Line 180 
180    
181  sub OutputGenomeSet {  sub OutputGenomeSet {
182      # Get the parameters.      # Get the parameters.
183      my ($self, $names, $setNames, $genomes) = @_;      my ($self, $names, $setID, $genomes) = @_;
184      # Only proceed if there is at least one genome.      # Only proceed if there is at least one genome.
185      my $count = scalar @$genomes;      my $count = scalar @$genomes;
186      if ($count) {      if ($count) {
         # First we compute the name. Sort the genus names by occurrence count.  
         my ($setName) = sort { $names->{$a} <=> $names->{$b} } keys %$names;  
         # Apply a suffix to make it unique.  
         my $i = 1;  
         $i++ while $setNames->{"$setName/$i"};  
         $setName .= "/$i";  
         # Insure we don't reuse this set name.  
         $setNames->{$setName} = 1;  
187          # Create the set record.          # Create the set record.
188          $self->PutE(GenomeSet => $setName);          $self->PutE(GenomeSet => $setID);
189          # This will be TRUE for the first genome and FALSE thereafter, insuring that          # This will be TRUE for the first genome and FALSE thereafter, insuring that
190          # the first genome is used for the representative.          # the first genome is used for the representative.
191          my $repFlag = 1;          my $repFlag = 1;
192          # Connect all the genomes to it.          # Connect all the genomes to it.
193          for my $genome (@$genomes) {          for my $genome (@$genomes) {
194              $self->PutR(IsCollectionOf => $setName, $genome, representative => $repFlag);              $self->PutR(IsCollectionOf => $setID, $genome, representative => $repFlag);
195              $repFlag = 0;              $repFlag = 0;
196          }          }
197      }      }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3