Commit patch to not break on spaces.
[bowtie.git] / scripts / make_m_musculus_ncbi37.sh
1 #!/bin/sh
2
3 #
4 # Downloads assembled sequence for M. musculus (mouse) from NCBI.
5 #
6 # From README_CURRENT_BUILD:
7 #  Organism: Mus musculus (mouse)
8 #  NCBI Build Number: 37
9 #  Version: 1
10 #  Release date: 05 July 2007
11 #
12
13 M_MUS_FTP=ftp://ftp.ncbi.nih.gov/genomes/M_musculus/Assembled_chromosomes
14 M_MUS_MT_FTP=ftp://ftp.ncbi.nih.gov/genomes/M_musculus/CHR_MT
15 OUTPUT=m_musculus_ncbi37
16
17 get() {
18         file=$1
19         if ! wget --version >/dev/null 2>/dev/null ; then
20                 if ! curl --version >/dev/null 2>/dev/null ; then
21                         echo "Please install wget or curl somewhere in your PATH"
22                         exit 1
23                 fi
24                 curl -o `basename $1` $1
25                 return $?
26         else
27                 wget $1
28                 return $?
29         fi
30 }
31
32 BOWTIE_BUILD_EXE=./bowtie-build
33 if [ ! -x "$BOWTIE_BUILD_EXE" ] ; then
34         if ! which bowtie-build ; then
35                 echo "Could not find bowtie-build in current directory or in PATH"
36                 exit 1
37         else
38                 BOWTIE_BUILD_EXE=`which bowtie-build`
39         fi
40 fi
41
42 INPUTS=
43 append() {
44         [ -n "$INPUTS" ] && INPUTS=$INPUTS,$1
45         [ -z "$INPUTS" ] && INPUTS=$1
46 }
47
48 for c in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 X Y ; do
49         F=mm_ref_chr$c.fa
50         if [ ! -f mm_ref_chr$c.fa ] ; then
51                 FGZ=$F.gz
52                 get $M_MUS_FTP/$FGZ || (echo "Error getting $FGZ" && exit 1)
53                 gunzip $FGZ || (echo "Error unzipping $FGZ" && exit 1)
54         fi
55         append $F
56 done
57
58 F=mm_ref_chrMT.fa
59 if [ ! -f mm_ref_chrMT.fa ] ; then
60         FGZ=$F.gz
61         get $M_MUS_MT_FTP/$FGZ  || (echo "Error getting $FGZ" && exit 1)
62         gunzip $FGZ || (echo "Error unzipping $FGZ" && exit 1)
63 fi
64 append $F
65
66 CMD="$BOWTIE_BUILD_EXE $* $INPUTS $OUTPUT"
67 echo $CMD
68 if $CMD ; then
69         echo "$OUTPUT index built; you may remove fasta files"
70 else
71         echo "Index building failed; see error message"
72 fi