/cron/updateucsc.sh.sample
https://bitbucket.org/cistrome/cistrome-harvard/ · Shell · 104 lines · 83 code · 9 blank · 12 comment · 12 complexity · bf5b60c131171350017df86fab5d1276 MD5 · raw file
- #!/bin/sh
- #
- # Script to update UCSC shared data tables. The idea is to update, but if
- # the update fails, not replace current data/tables with error
- # messages.
- # Edit this line to refer to galaxy's path:
- GALAXY=/galaxy/path
- PYTHONPATH=${GALAXY}/lib
- export PYTHONPATH
- # setup directories
- echo "Creating required directories."
- DIRS="
- ${GALAXY}/tool-data/shared/ucsc/new
- ${GALAXY}/tool-data/shared/ucsc/chrom
- ${GALAXY}/tool-data/shared/ucsc/chrom/new
- "
- for dir in $DIRS; do
- if [ ! -d $dir ]; then
- echo "Creating $dir"
- mkdir $dir
- else
- echo "$dir already exists, continuing."
- fi
- done
- date
- echo "Updating UCSC shared data tables."
- # Try to build "publicbuilds.txt"
- echo "Updating publicbuilds.txt"
- python ${GALAXY}/cron/parse_publicbuilds.py > ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt
- if [ $? -eq 0 ]
- then
- diff ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt ${GALAXY}/tool-data/shared/ucsc/publicbuilds.txt > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- cp -f ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt ${GALAXY}/tool-data/shared/ucsc/publicbuilds.txt
- fi
- else
- echo "Failed to update publicbuilds.txt" >&2
- fi
- # Try to build "builds.txt"
- echo "Updating builds.txt"
- python ${GALAXY}/cron/parse_builds.py > ${GALAXY}/tool-data/shared/ucsc/new/builds.txt
- if [ $? -eq 0 ]
- then
- diff ${GALAXY}/tool-data/shared/ucsc/new/builds.txt ${GALAXY}/tool-data/shared/ucsc/builds.txt > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- cp -f ${GALAXY}/tool-data/shared/ucsc/new/builds.txt ${GALAXY}/tool-data/shared/ucsc/builds.txt
- fi
- else
- echo "Failed to update builds.txt" >&2
- fi
- # Try to build ucsc_build_sites.txt
- echo "Updating ucsc_build_sites.txt"
- python ${GALAXY}/cron/parse_builds_3_sites.py > ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt
- if [ $? -eq 0 ]
- then
- diff ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt ${GALAXY}/tool-data/shared/ucsc/ucsc_build_sites.txt > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- cp -f ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt ${GALAXY}/tool-data/shared/ucsc/ucsc_build_sites.txt
- fi
- else
- echo "Failed to update builds.txt" >&2
- fi
- # Try to build chromInfo tables
- echo "Building chromInfo tables."
- python ${GALAXY}/cron/build_chrom_db.py ${GALAXY}/tool-data/shared/ucsc/chrom/new/ ${GALAXY}/tool-data/shared/ucsc/builds.txt
- if [ $? -eq 0 ]
- then
- for src in ${GALAXY}/tool-data/shared/ucsc/chrom/new/*.len
- do
- dst=${GALAXY}/tool-data/shared/ucsc/chrom/`basename $src`
- diff $src $dst > /dev/null 2>&1
- if [ $? -ne 0 ]
- then
- echo "cp -f $src $dst"
- cp -f $src $dst
- fi
- done
- else
- echo "Failed to update chromInfo tables." >&2
- fi
- rm -rf ${GALAXY}/tool-data/shared/ucsc/new
- rm -rf ${GALAXY}/tool-data/shared/ucsc/chrom/new
- echo "Update complete."
- #Perform Manual Additions here
- echo "Adding Manual Builds."
- python ${GALAXY}/cron/add_manual_builds.py ${GALAXY}/tool-data/shared/ucsc/manual_builds.txt ${GALAXY}/tool-data/shared/ucsc/builds.txt ${GALAXY}/tool-data/shared/ucsc/chrom/
- if [ $? -eq 0 ]
- then
- echo "Manual addition was successful."
- else
- echo "Manual addition failed" >&2
- fi