[Bio] / Sprout / LoadSproutTables.pl Repository:
ViewVC logotype

Diff of /Sprout/LoadSproutTables.pl

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

revision 1.15, Wed Dec 7 01:19:00 2005 UTC revision 1.24, Fri Mar 31 18:38:35 2006 UTC
# Line 78  Line 78 
78  =item 1  =item 1
79    
80  Type C<LoadSproutTables -dbLoad -dbCreate "*"> and press ENTER. This will create  Type C<LoadSproutTables -dbLoad -dbCreate "*"> and press ENTER. This will create
81  the C<dtx> files and load them.  the C<dtx> files and load them. You may be asked for a password. If this is the
82    case, simply press ENTER. If that does not work, use the C<dbpass> value specified
83    in your C<FIG_Config.pm> file.
84    
85  =item 2  =item 2
86    
87  Type C<TestSproutLoad> and press ENTER. This will validate the Sprout database  Type C<TestSproutLoad 100226.1 83333.1> and press ENTER. This will validate
88  against the SEED data.  the Sprout database against the SEED data.
89    
90  =item 3  =item 3
91    
# Line 184  Line 186 
186    
187  Desired tracing level. The default is 3.  Desired tracing level. The default is 3.
188    
 =item limitedFeatures  
   
 Only generate the B<Feature> and B<IsLocatedIn> tables when processing the feature group.  
   
