PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1#!/bin/sh 
  2#
  3# Script to update UCSC shared data tables.  The idea is to update, but if
  4# the update fails, not replace current data/tables with error
  5# messages.
  6
  7# Edit this line to refer to galaxy's path:
  8GALAXY=/galaxy/path
  9PYTHONPATH=${GALAXY}/lib
 10export PYTHONPATH
 11
 12# setup directories
 13echo "Creating required directories."
 14DIRS="
 15${GALAXY}/tool-data/shared/ucsc/new
 16${GALAXY}/tool-data/shared/ucsc/chrom
 17${GALAXY}/tool-data/shared/ucsc/chrom/new
 18"
 19for dir in $DIRS; do
 20    if [ ! -d $dir ]; then
 21        echo "Creating $dir"
 22        mkdir $dir
 23    else
 24        echo "$dir already exists, continuing."
 25    fi
 26done
 27
 28date
 29echo "Updating UCSC shared data tables."
 30
 31# Try to build "publicbuilds.txt"
 32echo "Updating publicbuilds.txt"
 33python ${GALAXY}/cron/parse_publicbuilds.py > ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt
 34if [ $? -eq 0 ]
 35then
 36    diff ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt ${GALAXY}/tool-data/shared/ucsc/publicbuilds.txt > /dev/null 2>&1
 37    if [ $? -ne 0 ]
 38    then
 39        cp -f ${GALAXY}/tool-data/shared/ucsc/new/publicbuilds.txt ${GALAXY}/tool-data/shared/ucsc/publicbuilds.txt
 40    fi
 41else
 42    echo "Failed to update publicbuilds.txt" >&2
 43fi
 44
 45# Try to build "builds.txt"
 46echo "Updating builds.txt"
 47python ${GALAXY}/cron/parse_builds.py > ${GALAXY}/tool-data/shared/ucsc/new/builds.txt
 48if [ $? -eq 0 ]
 49then
 50    diff ${GALAXY}/tool-data/shared/ucsc/new/builds.txt ${GALAXY}/tool-data/shared/ucsc/builds.txt > /dev/null 2>&1
 51    if [ $? -ne 0 ]
 52    then
 53        cp -f ${GALAXY}/tool-data/shared/ucsc/new/builds.txt ${GALAXY}/tool-data/shared/ucsc/builds.txt
 54    fi
 55else
 56    echo "Failed to update builds.txt" >&2
 57fi
 58
 59# Try to build ucsc_build_sites.txt
 60echo "Updating ucsc_build_sites.txt"
 61python ${GALAXY}/cron/parse_builds_3_sites.py > ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt
 62if [ $? -eq 0 ]
 63then
 64    diff ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt ${GALAXY}/tool-data/shared/ucsc/ucsc_build_sites.txt > /dev/null 2>&1
 65    if [ $? -ne 0 ]
 66    then
 67        cp -f ${GALAXY}/tool-data/shared/ucsc/new/ucsc_build_sites.txt ${GALAXY}/tool-data/shared/ucsc/ucsc_build_sites.txt
 68    fi
 69else
 70    echo "Failed to update builds.txt" >&2
 71fi
 72
 73# Try to build chromInfo tables
 74echo "Building chromInfo tables."
 75python ${GALAXY}/cron/build_chrom_db.py ${GALAXY}/tool-data/shared/ucsc/chrom/new/ ${GALAXY}/tool-data/shared/ucsc/builds.txt
 76if [ $? -eq 0 ]
 77then
 78    for src in ${GALAXY}/tool-data/shared/ucsc/chrom/new/*.len
 79    do
 80        dst=${GALAXY}/tool-data/shared/ucsc/chrom/`basename $src`
 81        diff $src $dst > /dev/null 2>&1
 82        if [ $? -ne 0 ]
 83        then
 84            echo "cp -f $src $dst"
 85            cp -f $src $dst
 86        fi
 87    done
 88else
 89    echo "Failed to update chromInfo tables." >&2
 90fi
 91
 92rm -rf ${GALAXY}/tool-data/shared/ucsc/new
 93rm -rf ${GALAXY}/tool-data/shared/ucsc/chrom/new
 94echo "Update complete."
 95
 96#Perform Manual Additions here
 97echo "Adding Manual Builds."
 98python ${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/
 99if [ $? -eq 0 ]
100then
101    echo "Manual addition was successful."
102else
103    echo "Manual addition failed" >&2
104fi