[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.21, Sat Nov 12 03:42:48 2005 UTC revision 1.29, Mon Mar 13 19:19:37 2006 UTC
# Line 171  Line 171 
171      return $retVal;      return $retVal;
172  }  }
173    
174    =head3 LoadOnly
175    
176    C<< my $flag = $spl->LoadOnly; >>
177    
178    Return TRUE if we are in load-only mode, else FALSE.
179    
180    =cut
181    
182    sub LoadOnly {
183        my ($self) = @_;
184        return $self->{options}->{loadOnly};
185    }
186    
187    =head3 PrimaryOnly
188    
189    C<< my $flag = $spl->PrimaryOnly; >>
190    
191    Return TRUE if only the main entity is to be loaded, else FALSE.
192    
193    =cut
194    
195    sub PrimaryOnly {
196        my ($self) = @_;
197        return $self->{options}->{primaryOnly};
198    }
199    
200  =head3 LoadGenomeData  =head3 LoadGenomeData
201    
202  C<< my $stats = $spl->LoadGenomeData(); >>  C<< my $stats = $spl->LoadGenomeData(); >>
# Line 198  Line 224 
224    
225  =back  =back
226    
 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.)  
   
227  =cut  =cut
228  #: Return Type $%;  #: Return Type $%;
229  sub LoadGenomeData {  sub LoadGenomeData {
# Line 216  Line 234 
234      # Get the genome count.      # Get the genome count.
235      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
236      my $genomeCount = (keys %{$genomeHash});      my $genomeCount = (keys %{$genomeHash});
     Trace("Beginning genome data load.") if T(2);  
237      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
238      my $loadGenome = $self->_TableLoader('Genome', $genomeCount);      my $loadGenome = $self->_TableLoader('Genome');
239      my $loadHasContig = $self->_TableLoader('HasContig', $genomeCount * 300);      my $loadHasContig = $self->_TableLoader('HasContig', $self->PrimaryOnly);
240      my $loadContig = $self->_TableLoader('Contig', $genomeCount * 300);      my $loadContig = $self->_TableLoader('Contig', $self->PrimaryOnly);
241      my $loadIsMadeUpOf = $self->_TableLoader('IsMadeUpOf', $genomeCount * 60000);      my $loadIsMadeUpOf = $self->_TableLoader('IsMadeUpOf', $self->PrimaryOnly);
242      my $loadSequence = $self->_TableLoader('Sequence', $genomeCount * 60000);      my $loadSequence = $self->_TableLoader('Sequence', $self->PrimaryOnly);
243        if ($self->{options}->{loadOnly}) {
244            Trace("Loading from existing files.") if T(2);
245        } else {
246            Trace("Generating genome data.") if T(2);
247      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
248      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
249          Trace("Loading data for genome $genomeID.") if T(3);              Trace("Generating data for genome $genomeID.") if T(3);
250          $loadGenome->Add("genomeIn");          $loadGenome->Add("genomeIn");
251          # The access code comes in via the genome hash.          # The access code comes in via the genome hash.
252          my $accessCode = $genomeHash->{$genomeID};          my $accessCode = $genomeHash->{$genomeID};
253          # 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.  
254          my ($genus, $species, @extraData) = split / /, $self->{fig}->genus_species($genomeID);          my ($genus, $species, @extraData) = split / /, $self->{fig}->genus_species($genomeID);
255          my $extra = join " ", @extraData, "[$genomeID]";              my $extra = join " ", @extraData;
256          # Get the full taxonomy.          # Get the full taxonomy.
257          my $taxonomy = $fig->taxonomy_of($genomeID);          my $taxonomy = $fig->taxonomy_of($genomeID);
258          # Output the genome record.          # Output the genome record.
# Line 268  Line 288 
288              }              }
289          }          }
290      }      }
291        }
292      # Finish the loads.      # Finish the loads.
293      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
294      # Return the result.      # Return the result.
# Line 311  Line 332 
332      my $genomeCount = (keys %{$genomeFilter});      my $genomeCount = (keys %{$genomeFilter});
333      my $featureCount = $genomeCount * 4000;      my $featureCount = $genomeCount * 4000;
334      # Start the loads.      # Start the loads.
335      my $loadCoupling = $self->_TableLoader('Coupling', $featureCount * $genomeCount);      my $loadCoupling = $self->_TableLoader('Coupling');
336      my $loadIsEvidencedBy = $self->_TableLoader('IsEvidencedBy', $featureCount * 8000);      my $loadIsEvidencedBy = $self->_TableLoader('IsEvidencedBy', $self->PrimaryOnly);
337      my $loadPCH = $self->_TableLoader('PCH', $featureCount * 2000);      my $loadPCH = $self->_TableLoader('PCH', $self->PrimaryOnly);
338      my $loadParticipatesInCoupling = $self->_TableLoader('ParticipatesInCoupling', $featureCount * 2000);      my $loadParticipatesInCoupling = $self->_TableLoader('ParticipatesInCoupling', $self->PrimaryOnly);
339      my $loadUsesAsEvidence = $self->_TableLoader('UsesAsEvidence', $featureCount * 8000);      my $loadUsesAsEvidence = $self->_TableLoader('UsesAsEvidence', $self->PrimaryOnly);
340      Trace("Beginning coupling data load.") if T(2);      if ($self->{options}->{loadOnly}) {
341            Trace("Loading from existing files.") if T(2);
342        } else {
343            Trace("Generating coupling data.") if T(2);
344      # Loop through the genomes found.      # Loop through the genomes found.
345      for my $genome (sort keys %{$genomeFilter}) {      for my $genome (sort keys %{$genomeFilter}) {
346          Trace("Generating coupling data for $genome.") if T(3);          Trace("Generating coupling data for $genome.") if T(3);
# Line 389  Line 413 
413              }              }
414          }          }
415      }      }
416        }
417      # All done. Finish the load.      # All done. Finish the load.
418      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
419      return $retVal;      return $retVal;
# Line 426  Line 451 
451      my ($self) = @_;      my ($self) = @_;
452      # Get the FIG object.      # Get the FIG object.
453      my $fig = $self->{fig};      my $fig = $self->{fig};
     # Find out if this is a limited run.  
     my $limited = $self->{options}->{limitedFeatures};  
