ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/aglappe-0.9.3/createGraphDb.sh
Revision: 492
Committed: Wed Jan 2 13:18:57 2008 UTC (11 years, 8 months ago) by duarte
Original Path: trunk/createGraphDb.sh
File size: 2653 byte(s)
Log Message:
Copied the aglappe-jung branch into trunk.

Line File contents
1 #!/bin/sh
2 function usage {
3 echo
4 echo "Script to create/link/index a graph database. "
5 echo
6 echo "Usage: $1 -d <db_name> -m <mode>"
7 echo
8 echo "-d <db_name> the graph database name "
9 echo "-m <mode> create/index/unindex tables "
10 echo
11 }
12
13 #
14 #Set default value for variables
15 #
16 graphDb=""
17 mode=""
18 h="white"
19
20 while getopts d:m: opt
21 do
22 case "$opt" in
23 d) graphDb="$OPTARG";;
24 m) mode="$OPTARG";;
25 esac
26 done
27
28 if [ -z "$graphDb" ] || [ -z "$mode" ]
29 then
30 echo "Missing or more arguments"
31 usage $0
32 exit 1
33 fi
34
35 arch=`uname -m`
36 case "$arch" in
37 i686)
38 mysqldir=/project/tla/dist/mysql-i686
39 ;;
40 x86_64)
41 mysqldir=/project/tla/dist/mysql
42 ;;
43 *)
44 mysqldir=/project/tla/dist/mysql-i686
45 ;;
46 esac
47
48 mysqlbin=$mysqldir/bin/mysql
49 master=white
50 db=test
51
52 if [ "$mode" == "CREATE" ]
53 then
54 $mysqlbin -pnieve -h $h -B -N $db <<ENDSQL
55 SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
56 CREATE DATABASE IF NOT EXISTS ${graphDb}
57 DEFAULT CHARACTER SET latin1 DEFAULT COLLATE latin1_general_cs;
58 ENDSQL
59 $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL1
60 SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
61 CREATE TABLE chain_graph LIKE abstract.chain_graph;
62 CREATE TABLE single_model_graph LIKE abstract.single_model_graph;
63 CREATE TABLE single_model_node LIKE abstract.single_model_node;
64 CREATE TABLE single_model_edge LIKE abstract.single_model_edge;
65 CREATE TABLE pdb_residue_info LIKE abstract.pdb_residue_info;
66
67 ALTER TABLE chain_graph
68 MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
69 MODIFY pchain_code VARCHAR(2) NOT NULL,
70 MODIFY scops INT,
71 MODIFY caths INT,
72 MODIFY entry_id INT,
73 MODIFY assembly_id INT,
74 MODIFY chain_id INT,
75 MODIFY model_id INT;
76
77 ALTER TABLE single_model_graph
78 MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT;
79
80 ALTER TABLE single_model_node
81 MODIFY ssid VARCHAR(5),
82 MODIFY sheet_serial CHAR(1);
83
84 ALTER TABLE single_model_edge
85 MODIFY i_ssid VARCHAR(5),
86 MODIFY i_sheet_serial CHAR(1),
87 MODIFY j_ssid VARCHAR(5),
88 MODIFY j_sheet_serial CHAR(1);
89 ENDSQL1
90 fi
91
92 if [ "$mode" == "INDEX" ]
93 then
94 $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
95 SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
96 CREATE INDEX NODE_GRAPH_IDX ON single_model_node (graph_id);
97 CREATE INDEX EDGE_GRAPH_IDX ON single_model_edge (graph_id);
98 CREATE INDEX CHAIN_IDX ON pdb_residue_info (pdb_code, chain_code, pdb_chain_code);
99 ENDSQL
100 fi
101
102 if [ "$mode" == "UNINDEX" ]
103 then
104 $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
105 SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
106 DROP INDEX NODE_GRAPH_IDX ON single_model_node;
107 DROP INDEX EDGE_GRAPH_IDX ON single_model_edge;
108 ENDSQL
109 fi

Properties

Name Value
svn:executable *