-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUploadToDatabase2
executable file
·93 lines (78 loc) · 2.32 KB
/
UploadToDatabase2
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#**************************************************************
# EPPIC Pre-Computation Script
# Author : Kumaran Baskaran
# Date : 05/07/2013
#***************************************************************
set -e
help="\t\tUsage : $0 \n
\t\t [-d <dir-path> : Directory contains downloaded files\n
\t\t -j <file-path> : eppic jar file path\n
\t\t -n <name> : database name (usually uniprot relese name)]\n
\t\tExample : ./Download files -o ~/Downloads "
if (($# == 0)); then
echo "`date +%d/%m/%y-%H:%M:%S` ERROR: Script requires arguments" >&2
echo -e $help
exit 1;
fi
while getopts :d:j:n:h opt
do
case $opt in
d) DOWNLOAD=$OPTARG;;
j) EPPIC_JAR=$OPTARG;;
n) DATABASE_NAME=$OPTARG;;
h) echo -e $help;;
\?) echo "`date +%d/%m/%y-%H:%M:%S` ERROR: Invalid option: -$OPTARG" >&2
exit 1;;
:) echo "`date +%d/%m/%y-%H:%M:%S` ERROR: Option -$OPTARG requires an argument." >&2
exit 1;;
esac
done
if [ -z $DOWNLOAD ] || [ -z $EPPIC_JAR ] || [ -z $DATABASE_NAME ]
then
echo -e "\n`date +%d/%m/%y-%H:%M:%S` ERROR: ---------Some Options not specified correctly -------" >&2
echo -e $help
exit 1
fi
if [ ! -e $EPPIC_JAR ]
then
echo -e "\t `date +%d/%m/%y-%H:%M:%S` ERROR: Couldn't find $EPPIC_JAR ..........." >&2
exit 1
fi
if [ ! -e $DOWNLOAD/uniref100.xml.gz ]
then
echo "`date +%d/%m/%y-%H:%M:%S` ERROR: Couldn't find $DOWNLOAD/uniref100.xml.gz" >&2
exit 1
fi
if [ ! -e $DOWNLOAD/taxonomy-all.tab ]
then
echo "`date +%d/%m/%y-%H:%M:%S` ERROR: Couldn't find $DOWNLOAD/taxonomy-all.tab" >&2
exit 1
fi
#------------Create taxonomy table-----------------------------
table=taxonomy
# creating tables
echo "`date +%d/%m/%y-%H:%M:%S` INFO: Creating $table table..."
mysql $DATABASE_NAME <<EOF
DROP TABLE IF EXISTS $table;
CREATE TABLE $table (
tax_id int PRIMARY KEY,
mnemonic varchar(20),
scientific varchar(255),
common varchar(255),
synonym varchar(255),
other text,
reviewed varchar(20),
rank varchar(20),
lineage text,
parent int
);
EOF
#-------------------------------------------------------------
# loading data
echo "`date +%d/%m/%y-%H:%M:%S` INFO: Loading data into $table table"
mysql --enable-local $DATABASE_NAME <<EOF
LOAD DATA LOCAL INFILE '$DOWNLOAD/taxonomy-all.tab' INTO TABLE $table IGNORE 1 LINES;
SHOW WARNINGS;
EOF
echo "`date +%d/%m/%y-%H:%M:%S` INFO: Finished loading data into taxonomy."