[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.20, Tue Jan 31 07:33:46 2006 UTC revision 1.47, Tue Feb 5 05:04:26 2008 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 1  =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  Type C<LoadSproutTables -dbLoad -dbCreate "*"> and press ENTER. This will create  User name for logging into the Sprout database.
 the C<dtx> files and load them.  
88    
89  =item 2  =item dbpass
90    
91  Type C<TestSproutLoad 100226.1 83333.1> and press ENTER. This will validate  Password for logging into the Sprout database.
 the Sprout database against the SEED data.  
92    
93  =item 3  =item nmpdr_site_url
94    
95  If any errors are detected in step (2), it is most likely due to a change in  URL for the NMPDR cover pages. The NMPDR cover pages are informational and text
96  SEED that did not make it to Sprout. Contact Bruce Parrello or Robert Olson  pages that serve as the entry point to the NMPDR web site. They are generated by
97  to get the code updated properly.  a Content Management tool, and some Sprout scripts need to know where to find
98    them.
99    
100  =item 4  =item nmpdr_site_template_id
101    
102  Type C<index_sprout> and press ENTER. This will create the Glimpse indexes  Page number for the template page used to generate results that look like they're
103  for the Sprout data.  part of the NMPDR web site.
104    
105  =back  =back
106    
107    Most of the above preparation is performed by the B<NMPDRSetup> utility.
108    NMPDRSetup prints the instructions for completing the process, including
109    loading the Sprout database. The specific procedure for loading
110    the Sprout data, however, is as follows.
111    
112  =head2 LoadSproutTables Command  =head2 LoadSproutTables Command
113    
114  C<LoadSproutTables> creates the load files for Sprout tables and optionally loads them.  C<LoadSproutTables> creates the load files for Sprout tables and optionally loads them.
# Line 110  Line 121 
121    
122  Loads B<Genome>, B<HasContig>, B<Contig>, B<IsMadeUpOf>, and B<Sequence>.  Loads B<Genome>, B<HasContig>, B<Contig>, B<IsMadeUpOf>, and B<Sequence>.
123    
 =item Coupling  
   
 Loads B<Coupling>, B<IsEvidencedBy>, B<PCH>, B<ParticipatesInCoupling>,  
 B<UsesAsEvidence>.  
   
124  =item Feature  =item Feature
125    
126  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,
127  B<IsLocatedIn>, B<FeatureLink>.  B<IsLocatedIn>, B<FeatureLink>, B<IsAliasOf>, B<CDD>, B<HasFeature>,
128    B<HasRoleInSubsystem>, B<FeatureEssential>, B<FeatureVirulent>, B<FeatureIEDB>,
129    B<CDD>, and B<IsPresentOnProteinOf>
130    
131  =item Subsystem  =item Subsystem
132    
# Line 126  Line 134 
134  B<IsRoleOf>, B<OccursInSubsystem>, B<ParticipatesIn>, B<HasSSCell>,  B<IsRoleOf>, B<OccursInSubsystem>, B<ParticipatesIn>, B<HasSSCell>,
135  B<Catalyzes>, B<ConsistsOfRoles>, B<RoleSubset>, B<HasRoleSubset>,  B<Catalyzes>, B<ConsistsOfRoles>, B<RoleSubset>, B<HasRoleSubset>,
136  B<ConsistsOfGenomes>, B<GenomeSubset>, B<HasGenomeSubset>, B<Diagram>,  B<ConsistsOfGenomes>, B<GenomeSubset>, B<HasGenomeSubset>, B<Diagram>,
137  B<RoleOccursIn>.  B<RoleOccursIn>, B<SubSystemClass>, B<RoleEC>, B<IsIdentifiedByEC>,
138    B<ContainsFeature>.
139    
140  =item Annotation  =item Annotation
141    
# Line 137  Line 146 
146    
147  Loads B<Property>, B<HasProperty>.  Loads B<Property>, B<HasProperty>.
148    
 =item BBH  
   
 Loads B<IsBidirectionalBestHitOf>.  
   
149  =item Group  =item Group
150    
151  Loads B<GenomeGroups>.  Loads B<GenomeGroups>.
# Line 158  Line 163 
163  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,
164  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.
165    
166    =item Synonym
167    
168    Loads B<SynonymGroup> and B<IsSynonymGroupFor>.
169    
170    =item Family
171    
172    Loads B<Family> and B<IsFamilyForFeature>.
173    
174    =item Drug
175    
176    Loads B<PDB>, B<DocksWith>, C<IsProteinForFeature>, and C<Ligand>.
177    
178  =item *  =item *
179    
180  Loads all of the above tables.  Loads all of the above tables.
# Line 173  Line 190 
190  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
191  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
192  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
193  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
194    default gene file-- C<genes.tbl> in the C<SproutData> directory.
195    
196  =item subsysFile  =item subsysFile
197    
# Line 184  Line 202 
202    
203  Desired tracing level. The default is 3.  Desired tracing level. The default is 3.
204    
205    =item user
206    
207    Suffix to use for trace, output, and error files created.
208    
209  =item dbLoad  =item dbLoad
210    
211  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 199  Line 221 
221  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
222  and have load files already set up from the original version.  and have load files already set up from the original version.
223    
224  =item primaryOnly  =item background
225    
226    Redirect the standard and error output to files in the FIG temporary directory.
227    
228    =item resume
229    
230    Resume an interrupted load, starting with the load group specified in the first
231    positional parameter.
232    
233    =item sql
234    
235  If TRUE, only the group's primary entity will be loaded.  Trace SQL statements.
236    
237    =item phone
238    
239    Phone number to message when the load finishes.
240    
241  =back  =back
242    
# Line 209  Line 244 
244    
245  use strict;  use strict;
246  use Tracer;  use Tracer;
 use DocUtils;  
247  use Cwd;  use Cwd;
248  use FIG;  use FIG;
249  use SFXlate;  use SFXlate;
# Line 219  Line 253 
253  use Stats;  use Stats;
254  use SFXlate;  use SFXlate;
255    
256    # This is a list of the load groups in their natural order. We'll go through these in sequence, processing
257    # the ones the user asks for.
258    my @LoadGroups = qw(Genome Feature Subsystem Property Annotation Source External Reaction Synonym Family Drug);
259    
260  # Get the command-line parameters and options.  # Get the command-line parameters and options.
261  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
262                                              'ERDB', 'Load'],                                              'ERDB', 'Load', 'Sprout', 'Subsystem'],
263                                              { geneFile => ["", "name of the genome list file"],                                              { geneFile => ["", "name of the genome list file"],
264                                                subsysFile => ["", "name of the trusted subsystem file"],                                                subsysFile => ["", "name of the trusted subsystem file"],
265                                                dbLoad => [0, "load the database from generated files"],                                                dbLoad => [0, "load the database from generated files"],
266                                                dbCreate => [0, "drop and re-create the database"],                                                dbCreate => [0, "drop and re-create the database"],
267                                                loadOnly => [0, "load the database from previously generated files"],                                                loadOnly => [0, "load the database from previously generated files"],
268                                                primaryOnly => [0, "only process the group's main entity"]                                                resume => [0, "resume a complete load starting with the first group specified in the parameter list"],
269                                                  phone => ["", "phone number (international format) to call when load finishes"],
270                                              },                                              },
271                                              "<group1> <group2> ...",                                              "<group1> <group2> ...",
272                                              @ARGV);                                              @ARGV);
# Line 240  Line 279 
279      my $db = $FIG_Config::sproutDB;      my $db = $FIG_Config::sproutDB;
280      DBKernel::CreateDB($db);      DBKernel::CreateDB($db);
281  }  }
282    # Compute the gene file name.
283    my $geneFile = $options->{geneFile};
284    if ($geneFile eq 'default') {
285        $geneFile = "$FIG_Config::sproutData/genes.tbl";
286    }
287  # Create the sprout loader object. Note that the Sprout object does not  # Create the sprout loader object. Note that the Sprout object does not
288  # open the database unless the "dbLoad" option is turned on.  # open the database unless the "dbLoad" option is turned on.
289  my $fig = FIG->new();  my $fig = FIG->new();
290  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});
291  my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);  my $spl = SproutLoad->new($sprout, $fig, $geneFile, $options->{subsysFile}, $options);
292  # Insure we have an output directory.  # Insure we have an output directory.
293  FIG::verify_dir($FIG_Config::sproutData);  FIG::verify_dir($FIG_Config::sproutData);
294    # Check for the "*" option.
295    if ($parameters[0] eq '*') {
296        @parameters = @LoadGroups;
297    }
298    # If we're resuming, we only want to have 1 parameter.
299    my $resume = $options->{resume};
300    if ($resume && @parameters > 1) {
301        Confess("If resume=1, only one load group can be specified.");
302    } elsif (! @parameters) {
303        Trace("No load groups were specified.") if T(0);
304    }
305    # Process the resume option here. We modify the incoming parameters to
306    # contain the resume group and everything after it.
307    if ($resume) {
308        # Save the starting group.
309        my $resumeGroup = $parameters[0];
310        # Copy the load group list into the parameter array.
311        @parameters = @LoadGroups;
312        # Shift out the groups until we reach our desired starting point.
313        while (scalar(@parameters) && $parameters[0] ne $resumeGroup) {
314            shift @parameters;
315        }
316        if (! @parameters) {
317            Confess("Resume group \"$resumeGroup\" not found.");
318        }
319    }
320    # Set a variable to contain return type information.
321    my $rtype;
322    # Set up a statistics object for statistics about the entire load.
323    my $totalStats = Stats->new();
324    # Insure we catch errors.
325    eval {
326  # Process the parameters.  # Process the parameters.
327  for my $group (@parameters) {  for my $group (@parameters) {
328      Trace("Processing load group $group.") if T(2);      Trace("Processing load group $group.") if T(2);
329      my $stats;          # Compute the string we want to execute.
330      if ($group eq 'Genome' || $group eq '*') {          my $code = "\$spl->Load${group}Data()";
331          $spl->LoadGenomeData();          # Load this group.
332      }          my $stats = eval($code);
333      if ($group eq 'Feature' || $group eq '*') {          if ($@) {
334          $spl->LoadFeatureData();              Confess("Load group error: $@");
335      }          }
336      if ($group eq 'Coupling' || $group eq '*') {          # Merge the statistics into the master.
337          $spl->LoadCouplingData();          $totalStats->Accumulate($stats);
338      }      }
339      if ($group eq 'Subsystem' || $group eq '*') {      # Compute the statistical display.
340          $spl->LoadSubsystemData();      my $statDisplay = $totalStats->Show();
341      }      # Display it.
342      if ($group eq 'Property' || $group eq '*') {      Trace("Statistics for this load:\n$statDisplay") if T(2);
343          $spl->LoadPropertyData();      # Check for a "table load failed" message. If we find one, we want
344      }      # to end with an error.
345      if ($group eq 'Annotation' || $group eq '*') {      if ($statDisplay =~ /table load failed/i) {
346          $spl->LoadAnnotationData();          Confess("One or more table loads failed.");
347      }      }
348      if ($group eq 'BBH' || $group eq '*') {  };
349          $spl->LoadBBHData();  if ($@) {
350      }      Trace("Load failed with error: $@") if T(0);
351      if ($group eq 'Group' || $group eq '*') {      $rtype = "error";
352          $spl->LoadGroupData();  } else {
353      }      Trace("Load complete.") if T(2);
354      if ($group eq 'Source' || $group eq '*') {      $rtype = "no error";
         $spl->LoadSourceData();  
355      }      }
356      if ($group eq 'External' || $group eq '*') {  if ($options->{phone}) {
357          $spl->LoadExternalData();      my $msgID = Tracer::SendSMS($options->{phone}, "Sprout load terminated with $rtype.");
358        if ($msgID) {
359            Trace("Phone message sent with ID $msgID.") if T(2);
360        } else {
361            Trace("Phone message not sent.") if T(2);
362      }      }
     if ($group eq 'Reaction' || $group eq '*') {  
         $spl->LoadReactionData();  
363      }      }
364    
 }  
 Trace("Load complete.") if T(2);  
   
365  1;  1;

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.47

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3