[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.19, Thu Oct 20 09:34:09 2005 UTC revision 1.39, Thu Jun 8 15:34:53 2006 UTC
# Line 80  Line 80 
80  =item subsysFile  =item subsysFile
81    
82  Either the name of the file containing the list of trusted subsystems or a reference  Either the name of the file containing the list of trusted subsystems or a reference
83  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 NMPDR subsystems will be
84  considered trusted. Only subsystem data related to the trusted subsystems is loaded.  considered trusted. (A subsystem is considered NMPDR if it has a file named C<NMPDR>
85    in its data directory.) Only subsystem data related to the trusted subsystems is loaded.
86    
87  =item options  =item options
88    
# Line 94  Line 95 
95  sub new {  sub new {
96      # Get the parameters.      # Get the parameters.
97      my ($class, $sprout, $fig, $genomeFile, $subsysFile, $options) = @_;      my ($class, $sprout, $fig, $genomeFile, $subsysFile, $options) = @_;
98      # Load the list of genomes into a hash.      # Create the genome hash.
99      my %genomes;      my %genomes = ();
100        # We only need it if load-only is NOT specified.
101        if (! $options->{loadOnly}) {
102      if (! defined($genomeFile) || $genomeFile eq '') {      if (! defined($genomeFile) || $genomeFile eq '') {
103          # Here we want all the complete genomes and an access code of 1.          # Here we want all the complete genomes and an access code of 1.
104          my @genomeList = $fig->genomes(1);          my @genomeList = $fig->genomes(1);
# Line 129  Line 132 
132              Confess("Invalid genome parameter ($type) in SproutLoad constructor.");              Confess("Invalid genome parameter ($type) in SproutLoad constructor.");
133          }          }
134      }      }
135        }
136      # Load the list of trusted subsystems.      # Load the list of trusted subsystems.
137      my %subsystems = ();      my %subsystems = ();
138        # We only need it if load-only is NOT specified.
139        if (! $options->{loadOnly}) {
140      if (! defined $subsysFile || $subsysFile eq '') {      if (! defined $subsysFile || $subsysFile eq '') {
141          # Here we want all the subsystems.              # Here we want all the NMPDR subsystems. First we get the whole list.
142          %subsystems = map { $_ => 1 } $fig->all_subsystems();              my @subs = $fig->all_subsystems();
143                # Loop through, checking for the NMPDR file.
144                for my $sub (@subs) {
145                    if (-e "$FIG_Config::data/Subsystems/$sub/NMPDR") {
146                        $subsystems{$sub} = 1;
147                    }
148                }
149      } else {      } else {
150          my $type = ref $subsysFile;          my $type = ref $subsysFile;
151          if ($type eq 'ARRAY') {          if ($type eq 'ARRAY') {
# Line 153  Line 165 
165              Confess("Invalid subsystem parameter in SproutLoad constructor.");              Confess("Invalid subsystem parameter in SproutLoad constructor.");
166          }          }
167      }      }
168        }
169      # Get the data directory from the Sprout object.      # Get the data directory from the Sprout object.
170      my ($directory) = $sprout->LoadInfo();      my ($directory) = $sprout->LoadInfo();
171      # Create the Sprout load object.      # Create the Sprout load object.
# Line 162  Line 175 
175                    subsystems => \%subsystems,                    subsystems => \%subsystems,
176                    sprout => $sprout,                    sprout => $sprout,
177                    loadDirectory => $directory,                    loadDirectory => $directory,
178                    erdb => $sprout->{_erdb},                    erdb => $sprout,
179                    loaders => [],                    loaders => [],
180                    options => $options                    options => $options
181                   };                   };
# Line 171  Line 184 
184      return $retVal;      return $retVal;
185  }  }
186    
187    =head3 LoadOnly
188    
189    C<< my $flag = $spl->LoadOnly; >>
190    
191    Return TRUE if we are in load-only mode, else FALSE.
192    
193    =cut
194    
195    sub LoadOnly {
196        my ($self) = @_;
197        return $self->{options}->{loadOnly};
198    }
199    
200    =head3 PrimaryOnly
201    
202    C<< my $flag = $spl->PrimaryOnly; >>
203    
204    Return TRUE if only the main entity is to be loaded, else FALSE.
205    
206    =cut
207    
208    sub PrimaryOnly {
209        my ($self) = @_;
210        return $self->{options}->{primaryOnly};
211    }
212    
213  =head3 LoadGenomeData  =head3 LoadGenomeData
214    
215  C<< my $stats = $spl->LoadGenomeData(); >>  C<< my $stats = $spl->LoadGenomeData(); >>
# Line 198  Line 237 
237    
238  =back  =back
239    
 B<TO DO>  
   
 Real quality vectors instead of C<unknown> for everything.  
   
 GenomeGroup relation. (The original script took group information from the C<NMPDR> file  
 in each genome's main directory, but no such file exists anywhere in my version of the  
 data store.)  
   
