ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/aglappe-0.9.3/createGraphDb.sh
Revision: 409
Committed: Tue Nov 20 19:09:21 2007 UTC (11 years, 10 months ago) by filippis
Original Path: trunk/createGraphDb.sh
File size: 2527 byte(s)
Log Message:
createGraphDb.sh added
Line User Rev File contents
1 filippis 409 #!/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 scops INT,
70     MODIFY caths INT,
71     MODIFY entry_id INT,
72     MODIFY assembly_id INT,
73     MODIFY chain_id INT,
74     MODIFY model_id INT;
75    
76     ALTER TABLE single_model_graph
77     MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT;
78    
79     ALTER TABLE single_model_node
80     MODIFY ssid VARCHAR(5),
81     MODIFY sheet_serial CHAR(1);
82    
83     ALTER TABLE single_model_edge
84     MODIFY i_ssid VARCHAR(5),
85     MODIFY i_sheet_serial CHAR(1),
86     MODIFY j_ssid VARCHAR(5),
87     MODIFY j_sheet_serial CHAR(1);
88     ENDSQL1
89     fi
90    
91     if [ "$mode" == "INDEX" ]
92     then
93     $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
94     SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
95     CREATE INDEX NODE_GRAPH_IDX ON single_model_node (graph_id);
96     CREATE INDEX EDGE_GRAPH_IDX ON single_model_edge (graph_id);
97     ENDSQL
98     fi
99    
100     if [ "$mode" == "UNINDEX" ]
101     then
102     $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
103     SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
104     DROP INDEX NODE_GRAPH_IDX ON single_model_node;
105     DROP INDEX EDGE_GRAPH_IDX ON single_model_edge;
106     ENDSQL
107     fi

Properties

Name Value
svn:executable *