From 6436c1cf0119530e51b8c5122b54ca12959cc3db Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Fri, 17 Aug 2012 21:40:52 -0700 Subject: [PATCH] allow the database to be specified --- utils/load_snp_data.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/utils/load_snp_data.sh b/utils/load_snp_data.sh index 5eae047..ec43b6d 100755 --- a/utils/load_snp_data.sh +++ b/utils/load_snp_data.sh @@ -1,35 +1,38 @@ #!/bin/sh -psql -c 'DROP DATABASE snp'; -psql -c 'CREATE DATABASE snp'; - DATA_DIR=/srv/ncbi/db_snp/ SCHEMA_DIR=/srv/ncbi/db_snp_utils/schema UTIL_DIR=${SCHEMA_DIR}/../utils/ +DB=snp + +psql -c "DROP DATABASE $DB"; +psql -c "CREATE DATABASE $DB"; + + (cd ${SCHEMA_DIR}/shared_schema; - cat dbSNP_main_table_postgresql.sql |psql snp; + cat dbSNP_main_table_postgresql.sql |psql "$DB"; ) (cd ${SCHEMA_DIR}/human_9606_schema; - cat *_table_postgresql.sql|psql snp; - ${UTIL_DIR}/human_gty1_indexes_creation.pl create trigger |psql snp; + cat *_table_postgresql.sql|psql "$DB"; + ${UTIL_DIR}/human_gty1_indexes_creation.pl create trigger |psql "$DB"; ) (cd ${DATA_DIR}/shared_data; for a in $(find -type f -iname '*.bcp.gz' -printf '%f\n'|sort); do echo $a; - zcat $a | perl -pe 's/\r/\\r/g' |psql snp -c "COPY ${a%%.bcp.gz} FROM STDIN WITH NULL ''"; + zcat $a | perl -pe 's/\r/\\r/g' |psql "$DB" -c "COPY ${a%%.bcp.gz} FROM STDIN WITH NULL ''"; done; ) (cd ${DATA_DIR}/organism_data; for a in $(find -type f -iname '*.bcp.gz' -printf '%f\n'|sort); do echo $a; - zcat $a | perl -pe 's/\r/\\r/g' |psql snp -c "COPY ${a%%.bcp.gz} FROM STDIN WITH NULL ''"; + zcat $a | perl -pe 's/\r/\\r/g' |psql "$DB" -c "COPY ${a%%.bcp.gz} FROM STDIN WITH NULL ''"; done; ) (cd ${SCHEMA_DIR}/shared_schema; - cat dbSNP_main_index_postgresql.sql dbSNP_main_constraint_postgresql.sql|psql snp; + cat dbSNP_main_index_postgresql.sql dbSNP_main_constraint_postgresql.sql|psql "$DB"; ) (cd ${SCHEMA_DIR}/human_9606_schema; - cat *_{index,constraint}_postgresql.sql|psql snp; - ${UTIL_DIR}/human_gty1_indexes_creation.pl index |psql snp; + cat *_{index,constraint}_postgresql.sql|psql "$DB"; + ${UTIL_DIR}/human_gty1_indexes_creation.pl index |psql "$DB"; ) -- 2.39.5