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