189  =item dbLoad  =item dbLoad
190    
191  If TRUE, the database tables will be loaded automatically from the load files created.  If TRUE, the database tables will be loaded automatically from the load files created.
# Line 197  Line 195 
195  If TRUE, the database will be created. If the database exists already, it will be  If TRUE, the database will be created. If the database exists already, it will be
196  dropped. Use the function with caution.  dropped. Use the function with caution.
197    
198    =item loadOnly
199    
200    If TRUE, the database tables will be loaded from existing load files. Load files
201    will not be created. This option is useful if you are setting up a copy of Sprout
202    and have load files already set up from the original version.
203    
204    =item primaryOnly
205    
206    If TRUE, only the group's primary entity will be loaded.
207    
208  =back  =back
209    
210  =cut  =cut
# Line 214  Line 222 
222  use SFXlate;  use SFXlate;
223    
224  # Get the command-line parameters and options.  # Get the command-line parameters and options.
225  my ($options, @parameters) = Tracer::ParseCommand({ geneFile => "", subsysFile => "",  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
226                                                      trace => 3, limitedFeatures => 0,                                              'ERDB', 'Load', 'Sprout'],
227                                                      dbLoad => 0, dbCreate => 0 }, @ARGV);                                              { geneFile => ["", "name of the genome list file"],
228  # Set up tracing.                                                subsysFile => ["", "name of the trusted subsystem file"],
229  TSetup("$options->{trace} SproutLoad ERDBLoad ERDB Stats Tracer Load", "+>$FIG_Config::temp/trace.log");                                                dbLoad => [0, "load the database from generated files"],
230                                                  dbCreate => [0, "drop and re-create the database"],
231                                                  loadOnly => [0, "load the database from previously generated files"],
232                                                  primaryOnly => [0, "only process the group's main entity"],
233                                                  resume => [0, "resume a complete load starting with the first group specified in the parameter list"],
234                                                },
235                                                "<group1> <group2> ...",
236                                                @ARGV);
237    # If we're doing a load-only, turn on loading.
238    if ($options->{loadOnly}) {
239        $options->{dbLoad} = 1
240    }
241  if ($options->{dbCreate}) {  if ($options->{dbCreate}) {
242      # Here we want to drop and re-create the database.      # Here we want to drop and re-create the database.
243      my $db = $FIG_Config::sproutDB;      my $db = $FIG_Config::sproutDB;
244      if ($FIG_Config::dbms eq "Pg") {      DBKernel::CreateDB($db);
         my $dbport = $FIG_Config::dbport;  
         my $dbuser = $FIG_Config::dbuser;  
         Trace("Dropping old database (failure is okay).") if T(2);  
         system("dropdb -p $dbport -U $dbuser $db");  
         Trace("Dropping old database (failure is okay).") if T(2);  
         &FIG::run("createdb -p $dbport -U $dbuser $db");  
     } elsif ($FIG_Config::dbms eq "mysql") {  
         Trace("Dropping old database (failure is okay).") if T(2);  
         system("mysqladmin -u $FIG_Config::dbuser -p drop $db");  
         &FIG::run("mysqladmin -u $FIG_Config::dbuser -p create $db");  
         Trace("Dropping old database (failure is okay).") if T(2);  
     }  
   
245  }  }
246  # Create the sprout loader object. Note that the Sprout object does not  # Create the sprout loader object. Note that the Sprout object does not
247  # open the database unless the "dbLoad" option is turned on.  # open the database unless the "dbLoad" option is turned on.
# Line 244  Line 250 
250  my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);  my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);
251  # Insure we have an output directory.  # Insure we have an output directory.
252  FIG::verify_dir($FIG_Config::sproutData);  FIG::verify_dir($FIG_Config::sproutData);
253    # If we're resuming, we only want to have 1 parameter.
254    my $resume = $options->{resume};
255    if ($resume && @parameters > 1) {
256        Confess("If resume=1, only one load group can be specified.");
257    } elsif (! @parameters) {
258        Confess("No load groups were specified.");
259    }
260  # Process the parameters.  # Process the parameters.
261  for my $group (@parameters) {  for my $group (@parameters) {
262      Trace("Processing load group $group.") if T(2);      Trace("Processing load group $group.") if T(2);
263      my $stats;      my $stats;
264      if ($group eq 'Genome' || $group eq '*') {      if ($group eq 'Genome' || $group eq '*') {
265          $spl->LoadGenomeData();          $spl->LoadGenomeData();
266            $group = ResumeCheck($resume);
267      }      }
268      if ($group eq 'Feature' || $group eq '*') {      if ($group eq 'Feature' || $group eq '*') {
269          $spl->LoadFeatureData();          $spl->LoadFeatureData();
270            $group = ResumeCheck($resume);
271      }      }
272      if ($group eq 'Coupling' || $group eq '*') {      if ($group eq 'Coupling' || $group eq '*') {
273          $spl->LoadCouplingData();          $spl->LoadCouplingData();
274            $group = ResumeCheck($resume);
275      }      }
276      if ($group eq 'Subsystem' || $group eq '*') {      if ($group eq 'Subsystem' || $group eq '*') {
277          $spl->LoadSubsystemData();          $spl->LoadSubsystemData();
278            $group = ResumeCheck($resume);
279      }      }
280      if ($group eq 'Property' || $group eq '*') {      if ($group eq 'Property' || $group eq '*') {
281          $spl->LoadPropertyData();          $spl->LoadPropertyData();
282            $group = ResumeCheck($resume);
283      }      }
284      if ($group eq 'Annotation' || $group eq '*') {      if ($group eq 'Annotation' || $group eq '*') {
285          $spl->LoadAnnotationData();          $spl->LoadAnnotationData();
286            $group = ResumeCheck($resume);
287      }      }
288      if ($group eq 'BBH' || $group eq '*') {      if ($group eq 'BBH' || $group eq '*') {
289          $spl->LoadBBHData();          $spl->LoadBBHData();
290            $group = ResumeCheck($resume);
291      }      }
292      if ($group eq 'Group' || $group eq '*') {      if ($group eq 'Group' || $group eq '*') {
293          $spl->LoadGroupData();          $spl->LoadGroupData();
294            $group = ResumeCheck($resume);
295      }      }
296      if ($group eq 'Source' || $group eq '*') {      if ($group eq 'Source' || $group eq '*') {
297          $spl->LoadSourceData();          $spl->LoadSourceData();
298            $group = ResumeCheck($resume);
299      }      }
300      if ($group eq 'External' || $group eq '*') {      if ($group eq 'External' || $group eq '*') {
301          $spl->LoadExternalData();          $spl->LoadExternalData();
302            $group = ResumeCheck($resume);
303      }      }
304      if ($group eq 'Reaction' || $group eq '*') {      if ($group eq 'Reaction' || $group eq '*') {
305          $spl->LoadReactionData();          $spl->LoadReactionData();
306            $group = ResumeCheck($resume);
307      }      }
308    
309  }  }
310  Trace("Load complete.") if T(2);  Trace("Load complete.") if T(2);
311    
312    # If the resume flag is set, return "*", else return "".
313    sub ResumeCheck {
314        my ($resume) = @_;
315        return ($resume ? "*" : "");
316    }
317    
318  1;  1;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.24

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3