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

Annotation of /Sprout/LoadProjections.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (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 Stats;
23 :     use ERDB;
24 :     use Sapling;
25 :     use SeedUtils;
26 :    
27 :     =head1 LoadProjections
28 :    
29 :     =head2 Introduction
30 :    
31 :     LoadProjections [options] <inputfile>
32 :    
33 :     This script will create the ProjectOnto relationship in the Sapling database and
34 :     load it from the specified flat file. It is intended as a one-time use script.
35 :    
36 :     =head2 Command-Line Options
37 :    
38 :     =over 4
39 :    
40 :     =item trace
41 :    
42 :     Specifies the tracing level. The higher the tracing level, the more messages
43 :     will appear in the trace log. Use E to specify emergency tracing.
44 :    
45 :     =item user
46 :    
47 :     Name suffix to be used for log files. If omitted, the PID is used.
48 :    
49 :     =item sql
50 :    
51 :     If specified, turns on tracing of SQL activity.
52 :    
53 :     =item background
54 :    
55 :     Save the standard and error output to files. The files will be created
56 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
57 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
58 :     B<user> option above.
59 :    
60 :     =item DBD
61 :    
62 :     Name of the XML database definition file, if specified. Otherwise, the
63 :     default DBD will be used.
64 :    
65 :     =item dbName
66 :    
67 :     SQL name of the target database. If not specified, the default name is used.
68 :     This option allows you to specify a backup or alternate database that can
69 :     be updated without compromising the main database.
70 :    
71 :     =item dbhost
72 :    
73 :     Name of the MySQL database host. If not specified, the default host is used.
74 :     This option is required when the default host is restricted to read-only
75 :     database access.
76 :    
77 :     =item help
78 :    
79 :     Display this command's parameters and options.
80 :    
81 :     =back
82 :    
83 :     =cut
84 :    
85 :     # Get the command-line options and parameters.
86 :     my ($options, @parameters) = StandardSetup([qw(ERDB) ],
87 :     {
88 :     DBD => ["", "if specified, the name of the DBD file to use"],
89 :     dbName => ["", "if specified, the SQL name of the target database"],
90 :     dbhost => ["", "if specified, the name of the target database"],
91 :     trace => ["2", "tracing level"],
92 :     },
93 :     "",
94 :     @ARGV);
95 :     # Create the statistics object.
96 :     my $stats = Stats->new();
97 :     # Create the SAPLING object.
98 : parrello 1.3 my $sap = Sapling->new(%$options);
99 : parrello 1.1 # Get the input file name.
100 :     my $fileName = $parameters[0];
101 :     # If a DBD was specified, internalize it.
102 :     if ($options->{DBD}) {
103 :     Trace("Storing $options->{DBD} in database.") if T(2);
104 :     $sap->InternalizeDBD();
105 :     }
106 :     # Now we must create a copy of the input file that has no redundant projections.
107 :     my $ih = Tracer::Open(undef, "<$fileName");
108 : parrello 1.2 my $oh = Tracer::Open(undef, ">$FIG_Config::temp/projections.copy.tbl");
109 : parrello 1.1 while (! eof $ih) {
110 :     my ($from, $to, $context, $percent, $score) = Tracer::GetLine($ih);
111 :     if ($from lt $to) {
112 :     Tracer::PutLine($oh, [$from, $to, $context, $percent, $score]);
113 :     }
114 :     }
115 :     close $ih;
116 :     close $oh;
117 :     # Load the table.
118 :     Trace("Loading projection data.") if T(2);
119 : parrello 1.2 $sap->LoadTable("$FIG_Config::temp/projections.copy.tbl", 'ProjectsOnto', truncate => 1, failOnError => 1);
120 : parrello 1.1 # Display the run statistics.
121 :     Trace("Statistics for this run:\n" . $stats->Show()) if T(2);
122 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3