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