454      # Get the table of genome IDs.      # Get the table of genome IDs.
455      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
     my $featureCount = $genomeCount * 4000;  
456      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
457      my $loadFeature = $self->_TableLoader('Feature', $featureCount);      my $loadFeature = $self->_TableLoader('Feature');
458      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $featureCount);      my $loadIsLocatedIn = $self->_TableLoader('IsLocatedIn', $self->PrimaryOnly);
459      my $loadFeatureAlias = $self->_TableLoader('FeatureAlias', $featureCount * 6);      my $loadFeatureAlias = $self->_TableLoader('FeatureAlias');
460      my ($loadFeatureLink, $loadFeatureTranslation, $loadFeatureUpstream);      my $loadFeatureLink = $self->_TableLoader('FeatureLink');
461      if (! $limited) {      my $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation');
462          $loadFeatureLink = $self->_TableLoader('FeatureLink', $featureCount * 10);      my $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream');
         $loadFeatureTranslation = $self->_TableLoader('FeatureTranslation', $featureCount);  
         $loadFeatureUpstream = $self->_TableLoader('FeatureUpstream', $featureCount);  
     }  
463      # 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
464      # locations.      # locations.
465      my $chunkSize = $self->{sprout}->MaxSegment();      my $chunkSize = $self->{sprout}->MaxSegment();
466      Trace("Beginning feature data load.") if T(2);      if ($self->{options}->{loadOnly}) {
467            Trace("Loading from existing files.") if T(2);
468        } else {
469            Trace("Generating feature data.") if T(2);
470      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
471      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
472          Trace("Loading features for genome $genomeID.") if T(3);          Trace("Loading features for genome $genomeID.") if T(3);
# Line 463  Line 484 
484              for my $alias ($fig->feature_aliases($featureID)) {              for my $alias ($fig->feature_aliases($featureID)) {
485                  $loadFeatureAlias->Put($featureID, $alias);                  $loadFeatureAlias->Put($featureID, $alias);
486              }              }
             # The next stuff is for a full load only.  
             if (! $limited) {  
487                  # Get the links.                  # Get the links.
488                  my @links = $fig->fid_links($featureID);                  my @links = $fig->fid_links($featureID);
489                  for my $link (@links) {                  for my $link (@links) {
# Line 483  Line 502 
502                          $loadFeatureUpstream->Put($featureID, $upstream);                          $loadFeatureUpstream->Put($featureID, $upstream);
503                      }                      }
504                  }                  }
             }  
