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

Diff of /Sprout/SproutLoad.pm

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

revision 1.7, Tue Sep 13 19:05:20 2005 UTC revision 1.9, Wed Sep 14 11:21:24 2005 UTC
# Line 51  Line 51 
51    
52  =head3 new  =head3 new
53    
54  C<< my $spl = SproutLoad->new($sprout, $fig, $genomeFile, $subsysFile); >>  C<< my $spl = SproutLoad->new($sprout, $fig, $genomeFile, $subsysFile, $options); >>
55    
56  Construct a new Sprout Loader object, specifying the two participating databases and  Construct a new Sprout Loader object, specifying the two participating databases and
57  the name of the files containing the list of genomes and subsystems to use.  the name of the files containing the list of genomes and subsystems to use.
# Line 82  Line 82 
82  to a list of subsystem names. If nothing is specified, all known subsystems will be  to a list of subsystem names. If nothing is specified, all known subsystems will be
83  considered trusted. Only subsystem data related to the trusted subsystems is loaded.  considered trusted. Only subsystem data related to the trusted subsystems is loaded.
84    
85    =item options
86    
87    Reference to a hash of command-line options.
88    
89  =back  =back
90    
91  =cut  =cut
92    
93  sub new {  sub new {
94      # Get the parameters.      # Get the parameters.
95      my ($class, $sprout, $fig, $genomeFile, $subsysFile) = @_;      my ($class, $sprout, $fig, $genomeFile, $subsysFile, $options) = @_;
96      # Load the list of genomes into a hash.      # Load the list of genomes into a hash.
97      my %genomes;      my %genomes;
98      if (! defined($genomeFile) || $genomeFile eq '') {      if (! defined($genomeFile) || $genomeFile eq '') {
# Line 158  Line 162 
162                    sprout => $sprout,                    sprout => $sprout,
163                    loadDirectory => $directory,                    loadDirectory => $directory,
164                    erdb => $sprout->{_erdb},                    erdb => $sprout->{_erdb},
165                    loaders => []                    loaders => [],
166                      options => $options
167                   };                   };
168      # Bless and return it.      # Bless and return it.
169      bless $retVal, $class;      bless $retVal, $class;
# Line 420  Line 425 
425      my ($self) = @_;      my ($self) = @_;
426      # Get the FIG object.      # Get the FIG object.
427      my $fig = $self->{fig};      my $fig = $self->{fig};
428        # Find out if this is a limited run.
429        my $limited = $self->{options}->{limitedFeatures};
430      # Get the table of genome IDs.      # Get the table of genome IDs.
431      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
432      my $genomeCount = (keys %{$genomeHash});      my $genomeCount = (keys %{$genomeHash});
433      my $featureCount = $genomeCount * 4000;      my $featureCount = $genomeCount * 4000;
434      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
435      my $loadFeature = $self->_TableLoader('Feature', $featureCount);      my $loadFeature = $self->_TableLoader('Feature', $featureCount);
     my $loadFeatureAlias = $self->_TableLoader('FeatureAlias', $featureCount * 6);  
     my $loadFeatureLink = $self->_TableLoader('FeatureLink', $featureCount * 10);  
     my $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation', $featureCount);  
     my $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream', $featureCount);  
436      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $featureCount);      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $featureCount);
437        my ($loadFeatureAlias, $loadFeatureLink, $loadFeatureTranslation, $loadFeatureUpstream);
438        if (! $limited) {
439            $loadFeatureAlias = $self->_TableLoader('FeatureAlias', $featureCount * 6);
440            $loadFeatureLink = $self->_TableLoader('FeatureLink', $featureCount * 10);
441            $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation', $featureCount);
442            $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream', $featureCount);
443        }
444      # Get the maximum sequence size. We need this later for splitting up the      # Get the maximum sequence size. We need this later for splitting up the
445      # locations.      # locations.
446      my $chunkSize = $self->{sprout}->MaxSegment();      my $chunkSize = $self->{sprout}->MaxSegment();
# Line 448  Line 458 
458              my ($featureID, $locations, $aliases, $type) = @{$featureData};              my ($featureID, $locations, $aliases, $type) = @{$featureData};
459              # Create the feature record.              # Create the feature record.
460              $loadFeature->Put($featureID, 1, $type);              $loadFeature->Put($featureID, 1, $type);
461                # The next stuff is for a full load only.
462                if (! $limited) {
463              # Create the aliases.              # Create the aliases.
464              for my $alias (split /\s*,\s*/, $aliases) {              for my $alias (split /\s*,\s*/, $aliases) {
465                  $loadFeatureAlias->Put($featureID, $alias);                  $loadFeatureAlias->Put($featureID, $alias);
# Line 470  Line 482 
482                      $loadFeatureUpstream->Put($featureID, $upstream);                      $loadFeatureUpstream->Put($featureID, $upstream);
483                  }                  }
484              }              }
485                }
486              # This part is the roughest. We need to relate the features to contig              # This part is the roughest. We need to relate the features to contig
487              # locations, and the locations must be split so that none of them exceed              # locations, and the locations must be split so that none of them exceed
488              # the maximum segment size. This simplifies the genes_in_region processing              # the maximum segment size. This simplifies the genes_in_region processing
489              # for Sprout.              # for Sprout.
490              my @locationList = split /\s*,\s*/, $locations;              my @locationList = map { "$genomeID:$_" } split /\s*,\s*/, $locations;
491                # Create the location position indicator.
492                my $i = 1;
493              # Loop through the locations.              # Loop through the locations.
494              for my $location (@locationList) {              for my $location (@locationList) {
495                  # Parse the location.                  # Parse the location.
# Line 488  Line 503 
503                  push @locOList, $locObject;                  push @locOList, $locObject;
504                  # Loop through the chunks, creating IsLocatedIn records. The variable                  # Loop through the chunks, creating IsLocatedIn records. The variable
505                  # "$i" will be used to keep the location index.                  # "$i" will be used to keep the location index.
                 my $i = 1;  
506                  for my $locChunk (@locOList) {                  for my $locChunk (@locOList) {
507                      $loadIsLocatedIn->Put($featureID, $locChunk->Contig, $locChunk->Left,                      $loadIsLocatedIn->Put($featureID, $locChunk->Contig, $locChunk->Left,
508                                            $locChunk->Dir, $locChunk->Length, $i);                                            $locChunk->Dir, $locChunk->Length, $i);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3