[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.12, Fri Sep 16 02:09:47 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 = $self->_TableLoader('FeatureAlias', $featureCount * 6);
438        my ($loadFeatureLink, $loadFeatureTranslation, $loadFeatureUpstream);
439        if (! $limited) {
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 445  Line 455 
455          for my $featureData (@{$features}) {          for my $featureData (@{$features}) {
456              $loadFeature->Add("featureIn");              $loadFeature->Add("featureIn");
457              # Split the tuple.              # Split the tuple.
458              my ($featureID, $locations, $aliases, $type) = @{$featureData};              my ($featureID, $locations, undef, $type) = @{$featureData};
459              # Create the feature record.              # Create the feature record.
460              $loadFeature->Put($featureID, 1, $type);              $loadFeature->Put($featureID, 1, $type);
461              # Create the aliases.              # Create the aliases.
462              for my $alias (split /\s*,\s*/, $aliases) {              for my $alias ($fig->feature_aliases($featureID)) {
463                  $loadFeatureAlias->Put($featureID, $alias);                  $loadFeatureAlias->Put($featureID, $alias);
464              }              }
465                # The next stuff is for a full load only.
466                if (! $limited) {
467              # Get the links.              # Get the links.
468              my @links = $fig->fid_links($featureID);              my @links = $fig->fid_links($featureID);
469              for my $link (@links) {              for my $link (@links) {
# 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 = 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.
496                  my $locObject = BasicLocation->new($location);                  my $locObject = BasicLocation->new("$genomeID:$location");
497                  # Split it into a list of chunks.                  # Split it into a list of chunks.
498                  my @locOList = ();                  my @locOList = ();
499                  while (my $peeling = $locObject->Peel($chunkSize)) {                  while (my $peeling = $locObject->Peel($chunkSize)) {
# 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);
# Line 662  Line 676 
676          for my $genomeID (@genomes) {          for my $genomeID (@genomes) {
677              # Only process this genome if it's one of ours.              # Only process this genome if it's one of ours.
678              if (exists $genomeHash->{$genomeID}) {              if (exists $genomeHash->{$genomeID}) {
679                    Trace("Processing genome $genomeID for subsystem $subsysID.");
680                  # Connect the genome to the subsystem.                  # Connect the genome to the subsystem.
681                  $loadParticipatesIn->Put($genomeID, $subsysID);                  $loadParticipatesIn->Put($genomeID, $subsysID);
682                    # Count the PEGs and cells found for verification purposes.
683                    my $pegCount = 0;
684                    my $cellCount = 0;
685                  # Loop through the subsystem's roles. We use an index because it is                  # Loop through the subsystem's roles. We use an index because it is
686                  # part of the spreadsheet cell ID.                  # part of the spreadsheet cell ID.
687                  for (my $i = 0; $i <= $#roles; $i++) {                  for (my $i = 0; $i <= $#roles; $i++) {
# Line 673  Line 691 
691                      # Only proceed if features exist.                      # Only proceed if features exist.
692                      if (@pegs > 0) {                      if (@pegs > 0) {
693                          # Create the spreadsheet cell.                          # Create the spreadsheet cell.
694                            $cellCount++;
695                          my $cellID = "$subsysID:$genomeID:$i";                          my $cellID = "$subsysID:$genomeID:$i";
696                          $loadSSCell->Put($cellID);                          $loadSSCell->Put($cellID);
697                          $loadIsGenomeOf->Put($genomeID, $cellID);                          $loadIsGenomeOf->Put($genomeID, $cellID);
# Line 681  Line 700 
700                          # Attach the features to it.                          # Attach the features to it.
701                          for my $pegID (@pegs) {                          for my $pegID (@pegs) {
702                              $loadContainsFeature->Put($cellID, $pegID);                              $loadContainsFeature->Put($cellID, $pegID);
703                                $pegCount++;
704                          }                          }
705                      }                      }
706                  }                  }
707                    Trace("$pegCount PEGs found in $cellCount cells.") if T(3);
708              }              }
709          }          }
710      }      }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3