-
Notifications
You must be signed in to change notification settings - Fork 7
/
make_sacCer3.sh
executable file
·95 lines (82 loc) · 2.04 KB
/
make_sacCer3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
# This script is a modification of the make_hg19.sh script from the bowtie2
# distribution.
# Downloads sequence for the sacCer3 version of S. cerevisiae(baker's yeast) from
# UCSC.
GENOME_NAME=sacCer3
UCSC_BASE=http://hgdownload.cse.ucsc.edu/goldenPath/${GENOME_NAME}/chromosomes
CHRS_TO_INDEX="chrI,chr1 \
chrII,chr2 \
chrIII,chr3 \
chrIV,chr4 \
chrV,chr5 \
chrVI,chr6 \
chrVII,chr7 \
chrVIII,chr8 \
chrIX,chr9 \
chrX,chr10 \
chrXI,chr11 \
chrXII,chr12 \
chrXIII,chr13 \
chrXIV,chr14 \
chrXV,chr15 \
chrXVI,chr16 \
chrM,chrM"
BOWTIE_FOLDER=`find ./bin -iname "*bowtie*" -type d | head -1`
echo ${BOWTIE_FOLDER}
get() {
echo ${1} ${2}
file=$1
outfile=$2
if ! wget --version >/dev/null 2>/dev/null ; then
if ! curl --version >/dev/null 2>/dev/null ; then
echo "Please install wget or curl somewhere in your PATH"
exit 1
fi
curl -o `basename $1` $2
return $?
else
wget $1 -O $2
return $?
fi
}
BOWTIE_BUILD_EXE=${BOWTIE_FOLDER}/bowtie2-build
if [ ! -x "$BOWTIE_BUILD_EXE" ] ; then
if ! which bowtie2-build ; then
echo "Could not find bowtie2-build in current directory or in PATH"
exit 1
else
BOWTIE_BUILD_EXE=`which bowtie2-build`
fi
fi
OLDIFS=$IFS
INPUTS=
for c in $CHRS_TO_INDEX ; do
IFS=","
set $c
F=${1}.fa.gz
OUT_F=${2}.fa
if [ ! -f ${OUT_F} ] ; then
get ${UCSC_BASE}/$F $F|| (echo "Error getting $F" && exit 1)
zcat ${F} | sed 's/'${1}/${2}'/' > ${OUT_F} || (echo "Error unzipping $F" && exit 1)
rm ${F}
fi
[ -n "$INPUTS" ] && INPUTS=$INPUTS,${OUT_F}
[ -z "$INPUTS" ] && INPUTS=${OUT_F}
done
IFS=$OLDIFS
CMD="${BOWTIE_BUILD_EXE} ${INPUTS} ${GENOME_NAME}"
echo Running $CMD
if $CMD ; then
echo "${GENOME_NAME} index built"
else
echo "Index building failed; see error message"
fi
echo "Move the bowtie index to the bowtie folder"
mkdir -p ${BOWTIE_FOLDER}/index
mv *.bt2 ${BOWTIE_FOLDER}/index
echo "Move the ${GENOME_NAME} FASTA genome to the fasta folder"
mkdir -p fasta/${GENOME_NAME}
mv *.fa fasta/${GENOME_NAME}
echo "Make the gap file"
python make_sacCer3_gap.py fasta/${GENOME_NAME}