505              # 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
506              # 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
507              # 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 530 
530              }              }
531          }          }
532      }      }
533        }
534      # Finish the loads.      # Finish the loads.
535      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
536      return $retVal;      return $retVal;
# Line 548  Line 567 
567      my $fig = $self->{fig};      my $fig = $self->{fig};
568      # Get the table of genome IDs.      # Get the table of genome IDs.
569      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
     my $featureCount = $genomeCount * 4000;  
570      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
571      my $loadIsBidirectionalBestHitOf = $self->_TableLoader('IsBidirectionalBestHitOf',      my $loadIsBidirectionalBestHitOf = $self->_TableLoader('IsBidirectionalBestHitOf');
572                                                             $featureCount * $genomeCount);      if ($self->{options}->{loadOnly}) {
573      Trace("Beginning BBH load.") if T(2);          Trace("Loading from existing files.") if T(2);
574        } else {
575            Trace("Generating BBH data.") if T(2);
576      # Now we loop through the genomes, generating the data for each one.      # Now we loop through the genomes, generating the data for each one.
577      for my $genomeID (sort keys %{$genomeHash}) {      for my $genomeID (sort keys %{$genomeHash}) {
578          $loadIsBidirectionalBestHitOf->Add("genomeIn");          $loadIsBidirectionalBestHitOf->Add("genomeIn");
# Line 579  Line 598 
598              }              }
599          }          }
600      }      }
601        }
602      # Finish the loads.      # Finish the loads.
603      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
604      return $retVal;      return $retVal;
# Line 639  Line 659 
659      # Get the subsystem hash. This lists the subsystems we'll process.      # Get the subsystem hash. This lists the subsystems we'll process.
660      my $subsysHash = $self->{subsystems};      my $subsysHash = $self->{subsystems};
661      my @subsysIDs = sort keys %{$subsysHash};      my @subsysIDs = sort keys %{$subsysHash};
     my $subsysCount = @subsysIDs;  
     my $genomeCount = (keys %{$genomeHash});  
     my $featureCount = $genomeCount * 4000;  
662      # Get the map list.      # Get the map list.
663      my @maps = $fig->all_maps;      my @maps = $fig->all_maps;
     my $mapCount = @maps;  
     # Create load objects for each of the tables we're loading.  
     my $loadDiagram = $self->_TableLoader('Diagram', $mapCount);  
     my $loadRoleOccursIn = $self->_TableLoader('RoleOccursIn', $featureCount * 6);  
     my $loadSubsystem = $self->_TableLoader('Subsystem', $subsysCount);  
     my $loadRole = $self->_TableLoader('Role', $featureCount * 6);  
     my $loadRoleEC = $self->_TableLoader('RoleEC', $featureCount * 6);  
     my $loadCatalyzes = $self->_TableLoader('Catalyzes', $genomeCount * $featureCount);  
     my $loadSSCell = $self->_TableLoader('SSCell', $featureCount * $genomeCount);  
     my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $featureCount * $subsysCount);  
     my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $featureCount * $genomeCount);  
     my $loadIsRoleOf = $self->_TableLoader('IsRoleOf', $featureCount * $genomeCount);  
     my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $featureCount * 6);  
     my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $subsysCount * $genomeCount);  
     my $loadHasSSCell = $self->_TableLoader('HasSSCell', $featureCount * $genomeCount);  
     my $loadRoleSubset = $self->_TableLoader('RoleSubset', $subsysCount * 50);  
     my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $subsysCount * 50);  
     my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $featureCount * $genomeCount);  
     my $loadConsistsOfGenomes = $self->_TableLoader('ConsistsOfGenomes', $featureCount * $genomeCount);  
     my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $subsysCount * 50);  
     my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $subsysCount * 50);  