240  =cut  =cut
241  #: Return Type $%;  #: Return Type $%;
242  sub LoadGenomeData {  sub LoadGenomeData {
# Line 216  Line 247 
247      # Get the genome count.      # Get the genome count.
248      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
249      my $genomeCount = (keys %{$genomeHash});      my $genomeCount = (keys %{$genomeHash});
     Trace("Beginning genome data load.") if T(2);  
250      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
251      my $loadGenome = $self->_TableLoader('Genome', $genomeCount);      my $loadGenome = $self->_TableLoader('Genome');
252      my $loadHasContig = $self->_TableLoader('HasContig', $genomeCount * 300);      my $loadHasContig = $self->_TableLoader('HasContig', $self->PrimaryOnly);
253      my $loadContig = $self->_TableLoader('Contig', $genomeCount * 300);      my $loadContig = $self->_TableLoader('Contig', $self->PrimaryOnly);
254      my $loadIsMadeUpOf = $self->_TableLoader('IsMadeUpOf', $genomeCount * 60000);      my $loadIsMadeUpOf = $self->_TableLoader('IsMadeUpOf', $self->PrimaryOnly);
255      my $loadSequence = $self->_TableLoader('Sequence', $genomeCount * 60000);      my $loadSequence = $self->_TableLoader('Sequence', $self->PrimaryOnly);
256        if ($self->{options}->{loadOnly}) {
257            Trace("Loading from existing files.") if T(2);
258        } else {
259            Trace("Generating genome data.") if T(2);
260      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
261      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
262          Trace("Loading data for genome $genomeID.") if T(3);              Trace("Generating data for genome $genomeID.") if T(3);
263          $loadGenome->Add("genomeIn");          $loadGenome->Add("genomeIn");
264          # The access code comes in via the genome hash.          # The access code comes in via the genome hash.
265          my $accessCode = $genomeHash->{$genomeID};          my $accessCode = $genomeHash->{$genomeID};
266          # Get the genus, species, and strain from the scientific name. Note that we append              # Get the genus, species, and strain from the scientific name.
         # the genome ID to the strain. In some cases this is the totality of the strain name.  
267          my ($genus, $species, @extraData) = split / /, $self->{fig}->genus_species($genomeID);          my ($genus, $species, @extraData) = split / /, $self->{fig}->genus_species($genomeID);
268          my $extra = join " ", @extraData, "[$genomeID]";              my $extra = join " ", @extraData;
269          # Get the full taxonomy.          # Get the full taxonomy.
270          my $taxonomy = $fig->taxonomy_of($genomeID);          my $taxonomy = $fig->taxonomy_of($genomeID);
271          # Output the genome record.          # Output the genome record.
# Line 268  Line 301 
301              }              }
302          }          }
303      }      }
304        }
305      # Finish the loads.      # Finish the loads.
306      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
307      # Return the result.      # Return the result.
# Line 311  Line 345 
345      my $genomeCount = (keys %{$genomeFilter});      my $genomeCount = (keys %{$genomeFilter});
346      my $featureCount = $genomeCount * 4000;      my $featureCount = $genomeCount * 4000;
347      # Start the loads.      # Start the loads.
348      my $loadCoupling = $self->_TableLoader('Coupling', $featureCount * $genomeCount);      my $loadCoupling = $self->_TableLoader('Coupling');
349      my $loadIsEvidencedBy = $self->_TableLoader('IsEvidencedBy', $featureCount * 8000);      my $loadIsEvidencedBy = $self->_TableLoader('IsEvidencedBy', $self->PrimaryOnly);
350      my $loadPCH = $self->_TableLoader('PCH', $featureCount * 2000);      my $loadPCH = $self->_TableLoader('PCH', $self->PrimaryOnly);
351      my $loadParticipatesInCoupling = $self->_TableLoader('ParticipatesInCoupling', $featureCount * 2000);      my $loadParticipatesInCoupling = $self->_TableLoader('ParticipatesInCoupling', $self->PrimaryOnly);
352      my $loadUsesAsEvidence = $self->_TableLoader('UsesAsEvidence', $featureCount * 8000);      my $loadUsesAsEvidence = $self->_TableLoader('UsesAsEvidence', $self->PrimaryOnly);
353      Trace("Beginning coupling data load.") if T(2);      if ($self->{options}->{loadOnly}) {
354            Trace("Loading from existing files.") if T(2);
355        } else {
356            Trace("Generating coupling data.") if T(2);
357      # Loop through the genomes found.      # Loop through the genomes found.
358      for my $genome (sort keys %{$genomeFilter}) {      for my $genome (sort keys %{$genomeFilter}) {
359          Trace("Generating coupling data for $genome.") if T(3);          Trace("Generating coupling data for $genome.") if T(3);
# Line 389  Line 426 
426              }              }
427          }          }
428      }      }
429        }
430      # All done. Finish the load.      # All done. Finish the load.
431      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
432      return $retVal;      return $retVal;
# Line 410  Line 448 
448      FeatureTranslation      FeatureTranslation
449      FeatureUpstream      FeatureUpstream
450      IsLocatedIn      IsLocatedIn
451        HasFeature
452    
453  =over 4  =over 4
454    
# Line 426  Line 465 
465      my ($self) = @_;      my ($self) = @_;
466      # Get the FIG object.      # Get the FIG object.
467      my $fig = $self->{fig};      my $fig = $self->{fig};
     # Find out if this is a limited run.  
     my $limited = $self->{options}->{limitedFeatures};  
468      # Get the table of genome IDs.      # Get the table of genome IDs.
469      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
     my $featureCount = $genomeCount * 4000;  
470      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
471      my $loadFeature = $self->_TableLoader('Feature', $featureCount);      my $loadFeature = $self->_TableLoader('Feature');
472      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $featureCount);      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $self->PrimaryOnly);
473      my $loadFeatureAlias = $self->_TableLoader('FeatureAlias', $featureCount * 6);      my $loadFeatureAlias = $self->_TableLoader('FeatureAlias');
474      my ($loadFeatureLink, $loadFeatureTranslation, $loadFeatureUpstream);      my $loadFeatureLink = $self->_TableLoader('FeatureLink');
475      if (! $limited) {      my $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation');
476          $loadFeatureLink = $self->_TableLoader('FeatureLink', $featureCount * 10);      my $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream');
477          $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation', $featureCount);      my $loadHasFeature = $self->_TableLoader('HasFeature');
         $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream', $featureCount);  
     }  
