-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorthomclDropSchema
77 lines (56 loc) · 1.71 KB
/
orthomclDropSchema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
use DBI;
use FindBin;
use lib "$FindBin::Bin/../lib/perl";
use OrthoMCLEngine::Main::Base;
use strict;
usage() unless (@ARGV >= 1);
my $configFile = $ARGV[0];
my $sqlLog = $ARGV[1];
my $suffix = $ARGV[2];
my $base = OrthoMCLEngine::Main::Base->new($configFile);
my $dbh = $base->getDbh();
if ($sqlLog) {
open (LOGFILE, ">$sqlLog");
}
runSql("drop table " . $base->getConfig("similarSequencesTable") . $suffix);
runSql("drop table " . $base->getConfig("inParalogTable") . $suffix);
runSql("drop table " . $base->getConfig("orthologTable") . $suffix);
runSql("drop table " . $base->getConfig("coOrthologTable") . $suffix);
runSql("drop view " . $base->getConfig("interTaxonMatchView") . $suffix);
##############################################################
sub runSql {
my $sql = $_[0];
if ($sqlLog) {
logSql($sql);
}
my $stmt = $dbh->prepare($sql) or die DBI::errstr;
$stmt->execute() or die DBI::errstr;
}
sub logSql {
my $sql = $_[0];
print LOGFILE "\n$sql";
}
sub usage {
print STDERR "
Drop OrthoMCL schema
usage: orthomclDropSchema config_file sql_log_file
where:
config_file : see below
sql_log_file : optional log of sql executed
EXAMPLE: orthomclDropSchema my_orthomcl_dir/orthomcl.config my_orthomcl_dir/drop_schema.log
NOTE: the database login in the config file must have the required database privileges on the tables specified in the config file.
Sample Config File:
dbVendor=oracle (or mysql)
dbConnectString=dbi:Oracle:orthomcl
dbLogin=my_db_login
dbPassword=my_db_password
oracleIndexTablespace=
similarSequencesTable=SimilarSequences
orthologTable=Ortholog
inParalogTable=InParalog
coOrthologTable=CoOrtholog
interTaxonMatchView=InterTaxonMatch
";
exit(1);
}