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

Annotation of /Sprout/LoadSproutTables.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 Load Sprout Tables
4 :    
5 : parrello 1.12 =head2 Introduction
6 :    
7 : parrello 1.14 The Sprout database reflects a snapshot of the SEED taken at a particular point in
8 :     time. At some point in the future, it will be possible to add annotations to the
9 :     Sprout data. All records added to Sprout after the snapshot is taken are
10 :     specially-marked so that the changes can be copied to the SEED. The SEED remains
11 :     the live version of the data.
12 :    
13 :     The snapshot is produced by reading the SEED data and writing it to sequential
14 :     files. There is one file per Sprout table, and each such file's name consists of
15 :     the table name with the suffix C<dtx>. Thus, the file for the C<Genome> table
16 :     would be named C<Genome.dtx>. These files are used to load the actual Sprout
17 :     database and to generate Glimpse indices.
18 :    
19 :     To load all the Sprout tables and then validate the result, you need to issue three
20 :     commands.
21 :    
22 :     LoadSproutTables -dbLoad -dbCreate "*"
23 : parrello 1.27 TestSproutLoad [genomeID] ...
24 :     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 : parrello 1.14
29 :     All three commands send output to the console. In addition, C<LoadSproutTables> and
30 : parrello 1.27 C<TestSproutLoad> write tracing information to a trace log in the FIG temporary
31 : parrello 1.14 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
33 :     and the offending table group reloaded. So, for example, if there are errors in the
34 :     load of the B<MadeAnnotation> and B<Compound> tables, you would need to run
35 :    
36 :     LoadSproutTables -dbLoad Annotation Reaction
37 :    
38 :     because B<MadeAnnotation> is in the C<Annotation> group, and B<Compound> is in the
39 :     C<Reaction> group. A list of the groups is given below.
40 :    
41 :     You can omit the C<dbLoad> option to create the load files without
42 :     loading the database, and you can add a C<trace> option to change the trace level.
43 :     The command below creates the Genome-related load files with a trace level of 3 and
44 :     does not load them into the Sprout database.
45 :    
46 :     LoadSproutTables -trace=3 Genome
47 :    
48 :     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.
50 :    
51 :     Once the Sprout database is loaded, B<TestSproutLoad> can be used to verify the load
52 : parrello 1.27 against the FIG data. The end of the trace log file will contain statistics on
53 :     the errors found. Like C<LoadSproutTables>, C<TestSproutLoad> is a time-consuming
54 : parrello 1.14 script, so you may want to set the trace level to 3 to see visible progress.
55 :    
56 : parrello 1.27 TestSproutLoad -trace=3 [genomeID] ...
57 :    
58 :     The I<[genomeID]> specifies zero or more IDs of genomes to receive more thorough
59 :     testing. So, for example,
60 :    
61 :     TestSproutLoad -trace=3 100226.1 83333.1
62 :    
63 :     would do thorough testing of I<Streptomyces coelicolor A3-2> (100226.1) and
64 :     I<Escherichia coli K12> (83333.1).
65 : parrello 1.14
66 :     Unlike C<LoadSproutTables>, in C<TestSproutLoad>, the individual errors found are
67 :     mixed in with the trace messages. They are all, however, marked with a trace type
68 :     of B<Problem>, as shown in the fragment below.
69 :    
70 :     11/02/2005 19:15:16 <main>: Processing feature fig|100226.1.peg.7742.
71 :     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7741.
72 :     11/02/2005 19:15:17 <Problem>: assignment "Short-chain dehydrodenase ...
73 :     11/02/2005 19:15:17 <Problem>: assignment "putative oxidoreductase." ...
74 :     11/02/2005 19:15:17 <Problem>: Incorrect assignment for fig|100226.1.peg.7741...
75 :     11/02/2005 19:15:17 <Problem>: Incorrect number of annotations found in ...
76 :     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7740.
77 :     11/02/2005 19:15:18 <main>: Processing feature fig|100226.1.peg.7739.
78 :    
79 :     The test may reveal that some tables need to be reloaded, or that a software
80 :     problem has crept into the Sprout.
81 :    
82 : parrello 1.27 Once all the tables have the correct data, C<index_sprout_lucene> can be run to create the
83 :     Lucene search indexes. Lucene is a web site search engine produced by the Apache project.
84 :     It is written in Java, and in order to run it you must have the B<LuceneSearch> and
85 :     B<NmpdrConfigs> projects checked out from CVS and made.
86 : parrello 1.14
87 :     =head2 Procedure For Loading Sprout
88 :    
89 : parrello 1.27 In order to load the Sprout, you need to have the B<Sprout>, B<NmpdrConfigs>, and
90 :     B<LuceneSearch> projects checked out from CVS in addition to the standard FIG
91 :     projects. You must also set up the following B<FIG_Config.pm> variables in addition
92 :     to the normal ones.
93 :    
94 :     =over 4
95 :    
96 :     =item sproutData
97 :    
98 :     Name of the data directory for the Sprout load files.
99 :    
100 :     =item var
101 :    
102 :     Name of the directory to contain cached NMPDR pages. The most important file in
103 :     this directory is C<nmpdr_page_template.html>, which contains a skeleton page
104 :     from the main NMPDR web site. This skeleton page is used to generate output
105 :     pages that look like the other NMPDR pages.
106 :    
107 :     =item java
108 :    
109 :     Path to the Java runtime environment.
110 :    
111 :     =item sproutDB
112 :    
113 :     Name of the Sprout database
114 :    
115 :     =item dbuser
116 :    
117 :     User name for logging into the Sprout database.
118 :    
119 :     =item dbpass
120 :    
121 :     Password for logging into the Sprout database.
122 :    
123 :     =item nmpdr_site_url
124 :    
125 :     URL for the NMPDR cover pages. The NMPDR cover pages are informational and text
126 :     pages that serve as the entry point to the NMPDR web site. They are generated by
127 :     a Content Management tool, and some Sprout scripts need to know where to find
128 :     them.
129 :    
130 :     =item nmpdr_site_template_id
131 :    
132 :     Page number for the template page used to generate results that look like they're
133 :     part of the NMPDR web site.
134 :    
135 :     =back
136 :    
137 : parrello 1.14 =over 4
138 :    
139 : parrello 1.27 The procedure for loading Sprout is as follows.
140 :    
141 : parrello 1.14 =item 1
142 :    
143 : parrello 1.25 Type
144 :    
145 :     nohup LoadSproutTables -dbLoad -dbCreate -user=you -background "*" >null &
146 :    
147 : parrello 1.26 where C<you> is your user ID, and press ENTER. This will create the C<dtx> files
148 : parrello 1.25 and load them. You may be asked for a password. If this is the case, simply
149 :     press ENTER. If that does not work, use the C<dbpass> value specified in
150 :     your C<FIG_Config.pm> file.
151 :    
152 :     The above command line runs the load in the background. The standard output,
153 :     standard error, and trace output will be directed to files in the FIG temporary
154 :     directory. If your user name is C<Bruce> then the files will be named
155 :     C<outBruce.log>, C<errBruce.log>, and C<traceBruce.log> respectively.
156 :    
157 :     If the load fails at some point and you are able to correct the problem, use the
158 :     C<resume> option to restart it. For example, if the load failed while doing the
159 :     Feature load group, you would resume it using
160 :    
161 :     nohup LoadSproutTables -dbLoad -dbCreate -user=you -resume -background Feature >null &
162 : parrello 1.14
163 :     =item 2
164 :    
165 : parrello 1.27 Type
166 :    
167 :     nohup TestSproutLoad -user=you -background >null &100226.1 83333.1>
168 :    
169 :     and press ENTER. This will validate the Sprout database against the SEED data.
170 : parrello 1.14
171 :     =item 3
172 :    
173 :     If any errors are detected in step (2), it is most likely due to a change in
174 :     SEED that did not make it to Sprout. Contact Bruce Parrello or Robert Olson
175 :     to get the code updated properly.
176 :    
177 :     =item 4
178 :    
179 : parrello 1.27 Type
180 :    
181 :     index_sprout_lucene
182 :    
183 :     and press ENTER. This will create the Lucene indexes for the Sprout data.
184 :    
185 :     =item 5
186 :    
187 :     Change to the B<SproutData/Indexes> directory under B<FIGdisk> and look for the
188 :     directory created by C<index_sprout_lucene>. The directory name will be
189 :     something like C<Lucene.20060412-154112>. The numbers indicate the date and time
190 :     the index was created. In this case it was 04/12/2006 03:41:12pm. Type
191 :    
192 :     ln -sf directory Lucene
193 :    
194 :     where C<directory> is the new directory name, to point the C<Lucene> directory to the
195 :     new search index.
196 : parrello 1.14
197 :     =back
198 :    
199 :     =head2 LoadSproutTables Command
200 :    
201 :     C<LoadSproutTables> creates the load files for Sprout tables and optionally loads them.
202 : parrello 1.12 The parameters are the names of the table groups whose data is to be created.
203 :     The legal table group names are given below.
204 : parrello 1.1
205 :     =over 4
206 :    
207 :     =item Genome
208 :    
209 :     Loads B<Genome>, B<HasContig>, B<Contig>, B<IsMadeUpOf>, and B<Sequence>.
210 :    
211 :     =item Coupling
212 :    
213 :     Loads B<Coupling>, B<IsEvidencedBy>, B<PCH>, B<ParticipatesInCoupling>,
214 :     B<UsesAsEvidence>.
215 :    
216 :     =item Feature
217 :    
218 :     Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,
219 : parrello 1.2 B<IsLocatedIn>, B<FeatureLink>.
220 : parrello 1.1
221 :     =item Subsystem
222 :    
223 : parrello 1.2 Loads B<Subsystem>, B<Role>, B<SSCell>, B<ContainsFeature>, B<IsGenomeOf>,
224 : parrello 1.8 B<IsRoleOf>, B<OccursInSubsystem>, B<ParticipatesIn>, B<HasSSCell>,
225 : parrello 1.11 B<Catalyzes>, B<ConsistsOfRoles>, B<RoleSubset>, B<HasRoleSubset>,
226 : parrello 1.13 B<ConsistsOfGenomes>, B<GenomeSubset>, B<HasGenomeSubset>, B<Diagram>,
227 :     B<RoleOccursIn>.
228 : parrello 1.1
229 : parrello 1.2 =item Annotation
230 :    
231 :     Loads B<SproutUser>, B<UserAccess>, B<Annotation>, B<IsTargetOfAnnotation>,
232 :     B<MadeAnnotation>.
233 :    
234 :     =item Property
235 :    
236 :     Loads B<Property>, B<HasProperty>.
237 :    
238 :     =item BBH
239 :    
240 :     Loads B<IsBidirectionalBestHitOf>.
241 :    
242 : parrello 1.3 =item Group
243 :    
244 :     Loads B<GenomeGroups>.
245 :    
246 :     =item Source
247 :    
248 :     Loads B<Source>, B<ComesFrom>, B<SourceURL>.
249 :    
250 : parrello 1.4 =item External
251 :    
252 :     Loads B<ExternalAliasOrg>, B<ExternalAliasFunc>.
253 :    
254 : parrello 1.8 =item Reaction
255 :    
256 :     Loads B<ReactionURL>, B<Compound>, B<CompoundName>,
257 : parrello 1.11 B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.
258 : parrello 1.8
259 : parrello 1.3 =item *
260 :    
261 :     Loads all of the above tables.
262 :    
263 : parrello 1.1 =back
264 :    
265 : parrello 1.7 The command-line options are given below.
266 : parrello 1.1
267 :     =over 4
268 :    
269 :     =item geneFile
270 :    
271 :     The name of the file containing the genomes and their associated access codes. The
272 :     file should have one line per genome, each line consisting of the genome ID followed
273 :     by the access code, separated by a tab. If no file is specified, all complete genomes
274 :     will be processed and the access code will be 1.
275 :    
276 :     =item subsysFile
277 :    
278 :     The name of the file containing the trusted subsystems. The file should have one line
279 :     per trusted subsystem. If no file is specified, all subsystems will be trusted.
280 :    
281 :     =item trace
282 :    
283 :     Desired tracing level. The default is 3.
284 :    
285 : parrello 1.25 =item user
286 :    
287 :     Suffix to use for trace, output, and error files created in
288 :    
289 : parrello 1.10 =item dbLoad
290 :    
291 :     If TRUE, the database tables will be loaded automatically from the load files created.
292 :    
293 : parrello 1.14 =item dbCreate
294 : parrello 1.1
295 : parrello 1.14 If TRUE, the database will be created. If the database exists already, it will be
296 :     dropped. Use the function with caution.
297 : parrello 1.12
298 : parrello 1.17 =item loadOnly
299 :    
300 :     If TRUE, the database tables will be loaded from existing load files. Load files
301 :     will not be created. This option is useful if you are setting up a copy of Sprout
302 :     and have load files already set up from the original version.
303 :    
304 : parrello 1.19 =item primaryOnly
305 :    
306 :     If TRUE, only the group's primary entity will be loaded.
307 :    
308 : parrello 1.25 =item background
309 :    
310 :     Redirect the standard and error output to files in the FIG temporary directory.
311 :    
312 :     =item resume
313 :    
314 :     Resume an interrupted load, starting with the load group specified in the first
315 :     positional parameter.
316 :    
317 :     =item sql
318 :    
319 :     Trace SQL statements.
320 :    
321 : parrello 1.14 =back
322 : parrello 1.12
323 : parrello 1.1 =cut
324 :    
325 :     use strict;
326 :     use Tracer;
327 :     use DocUtils;
328 :     use Cwd;
329 :     use FIG;
330 :     use SFXlate;
331 :     use File::Copy;
332 :     use File::Path;
333 :     use SproutLoad;
334 :     use Stats;
335 : parrello 1.9 use SFXlate;
336 : parrello 1.1
337 :     # Get the command-line parameters and options.
338 : parrello 1.17 my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
339 : parrello 1.26 'ERDB', 'Load', 'Sprout', 'Subsystem'],
340 : parrello 1.18 { geneFile => ["", "name of the genome list file"],
341 :     subsysFile => ["", "name of the trusted subsystem file"],
342 :     dbLoad => [0, "load the database from generated files"],
343 :     dbCreate => [0, "drop and re-create the database"],
344 : parrello 1.19 loadOnly => [0, "load the database from previously generated files"],
345 : parrello 1.23 primaryOnly => [0, "only process the group's main entity"],
346 :     resume => [0, "resume a complete load starting with the first group specified in the parameter list"],
347 : parrello 1.18 },
348 :     "<group1> <group2> ...",
349 : parrello 1.17 @ARGV);
350 :     # If we're doing a load-only, turn on loading.
351 :     if ($options->{loadOnly}) {
352 :     $options->{dbLoad} = 1
353 :     }
354 : parrello 1.14 if ($options->{dbCreate}) {
355 :     # Here we want to drop and re-create the database.
356 :     my $db = $FIG_Config::sproutDB;
357 : parrello 1.20 DBKernel::CreateDB($db);
358 : parrello 1.14 }
359 : parrello 1.9 # Create the sprout loader object. Note that the Sprout object does not
360 : parrello 1.10 # open the database unless the "dbLoad" option is turned on.
361 : parrello 1.1 my $fig = FIG->new();
362 : parrello 1.10 my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});
363 : parrello 1.7 my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);
364 : parrello 1.15 # Insure we have an output directory.
365 :     FIG::verify_dir($FIG_Config::sproutData);
366 : parrello 1.23 # If we're resuming, we only want to have 1 parameter.
367 :     my $resume = $options->{resume};
368 :     if ($resume && @parameters > 1) {
369 :     Confess("If resume=1, only one load group can be specified.");
370 :     } elsif (! @parameters) {
371 :     Confess("No load groups were specified.");
372 :     }
373 : parrello 1.1 # Process the parameters.
374 :     for my $group (@parameters) {
375 :     Trace("Processing load group $group.") if T(2);
376 :     my $stats;
377 : parrello 1.3 if ($group eq 'Genome' || $group eq '*') {
378 : parrello 1.1 $spl->LoadGenomeData();
379 : parrello 1.24 $group = ResumeCheck($resume);
380 : parrello 1.3 }
381 :     if ($group eq 'Feature' || $group eq '*') {
382 : parrello 1.1 $spl->LoadFeatureData();
383 : parrello 1.24 $group = ResumeCheck($resume);
384 : parrello 1.3 }
385 :     if ($group eq 'Coupling' || $group eq '*') {
386 : parrello 1.1 $spl->LoadCouplingData();
387 : parrello 1.24 $group = ResumeCheck($resume);
388 : parrello 1.3 }
389 :     if ($group eq 'Subsystem' || $group eq '*') {
390 : parrello 1.1 $spl->LoadSubsystemData();
391 : parrello 1.24 $group = ResumeCheck($resume);
392 : parrello 1.3 }
393 :     if ($group eq 'Property' || $group eq '*') {
394 : parrello 1.1 $spl->LoadPropertyData();
395 : parrello 1.24 $group = ResumeCheck($resume);
396 : parrello 1.3 }
397 :     if ($group eq 'Annotation' || $group eq '*') {
398 : parrello 1.2 $spl->LoadAnnotationData();
399 : parrello 1.24 $group = ResumeCheck($resume);
400 : parrello 1.3 }
401 :     if ($group eq 'BBH' || $group eq '*') {
402 : parrello 1.2 $spl->LoadBBHData();
403 : parrello 1.24 $group = ResumeCheck($resume);
404 : parrello 1.1 }
405 : parrello 1.4 if ($group eq 'Group' || $group eq '*') {
406 : parrello 1.3 $spl->LoadGroupData();
407 : parrello 1.24 $group = ResumeCheck($resume);
408 : parrello 1.3 }
409 :     if ($group eq 'Source' || $group eq '*') {
410 :     $spl->LoadSourceData();
411 : parrello 1.24 $group = ResumeCheck($resume);
412 : parrello 1.3 }
413 : parrello 1.4 if ($group eq 'External' || $group eq '*') {
414 :     $spl->LoadExternalData();
415 : parrello 1.24 $group = ResumeCheck($resume);
416 : parrello 1.4 }
417 : parrello 1.8 if ($group eq 'Reaction' || $group eq '*') {
418 :     $spl->LoadReactionData();
419 : parrello 1.24 $group = ResumeCheck($resume);
420 : parrello 1.8 }
421 : parrello 1.3
422 : parrello 1.1 }
423 :     Trace("Load complete.") if T(2);
424 :    
425 : parrello 1.23 # If the resume flag is set, return "*", else return "".
426 :     sub ResumeCheck {
427 :     my ($resume) = @_;
428 :     return ($resume ? "*" : "");
429 :     }
430 :    
431 : parrello 1.1 1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3