[Bio] / FigKernelScripts / load_sims.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/load_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1
2 :    
3 :     # -*- perl -*-
4 :    
5 :     use FIG;
6 : overbeek 1.6 use strict;
7 :    
8 :     use Cwd 'abs_path';
9 :    
10 : overbeek 1.1 my $fig = new FIG;
11 :    
12 :     use DBrtns;
13 :    
14 : overbeek 1.6 my $usage = "usage: load_sims SimsDir";
15 :    
16 :     my $dir;
17 :    
18 : overbeek 1.2 ($dir = shift @ARGV)
19 :     || die $usage;
20 : overbeek 1.1
21 : overbeek 1.6 $dir = abs_path($dir);
22 :    
23 :     -d $dir or die "Sims dir $dir does not exist\n";
24 :    
25 :     my $dbf = $fig->db_handle();
26 : overbeek 1.1
27 : overbeek 1.6 my($mediumint, $pscType);
28 : overbeek 1.5 if ($dbf->{_dbms} eq 'mysql')
29 :     {
30 :     $mediumint = "mediumint";
31 : overbeek 1.6 $pscType = "real";
32 : overbeek 1.5 }
33 :     else
34 :     {
35 :     $mediumint = "integer";
36 : overbeek 1.6 $pscType = "float8";
37 : overbeek 1.5 }
38 :    
39 : olson 1.7
40 :     opendir(SIMS,$dir) || die "$dir does not exist";
41 : olson 1.8 my @files = map { "$dir/$_" } grep { $_ !~ /^\./ } readdir(SIMS);
42 : olson 1.7
43 :     closedir(SIMS);
44 :    
45 :     my($row_size, $max_rows) = $dbf->estimate_table_size(\@files);
46 :    
47 : overbeek 1.1 $dbf->drop_table( tbl => "condensed_sims" );
48 :     $dbf->create_table( tbl => 'condensed_sims',
49 : overbeek 1.6 flds => "g1 smallint, p1 $mediumint, g2 smallint, p2 $mediumint, iden real, psc $pscType, paraN INTEGER",
50 : olson 1.4 type => 'InnoDB'
51 : overbeek 1.1 );
52 : olson 1.7
53 : olson 1.8 foreach my $file (@files)
54 : overbeek 1.1 {
55 : olson 1.8 if (-s $file)
56 : overbeek 1.3 {
57 : olson 1.8 print "Loading $file\n";
58 : overbeek 1.3 $dbf->load_table( tbl => "condensed_sims",
59 : olson 1.8 file => $file );
60 : overbeek 1.3 }
61 : overbeek 1.1 }
62 : olson 1.4 print "Creating index\n";
63 : overbeek 1.1 $dbf->create_index( idx => "condensed_sims_ix",
64 :     tbl => "condensed_sims",
65 :     type => "btree",
66 : olson 1.4 flds => "g1, p1" );
67 : overbeek 1.1
68 :     $dbf->vacuum_it("condensed_sims");
69 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3