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

View of /FigKernelScripts/load_coupling.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.6 - (download) (as text) (annotate)
Wed Aug 17 19:32:24 2005 UTC (14 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: caBIG-dataload-0, caBIG-00-00-00
Changes since 1.5: +13 -4 lines
Add table size estimation code for supporting MyISAM.

# -*- perl -*-

use FIG;
use Tracer;

my $fig = new FIG;

# usage: load_coupling

$pchD   = "$FIG_Config::data/CouplingData/PCHs";
$scores = "$FIG_Config::data/CouplingData/scores";

use DBrtns;

if (!(-d $pchD)) {
    Trace("Coupling directory $pchD not found.") if T(1);
} elsif (!(-s $scores)) {
    Trace("Coupling data file $scores not found.") if T(1);
Trace("Re-creating coupling table.") if T(2);
my $dbf = $fig->db_handle;
$dbf->reload_table('all', 'fc_pegs',
                   "peg1 varchar(32), peg2 varchar(32), score integer",
                   { fc_pegs_ix => "peg1, peg2" },

Trace("Estimating size of PCH table.") if T(2);

@files = grep { (-s $_) } map { "$pchD/$_" }  OpenDir($pchD, 1);

my($row_size, $max_rows) = $dbf->estimate_table_size(\@files);

Trace("Re-creating PCH table with row_size=$row_size max_rows=$max_rows.") if T(2);

$dbf->reload_table('all', "pchs",
                   "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)",
                    { pchs_ix => "peg1, peg2" }, undef, undef, undef, [$row_size, $max_rows]

Trace("Reading PCH directory.") if T(2);

foreach $file (@files) {
    Trace("Loading PCH data from $file.") if T(3);
    $dbf->load_table( tbl => "pchs",
                      file => $file );
Trace("Finishing PCH load.") if T(2);
$dbf->finish_load('all', 'pchs');

Trace("Couplings loaded.") if T(2);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3