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

Diff of /FigKernelScripts/load_coupling.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Wed Jun 1 01:18:50 2005 UTC revision 1.7, Mon Dec 5 18:56:37 2005 UTC
# Line 1  Line 1 
1    #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18    
19  # -*- perl -*-  # -*- perl -*-
20    
21  use FIG;  use FIG;
22    use Tracer;
23    
24  my $fig = new FIG;  my $fig = new FIG;
25    
26  # usage: load_coupling  # usage: load_coupling
27    
28  $pchD   = "$FIG_Config::fig/CouplingData/PCHs";  $pchD   = "$FIG_Config::data/CouplingData/PCHs";
29  $scores = "$FIG_Config::fig/CouplingData/scores";  $scores = "$FIG_Config::data/CouplingData/scores";
30    
31  use DBrtns;  use DBrtns;
32    
33  if (! ((-d $pchD) && (-s $scores))) { exit }  if (!(-d $pchD)) {
34        Trace("Coupling directory $pchD not found.") if T(1);
35        exit;
36    } elsif (!(-s $scores)) {
37        Trace("Coupling data file $scores not found.") if T(1);
38        exit;
39    }
40    Trace("Re-creating coupling table.") if T(2);
41    my $dbf = $fig->db_handle;
42    $dbf->reload_table('all', 'fc_pegs',
43                       "peg1 varchar(32), peg2 varchar(32), score integer",
44                       { fc_pegs_ix => "peg1, peg2" },
45                       $scores
46              );
47    
48  my $dbf = $fig->{_dbf};  Trace("Estimating size of PCH table.") if T(2);
49    
50  $dbf->drop_table( tbl => "fc_pegs" );  @files = grep { (-s $_) } map { "$pchD/$_" }  OpenDir($pchD, 1);
51  $dbf->create_table( tbl => 'fc_pegs',  
52                      flds => "peg1 varchar(32), peg2 varchar(32), score integer"  my($row_size, $max_rows) = $dbf->estimate_table_size(\@files);
53                    );  
54  $dbf->load_table( tbl => "fc_pegs",  Trace("Re-creating PCH table with row_size=$row_size max_rows=$max_rows.") if T(2);
55                    file => $scores );  
56  $dbf->create_index( idx  => "fc_pegs_ix",  $dbf->reload_table('all', "pchs",
57                      tbl  => "fc_pegs",                     "peg1 varchar(32), peg2 varchar(32), peg3 varchar(32), peg4 varchar(32),
58                      type => "btree",                         inden13 varchar(6), inden24 varchar(6), para3  integer, para4 integer, rep char(1)",
59                      flds => "peg1,peg2" );                      { pchs_ix => "peg1, peg2" }, undef, undef, undef, [$row_size, $max_rows]
   
 $dbf->vacuum_it("fc_pegs");  
   
 $dbf->drop_table( tbl => "pchs" );  
 $dbf->create_table( tbl => 'pchs',  
                     flds => "peg1 varchar(32), peg2 varchar(32), peg3 varchar(32), peg4 varchar(32),  
                              inden13 varchar(6), inden24 varchar(6), para3  integer, para4 integer, rep char(1)"  
60                    );                    );
61    
62  opendir(PCHD,$pchD) || die "could not open $pchD";  Trace("Reading PCH directory.") if T(2);
63  @files = grep { ($_ !~ /^\./) && (-s "$pchD/$_") } readdir(PCHD);  
64  foreach $file (@files)  foreach $file (@files) {
65  {      Trace("Loading PCH data from $file.") if T(3);
66      $dbf->load_table( tbl => "pchs",      $dbf->load_table( tbl => "pchs",
67                    file => "$pchD/$file" );                        file => $file );
68  }  }
69  $dbf->create_index( idx  => "pchs_ix",  Trace("Finishing PCH load.") if T(2);
70                      tbl  => "pchs",  $dbf->finish_load('all', 'pchs');
                     type => "btree",  
                     flds => "peg1,peg2" );  
   
 $dbf->vacuum_it("pchs");  
71    
72    Trace("Couplings loaded.") if T(2);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3