[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.40, Wed Sep 13 04:27:38 2006 UTC
# Line 20  Line 20 
20  commands.  commands.
21    
22      LoadSproutTables -dbLoad -dbCreate "*"      LoadSproutTables -dbLoad -dbCreate "*"
23      TestSproutLoad      TestSproutLoad [genomeID] ...
24      index_sprout      index_sprout_lucene
25    
26    where I<[genomeID]> is one or more genome IDs. These genomes will be tested more
27    thoroughly than the others.
28    
29  All three commands send output to the console. In addition, C<LoadSproutTables> and  All three commands send output to the console. In addition, C<LoadSproutTables> and
30  C<TestSproutLoad> write tracing information to C<trace.log> in the FIG temporary  C<TestSproutLoad> write tracing information to a trace log in the FIG temporary
31  directory (B<$FIG_Config::Tmp>). At the bottom of the log file will be a complete  directory (B<$FIG_Config::Tmp>). At the bottom of the log file will be a complete
32  list of errors. If errors occur in C<LoadSproutTables>, then the data must be corrected  list of errors. If errors occur in C<LoadSproutTables>, then the data must be corrected
33  and the offending table group reloaded. So, for example, if there are errors in the  and the offending table group reloaded. So, for example, if there are errors in the
# Line 45  Line 48 
48  C<LoadSproutTables> takes a long time to run, so setting the trace level to 3 helps  C<LoadSproutTables> takes a long time to run, so setting the trace level to 3 helps
49  to give you an idea of the progress.  to give you an idea of the progress.
50    
51  Once the Sprout database is loaded, B<TestSproutLoad> can be used to verify the load  =head2 The NMPDR Web Site
 against the FIG data. Again, the end of the C<trace.log> file will contain a summary  
 of the errors found. Like C<LoadSproutTables>, C<TestSproutLoad> 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<LoadSproutTables>, in C<TestSproutLoad>, the individual errors found are  
 mixed in with the trace messages. They are all, however, marked with a trace type  
 of B<Problem>, as shown in the fragment below.  
   
     11/02/2005 19:15:16 <main>: Processing feature fig|100226.1.peg.7742.  
     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7741.  
     11/02/2005 19:15:17 <Problem>: assignment "Short-chain dehydrodenase ...  
     11/02/2005 19:15:17 <Problem>: assignment "putative oxidoreductase." ...  
     11/02/2005 19:15:17 <Problem>: Incorrect assignment for fig|100226.1.peg.7741...  
     11/02/2005 19:15:17 <Problem>: Incorrect number of annotations found in ...  
     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7740.  
     11/02/2005 19:15:18 <main>: 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.  
52    
53  Once all the tables have the correct data, C<index_sprout> can be run to create the  Sprout is the database engine for the NMPDR web site. The NMPDR web site consists of two
54  Glimpse indexes.  pieces that run on two different machines. The B<WEB> machine contains HTML pages
55    generated by a Content Management Tool.
56    
57  =head2 Procedure For Loading Sprout  =head2 Procedure For Loading Sprout
58    
59    In order to load the Sprout, you need to have the B<Sprout>, B<NmpdrConfigs>, and
60    B<LuceneSearch> projects checked out from CVS in addition to the standard FIG
61    projects. You must also set up the following B<FIG_Config.pm> variables in addition
62    to the normal ones.
63    
64  =over 4  =over 4
65    
66    =item sproutData
67    
68    Name of the data directory for the Sprout load files.
69    
70    =item var
71    
72    Name of the directory to contain cached NMPDR pages. The most important file in
73    this directory is C<nmpdr_page_template.html>, which contains a skeleton page
74    from the main NMPDR web site. This skeleton page is used to generate output
75    pages that look like the other NMPDR pages.
76    
77    =item java
78    
79    Path to the Java runtime environment.
80    
81    =item sproutDB
82    
83    Name of the Sprout database
84    
85    =item dbuser
86    
87    User name for logging into the Sprout database.
88    
89    =item dbpass
90    
91    Password for logging into the Sprout database.
92    
93    =item nmpdr_site_url
94    
95    URL for the NMPDR cover pages. The NMPDR cover pages are informational and text
96    pages that serve as the entry point to the NMPDR web site. They are generated by
97    a Content Management tool, and some Sprout scripts need to know where to find
98    them.
99    
100    =item nmpdr_site_template_id
101    
102    Page number for the template page used to generate results that look like they're
103    part of the NMPDR web site.
104    
105    =back
106    
107    =over 4
108    
109    Most of the above preparation is performed by the B<NMPDRSetup> utility.
110    NMPDRSetup prints the instructions for completing the process, including
111    loading the Sprout database. The specific procedure for loading
112    the Sprout data, however, is as follows.
113    
114  =item 1  =item 1
115    
116  Type C<LoadSproutTables -dbLoad -dbCreate "*"> and press ENTER. This will create  Type
 the C<dtx> files and load them.  
117    
118  =item 2      nohup LoadSproutTables -dbLoad -user=you -background "*" >null &
119    
120  Type C<TestSproutLoad> and press ENTER. This will validate the Sprout database  where C<you> is your user ID, and press ENTER.
 against the SEED data.  
121    
122  =item 3  The above command line runs the load in the background. The standard output,
123    standard error, and trace output will be directed to files in the FIG temporary
124    directory. If your user name is C<Bruce> then the files will be named
125    C<outBruce.log>, C<errBruce.log>, and C<traceBruce.log> respectively.
126    
127  If any errors are detected in step (2), it is most likely due to a change in  If the load fails at some point and you are able to correct the problem, use the
128  SEED that did not make it to Sprout. Contact Bruce Parrello or Robert Olson  C<resume> option to restart it. For example, if the load failed while doing the
129  to get the code updated properly.  Feature load group, you would resume it using
130    
131  =item 4      nohup LoadSproutTables -dbLoad -dbCreate -user=you -resume -background Feature >null &
132    
133  Type C<index_sprout> and press ENTER. This will create the Glimpse indexes  =item 2
134  for the Sprout data.  
135    Type
136    
137        index_sprout_lucene
138    
139     and press ENTER. This will create the Lucene indexes for the Sprout data.
140    
141  =back  =back
142    
# Line 110  Line 152 
152    
153  Loads B<Genome>, B<HasContig>, B<Contig>, B<IsMadeUpOf>, and B<Sequence>.  Loads B<Genome>, B<HasContig>, B<Contig>, B<IsMadeUpOf>, and B<Sequence>.
154    
 =item Coupling  
   
 Loads B<Coupling>, B<IsEvidencedBy>, B<PCH>, B<ParticipatesInCoupling>,  
 B<UsesAsEvidence>.  
   
155  =item Feature  =item Feature
156    
157  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,
158  B<IsLocatedIn>, B<FeatureLink>.  B<IsLocatedIn>, B<FeatureLink>.
159    
160    =item Coupling
161    
162    Loads B<Coupling>, B<IsEvidencedBy>, B<PCH>, B<ParticipatesInCoupling>,
163    B<UsesAsEvidence>.
164    
165  =item Subsystem  =item Subsystem
166    
167  Loads B<Subsystem>, B<Role>, B<SSCell>, B<ContainsFeature>, B<IsGenomeOf>,  Loads B<Subsystem>, B<Role>, B<SSCell>, B<ContainsFeature>, B<IsGenomeOf>,
# Line 137  Line 179 
179    
180  Loads B<Property>, B<HasProperty>.  Loads B<Property>, B<HasProperty>.
181    
 =item BBH  
   
 Loads B<IsBidirectionalBestHitOf>.  
   
182  =item Group  =item Group
183    
184  Loads B<GenomeGroups>.  Loads B<GenomeGroups>.
# Line 158  Line 196 
196  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,
197  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.
198    
199    =item Synonym
200    
201    Loads B<SynonymGroup> and B<IsSynonymGroupFor>.
202    
203    =item Family
204    
205    Loads B<Family> and B<IsFamilyForFeature>.
206    
207  =item *  =item *
208    
209  Loads all of the above tables.  Loads all of the above tables.
# Line 173  Line 219 
219  The name of the file containing the genomes and their associated access codes. The  The name of the file containing the genomes and their associated access codes. The
220  file should have one line per genome, each line consisting of the genome ID followed  file should have one line per genome, each line consisting of the genome ID followed
221  by the access code, separated by a tab. If no file is specified, all complete genomes  by the access code, separated by a tab. If no file is specified, all complete genomes
222  will be processed and the access code will be 1.  will be processed and the access code will be 1. Specify C<default> to use the
223    default gene file-- C<genes.tbl> in the C<SproutData> directory.
224    
225  =item subsysFile  =item subsysFile
226    
# Line 184  Line 231 
231    
232  Desired tracing level. The default is 3.  Desired tracing level. The default is 3.
233    
234  =item limitedFeatures  =item user
235    
236  Only generate the B<Feature> and B<IsLocatedIn> tables when processing the feature group.  Suffix to use for trace, output, and error files created.
237    
238  =item dbLoad  =item dbLoad
239    
# Line 197  Line 244 
244  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
245  dropped. Use the function with caution.  dropped. Use the function with caution.
246    
247    =item loadOnly
248    
249    If TRUE, the database tables will be loaded from existing load files. Load files
250    will not be created. This option is useful if you are setting up a copy of Sprout
251    and have load files already set up from the original version.
252    
253    =item primaryOnly
254    
255    If TRUE, only the group's primary entity will be loaded.
256    
257    =item background
258    
259    Redirect the standard and error output to files in the FIG temporary directory.
260    
261    =item resume
262    
263    Resume an interrupted load, starting with the load group specified in the first
264    positional parameter.
265    
266    =item sql
267    
268    Trace SQL statements.
269    
270    =item phone
271    
272    Phone number to message when the load finishes.
273    
274  =back  =back
275    
276  =cut  =cut
# Line 214  Line 288 
288  use SFXlate;  use SFXlate;
289    
290  # Get the command-line parameters and options.  # Get the command-line parameters and options.
291  my ($options, @parameters) = Tracer::ParseCommand({ geneFile => "", subsysFile => "",  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
292                                                      trace => 3, limitedFeatures => 0,                                              'ERDB', 'Load', 'Sprout', 'Subsystem'],
293                                                      dbLoad => 0, dbCreate => 0 }, @ARGV);                                              { geneFile => ["", "name of the genome list file"],
294  # Set up tracing.                                                subsysFile => ["", "name of the trusted subsystem file"],
295  TSetup("$options->{trace} SproutLoad ERDBLoad ERDB Stats Tracer Load", "+>$FIG_Config::temp/trace.log");                                                dbLoad => [0, "load the database from generated files"],
296                                                  dbCreate => [0, "drop and re-create the database"],
297                                                  loadOnly => [0, "load the database from previously generated files"],
298                                                  primaryOnly => [0, "only process the group's main entity"],
299                                                  resume => [0, "resume a complete load starting with the first group specified in the parameter list"],
300                                                  phone => ["", "phone number (international format) to call when load finishes"],
301                                                },
302                                                "<group1> <group2> ...",
303                                                @ARGV);
304    # If we're doing a load-only, turn on loading.
305    if ($options->{loadOnly}) {
306        $options->{dbLoad} = 1
307    }
308  if ($options->{dbCreate}) {  if ($options->{dbCreate}) {
309      # Here we want to drop and re-create the database.      # Here we want to drop and re-create the database.
310      my $db = $FIG_Config::sproutDB;      my $db = $FIG_Config::sproutDB;
311      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);  
312      }      }
313    # Compute the gene file name.
314    my $geneFile = $options->{geneFile};
315    if ($geneFile eq 'default') {
316        $geneFile = "$FIG_Config::sproutData/genes.tbl";
317  }  }
318  # Create the sprout loader object. Note that the Sprout object does not  # Create the sprout loader object. Note that the Sprout object does not
319  # open the database unless the "dbLoad" option is turned on.  # open the database unless the "dbLoad" option is turned on.
320  my $fig = FIG->new();  my $fig = FIG->new();
321  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});
322  my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);  my $spl = SproutLoad->new($sprout, $fig, $geneFile, $options->{subsysFile}, $options);
323  # Insure we have an output directory.  # Insure we have an output directory.
324  FIG::verify_dir($FIG_Config::sproutData);  FIG::verify_dir($FIG_Config::sproutData);
325    # If we're resuming, we only want to have 1 parameter.
326    my $resume = $options->{resume};
327    if ($resume && @parameters > 1) {
328        Confess("If resume=1, only one load group can be specified.");
329    } elsif (! @parameters) {
330        Trace("No load groups were specified.") if T(0);
331    }
332    # Set a variable to contain return type information.
333    my $rtype;
334    # Insure we catch errors.
335    eval {
336  # Process the parameters.  # Process the parameters.
337  for my $group (@parameters) {  for my $group (@parameters) {
338      Trace("Processing load group $group.") if T(2);      Trace("Processing load group $group.") if T(2);
339      my $stats;      my $stats;
340      if ($group eq 'Genome' || $group eq '*') {      if ($group eq 'Genome' || $group eq '*') {
341          $spl->LoadGenomeData();          $spl->LoadGenomeData();
342                $group = ResumeCheck($resume, $group);
343      }      }
344      if ($group eq 'Feature' || $group eq '*') {      if ($group eq 'Feature' || $group eq '*') {
345          $spl->LoadFeatureData();          $spl->LoadFeatureData();
346                $group = ResumeCheck($resume, $group);
347      }      }
348      if ($group eq 'Coupling' || $group eq '*') {      if ($group eq 'Coupling' || $group eq '*') {
349          $spl->LoadCouplingData();          $spl->LoadCouplingData();
350                $group = ResumeCheck($resume, $group);
351      }      }
352      if ($group eq 'Subsystem' || $group eq '*') {      if ($group eq 'Subsystem' || $group eq '*') {
353          $spl->LoadSubsystemData();          $spl->LoadSubsystemData();
354                $group = ResumeCheck($resume, $group);
355      }      }
356      if ($group eq 'Property' || $group eq '*') {      if ($group eq 'Property' || $group eq '*') {
357          $spl->LoadPropertyData();          $spl->LoadPropertyData();
358                $group = ResumeCheck($resume, $group);
359      }      }
360      if ($group eq 'Annotation' || $group eq '*') {      if ($group eq 'Annotation' || $group eq '*') {
361          $spl->LoadAnnotationData();          $spl->LoadAnnotationData();
362                $group = ResumeCheck($resume, $group);
363      }      }
364      if ($group eq 'BBH' || $group eq '*') {          #if ($group eq 'BBH' || $group eq '*') {
365          $spl->LoadBBHData();          #    $spl->LoadBBHData();
366      }          #    $group = ResumeCheck($resume, $group);
367            #}
368      if ($group eq 'Group' || $group eq '*') {      if ($group eq 'Group' || $group eq '*') {
369          $spl->LoadGroupData();          $spl->LoadGroupData();
370                $group = ResumeCheck($resume, $group);
371      }      }
372      if ($group eq 'Source' || $group eq '*') {      if ($group eq 'Source' || $group eq '*') {
373          $spl->LoadSourceData();          $spl->LoadSourceData();
374                $group = ResumeCheck($resume, $group);
375      }      }
376      if ($group eq 'External' || $group eq '*') {      if ($group eq 'External' || $group eq '*') {
377          $spl->LoadExternalData();          $spl->LoadExternalData();
378                $group = ResumeCheck($resume, $group);
379      }      }
380      if ($group eq 'Reaction' || $group eq '*') {      if ($group eq 'Reaction' || $group eq '*') {
381          $spl->LoadReactionData();          $spl->LoadReactionData();
382                $group = ResumeCheck($resume, $group);
383            }
384            if ($group eq 'Synonym' || $group eq '*') {
385                $spl->LoadSynonymData();
386                $group = ResumeCheck($resume, $group);
387            }
388            if ($group eq 'Family' || $group eq '*') {
389                $spl->LoadFamilyData();
390                $group = ResumeCheck($resume, $group);
391            }
392        }
393    };
394    if ($@) {
395        Trace("Load failed with error: $@") if T(0);
396        $rtype = "error";
397    } else {
398        Trace("Load complete.") if T(2);
399        $rtype = "no error";
400    }
401    if ($options->{phone}) {
402        my $msgID = Tracer::SendSMS($options->{phone}, "Sprout load terminated with $rtype.");
403        if ($msgID) {
404            Trace("Phone message sent with ID $msgID.") if T(2);
405        } else {
406            Trace("Phone message not sent.") if T(2);
407        }
408      }      }
409    
410    # If the resume flag is set, return "*", else return "".
411    sub ResumeCheck {
412        my ($resume, $group) = @_;
413        return ($resume ? "*" : $group);
414  }  }
 Trace("Load complete.") if T(2);  
415    
416  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3