#!/usr/local/bin/perl -w
eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
=head1 NAME
ldas_bulk_load.pl -- Bulk Load a LDAS Bio::DB::GFF databases
=head1 SYNOPSIS
This manual page is pending.
=head1 DESCRIPTION
=head1 BUGS
=head1 SEE ALSO
=head1 AUTHOR
Lincoln Stein <lstein@cshl.org>
=cut
use strict;
use Getopt::Long;
use FindBin qw($Bin);
my ($DSN,$FORCE,$USER,$PASSWORD,$FASTA);
GetOptions ('database:s' => \$DSN,
'create' => \$FORCE,
'fasta:s' => \$FASTA,
'user:s' => \$USER,
'password:s' => \$PASSWORD,
) or die <<USAGE;
Usage: $0 [options] <gff file 1> <gff file 2> ...
Bulk-load a DAS database from GFF or Das flat files.
Options:
--database <dsn> Mysql database name
--fasta <path> Path to FASTA file or directory to load (optional)
--create Create/reinitialize existing data tables without asking
--user Username to log in as
--password Password to use for authentication
NOTE: If no arguments are provided, then the input is taken from
standard input. Compressed files (.gz, .Z, .bz2) are automatically
uncompressed.
The nature of the bulk load requires that the database be on the local
machine and that the indicated user have the "file" privilege to load
the tables and have enough room in /usr/tmp (or whatever is specified
by the \$TMPDIR environment variable), to hold the tables transiently.
This scripts requires the bulk_load_gff.pl script to be in the command
search path. This script can be found in the BioPerl distribution,
under scripts/Bio::DB::GFF.
USAGE
;
$DSN ||= 'test';
unless ($FORCE) {
open (TTY,"/dev/tty") or die "/dev/tty: $!\n";
print STDERR "This operation will delete all existing data in database $DSN. Continue? ";
my $f = <TTY>;
die "Aborted\n" unless $f =~ /^[yY]/;
close TTY;
}
foreach (@ARGV) {
if (/\.das(\.(gz|Z|bz2))?$/) {
$_ = "$Bin/Das2GFF.pl $_ |";
} else {
$_ = "gunzip -c $_ |" if /\.gz$/;
$_ = "uncompress -c $_ |" if /\.Z$/;
$_ = "bunzip2 -c $_ |" if /\.bz2$/;
}
}
my @args = qw(--create);
push @args,('--database'=> $DSN) if defined $DSN;
push @args,('--fasta' => $FASTA) if defined $FASTA;
push @args,('--user' => $USER) if defined $USER;
push @args,('--password'=> $PASSWORD) if defined $PASSWORD;
system "bulk_load_gff.pl",@args,@ARGV;