#!/usr/bin/perl -w =head1 Load Sprout Tables =head2 Introduction The Sprout database reflects a snapshot of the SEED taken at a particular point in time. At some point in the future, it will be possible to add annotations to the Sprout data. All records added to Sprout after the snapshot is taken are specially-marked so that the changes can be copied to the SEED. The SEED remains the live version of the data. The snapshot is produced by reading the SEED data and writing it to sequential files. There is one file per Sprout table, and each such file's name consists of the table name with the suffix C. Thus, the file for the C table would be named C. These files are used to load the actual Sprout database and to generate Glimpse indices. To load all the Sprout tables and then validate the result, you need to issue three commands. LoadSproutTables -dbLoad -dbCreate "*" TestSproutLoad index_sprout All three commands send output to the console. In addition, C and C write tracing information to C in the FIG temporary directory (B<$FIG_Config::Tmp>). At the bottom of the log file will be a complete list of errors. If errors occur in C, then the data must be corrected and the offending table group reloaded. So, for example, if there are errors in the load of the B and B tables, you would need to run LoadSproutTables -dbLoad Annotation Reaction because B is in the C group, and B is in the C group. A list of the groups is given below. You can omit the C option to create the load files without loading the database, and you can add a C option to change the trace level. The command below creates the Genome-related load files with a trace level of 3 and does not load them into the Sprout database. LoadSproutTables -trace=3 Genome C takes a long time to run, so setting the trace level to 3 helps to give you an idea of the progress. Once the Sprout database is loaded, B can be used to verify the load against the FIG data. Again, the end of the C file will contain a summary of the errors found. Like C, C is a time-consuming script, so you may want to set the trace level to 3 to see visible progress. TestSproutLoad -trace=3 Unlike C, in C, the individual errors found are mixed in with the trace messages. They are all, however, marked with a trace type of B, as shown in the fragment below. 11/02/2005 19:15:16
: Processing feature fig|100226.1.peg.7742. 11/02/2005 19:15:17
: Processing feature fig|100226.1.peg.7741. 11/02/2005 19:15:17 : assignment "Short-chain dehydrodenase ... 11/02/2005 19:15:17 : assignment "putative oxidoreductase." ... 11/02/2005 19:15:17 : Incorrect assignment for fig|100226.1.peg.7741... 11/02/2005 19:15:17 : Incorrect number of annotations found in ... 11/02/2005 19:15:17
: Processing feature fig|100226.1.peg.7740. 11/02/2005 19:15:18
: Processing feature fig|100226.1.peg.7739. The test may reveal that some tables need to be reloaded, or that a software problem has crept into the Sprout. Once all the tables have the correct data, C can be run to create the Glimpse indexes. =head2 Procedure For Loading Sprout =over 4 =item 1 Type C and press ENTER. This will create the C files and load them. =item 2 Type C and press ENTER. This will validate the Sprout database against the SEED data. =item 3 If any errors are detected in step (2), it is most likely due to a change in SEED that did not make it to Sprout. Contact Bruce Parrello or Robert Olson to get the code updated properly. =item 4 Type C and press ENTER. This will create the Glimpse indexes for the Sprout data. =back =head2 LoadSproutTables Command C creates the load files for Sprout tables and optionally loads them. The parameters are the names of the table groups whose data is to be created. The legal table group names are given below. =over 4 =item Genome Loads B, B, B, B, and B. =item Coupling Loads B, B, B, B, B. =item Feature Loads B, B, B, B, B, B. =item Subsystem Loads B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B. =item Annotation Loads B, B, B, B, B. =item Property Loads B, B. =item BBH Loads B. =item Group Loads B. =item Source Loads B, B, B. =item External Loads B, B. =item Reaction Loads B, B, B, B, B, B. =item * Loads all of the above tables. =back The command-line options are given below. =over 4 =item geneFile The name of the file containing the genomes and their associated access codes. The file should have one line per genome, each line consisting of the genome ID followed by the access code, separated by a tab. If no file is specified, all complete genomes will be processed and the access code will be 1. =item subsysFile The name of the file containing the trusted subsystems. The file should have one line per trusted subsystem. If no file is specified, all subsystems will be trusted. =item trace Desired tracing level. The default is 3. =item limitedFeatures Only generate the B and B tables when processing the feature group. =item dbLoad If TRUE, the database tables will be loaded automatically from the load files created. =item dbCreate If TRUE, the database will be created. If the database exists already, it will be dropped. Use the function with caution. =back =cut use strict; use Tracer; use DocUtils; use Cwd; use FIG; use SFXlate; use File::Copy; use File::Path; use SproutLoad; use Stats; use SFXlate; # Get the command-line parameters and options. my ($options, @parameters) = Tracer::ParseCommand({ geneFile => "", subsysFile => "", trace => 3, limitedFeatures => 0, dbLoad => 0, dbCreate => 0 }, @ARGV); # Set up tracing. TSetup("$options->{trace} SproutLoad ERDBLoad ERDB Stats Tracer Load", "+>$FIG_Config::temp/trace.log"); if ($options->{dbCreate}) { # Here we want to drop and re-create the database. my $db = $FIG_Config::sproutDB; if ($FIG_Config::dbms eq "Pg") { my $dbport = $FIG_Config::dbport; my $dbuser = $FIG_Config::dbuser; system("dropdb -p $dbport -U $dbuser $db"); &FIG::run("createdb -p $dbport -U $dbuser $db"); } elsif ($FIG_Config::dbms eq "mysql") { system("mysqladmin -u $FIG_Config::dbuser -p drop $db"); &FIG::run("mysqladmin -u $FIG_Config::dbuser -p create $db"); } } # Create the sprout loader object. Note that the Sprout object does not # open the database unless the "dbLoad" option is turned on. my $fig = FIG->new(); my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad}); my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options); # Process the parameters. for my $group (@parameters) { Trace("Processing load group $group.") if T(2); my $stats; if ($group eq 'Genome' || $group eq '*') { $spl->LoadGenomeData(); } if ($group eq 'Feature' || $group eq '*') { $spl->LoadFeatureData(); } if ($group eq 'Coupling' || $group eq '*') { $spl->LoadCouplingData(); } if ($group eq 'Subsystem' || $group eq '*') { $spl->LoadSubsystemData(); } if ($group eq 'Property' || $group eq '*') { $spl->LoadPropertyData(); } if ($group eq 'Annotation' || $group eq '*') { $spl->LoadAnnotationData(); } if ($group eq 'BBH' || $group eq '*') { $spl->LoadBBHData(); } if ($group eq 'Group' || $group eq '*') { $spl->LoadGroupData(); } if ($group eq 'Source' || $group eq '*') { $spl->LoadSourceData(); } if ($group eq 'External' || $group eq '*') { $spl->LoadExternalData(); } if ($group eq 'Reaction' || $group eq '*') { $spl->LoadReactionData(); } } Trace("Load complete.") if T(2); 1;