Parent Directory
|
Revision Log
defer indexes until after complete load
# -*- perl -*- use strict; use FIG; my $fig = new FIG; use DBrtns; my $temp_dir = "$FIG_Config::temp"; my($organisms_dir) = "$FIG_Config::organisms"; my($genome,@types,$type,$id,$loc,@aliases,$aliases,$contig); # usage: load_features [G1 G2 G3 ... ] open(REL,">$temp_dir/tmpfeat$$") || die "could not open $temp_dir/tmpfeat$$"; my $dbf = $fig->{_dbf}; my @genomes; if (@ARGV == 0) { $dbf->drop_table( tbl => "features" ); if ($FIG_Config::dbms eq "Pg") { $dbf->create_table( tbl => "features", flds => "id varchar(32) UNIQUE NOT NULL, type varchar(16),genome varchar(16)," . "location varchar(5000)," . "contig varchar(96), minloc INTEGER, maxloc INTEGER," . "aliases TEXT, PRIMARY KEY ( id )" ); } elsif ($FIG_Config::dbms eq "mysql") { $dbf->create_table( tbl => "features", flds => "id varchar(32) UNIQUE NOT NULL, type varchar(16),genome varchar(16)," . "location TEXT," . "contig varchar(96), minloc INTEGER, maxloc INTEGER," . "aliases TEXT, PRIMARY KEY ( id )" ); } @genomes = $fig->genomes; } else { @genomes = @ARGV; foreach $genome (@genomes) { $dbf->SQL("DELETE FROM features WHERE ( genome = \'$genome\' )"); } } foreach $genome (@genomes) { opendir(FEAT,"$organisms_dir/$genome/Features") || die "could not open $genome/Features"; @types = grep { $_ =~ /^[a-zA-Z]+$/ } readdir(FEAT); closedir(FEAT); foreach $type (@types) { if ((-s "$organisms_dir/$genome/Features/$type/tbl") && open(TBL,"<$organisms_dir/$genome/Features/$type/tbl")) { # print STDERR "loading $genome/Features/$type/tbl\n"; while (defined($_ = <TBL>)) { chop; ($id,$loc,@aliases) = split(/\t/,$_); if ($id) { my($minloc,$maxloc); if ($loc) { $loc =~ s/\s+$//; ($contig,$minloc,$maxloc) = &FIG::boundaries_of($loc); if ($minloc && $maxloc) { ($minloc < $maxloc) || (($minloc,$maxloc) = ($maxloc,$minloc)); } } if (! $contig) { $loc = $contig = $minloc = $maxloc = ""; } if (@aliases > 0) { $aliases = join(",",grep(/\S/,@aliases)); } else { $aliases = ""; } $minloc = (! $minloc) ? 0 : $minloc; $maxloc = (! $maxloc) ? 0 : $maxloc; if ((length($loc) < 5000) && (length($contig) < 96) && (length($id) < 32)) { print REL "$id\t$type\t$genome\t$loc\t$contig\t$minloc\t$maxloc\t$aliases\n"; } } } close(TBL); } } } close(REL); $dbf->load_table( tbl => "features", file => "$temp_dir/tmpfeat$$" ); if (@ARGV == 0) { $dbf->create_index( idx => "features_org_ix", tbl => "features", type => "btree", flds => "genome" ); $dbf->create_index( idx => "features_type_ix", type => "btree", tbl => "features", flds => "type" ); $dbf->create_index( idx => "features_beg_ix", type => "btree", tbl => "features", flds => "genome,contig,minloc" ); $dbf->vacuum_it("features") } } unlink("$temp_dir/tmpfeat$$");
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |