[Bio] / FortyEightMeta / mg_create_db_indexes.pl Repository:
ViewVC logotype

View of /FortyEightMeta/mg_create_db_indexes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Wed Jun 11 21:16:42 2008 UTC (11 years, 8 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, mgrast_rel_2008_0806, mgrast_dev_10262011, mgrast_dev_02212011, mgrast_rel_2008_0923, mgrast_release_3_0, mgrast_dev_03252011, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, mgrast_rel_2008_0919, mgrast_rel_2008_1110, myrast_33, mgrast_rel_2008_0917, mgrast_dev_04052011, mgrast_dev_02222011, HEAD
Commit of initial MGRAST2 code.

#
# Create the indices needed on the tables for this job.
#

use strict;
use JobStage;
use DBrtns;
use File::Basename;

@ARGV == 1 or die "Usage: $0 job-dir\n";

my $jobdir = shift;

-d $jobdir or die "$0: job dir $jobdir does not exist\n";

my $STAGE = 'create_indexes';

my $stage = new JobStage('Job48', $STAGE, $jobdir);
$stage or die "Cannot create job for $jobdir\n";

my $job_id = basename($jobdir);

my($mgdb);
eval {
    $mgdb = new DBrtns($FIG_Config::mgrast_dbms, $FIG_Config::mgrast_db,
		       $FIG_Config::mgrast_dbuser, $FIG_Config::mgrast_dbpass,
		       $FIG_Config::mgrast_dbport, $FIG_Config::mgrast_dbhost,
		       $FIG_Config::mgrast_dbsock);

};
if ($@ or !defined($mgdb))
{
    die "cannot connect to database: $@";
}

my $dbh = $mgdb->{_dbh};

my $full_tbl = $stage->get_metadata('db.table_name');
my @other_tbls = map { $stage->get_metadata($_) } ('db.best_by_iden_table_name', 'db.best_by_psc_table_name');

for my $tbl ($full_tbl, @other_tbls)
{
    make_index($dbh, $tbl, ['id1']);
    make_index($dbh, $tbl, ['iden']);
    make_index($dbh, $tbl, ['ali_ln']);
    make_index($dbh, $tbl, ['logpsc']);
    make_index($dbh, $tbl, ['bsc']);
    make_index($dbh, $tbl, ['tax_group_1', 'tax_group_2', 'tax_group_3']);
}

make_index($dbh, $full_tbl, ['rank_psc']);
make_index($dbh, $full_tbl, ['rank_iden']);

sub make_index
{
    my($dbh, $tbl, $cols) = @_;
    
    my $iname = $tbl . '_' . join("_", @$cols);
    my $clist = join(", ", @$cols);
    my $q = qq(CREATE INDEX $iname ON $tbl($clist));
    print "$q\n";
    $dbh->do($q);
}

__END__
    
create index tax_sim_565_id1 on tax_sim_565(id1);
create index tax_sim_565_iden on tax_sim_565(iden);
create index tax_sim_565_ali_ln on tax_sim_565(ali_ln);
create index tax_sim_565_logpsc on tax_sim_565(logpsc);
create index tax_sim_565_bsc on tax_sim_565(bsc);
create index tax_sim_565_rank_iden on tax_sim_565(rank_iden);
create index tax_sim_565_rank_psc on tax_sim_565(rank_psc);
create index tax_sim_565_tax_group_1_tax_group_2_tax_group_3 on tax_sim_565(tax_group_1, tax_group_2, tax_group_3);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3