Skip to content

Instantly share code, notes, and snippets.

@brentp
Created May 23, 2011 17:50
Show Gist options
  • Save brentp/987144 to your computer and use it in GitHub Desktop.
Save brentp/987144 to your computer and use it in GitHub Desktop.
mirror essential tables from UCSC to a local mysql database. (change $ORG to mm8/hg18/dm3 or your organism of choice.)
ORG=hg19
USER=brentp
# from: http://nsaunders.wordpress.com/2011/05/18/how-to-create-a-partial-ucsc-genome-mysql-database/
# create database
mysql -u $USER -e "CREATE DATABASE $ORG";
mkdir -p ucsc-data/$ORG
cd ucsc-data/$ORG
for table in knownGene refGene ensGene kgXref chromInfo cpgIslandExt cytoBand
do
mysql -u $USER $ORG -e "DROP TABLE $table;"
# obtain table schema
wget http://hgdownload.cse.ucsc.edu/goldenPath/$ORG/database/${table}.sql
# create table
mysql -u $USER $ORG < ${table}.sql
# obtain and import table data
wget http://hgdownload.cse.ucsc.edu/goldenPath/$ORG/database/${table}.txt.gz
gunzip ${table}.txt.gz
mysqlimport -u $USER --local $ORG ${table}.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment