Skip to content
Snippets Groups Projects
Commit 6e2afb3c authored by Andy Yates's avatar Andy Yates
Browse files

allow for column configuration

parent e40dbbdc
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ use POSIX qw/strftime/;
my ($db_name,$db_host,$db_user,$db_pass,$db_port,$help);
my @tables;
my @columns;
my ($optimise, $nobackup, $nolock);
GetOptions ("db_name|dbname|database=s" => \$db_name,
......@@ -22,12 +23,17 @@ GetOptions ("db_name|dbname|database=s" => \$db_name,
'optimise!' => \$optimise,
'nolock!' => \$nolock,
'nobackup!' => \$nobackup,
'columns=s@' => \@columns,
"h|help!" => \$help,
);
if ($help) {&usage; exit 0;}
unless ($db_name and $db_host) {print "Insufficient arguments\n"; &usage; exit 1;}
if(!@columns) {
@columns = qw/seq_region_id seq_region_start seq_region_end/;
}
sub get_adaptor {
my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-species => 'tmp',
......@@ -67,7 +73,8 @@ sub sort_table {
}
info("Re-ordering table");
$dba->dbc()->do("ALTER TABLE ${table} ORDER BY seq_region_id, seq_region_start, seq_region_end");
my $cols = join(',', @columns);
$dba->dbc()->do("ALTER TABLE ${table} ORDER BY $cols");
if(!$nolock) {
info("Unlocking table %s", $table);
......@@ -166,6 +173,10 @@ Options:
-nolock Stop the code from applying for table locks
-columns Specify the columns to sort on. Defaults to
seq_region_id, seq_region_start and seq_region_end.
Multiple parameters allowed
-help
";
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment