Imported Upstream version 0.12.7
[bowtie.git] / scripts / make_canFam2.sh
1 #!/bin/sh
2
3 #
4 # Downloads sequence for the canFam2 version of C. familiaris (dog)
5 # from UCSC.
6 #
7
8 i=2
9 BASE_CHRS=chr1
10 while [ $i -lt 39 ] ; do
11         BASE_CHRS="$BASE_CHRS chr$i"
12         i=`expr $i + 1`
13 done
14 BASE_CHRS="$BASE_CHRS chrX chrM chrUn"
15 CHRS_TO_INDEX=$BASE_CHRS
16
17 CANFAM2_BASE=ftp://hgdownload.cse.ucsc.edu/goldenPath/canFam2/chromosomes
18
19 get() {
20         file=$1
21         if ! wget --version >/dev/null 2>/dev/null ; then
22                 if ! curl --version >/dev/null 2>/dev/null ; then
23                         echo "Please install wget or curl somewhere in your PATH"
24                         exit 1
25                 fi
26                 curl -o `basename $1` $1
27                 return $?
28         else
29                 wget $1
30                 return $?
31         fi
32 }
33
34 BOWTIE_BUILD_EXE=./bowtie-build
35 if [ ! -x "$BOWTIE_BUILD_EXE" ] ; then
36         if ! which bowtie-build ; then
37                 echo "Could not find bowtie-build in current directory or in PATH"
38                 exit 1
39         else
40                 BOWTIE_BUILD_EXE=`which bowtie-build`
41         fi
42 fi
43
44 INPUTS=
45 for c in $CHRS_TO_INDEX ; do
46         if [ ! -f ${c}.fa ] ; then
47                 F=${c}.fa.gz
48                 get ${CANFAM2_BASE}/$F || (echo "Error getting $F" && exit 1)
49                 gunzip $F || (echo "Error unzipping $F" && exit 1)
50         fi
51         [ -n "$INPUTS" ] && INPUTS=$INPUTS,${c}.fa
52         [ -z "$INPUTS" ] && INPUTS=${c}.fa
53 done
54
55 CMD="${BOWTIE_BUILD_EXE} $* ${INPUTS} canFam2"
56 echo Running $CMD
57 if $CMD ; then
58         echo "canFam2 index built; you may remove fasta files"
59 else
60         echo "Index building failed; see error message"
61 fi