664      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
665      Trace("Beginning subsystem data load.") if T(2);      my $loadDiagram = $self->_TableLoader('Diagram', $self->PrimaryOnly);
666        my $loadRoleOccursIn = $self->_TableLoader('RoleOccursIn', $self->PrimaryOnly);
667        my $loadSubsystem = $self->_TableLoader('Subsystem');
668        my $loadRole = $self->_TableLoader('Role', $self->PrimaryOnly);
669        my $loadRoleEC = $self->_TableLoader('RoleEC', $self->PrimaryOnly);
670        my $loadCatalyzes = $self->_TableLoader('Catalyzes', $self->PrimaryOnly);
671        my $loadSSCell = $self->_TableLoader('SSCell', $self->PrimaryOnly);
672        my $loadContainsFeature = $self->_TableLoader('ContainsFeature', $self->PrimaryOnly);
673        my $loadIsGenomeOf = $self->_TableLoader('IsGenomeOf', $self->PrimaryOnly);
674        my $loadIsRoleOf = $self->_TableLoader('IsRoleOf', $self->PrimaryOnly);
675        my $loadOccursInSubsystem = $self->_TableLoader('OccursInSubsystem', $self->PrimaryOnly);
676        my $loadParticipatesIn = $self->_TableLoader('ParticipatesIn', $self->PrimaryOnly);
677        my $loadHasSSCell = $self->_TableLoader('HasSSCell', $self->PrimaryOnly);
678        my $loadRoleSubset = $self->_TableLoader('RoleSubset', $self->PrimaryOnly);
679        my $loadGenomeSubset = $self->_TableLoader('GenomeSubset', $self->PrimaryOnly);
680        my $loadConsistsOfRoles = $self->_TableLoader('ConsistsOfRoles', $self->PrimaryOnly);
681        my $loadConsistsOfGenomes = $self->_TableLoader('ConsistsOfGenomes', $self->PrimaryOnly);
682        my $loadHasRoleSubset = $self->_TableLoader('HasRoleSubset', $self->PrimaryOnly);
683        my $loadHasGenomeSubset = $self->_TableLoader('HasGenomeSubset', $self->PrimaryOnly);
684        if ($self->{options}->{loadOnly}) {
685            Trace("Loading from existing files.") if T(2);
686        } else {
687            Trace("Generating subsystem data.") if T(2);
688      # This hash will contain the role for each EC. When we're done, this      # This hash will contain the role for each EC. When we're done, this
689      # information will be used to generate the Catalyzes table.      # information will be used to generate the Catalyzes table.
690      my %ecToRoles = ();      my %ecToRoles = ();
# Line 782  Line 800 
800              # Connect the subset to the subsystem.              # Connect the subset to the subsystem.
801              $loadHasRoleSubset->Put($subsysID, $actualID);              $loadHasRoleSubset->Put($subsysID, $actualID);
802              # Connect the subset to its roles.              # Connect the subset to its roles.
803              my @roles = $sub->get_subset($subsetID);                  my @roles = $sub->get_subsetC_roles($subsetID);
804              for my $roleID (@roles) {              for my $roleID (@roles) {
805                  $loadConsistsOfRoles->Put($actualID, $roleID);                  $loadConsistsOfRoles->Put($actualID, $roleID);
806              }              }
# Line 834  Line 852 
852              }              }
853          }          }
854      }      }
855        }
856      # Finish the load.      # Finish the load.
857      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
858      return $retVal;      return $retVal;
# Line 875  Line 894 
894      my $fig = $self->{fig};      my $fig = $self->{fig};
895      # Get the genome hash.      # Get the genome hash.
896      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
897      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
898      my $loadProperty = $self->_TableLoader('Property', $genomeCount * 1500);      my $loadProperty = $self->_TableLoader('Property');
899      my $loadHasProperty = $self->_TableLoader('HasProperty', $genomeCount * 1500);      my $loadHasProperty = $self->_TableLoader('HasProperty', $self->PrimaryOnly);
900      Trace("Beginning property data load.") if T(2);      if ($self->{options}->{loadOnly}) {
901            Trace("Loading from existing files.") if T(2);
902        } else {
903            Trace("Generating property data.") if T(2);
904      # Create a hash for storing property IDs.      # Create a hash for storing property IDs.
905      my %propertyKeys = ();      my %propertyKeys = ();
906      my $nextID = 1;      my $nextID = 1;
907      # Loop through the genomes.      # Loop through the genomes.
908      for my $genomeID (keys %{$genomeHash}) {      for my $genomeID (keys %{$genomeHash}) {
909          $loadProperty->Add("genomeIn");          $loadProperty->Add("genomeIn");
910                Trace("Generating properties for $genomeID.") if T(3);
911          # 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
912          # tuples returned by "all_features_detailed". We use "all_features_detailed"          # tuples returned by "all_features_detailed". We use "all_features_detailed"
913          # rather than "all_features" because we want all features regardless of type.          # rather than "all_features" because we want all features regardless of type.
914          my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};          my @features = map { $_->[0] } @{$fig->all_features_detailed($genomeID)};
915                my $featureCount = 0;
916                my $propertyCount = 0;
917          # Loop through the features, creating HasProperty records.          # Loop through the features, creating HasProperty records.
918          for my $fid (@features) {          for my $fid (@features) {
             $loadProperty->Add("featureIn");  
919              # 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
920              # to insure we do not get any genome attributes.              # to insure we do not get any genome attributes.
921              my @attributeList = $fig->get_attributes($fid, '', '', '');              my @attributeList = $fig->get_attributes($fid, '', '', '');
922                    if (scalar @attributeList) {
923                        $featureCount++;
924                    }
925              # Loop through the attributes.              # Loop through the attributes.
926              for my $tuple (@attributeList) {              for my $tuple (@attributeList) {
927                        $propertyCount++;
928                  # 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,
929                  # since it will always be the same as the value if "$fid".                  # since it will always be the same as the value if "$fid".
930                  my (undef, $key, $value, $url) = @{$tuple};                  my (undef, $key, $value, $url) = @{$tuple};
# Line 919  Line 946 
946                  $loadHasProperty->Put($fid, $propertyID, $url);                  $loadHasProperty->Put($fid, $propertyID, $url);
947              }              }
948          }          }
949                # Update the statistics.
950                Trace("$propertyCount attributes processed for $featureCount features.") if T(3);
951                $loadHasProperty->Add("featuresIn", $featureCount);
952                $loadHasProperty->Add("propertiesIn", $propertyCount);
953            }
954      }      }
955      # Finish the load.      # Finish the load.
956      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
# Line 959  Line 991 
991      my $fig = $self->{fig};      my $fig = $self->{fig};
992      # Get the genome hash.      # Get the genome hash.
993      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
994      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
995      my $loadAnnotation = $self->_TableLoader('Annotation', $genomeCount * 4000);      my $loadAnnotation = $self->_TableLoader('Annotation');
996      my $loadIsTargetOfAnnotation = $self->_TableLoader('IsTargetOfAnnotation', $genomeCount * 4000);      my $loadIsTargetOfAnnotation = $self->_TableLoader('IsTargetOfAnnotation', $self->PrimaryOnly);
997      my $loadSproutUser = $self->_TableLoader('SproutUser', 100);      my $loadSproutUser = $self->_TableLoader('SproutUser', $self->PrimaryOnly);
998      my $loadUserAccess = $self->_TableLoader('UserAccess', 1000);      my $loadUserAccess = $self->_TableLoader('UserAccess', $self->PrimaryOnly);
999      my $loadMadeAnnotation = $self->_TableLoader('MadeAnnotation', $genomeCount * 4000);      my $loadMadeAnnotation = $self->_TableLoader('MadeAnnotation', $self->PrimaryOnly);
1000      Trace("Beginning annotation data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1001            Trace("Loading from existing files.") if T(2);
1002        } else {
1003            Trace("Generating annotation data.") if T(2);
1004      # 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
1005      # user records.      # user records.
1006      my %users = ( FIG => 1, master => 1 );      my %users = ( FIG => 1, master => 1 );
# Line 987  Line 1021 
1021              # 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
1022              # from showing up for a single PEG's annotations.              # from showing up for a single PEG's annotations.
1023              my %seenTimestamps = ();              my %seenTimestamps = ();
1024              # Check for a functional assignment.                  # Loop through the annotations.
             my $func = $fig->function_of($peg);  
             if ($func) {  
                 # If this is NOT a hypothetical assignment, we create an  
                 # assignment annotation for it.  
                 if (! FIG::hypo($peg)) {  
                     # 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.  
1025              for my $tuple ($fig->feature_annotations($peg, "raw")) {              for my $tuple ($fig->feature_annotations($peg, "raw")) {
1026                  my ($fid, $timestamp, $user, $text) = @{$tuple};                  my ($fid, $timestamp, $user, $text) = @{$tuple};
1027                  # Here we fix up the annotation text. "\r" is removed,                  # Here we fix up the annotation text. "\r" is removed,
# Line 1041  Line 1060 
1060              }              }
1061          }          }
1062      }      }
1063        }
1064      # Finish the load.      # Finish the load.
1065      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1066      return $retVal;      return $retVal;
# Line 1081  Line 1101 
1101      my $fig = $self->{fig};      my $fig = $self->{fig};
1102      # Get the genome hash.      # Get the genome hash.
1103      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1104      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1105      my $loadComesFrom = $self->_TableLoader('ComesFrom', $genomeCount * 4);      my $loadComesFrom = $self->_TableLoader('ComesFrom', $self->PrimaryOnly);
1106      my $loadSource = $self->_TableLoader('Source', $genomeCount * 4);      my $loadSource = $self->_TableLoader('Source');
1107      my $loadSourceURL = $self->_TableLoader('SourceURL', $genomeCount * 8);      my $loadSourceURL = $self->_TableLoader('SourceURL');
1108      Trace("Beginning source data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1109            Trace("Loading from existing files.") if T(2);
1110        } else {
1111            Trace("Generating annotation data.") if T(2);
1112      # Create hashes to collect the Source information.      # Create hashes to collect the Source information.
1113      my %sourceURL = ();      my %sourceURL = ();
1114      my %sourceDesc = ();      my %sourceDesc = ();
# Line 1116  Line 1138 
1138      for my $sourceID (keys %sourceDesc) {      for my $sourceID (keys %sourceDesc) {
1139          $loadSource->Put($sourceID, $sourceDesc{$sourceID});          $loadSource->Put($sourceID, $sourceDesc{$sourceID});
1140      }      }
1141        }
1142      # Finish the load.      # Finish the load.
1143      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1144      return $retVal;      return $retVal;
# Line 1155  Line 1178 
1178      my $fig = $self->{fig};      my $fig = $self->{fig};
1179      # Get the genome hash.      # Get the genome hash.
1180      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1181      # 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
1182      # it the key.      # it the key.
1183      my %speciesHash = map { $fig->genus_species($_) => $_ } (keys %{$genomeHash});      my %speciesHash = map { $fig->genus_species($_) => $_ } (keys %{$genomeHash});
1184      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1185      my $loadExternalAliasFunc = $self->_TableLoader('ExternalAliasFunc', $genomeCount * 4000);      my $loadExternalAliasFunc = $self->_TableLoader('ExternalAliasFunc');
1186      my $loadExternalAliasOrg = $self->_TableLoader('ExternalAliasOrg', $genomeCount * 4000);      my $loadExternalAliasOrg = $self->_TableLoader('ExternalAliasOrg');
1187      Trace("Beginning external data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1188            Trace("Loading from existing files.") if T(2);
1189        } else {
1190            Trace("Generating external data.") if T(2);
1191      # 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.
1192      Open(\*ORGS, "<$FIG_Config::global/ext_org.table");      Open(\*ORGS, "<$FIG_Config::global/ext_org.table");
1193      my $orgLine;      my $orgLine;
# Line 1192  Line 1217 
1217              $loadExternalAliasFunc->Put(@funcFields[0,1]);              $loadExternalAliasFunc->Put(@funcFields[0,1]);
1218          }          }
1219      }      }
1220        }
1221      # Finish the load.      # Finish the load.
1222      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1223      return $retVal;      return $retVal;
# Line 1232  Line 1258 
1258      my ($self) = @_;      my ($self) = @_;
1259      # Get the FIG object.      # Get the FIG object.
1260      my $fig = $self->{fig};      my $fig = $self->{fig};
     # Get the genome hash.  
     my $genomeHash = $self->{genomes};  
     my $genomeCount = (keys %{$genomeHash});  
