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

View of /FigKernelScripts/index_subsystems.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (download) (as text) (annotate)
Mon Oct 13 20:26:02 2008 UTC (11 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: rast_rel_2009_05_18, rast_rel_2008_12_18, rast_rel_2010_0928, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2010_1206, rast_rel_2010_0118, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, rast_rel_2008_10_29, rast_rel_2009_03_26, rast_rel_2008_11_24
Changes since 1.10: +23 -3 lines
Add support for subsystem_metadata table. Updates via Subsystem::db_sync.

# -*- perl -*-
#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#


# usage: index_subsystems [sub1 sub2 ...]

# if there are arguments, then the database is NOT reinitialized, and only the 
# designated new set of subsystms is indexed.

use FIG;
my $fig = new FIG;
use Tracer;

my @to_process = ();
my $dbf = $fig->{_dbf};

if (@ARGV == 0)
{
    Trace("Recreating subsystem index table.") if T(2);
    $dbf->drop_table( tbl => "subsystem_index" );
    $dbf->create_table( tbl  => "subsystem_index",
			flds => <<EOFLD);
    protein varchar(32),
    subsystem varchar(255),
    role varchar(255),
    variant varchar(32)
EOFLD

    $dbf->drop_table( tbl => "aux_roles" );
    $dbf->create_table( tbl => "aux_roles", flds => "subsystem varchar(255),role varchar(255)" );

    $dbf->drop_table(tbl => "subsystem_metadata");
    $dbf->create_table(tbl => "subsystem_metadata",
		      flds => qq(subsystem	varchar(255),
				 classification	text,
				 class_1	varchar(255),
				 class_2	varchar(255),
				 curator	varchar(255),
				 creation_date	integer,
				 last_update	integer,
				 version	integer,
				 exchangable	integer
				 ));
				 
}    
	


#
# Determine which subsystems to load.
#


my @subsystems;
my $skip_delete;

if (@ARGV == 0)
{
    @subsystems = $fig->all_subsystems();
    $skip_delete = 1;
}
else
{
    @subsystems = @ARGV;
    $skip_delete = 0;
}
Trace("Iterating through subsystems.") if T(2);
for my $subsystem (@subsystems)
{
	Trace("Processing subsystem $subsystem.") if T(3);
    my $sub = $fig->get_subsystem($subsystem);

    if (!$sub)
    {
	Trace("Could not find subsystem for $subsystem") if T(1);
	next;
    }

    $sub->db_sync($skip_delete);
}

if (@ARGV == 0) 
{
	Trace("Indexing subsystem table.") if T(2);
    $dbf->create_index( idx  => "subsystems_protein_ix",
			tbl  => "subsystem_index",
			type => "btree",
			flds => "protein");

    $dbf->create_index( idx  => "subsystems_role_ix",
			tbl  => "subsystem_index",
			type => "btree",
			flds => "role");

    $dbf->create_index( idx  => "subsystems_by_subsystem_ix",
			tbl  => "subsystem_index",
			type => "btree",
			flds => "subsystem");

    $dbf->create_index( idx => "aux_roles_ids",
			tbl => "aux_roles",
			type => "btree",
			flds => "subsystem,role");
	$dbf->create_index(idx => "subsystem_metadata_ix",
			   tbl => "subsystem_metadata",
			   flds => "subsystem");
}
    $dbf->vacuum_it("subsystem_index");
    $dbf->vacuum_it("subsystem_metadata");
    $dbf->vacuum_it("aux_roles");
#}

undef $fig;
Trace("Subsystems indexed.");

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3