[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.18, Sun Jan 15 21:32:17 2006 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    
# Line 199  Line 201 
201  will not be created. This option is useful if you are setting up a copy of Sprout  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.  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 217  Line 223 
223    
224  # Get the command-line parameters and options.  # Get the command-line parameters and options.
225  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
226                                              'ERDB', 'Load'],                                              'ERDB', 'Load', 'Sprout'],
227                                              { geneFile => ["", "name of the genome list file"],                                              { geneFile => ["", "name of the genome list file"],
228                                                subsysFile => ["", "name of the trusted subsystem file"],                                                subsysFile => ["", "name of the trusted subsystem file"],
229                                                dbLoad => [0, "load the database from generated files"],                                                dbLoad => [0, "load the database from generated files"],
230                                                dbCreate => [0, "drop and re-create the database"],                                                dbCreate => [0, "drop and re-create the database"],
231                                                loadOnly => [0, "load the database from previously generated files"]                                                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> ...",                                              "<group1> <group2> ...",
236                                              @ARGV);                                              @ARGV);
# Line 233  Line 241 
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("Creating new database.") 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("Creating new database.") 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 254  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.18  
changed lines
  Added in v.1.24

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3