1261      # Create load objects for each of the tables we're loading.      # Create load objects for each of the tables we're loading.
1262      my $loadReaction = $self->_TableLoader('Reaction', $genomeCount * 4000);      my $loadReaction = $self->_TableLoader('Reaction');
1263      my $loadReactionURL = $self->_TableLoader('ReactionURL', $genomeCount * 4000);      my $loadReactionURL = $self->_TableLoader('ReactionURL', $self->PrimaryOnly);
1264      my $loadCompound = $self->_TableLoader('Compound', $genomeCount * 4000);      my $loadCompound = $self->_TableLoader('Compound', $self->PrimaryOnly);
1265      my $loadCompoundName = $self->_TableLoader('CompoundName', $genomeCount * 8000);      my $loadCompoundName = $self->_TableLoader('CompoundName', $self->PrimaryOnly);
1266      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $genomeCount * 4000);      my $loadCompoundCAS = $self->_TableLoader('CompoundCAS', $self->PrimaryOnly);
1267      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $genomeCount * 12000);      my $loadIsAComponentOf = $self->_TableLoader('IsAComponentOf', $self->PrimaryOnly);
1268      Trace("Beginning reaction/compound data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1269            Trace("Loading from existing files.") if T(2);
1270        } else {
1271            Trace("Generating annotation data.") if T(2);
1272      # First we create the compounds.      # First we create the compounds.
1273      my @compounds = $fig->all_compounds();      my @compounds = $fig->all_compounds();
1274      for my $cid (@compounds) {      for my $cid (@compounds) {
# Line 1291  Line 1317 
1317              }              }
1318          }          }
1319      }      }
1320        }
1321      # Finish the load.      # Finish the load.
1322      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1323      return $retVal;      return $retVal;
# Line 1326  Line 1353 
1353      my $fig = $self->{fig};      my $fig = $self->{fig};
1354      # Get the genome hash.      # Get the genome hash.
1355      my $genomeHash = $self->{genomes};      my $genomeHash = $self->{genomes};
     my $genomeCount = (keys %{$genomeHash});  