478      # 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
479      # locations.      # locations.
480      my $chunkSize = $self->{sprout}->MaxSegment();      my $chunkSize = $self->{sprout}->MaxSegment();
481      Trace("Beginning feature data load.") if T(2);      if ($self->{options}->{loadOnly}) {
482            Trace("Loading from existing files.") if T(2);
483        } else {
484            Trace("Generating feature data.") if T(2);
485      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
486      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
487          Trace("Loading features for genome $genomeID.") if T(3);          Trace("Loading features for genome $genomeID.") if T(3);
# Line 459  Line 495 
495              my ($featureID, $locations, undef, $type) = @{$featureData};              my ($featureID, $locations, undef, $type) = @{$featureData};
496              # Create the feature record.              # Create the feature record.
497              $loadFeature->Put($featureID, 1, $type);              $loadFeature->Put($featureID, 1, $type);
498                    # Link it to the parent genome.
499                    $loadHasFeature->Put($genomeID, $featureID, $type);
500              # Create the aliases.              # Create the aliases.
501              for my $alias ($fig->feature_aliases($featureID)) {              for my $alias ($fig->feature_aliases($featureID)) {
502                  $loadFeatureAlias->Put($featureID, $alias);                  $loadFeatureAlias->Put($featureID, $alias);
503              }              }
             # The next stuff is for a full load only.  
             if (! $limited) {  
504                  # Get the links.                  # Get the links.
505                  my @links = $fig->fid_links($featureID);                  my @links = $fig->fid_links($featureID);
506                  for my $link (@links) {                  for my $link (@links) {
# Line 483  Line 519 
519                          $loadFeatureUpstream->Put($featureID, $upstream);                          $loadFeatureUpstream->Put($featureID, $upstream);
520                      }                      }
521                  }                  }
             }  
522              # 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
523              # 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
524              # the maximum segment size. This simplifies the genes_in_region processing              # the maximum segment size. This simplifies the genes_in_region processing
# Line 512  Line 547 
547              }              }
548          }          }
549      }      }
550        }
551      # Finish the loads.      # Finish the loads.
552      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
553      return $retVal;      return $retVal;
# Line 548  Line 584 
584      my $fig = $self->{fig};      my $fig = $self->{fig};
585      # Get the table of genome IDs.      # Get the table of genome IDs.
586      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
     my $featureCount = $genomeCount * 4000;  
587      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
588      my $loadIsBidirectionalBestHitOf = $self->_TableLoader('IsBidirectionalBestHitOf',      my $loadIsBidirectionalBestHitOf = $self->_TableLoader('IsBidirectionalBestHitOf');
589                                                             $featureCount * $genomeCount);      if ($self->{options}->{loadOnly}) {
590      Trace("Beginning BBH load.") if T(2);          Trace("Loading from existing files.") if T(2);
591        } else {
592            Trace("Generating BBH data.") if T(2);
593      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
594      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
595          $loadIsBidirectionalBestHitOf->Add("genomeIn");          $loadIsBidirectionalBestHitOf->Add("genomeIn");
# Line 579  Line 615 
615              }              }
616          }          }
617      }      }
618        }
619      # Finish the loads.      # Finish the loads.
620      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
621      return $retVal;      return $retVal;
# Line 608  Line 645 
645      OccursInSubsystem      OccursInSubsystem
646      ParticipatesIn      ParticipatesIn
647      HasSSCell      HasSSCell
     Catalyzes  
     Reaction  
648      ConsistsOfRoles      ConsistsOfRoles
649      RoleSubset      RoleSubset
650      HasRoleSubset      HasRoleSubset
651      ConsistsOfGenomes      ConsistsOfGenomes
652      GenomeSubset      GenomeSubset
653      HasGenomeSubset      HasGenomeSubset
654        Catalyzes
655        Diagram
656        RoleOccursIn
657    
658  =over 4  =over 4
659    
# Line 638  Line 676 
676      # Get the subsystem hash. This lists the subsystems we'll process.      # Get the subsystem hash. This lists the subsystems we'll process.
677      my $subsysHash = $self->{subsystems};      my $subsysHash = $self->{subsystems};
678      my @subsysIDs = sort keys %{$subsysHash};      my @subsysIDs = sort keys %{$subsysHash};
679      my $subsysCount = @subsysIDs;      # Get the map list.
680      my $genomeCount = (keys %{$genomeHash});      my @maps = $fig->all_maps;
     my $featureCount = $genomeCount * 4000;  
