ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/aglappe-1.1.2/createGraphDb.sh
Revision: 949
Committed: Thu Jan 28 16:11:34 2010 UTC (9 years, 10 months ago) by duarte
File size: 3694 byte(s)
Log Message:
Tagging version 1.1.2 before major refactoring.
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 filippis 576 echo "-m <mode> create/index/unindex/drop tables "
10 filippis 409 echo
11     }
12    
13     #
14     #Set default value for variables
15     #
16     graphDb=""
17     mode=""
18 filippis 789 h="talyn"
19 filippis 409
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 filippis 790 master=talyn
50 filippis 409 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 filippis 503 CREATE TABLE scop_graph LIKE abstract.scop_graph;
63 filippis 409 CREATE TABLE single_model_graph LIKE abstract.single_model_graph;
64     CREATE TABLE single_model_node LIKE abstract.single_model_node;
65     CREATE TABLE single_model_edge LIKE abstract.single_model_edge;
66     CREATE TABLE pdb_residue_info LIKE abstract.pdb_residue_info;
67    
68     ALTER TABLE chain_graph
69     MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
70 filippis 413 MODIFY pchain_code VARCHAR(2) NOT NULL,
71 filippis 409 MODIFY scops INT,
72     MODIFY caths INT,
73     MODIFY entry_id INT,
74     MODIFY assembly_id INT,
75     MODIFY chain_id INT,
76     MODIFY model_id INT;
77    
78 filippis 503 ALTER TABLE scop_graph
79     MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
80     MODIFY pchain_code VARCHAR(2) NOT NULL,
81     MODIFY sunid INT UNSIGNED,
82     MODIFY sccs VARCHAR(10),
83     MODIFY domain_type ENUM('UNKNOWN', 'WHOLECHAIN', 'SINGLEFRAGMENT', 'MULTIFRAGMENT', 'MULTICHAIN'),
84     MODIFY num_chain INT,
85     MODIFY num_fragment INT,
86     MODIFY caths INT,
87     MODIFY num_chain_res INT,
88     MODIFY chain_scops INT,
89     MODIFY entry_id INT,
90     MODIFY assembly_id INT,
91     MODIFY chain_id VARCHAR(35),
92     MODIFY model_id INT;
93    
94 filippis 409 ALTER TABLE single_model_graph
95     MODIFY graph_id INT UNSIGNED NOT NULL AUTO_INCREMENT;
96    
97     ALTER TABLE single_model_node
98 filippis 580 MODIFY node_id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
99 filippis 503 MODIFY num INT NOT NULL,
100 filippis 409 MODIFY ssid VARCHAR(5),
101     MODIFY sheet_serial CHAR(1);
102    
103     ALTER TABLE single_model_edge
104 filippis 503 MODIFY i_num INT NOT NULL,
105 filippis 409 MODIFY i_ssid VARCHAR(5),
106     MODIFY i_sheet_serial CHAR(1),
107 filippis 503 MODIFY j_num INT NOT NULL,
108 filippis 409 MODIFY j_ssid VARCHAR(5),
109     MODIFY j_sheet_serial CHAR(1);
110     ENDSQL1
111     fi
112    
113     if [ "$mode" == "INDEX" ]
114     then
115     $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
116     SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
117     CREATE INDEX NODE_GRAPH_IDX ON single_model_node (graph_id);
118     CREATE INDEX EDGE_GRAPH_IDX ON single_model_edge (graph_id);
119 filippis 413 CREATE INDEX CHAIN_IDX ON pdb_residue_info (pdb_code, chain_code, pdb_chain_code);
120 filippis 409 ENDSQL
121     fi
122    
123     if [ "$mode" == "UNINDEX" ]
124     then
125     $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
126     SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
127     DROP INDEX NODE_GRAPH_IDX ON single_model_node;
128     DROP INDEX EDGE_GRAPH_IDX ON single_model_edge;
129     ENDSQL
130     fi
131 filippis 576
132     if [ "$mode" == "DROP" ]
133     then
134     $mysqlbin -pnieve -h $h -B -N $graphDb <<ENDSQL
135     SET sql_mode = "NO_UNSIGNED_SUBTRACTION,TRADITIONAL";
136     DROP TABLE chain_graph;
137     DROP TABLE scop_graph;
138     DROP TABLE single_model_graph;
139     DROP TABLE single_model_node;
140     DROP TABLE single_model_edge;
141     DROP TABLE pdb_residue_info;
142     ENDSQL
143     fi

Properties

Name Value
svn:executable *