1356      # Create a load object for the table we're loading.      # Create a load object for the table we're loading.
1357      my $loadGenomeGroups = $self->_TableLoader('GenomeGroups', $genomeCount * 4);      my $loadGenomeGroups = $self->_TableLoader('GenomeGroups');
1358      Trace("Beginning group data load.") if T(2);      if ($self->{options}->{loadOnly}) {
1359            Trace("Loading from existing files.") if T(2);
1360        } else {
1361            Trace("Generating group data.") if T(2);
1362      # Loop through the genomes.      # Loop through the genomes.
1363      my $line;      my $line;
1364      for my $genomeID (keys %{$genomeHash}) {      for my $genomeID (keys %{$genomeHash}) {
# Line 1345  Line 1374 
1374          }          }
1375          close TMP;          close TMP;
1376      }      }
1377        }
1378      # Finish the load.      # Finish the load.
1379      my $retVal = $self->_FinishAll();      my $retVal = $self->_FinishAll();
1380      return $retVal;      return $retVal;
# Line 1366  Line 1396 
1396    
1397  Name of the table (relation) being loaded.  Name of the table (relation) being loaded.
1398    
1399  =item rowCount (optional)  =item ignore
1400    
1401  Estimated maximum number of rows in the table.  TRUE if the table should be ignored entirely, else FALSE.
1402    
1403  =item RETURN  =item RETURN
1404    
# Line 1380  Line 1410 
1410    
1411  sub _TableLoader {  sub _TableLoader {
1412      # Get the parameters.      # Get the parameters.
1413      my ($self, $tableName, $rowCount) = @_;      my ($self, $tableName, $ignore) = @_;
1414      # Create the load object.      # Create the load object.
1415      my $retVal = ERDBLoad->new($self->{erdb}, $tableName, $self->{loadDirectory}, $rowCount);      my $retVal = ERDBLoad->new($self->{erdb}, $tableName, $self->{loadDirectory}, $self->LoadOnly,
1416                                   $ignore);
1417      # Cache it in the loader list.      # Cache it in the loader list.
1418      push @{$self->{loaders}}, $retVal;      push @{$self->{loaders}}, $retVal;
1419      # Return it to the caller.      # Return it to the caller.
# Line 1419  Line 1450 
1450      # 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
1451      # ignominiously. At some future point, we want to make the loads restartable.      # ignominiously. At some future point, we want to make the loads restartable.
1452      while (my $loader = pop @{$loadList}) {      while (my $loader = pop @{$loadList}) {
1453          # Trace the fact that we're cleaning up.          # Get the relation name.
1454          my $relName = $loader->RelName;          my $relName = $loader->RelName;
1455          Trace("Finishing load for $relName.") if T(2);          # Check the ignore flag.
1456            if ($loader->Ignore) {
1457                Trace("Relation $relName not loaded.") if T(2);
1458            } else {
1459                # Here we really need to finish.
1460                Trace("Finishing $relName.") if T(2);
1461          my $stats = $loader->Finish();          my $stats = $loader->Finish();
1462          if ($self->{options}->{dbLoad}) {          if ($self->{options}->{dbLoad}) {
1463              # 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 1433  Line 1469 
1469          $retVal->Accumulate($stats);          $retVal->Accumulate($stats);
1470          Trace("Statistics for $relName:\n" . $stats->Show()) if T(2);          Trace("Statistics for $relName:\n" . $stats->Show()) if T(2);
1471      }      }
1472        }
1473      # Return the load statistics.      # Return the load statistics.
1474      return $retVal;      return $retVal;
1475  }  }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.29

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3