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

Annotation of /Sprout/ERDBLoader.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     use strict;
21 :     use Tracer;
22 :     use ERDB;
23 :     use ERDBLoadGroup;
24 :     use ERDBGenerate;
25 :     use Stats;
26 :    
27 :    
28 :     =head1 ERDBLoader Script
29 :    
30 :     ERDBLoader [options] <database> <group1> <group2> ...
31 :    
32 :     ERDB Database Load Finisher
33 :    
34 :     =head2 Introduction
35 :    
36 :     This script finishes the database load process begun by [[ERDBGeneratorPl]].
37 :    
38 :     [[ERDBGeneratorPl]] divides the source data into sections, and generates a
39 :     partial load file for each section of each table. To finish the load process, we
40 :     need to combine the partial files into single files and load the resulting
41 :     single files into the database tables.
42 :    
43 :     Like [[ERDBGeneratorPl]], this script acts on load groups-- sets of related
44 :     tables that are loaded at the same time. For each table in a named group that
45 :     does not exist in the database, the script first attempts to find a completed
46 :     data file. If one does not exist, it attempts to create one by collating section
47 :     files. Once the collated section file is finished, it is loaded into the
48 :     database.
49 :    
50 :     =head2 Positional Parameters
51 :    
52 :     =over 4
53 :    
54 :     =item database
55 :    
56 :     Name of the ERDB database. This should be the class name for the subclass used
57 :     to access the database.
58 :    
59 :    
60 :     =back
61 :    
62 :     =head2 Command-Line Options
63 :    
64 :     =over 4
65 :    
66 :     =item trace
67 :    
68 :     Specifies the tracing level. The higher the tracing level, the more messages
69 :     will appear in the trace log. Use E to specify emergency tracing.
70 :    
71 :     =item replace
72 :    
73 :     Normally, if a table exists in the database, it will not be loaded. If this
74 :     option is specified, however, existing tables will be dropped and recreated.
75 :    
76 :     =item resume
77 :    
78 :     If specified, then the group list must contain a single group. The specified
79 :     group and all groups after it in the group list will be processed.
80 :    
81 :     =item user
82 :    
83 :     Name suffix to be used for log files. If omitted, the PID is used.
84 :    
85 :     =item sql
86 :    
87 :     If specified, turns on tracing of SQL activity.
88 :    
89 :     =item background
90 :    
91 :     Save the standard and error output to files. The files will be created
92 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
93 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
94 :     B<user> option above.
95 :    
96 :     =item help
97 :    
98 :     Display this command's parameters and options.
99 :    
100 :     =item warn
101 :    
102 :     Create an event in the RSS feed when an error occurs.
103 :    
104 :     =item phone
105 :    
106 :     Phone number to message when the script is complete.
107 :    
108 :     =back
109 :    
110 :     =cut
111 :    
112 :     # Get the command-line options and parameters.
113 :     my ($options, @parameters) = StandardSetup([qw(ERDBLoadGroup ERDB Stats) ],
114 :     {
115 :     trace => ["", "tracing level"],
116 :     replace => ["", "if specified, existing tables will be overwritten"],
117 :     resume => ["", "if specified, the specified group and all groups that normally come after it will be processed"],
118 :     phone => ["", "phone number (international format) to call when load finishes"]
119 :     },
120 :     "<database> <group1> <group2> ...",
121 :     @ARGV);
122 :     # Set a variable to contain return type information.
123 :     my $rtype;
124 :     # Insure we catch errors.
125 :     eval {
126 :     # Get the parameters.
127 :     my ($database, @groups) = @parameters;
128 :     # Connect to the database.
129 :     my $erdb = ERDB::GetDatabase($database);
130 :     # Fix the group list.
131 :     my @realGroups = ERDBLoadGroup::ComputeGroups($erdb, $options, \@groups);
132 :     # Get the source object and load directory for this database.
133 :     my $source = $erdb->GetSourceObject();
134 :     my $directory = $erdb->LoadDirectory();
135 :     # Get the list of sections.
136 :     my @sectionList = $erdb->SectionList($source);
137 :     # Create a statistics object to track our progress.
138 :     my $stats = Stats->new();
139 :     # Get the hash of group names to table names.
140 :     my $groupHash = ERDBLoadGroup::GetGroupHash($erdb);
141 :     # Loop through the groups.
142 :     for my $group (@realGroups) {
143 :     # Get the list of tables for this group.
144 :     my $tableList = $groupHash->{$group};
145 :     }
146 :     };
147 :     if ($@) {
148 :     Trace("Script failed with error: $@") if T(0);
149 :     $rtype = "error";
150 :     } else {
151 :     Trace("Script complete.") if T(2);
152 :     $rtype = "no error";
153 :     }
154 :     if ($options->{phone}) {
155 :     my $msgID = Tracer::SendSMS($options->{phone}, "ERDBLoader terminated with $rtype.");
156 :     if ($msgID) {
157 :     Trace("Phone message sent with ID $msgID.") if T(2);
158 :     } else {
159 :     Trace("Phone message not sent.") if T(2);
160 :     }
161 :     }
162 :    
163 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3