681      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
682      my $loadSubsystem = $self->_TableLoader('Subsystem', $subsysCount);      my $loadDiagram = $self->_TableLoader('Diagram', $self->PrimaryOnly);
683      my $loadRole = $self->_TableLoader('Role', $featureCount * 6);      my $loadRoleOccursIn = $self->_TableLoader('RoleOccursIn', $self->PrimaryOnly);
684      my $loadRoleEC = $self->_TableLoader('RoleEC', $featureCount * 6);      my $loadSubsystem = $self->_TableLoader('Subsystem');
685      my $loadSSCell = $self->_TableLoader('SSCell', $featureCount * $genomeCount);      my $loadRole = $self->_TableLoader('Role', $self->PrimaryOnly);
686      my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $featureCount * $subsysCount);      my $loadRoleEC = $self->_TableLoader('RoleEC', $self->PrimaryOnly);
687      my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $featureCount * $genomeCount);      my $loadCatalyzes = $self->_TableLoader('Catalyzes', $self->PrimaryOnly);
688      my $loadIsRoleOf = $self->_TableLoader('IsRoleOf', $featureCount * $genomeCount);      my $loadSSCell = $self->_TableLoader('SSCell', $self->PrimaryOnly);
689      my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $featureCount * 6);      my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $self->PrimaryOnly);
690      my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $subsysCount * $genomeCount);      my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $self->PrimaryOnly);
691      my $loadHasSSCell = $self->_TableLoader('HasSSCell', $featureCount * $genomeCount);      my $loadIsRoleOf = $self->_TableLoader('IsRoleOf', $self->PrimaryOnly);
692      my $loadReaction = $self->_TableLoader('Reaction', $featureCount * $genomeCount);      my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $self->PrimaryOnly);
693      my $loadCatalyzes = $self->_TableLoader('Catalyzes', $featureCount * $genomeCount);      my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $self->PrimaryOnly);
694      my $loadRoleSubset = $self->_TableLoader('RoleSubset', $subsysCount * 50);      my $loadHasSSCell = $self->_TableLoader('HasSSCell', $self->PrimaryOnly);
695      my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $subsysCount * 50);      my $loadRoleSubset = $self->_TableLoader('RoleSubset', $self->PrimaryOnly);
696      my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $featureCount * $genomeCount);      my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $self->PrimaryOnly);
697      my $loadConsistsOfGenomes = $self->_TableLoader('ConsistsOfGenomes', $featureCount * $genomeCount);      my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $self->PrimaryOnly);
698      my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $subsysCount * 50);      my $loadConsistsOfGenomes = $self->_TableLoader('ConsistsOfGenomes', $self->PrimaryOnly);
699      my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $subsysCount * 50);      my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $self->PrimaryOnly);
700      Trace("Beginning subsystem data load.") if T(2);      my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $self->PrimaryOnly);
701      # The reaction hash will contain a list of reactions for each role. When we're done,      if ($self->{options}->{loadOnly}) {
702      # a complicated sort and merge will be used to generate the Reaction and Catalyzes          Trace("Loading from existing files.") if T(2);
703      # tables.      } else {
704      my %reactionsToRoles = ();          Trace("Generating subsystem data.") if T(2);
705            # This hash will contain the role for each EC. When we're done, this
706            # information will be used to generate the Catalyzes table.
707            my %ecToRoles = ();
708      # Loop through the subsystems. Our first task will be to create the      # Loop through the subsystems. Our first task will be to create the
709      # roles. We do this by looping through the subsystems and creating a      # roles. We do this by looping through the subsystems and creating a
710      # role hash. The hash tracks each role ID so that we don't create      # role hash. The hash tracks each role ID so that we don't create
# Line 673  Line 713 
713      my ($genomeID, $roleID);      my ($genomeID, $roleID);
714      my %roleData = ();      my %roleData = ();
715      for my $subsysID (@subsysIDs) {      for my $subsysID (@subsysIDs) {
         Trace("Creating subsystem $subsysID.") if T(3);  
         $loadSubsystem->Add("subsystemIn");  
716          # Get the subsystem object.          # Get the subsystem object.
717          my $sub = $fig->get_subsystem($subsysID);          my $sub = $fig->get_subsystem($subsysID);
718          # Get its reaction hash.              # Only proceed if the subsystem has a spreadsheet.
719          my $reactionHash = $sub->get_reactions();              if (! $sub->{empty_ss}) {
720                    Trace("Creating subsystem $subsysID.") if T(3);
721                    $loadSubsystem->Add("subsystemIn");
722          # Create the subsystem record.          # Create the subsystem record.
723          my $curator = $sub->get_curator();          my $curator = $sub->get_curator();
724          my $notes = $sub->get_notes();          my $notes = $sub->get_notes();
# Line 697  Line 737 
737                  $roleData{$roleID} = 1;                  $roleData{$roleID} = 1;
738                  # Check for an EC number.                  # Check for an EC number.
739                  if ($roleID =~ /\(EC ([^.]+\.[^.]+\.[^.]+\.[^)]+)\)\s*$/) {                  if ($roleID =~ /\(EC ([^.]+\.[^.]+\.[^.]+\.[^)]+)\)\s*$/) {
740                      $loadRoleEC->Put($roleID, $1);                              my $ec = $1;
741                  }                              $loadRoleEC->Put($roleID, $ec);
742                  # Add the role's reactions.                              $ecToRoles{$ec} = $roleID;
                 my $reactions = $reactionHash->{$roleID};  
                 for my $reactionID (@{$reactions}) {  
                     if (! exists $reactionsToRoles{$reactionID}) {  
                         # Here the reaction is brand-new, so we create its reaction  
                         # record.  
                         $loadReaction->Put($reactionID, $fig->reversible($reactionID));  
                         # We also create a blank list for it in the reaction hash.  
                         $reactionsToRoles{$reactionID} = [];  
                     }  
                     # Add the role to the reaction's role list.  
                     push @{$reactionsToRoles{$reactionID}}, $roleID;  
743                  }                  }
744              }              }
745          }          }
# Line 737  Line 766 
766                  # part of the spreadsheet cell ID.                  # part of the spreadsheet cell ID.
767                  for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {                  for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) {
768                      # Get the features in the spreadsheet cell for this genome and role.                      # Get the features in the spreadsheet cell for this genome and role.
769                      my @pegs = $sub->get_pegs_from_cell($row, $col);                              my @pegs = grep { !$fig->is_deleted_fid($_) } $sub->get_pegs_from_cell($row, $col);
770                      # Only proceed if features exist.                      # Only proceed if features exist.
771                      if (@pegs > 0) {                      if (@pegs > 0) {
772                          # Create the spreadsheet cell.                          # Create the spreadsheet cell.
# Line 790  Line 819 
819              # Connect the subset to the subsystem.              # Connect the subset to the subsystem.
820              $loadHasRoleSubset->Put($subsysID, $actualID);              $loadHasRoleSubset->Put($subsysID, $actualID);
821              # Connect the subset to its roles.              # Connect the subset to its roles.
822              my @roles = $sub->get_subset($subsetID);                      my @roles = $sub->get_subsetC_roles($subsetID);
823              for my $roleID (@roles) {              for my $roleID (@roles) {
824                  $loadConsistsOfRoles->Put($actualID, $roleID);                  $loadConsistsOfRoles->Put($actualID, $roleID);
825              }              }
# Line 810  Line 839 
839              }              }
840          }          }
841      }      }
842      # Before we leave, we must create the Catalyzes table. The data is all stored in              # Now we loop through the diagrams. We need to create the diagram records
843      # "reactionToRoles" hash.              # and link each diagram to its roles. Note that only roles which occur
844      for my $reactionID (keys %reactionsToRoles) {              # in subsystems (and therefore appear in the %ecToRoles hash) are
845          # Get this reaction's list of roles. We sort it so we can merge out duplicates.              # included.
846          my @roles = sort @{$reactionsToRoles{$reactionID}};              for my $map (@maps) {
         my $lastRole = "";  
         # Loop through the roles, creating catalyzation records.  
         for my $thisRole (@roles) {  
             if ($thisRole ne $lastRole) {  
                 $loadCatalyzes->Put($thisRole, $reactionID);  
             }  
         }  
     }  
     # Finish the load.  
     my $retVal = $self->_FinishAll();  
     return $retVal;  
 }  
   
 =head3 LoadDiagramData  
   
 C<< my $stats = $spl->LoadDiagramData(); >>  
   
 Load the diagram data from FIG into Sprout.  
   
 Diagrams are used to organize functional roles. The diagram shows the  
 connections between chemicals that interact with a subsystem.  
   
 The following relations are loaded by this method.  
   
     Diagram  
     RoleOccursIn  
   
 =over 4  
   
 =item RETURNS  
   
 Returns a statistics object for the loads.  
   
 =back  
   
 =cut  
 #: Return Type $%;  
 sub LoadDiagramData {  
     # Get this object instance.  
     my ($self) = @_;  
     # Get the FIG object.  
     my $fig = $self->{fig};  
     # Get the map list.  
     my @maps = $fig->all_maps;  
     my $mapCount = @maps;  
     my $genomeCount = (keys %{$self->{genomes}});  
     my $featureCount = $genomeCount * 4000;  
     # Create load objects for each of the tables we're loading.  
     my $loadDiagram = $self->_TableLoader('Diagram', $mapCount);  
     my $loadRoleOccursIn = $self->_TableLoader('RoleOccursIn', $featureCount * 6);  
     Trace("Beginning diagram data load.") if T(2);  
     # Loop through the diagrams.  
     for my $map ($fig->all_maps) {  
847          Trace("Loading diagram $map.") if T(3);          Trace("Loading diagram $map.") if T(3);
848          # Get the diagram's descriptive name.          # Get the diagram's descriptive name.
849          my $name = $fig->map_name($map);          my $name = $fig->map_name($map);
# Line 876  Line 852 
852          # A hash is used to prevent duplicates.          # A hash is used to prevent duplicates.
853          my %roleHash = ();          my %roleHash = ();
854          for my $role ($fig->map_to_ecs($map)) {          for my $role ($fig->map_to_ecs($map)) {
855              if (! $roleHash{$role}) {                      if (exists $ecToRoles{$role} && ! $roleHash{$role}) {
856                  $loadRoleOccursIn->Put($role, $map);                          $loadRoleOccursIn->Put($ecToRoles{$role}, $map);
857                  $roleHash{$role} = 1;                  $roleHash{$role} = 1;
858              }              }
859          }          }
860      }      }
861                # Before we leave, we must create the Catalyzes table. We start with the reactions,
862                # then use the "ecToRoles" table to convert EC numbers to role IDs.
863                my @reactions = $fig->all_reactions();
864                for my $reactionID (@reactions) {
865                    # Get this reaction's list of roles. The results will be EC numbers.
866                    my @roles = $fig->catalyzed_by($reactionID);
867                    # Loop through the roles, creating catalyzation records.
868                    for my $thisRole (@roles) {
869                        if (exists $ecToRoles{$thisRole}) {
870                            $loadCatalyzes->Put($ecToRoles{$thisRole}, $reactionID);
871                        }
872                    }
873                }
874            }
875        }
876      # Finish the load.      # Finish the load.
877      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
878      return $retVal;      return $retVal;
# Line 923  Line 914 
914      my $fig = $self->{fig};      my $fig = $self->{fig};
915      # Get the genome hash.      # Get the genome hash.
916      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
917      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
918      my $loadProperty = $self->_TableLoader('Property', $genomeCount * 1500);      my $loadProperty = $self->_TableLoader('Property');
919      my $loadHasProperty = $self->_TableLoader('HasProperty', $genomeCount * 1500);      my $loadHasProperty = $self->_TableLoader('HasProperty', $self->PrimaryOnly);
920      Trace("Beginning property data load.") if T(2);      if ($self->{options}->{loadOnly}) {
921            Trace("Loading from existing files.") if T(2);
922        } else {
923            Trace("Generating property data.") if T(2);
924      # Create a hash for storing property IDs.      # Create a hash for storing property IDs.
925      my %propertyKeys = ();      my %propertyKeys = ();
926      my $nextID = 1;      my $nextID = 1;
927      # Loop through the genomes.      # Loop through the genomes.
928      for my $genomeID (keys %{$genomeHash}) {      for my $genomeID (keys %{$genomeHash}) {
929          $loadProperty->Add("genomeIn");          $loadProperty->Add("genomeIn");
930                Trace("Generating properties for $genomeID.") if T(3);
931          # Get the genome's features. The feature ID is the first field in the          # Get the genome's features. The feature ID is the first field in the
932          # tuples returned by "all_features_detailed". We use "all_features_detailed"          # tuples returned by "all_features_detailed". We use "all_features_detailed"
933          # rather than "all_features" because we want all features regardless of type.          # rather than "all_features" because we want all features regardless of type.
934          my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};          my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};
935                my $featureCount = 0;
936                my $propertyCount = 0;
937          # Loop through the features, creating HasProperty records.          # Loop through the features, creating HasProperty records.
938          for my $fid (@features) {          for my $fid (@features) {
             $loadProperty->Add("featureIn");  
939              # Get all attributes for this feature. We do this one feature at a time              # Get all attributes for this feature. We do this one feature at a time
940              # to insure we do not get any genome attributes.              # to insure we do not get any genome attributes.
941              my @attributeList = $fig->get_attributes($fid, '', '', '');              my @attributeList = $fig->get_attributes($fid, '', '', '');
942                    if (scalar @attributeList) {
943                        $featureCount++;
944                    }
945              # Loop through the attributes.              # Loop through the attributes.
946              for my $tuple (@attributeList) {              for my $tuple (@attributeList) {
947                        $propertyCount++;
948                  # Get this attribute value's data. Note that we throw away the FID,                  # Get this attribute value's data. Note that we throw away the FID,
949                  # since it will always be the same as the value if "$fid".                  # since it will always be the same as the value if "$fid".
950                  my (undef, $key, $value, $url) = @{$tuple};                  my (undef, $key, $value, $url) = @{$tuple};
# Line 967  Line 966 
966                  $loadHasProperty->Put($fid, $propertyID, $url);                  $loadHasProperty->Put($fid, $propertyID, $url);
967              }              }
968          }          }
969                # Update the statistics.
970                Trace("$propertyCount attributes processed for $featureCount features.") if T(3);
971                $loadHasProperty->Add("featuresIn", $featureCount);
972                $loadHasProperty->Add("propertiesIn", $propertyCount);
973            }
974      }      }
975      # Finish the load.      # Finish the load.
976      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
# Line 1007  Line 1011 
1011      my $fig = $self->{fig};      my $fig = $self->{fig};
1012      # Get the genome hash.      # Get the genome hash.
1013      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1014      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1015      my $loadAnnotation = $self->_TableLoader('Annotation', $genomeCount * 4000);      my $loadAnnotation = $self->_TableLoader('Annotation');
1016      my $loadIsTargetOfAnnotation = $self->_TableLoader('IsTargetOfAnnotation', $genomeCount * 4000);      my $loadIsTargetOfAnnotation = $self->_TableLoader('IsTargetOfAnnotation', $self->PrimaryOnly);
1017      my $loadSproutUser = $self->_TableLoader('SproutUser', 100);      my $loadSproutUser = $self->_TableLoader('SproutUser', $self->PrimaryOnly);
1018      my $loadUserAccess = $self->_TableLoader('UserAccess', 1000);      my $loadUserAccess = $self->_TableLoader('UserAccess', $self->PrimaryOnly);
1019      my $loadMadeAnnotation = $self->_TableLoader('MadeAnnotation', $genomeCount * 4000);      my $loadMadeAnnotation = $self->_TableLoader('MadeAnnotation', $self->PrimaryOnly);
1020      Trace("Beginning annotation data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1021            Trace("Loading from existing files.") if T(2);
1022        } else {
1023            Trace("Generating annotation data.") if T(2);
1024      # Create a hash of user names. We'll use this to prevent us from generating duplicate      # Create a hash of user names. We'll use this to prevent us from generating duplicate
1025      # user records.      # user records.
1026      my %users = ( FIG => 1, master => 1 );      my %users = ( FIG => 1, master => 1 );
# Line 1028  Line 1034 
1034      # Loop through the genomes.      # Loop through the genomes.
1035      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
1036          Trace("Processing $genomeID.") if T(3);          Trace("Processing $genomeID.") if T(3);
         # Get the genome's PEGs.  
         my @pegs = $fig->pegs_of($genomeID);  
         for my $peg (@pegs) {  
             Trace("Processing $peg.") if T(4);  
1037              # Create a hash of timestamps. We use this to prevent duplicate time stamps              # Create a hash of timestamps. We use this to prevent duplicate time stamps
1038              # from showing up for a single PEG's annotations.              # from showing up for a single PEG's annotations.
1039              my %seenTimestamps = ();              my %seenTimestamps = ();
1040              # Check for a functional assignment.              # Get the genome's annotations.
1041              my $func = $fig->function_of($peg);              my @annotations = $fig->read_all_annotations($genomeID);
1042              if ($func) {              Trace("Processing annotations.") if T(2);
1043                  # If this is NOT a hypothetical assignment, we create an              for my $tuple (@annotations) {
1044                  # assignment annotation for it.                  # Get the annotation tuple.
1045                  if (! FIG::hypo($peg)) {                  my ($peg, $timestamp, $user, $text) = @{$tuple};
                     # Note that we double the slashes so that what goes into the database is  
                     # a new-line escape sequence rather than an actual new-line.  
                     $loadAnnotation->Put("$peg:$time", $time, "FIG\\nSet function to\\n$func");  
                     $loadIsTargetOfAnnotation->Put($peg, "$peg:$time");  
                     $loadMadeAnnotation->Put("FIG", "$peg:$time");  
                     # Denote we've seen this timestamp.  
                     $seenTimestamps{$time} = 1;  
                 }  
             }  
             # Now loop through the real annotations.  
             for my $tuple ($fig->feature_annotations($peg, "raw")) {  
                 my ($fid, $timestamp, $user, $text) = @{$tuple};  
1046                  # Here we fix up the annotation text. "\r" is removed,                  # Here we fix up the annotation text. "\r" is removed,
1047                  # and "\t" and "\n" are escaped. Note we use the "s"                  # and "\t" and "\n" are escaped. Note we use the "s"
1048                  # modifier so that new-lines inside the text do not                  # modifier so that new-lines inside the text do not
# Line 1067  Line 1057 
1057                      # Here it's a number. We need to insure the one we use to form                      # Here it's a number. We need to insure the one we use to form
1058                      # the key is unique.                      # the key is unique.
1059                      my $keyStamp = $timestamp;                      my $keyStamp = $timestamp;
1060                      while ($seenTimestamps{$keyStamp}) {                      while ($seenTimestamps{"$peg:$keyStamp"}) {
1061                          $keyStamp++;                          $keyStamp++;
1062                      }                      }
                     $seenTimestamps{$keyStamp} = 1;  
1063                      my $annotationID = "$peg:$keyStamp";                      my $annotationID = "$peg:$keyStamp";
1064                        $seenTimestamps{$annotationID} = 1;
1065                      # Insure the user exists.                      # Insure the user exists.
1066                      if (! $users{$user}) {                      if (! $users{$user}) {
1067                          $loadSproutUser->Put($user, "SEED user");                          $loadSproutUser->Put($user, "SEED user");
# Line 1129  Line 1119 
1119      my $fig = $self->{fig};      my $fig = $self->{fig};
1120      # Get the genome hash.      # Get the genome hash.
1121      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1122      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1123      my $loadComesFrom = $self->_TableLoader('ComesFrom', $genomeCount * 4);      my $loadComesFrom = $self->_TableLoader('ComesFrom', $self->PrimaryOnly);
1124      my $loadSource = $self->_TableLoader('Source', $genomeCount * 4);      my $loadSource = $self->_TableLoader('Source');
1125      my $loadSourceURL = $self->_TableLoader('SourceURL', $genomeCount * 8);      my $loadSourceURL = $self->_TableLoader('SourceURL');
1126      Trace("Beginning source data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1127            Trace("Loading from existing files.") if T(2);
1128        } else {
1129            Trace("Generating annotation data.") if T(2);
1130      # Create hashes to collect the Source information.      # Create hashes to collect the Source information.
1131      my %sourceURL = ();      my %sourceURL = ();
1132      my %sourceDesc = ();      my %sourceDesc = ();
# Line 1164  Line 1156 
1156      for my $sourceID (keys %sourceDesc) {      for my $sourceID (keys %sourceDesc) {
1157          $loadSource->Put($sourceID, $sourceDesc{$sourceID});          $loadSource->Put($sourceID, $sourceDesc{$sourceID});
1158      }      }
1159        }
1160      # Finish the load.      # Finish the load.
1161      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1162      return $retVal;      return $retVal;
# Line 1203  Line 1196 
1196      my $fig = $self->{fig};      my $fig = $self->{fig};
1197      # Get the genome hash.      # Get the genome hash.
1198      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1199      # Convert the genome hash. We'll get the genus and species for each genome and make      # Convert the genome hash. We'll get the genus and species for each genome and make
1200      # it the key.      # it the key.
1201      my %speciesHash = map { $fig->genus_species($_) => $_ } (keys %{$genomeHash});      my %speciesHash = map { $fig->genus_species($_) => $_ } (keys %{$genomeHash});
1202      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1203      my $loadExternalAliasFunc = $self->_TableLoader('ExternalAliasFunc', $genomeCount * 4000);      my $loadExternalAliasFunc = $self->_TableLoader('ExternalAliasFunc');
1204      my $loadExternalAliasOrg = $self->_TableLoader('ExternalAliasOrg', $genomeCount * 4000);      my $loadExternalAliasOrg = $self->_TableLoader('ExternalAliasOrg');
1205      Trace("Beginning external data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1206            Trace("Loading from existing files.") if T(2);
1207        } else {
1208            Trace("Generating external data.") if T(2);
1209      # We loop through the files one at a time. First, the organism file.      # We loop through the files one at a time. First, the organism file.
1210      Open(\*ORGS, "<$FIG_Config::global/ext_org.table");      Open(\*ORGS, "<$FIG_Config::global/ext_org.table");
1211      my $orgLine;      my $orgLine;
# Line 1240  Line 1235 
1235              $loadExternalAliasFunc->Put(@funcFields[0,1]);              $loadExternalAliasFunc->Put(@funcFields[0,1]);
1236          }          }
1237      }      }
1238        }
1239      # Finish the load.      # Finish the load.
1240      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1241      return $retVal;      return $retVal;
# Line 1256  Line 1252 
1252    
1253  The following relations are loaded by this method.  The following relations are loaded by this method.
1254    
1255        Reaction
1256      ReactionURL      ReactionURL
1257      Compound      Compound
1258      CompoundName      CompoundName
# Line 1279  Line 1276 
1276      my ($self) = @_;      my ($self) = @_;
1277      # Get the FIG object.      # Get the FIG object.
1278      my $fig = $self->{fig};      my $fig = $self->{fig};
     # Get the genome hash.  
     my $genomeHash = $self->{genomes};  
     my $genomeCount = (keys %{$genomeHash});  
1279      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1280      my $loadReactionURL = $self->_TableLoader('ReactionURL', $genomeCount * 4000);      my $loadReaction = $self->_TableLoader('Reaction');
1281      my $loadCompound = $self->_TableLoader('Compound', $genomeCount * 4000);      my $loadReactionURL = $self->_TableLoader('ReactionURL', $self->PrimaryOnly);
1282      my $loadCompoundName = $self->_TableLoader('CompoundName', $genomeCount * 8000);      my $loadCompound = $self->_TableLoader('Compound', $self->PrimaryOnly);
1283      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $genomeCount * 4000);      my $loadCompoundName = $self->_TableLoader('CompoundName', $self->PrimaryOnly);
1284      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $genomeCount * 12000);      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $self->PrimaryOnly);
1285      Trace("Beginning reaction/compound data load.") if T(2);      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $self->PrimaryOnly);
1286      # Create a hash to remember the compounds we've generated in the compound table.      if ($self->{options}->{loadOnly}) {
1287      my %compoundHash = ();          Trace("Loading from existing files.") if T(2);
1288      # Loop through the reactions.      } else {
1289            Trace("Generating annotation data.") if T(2);
1290            # First we create the compounds.
1291            my @compounds = $fig->all_compounds();
1292            for my $cid (@compounds) {
1293                # Check for names.
1294                my @names = $fig->names_of_compound($cid);
1295                # Each name will be given a priority number, starting with 1.
1296                my $prio = 1;
1297                for my $name (@names) {
1298                    $loadCompoundName->Put($cid, $name, $prio++);
1299                }
1300                # Create the main compound record. Note that the first name
1301                # becomes the label.
1302                my $label = (@names > 0 ? $names[0] : $cid);
1303                $loadCompound->Put($cid, $label);
1304                # Check for a CAS ID.
1305                my $cas = $fig->cas($cid);
1306                if ($cas) {
1307                    $loadCompoundCAS->Put($cid, $cas);
1308                }
1309            }
1310            # All the compounds are set up, so we need to loop through the reactions next. First,
1311            # we initialize the discriminator index. This is a single integer used to insure
1312            # duplicate elements in a reaction are not accidentally collapsed.
1313            my $discrim = 0;
1314      my @reactions = $fig->all_reactions();      my @reactions = $fig->all_reactions();
1315      for my $reactionID (@reactions) {      for my $reactionID (@reactions) {
1316                # Create the reaction record.
1317                $loadReaction->Put($reactionID, $fig->reversible($reactionID));
1318          # Compute the reaction's URL.          # Compute the reaction's URL.
1319          my $url = HTML::reaction_link($reactionID);          my $url = HTML::reaction_link($reactionID);
1320          # Put it in the ReactionURL table.          # Put it in the ReactionURL table.
# Line 1302  Line 1323 
1323          # substrates first and then products.          # substrates first and then products.
1324          for my $product (0, 1) {          for my $product (0, 1) {
1325              # Get the compounds of the current type for the current reaction. FIG will              # Get the compounds of the current type for the current reaction. FIG will
1326              # give us 3-tuples: [ID, Stoichometry, main-flag]. At this time we do not                  # give us 3-tuples: [ID, stoichiometry, main-flag]. At this time we do not
1327              # have location data in SEED, so it defaults to the empty string.              # have location data in SEED, so it defaults to the empty string.
1328              my @compounds = $fig->reaction2comp($reactionID, $product);              my @compounds = $fig->reaction2comp($reactionID, $product);
1329              for my $compData (@compounds) {              for my $compData (@compounds) {
1330                  # Extract the compound data from the current tuple.                  # Extract the compound data from the current tuple.
1331                  my ($cid, $stoich, $main) = @{$compData};                  my ($cid, $stoich, $main) = @{$compData};
1332                  # Link the compound to the reaction.                  # Link the compound to the reaction.
1333                  $loadIsAComponentOf->Put($cid, $reactionID, "", $main, $product, $stoich);                      $loadIsAComponentOf->Put($cid, $reactionID, $discrim++, "", $main,
1334                  # If this is a new compound, we need to create its table entries.                                               $product, $stoich);
                 if (! exists $compoundHash{$cid}) {  
                     $compoundHash{$cid} = 1;  
                     # Create the main compound record and denote we've done it.  
                     $loadCompound->Put($cid);  
                     # Check for a CAS ID.  
                     my $cas = $fig->cas($cid);  
                     if ($cas) {  
                         $loadCompoundCAS->Put($cid, $cas);  
                     }  
                     # Check for names.  
                     my @names = $fig->names_of_compound($cid);  
                     # Each name will be given a priority number, starting with 1.  
                     my $prio = 0;  
                     for my $name (@names) {  
                         $loadCompoundName->Put($cid, $name, $prio++);  
                     }  
1335                  }                  }
1336              }              }
1337          }          }
# Line 1366  Line 1371 
1371      my $fig = $self->{fig};      my $fig = $self->{fig};
1372      # Get the genome hash.      # Get the genome hash.
1373      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1374      # Create a load object for the table we're loading.      # Create a load object for the table we're loading.
1375      my $loadGenomeGroups = $self->_TableLoader('GenomeGroups', $genomeCount * 4);      my $loadGenomeGroups = $self->_TableLoader('GenomeGroups');
1376      Trace("Beginning group data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1377            Trace("Loading from existing files.") if T(2);
1378        } else {
1379            Trace("Generating group data.") if T(2);
1380      # Loop through the genomes.      # Loop through the genomes.
1381      my $line;      my $line;
1382      for my $genomeID (keys %{$genomeHash}) {      for my $genomeID (keys %{$genomeHash}) {
# Line 1385  Line 1392 
1392          }          }
1393          close TMP;          close TMP;
1394      }      }
1395        }
1396      # Finish the load.      # Finish the load.
1397      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1398      return $retVal;      return $retVal;
# Line 1406  Line 1414 
1414    
1415  Name of the table (relation) being loaded.  Name of the table (relation) being loaded.
1416    
1417  =item rowCount (optional)  =item ignore
1418    
1419  Estimated maximum number of rows in the table.  TRUE if the table should be ignored entirely, else FALSE.
1420    
1421  =item RETURN  =item RETURN
1422    
# Line 1420  Line 1428 
1428    
1429  sub _TableLoader {  sub _TableLoader {
1430      # Get the parameters.      # Get the parameters.
1431      my ($self, $tableName, $rowCount) = @_;      my ($self, $tableName, $ignore) = @_;
1432      # Create the load object.      # Create the load object.
1433      my $retVal = ERDBLoad->new($self->{erdb}, $tableName, $self->{loadDirectory}, $rowCount);      my $retVal = ERDBLoad->new($self->{erdb}, $tableName, $self->{loadDirectory}, $self->LoadOnly,
1434                                   $ignore);
1435      # Cache it in the loader list.      # Cache it in the loader list.
1436      push @{$self->{loaders}}, $retVal;      push @{$self->{loaders}}, $retVal;
1437      # Return it to the caller.      # Return it to the caller.
# Line 1459  Line 1468 
1468      # Loop through the list, finishing the loads. Note that if the finish fails, we die      # Loop through the list, finishing the loads. Note that if the finish fails, we die
1469      # ignominiously. At some future point, we want to make the loads restartable.      # ignominiously. At some future point, we want to make the loads restartable.
1470      while (my $loader = pop @{$loadList}) {      while (my $loader = pop @{$loadList}) {
1471          # Trace the fact that we're cleaning up.          # Get the relation name.
1472          my $relName = $loader->RelName;          my $relName = $loader->RelName;
1473          Trace("Finishing load for $relName.") if T(2);          # Check the ignore flag.
1474            if ($loader->Ignore) {
1475                Trace("Relation $relName not loaded.") if T(2);
1476            } else {
1477                # Here we really need to finish.
1478                Trace("Finishing $relName.") if T(2);
1479          my $stats = $loader->Finish();          my $stats = $loader->Finish();
1480          if ($self->{options}->{dbLoad}) {          if ($self->{options}->{dbLoad}) {
1481              # Here we want to use the load file just created to load the database.              # Here we want to use the load file just created to load the database.
# Line 1473  Line 1487 
1487          $retVal->Accumulate($stats);          $retVal->Accumulate($stats);
1488          Trace("Statistics for $relName:\n" . $stats->Show()) if T(2);          Trace("Statistics for $relName:\n" . $stats->Show()) if T(2);
1489      }      }
1490        }
1491      # Return the load statistics.      # Return the load statistics.
1492      return $retVal;      return $retVal;
1493  }  }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.39

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3