-
Notifications
You must be signed in to change notification settings - Fork 38
/
install.sh
executable file
·306 lines (274 loc) · 8.58 KB
/
install.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/bash
usage()
{
USAGE="""
MToolBox: a tool for heteroplasmy annotation and accurate functional analysis of mitochondrial variants from high throughput sequencing data.
Written by Domenico Simone, Claudia Calabrese and Maria Angela Diroma 2013-2014.
Usage:
FOR FULL INSTALLATION (strongly raccomended):
./install.sh
TO CHANGE SOME OF THE SOFTWARE VERSIONS/KMER PARAMETER DURING THE FULL INSTALLATION OF MTOOLBOX:
./install.sh -g <gsnap_version> -z <zlib_version> -m <muscle_file> -s <samtools_version> -k <kmer_to_build_gsnap_db>
TO UPDATE ONLY ONE SPECIFIC SOTWARE:
./install.sh -i <software_name>
followed, in case, by one of the options to specify the software version/kmer parameter:
-g GSNAP version: default is 2015-12-31.v7
-a Anaconda version: default is 2-2.5.0
-z Zlib version: default is 1.2.11
-m MUSCLE version: default is muscle3.8.31_i86linux64
-s Samtools version: default is 1.6
-k Kmer used for GSNAP database: default is 15
-i install only one specific software [gsnap | anaconda | muscle | zlib | samtools | gsnap_db]
Help options:
-h show this help message
"""
echo "$USAGE"
}
gsnap_gmap_version=2015-12-31.v7
anaconda_version=2-2.5.0
muscle_file=muscle3.8.31_i86linux64
samtools_version=1.6
zlib_version=1.2.11
kmer=15
software_install=all
while getopts ":hg:s:m:a:z:k:i:" opt; do
case $opt in
h)
usage
exit 1
;;
g)
gsnap_gmap_version=$OPTARG
;;
s)
samtools_version=$OPTARG
;;
m)
muscle_file=$OPTARG
;;
a)
anaconda_version=$OPTARG
;;
z)
zlib_version=$OPTARG
;;
k)
kmer=$OPTARG
;;
i)
software_install=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
download()
{
URL=$1
OFILE=$2
wget --no-check-certificate -c -nc -L "$URL" -O $OFILE
}
muscle_install()
{
echo "Installing $muscle_file ..."
muscle_file=$muscle_file
muscle_url=http://www.drive5.com/muscle/downloads3.8.31/${muscle_file}.tar.gz
pushd .
cd bin
download $muscle_url $muscle_file.tar.gz
tar -zxvf $muscle_file.tar.gz
popd
echo "Installing muscle $muscle_file ...done."
}
samtools_install()
{
echo "Installing samtools $samtools_version"
samtools_version=$samtools_version
samtools_file=samtools-${samtools_version}.tar.bz2
samtools_url=https://github.com/samtools/samtools/releases/download/${samtools_version}/$samtools_file
pushd .
cd bin
download $samtools_url $samtools_file
tar xjvf $samtools_file
cd samtools-${samtools_version}
./configure
make
make prefix=../samtools/ install
popd
echo "Installing samtools $samtools_file ...done."
}
zlib_install() {
echo "Installing zlib $zlib_version ..."
zlib_version=$zlib_version
zlib_file=zlib-${zlib_version}.tar.gz
zlib_url=http://zlib.net/$zlib_file
pushd .
cd bin
download $zlib_url $zlib_file
tar xvzf $zlib_file
cd zlib-${zlib_version}
./configure --prefix ../zlib
make
make install
popd
echo "Installing zlib $zlib_version ...done."
echo "exporting zlib ..."
export LD_LIBRARY_PATH=$MTOOLBOX_BIN/zlib/lib:$LD_LIBRARY_PATH:/usr/local/lib
export CFLAGS="-I$MTOOLBOX_BIN/zlib/include $CFLAGS"
}
gsnap_install() {
echo "Installing gmap $gsnap_gmap_version ..."
gsnap_gmap_file=gmap-gsnap-${gsnap_gmap_version}.tar.gz
gsnap_gmap_url=http://research-pub.gene.com/gmap/src/$gsnap_gmap_file
pushd .
cd bin
download $gsnap_gmap_url $gsnap_gmap_file
tar xvzf $gsnap_gmap_file &&
rm $gsnap_gmap_file
cd gmap*
./configure --prefix=$MTOOLBOX_BIN/gmap
make
make install
echo "Installing gmap $gsnap_gmap_version...done"
popd
}
gsnap_db_install() {
nfasta_rcrs_url=http://sourceforge.net/projects/mtoolbox/files/genome_fasta/hg19RCRS.fa.gz
nfasta_rcrs=hg19RCRS.fa.gz
nfasta_rsrs_url=http://sourceforge.net/projects/mtoolbox/files/genome_fasta/hg19RSRS.fa.gz
nfasta_rsrs=hg19RSRS.fa.gz
rcrs_mfasta_url=http://sourceforge.net/projects/mtoolbox/files/genome_fasta/chrM.fa.gz
rcrs_mfasta=chrM.fa.gz
rsrs_mfasta_url=http://sourceforge.net/projects/mtoolbox/files/genome_fasta/chrRSRS.fa.gz
rsrs_mfasta=chrRSRS.fa.gz
download $nfasta_rcrs_url $nfasta_rcrs
download $nfasta_rsrs_url $nfasta_rsrs
download $rcrs_mfasta_url $rcrs_mfasta
download $rsrs_mfasta_url $rsrs_mfasta
if [ "$decompress_fasta"==True ];
then
echo "Building gmap db using $nfasta_rcrs..."
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_nfasta_rcrs -g $nfasta_rcrs -s numeric-alpha -k $kmer
echo "Building gmap db using $nfasta_rsrs..."
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_nfasta_rsrs -g $nfasta_rsrs -s numeric-alpha -k $kmer
echo "Building gmap db using $rcrs_mfasta"
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_rcrs -g $rcrs_mfasta -s numeric-alpha -k $kmer
echo "Building gmap db using $rsrs_mfasta"
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_rsrs -g $rsrs_mfasta -s numeric-alpha -k $kmer
else
echo "Building gmap db using $nfasta_rcrs..."
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_nfasta_rcrs $nfasta_rcrs -s numeric-alpha -k $kmer
echo "Building gmap db using $nfasta_rsrs..."
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_nfasta_rsrs $nfasta_rsrs -s numeric-alpha -k $kmer
echo "Building gmap db using $rcrs_mfasta"
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_rcrs $rcrs_mfasta -s numeric-alpha -k $kmer
echo "Building gmap db using $rsrs_mfasta"
$MTOOLBOX_BIN/gmap/bin/gmap_build -D $gmap_db -d $database_name_rsrs $rsrs_mfasta -s numeric-alpha -k $kmer
fi
echo "Building gmap db ...done"
}
anaconda_install() {
echo "Installing anaconda version $anaconda_version..."
unset PYTHONPATH
file=Anaconda$anaconda_version-Linux-x86_64.sh
download https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/$file $file
chmod +x $file
mkdir -p $MTOOLBOX_BIN/anaconda
./$file -p $MTOOLBOX_BIN/anaconda -b -f
echo "Installing anaconda... done."
echo "exporting anaconda path: $MTOOLBOX_BIN/anaconda/bin"
export PATH=$MTOOLBOX_BIN/anaconda/bin:$PATH
}
#########################################
decompress_fasta=True
database_name_rcrs=chrM
database_name_rsrs=chrRSRS
database_name_nfasta_rcrs=hg19RCRS
database_name_nfasta_rsrs=hg19RSRS
DIRECTORY=bin
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY already exists..."
else
echo "creating $DIRECTORY..."
mkdir $DIRECTORY
fi
MTOOLBOX_BIN=$(readlink -f $DIRECTORY)
GENOME_FASTA=genome_fasta
if [ -d "$GENOME_FASTA" ]; then
echo "$GENOME_FASTA already exists..."
else
echo "creating $GENOME_FASTA..."
mkdir $GENOME_FASTA
fi
gmap_db=gmapdb
if [ -d "$gmap_db" ]; then
echo "$gmap_db already exists..."
else
echo "creating $gmap_db..."
mkdir $gmap_db
fi
MTOOLBOX_DIR=$(pwd)
if [ "$software_install" == 'all' ]; then
echo "Installing anaconda,zlib,samtools,muscle,gsnap,gsnap_db"
anaconda_install
zlib_install
#echo "exporting zlib to generate gmap db..."
#export LD_LIBRARY_PATH=$MTOOLBOX_BIN/zlib/lib:$LD_LIBRARY_PATH:/usr/local/lib
#export CFLAGS="-I$MTOOLBOX_BIN/zlib/include $CFLAGS"
samtools_install
muscle_install
gsnap_install
gsnap_db_install
echo "moving fasta files into $GENOME_FASTA"
mv $rcrs_mfasta $GENOME_FASTA
mv $rsrs_mfasta $GENOME_FASTA
mv $nfasta_rcrs $GENOME_FASTA
mv $nfasta_rsrs $GENOME_FASTA
if [ "$decompress_fasta"==True ]
then
cd $GENOME_FASTA
echo "decompress nfasta..."
for i in $(ls *.gz); do gzip -d $i; done &&
cd ..
echo "Done"
else
echo "Done"
fi
echo "Generating fasta.fai indexes with samtools..."
cd $GENOME_FASTA
ls * > fasta.lst
for i in $(cat fasta.lst); do $MTOOLBOX_BIN/samtools/bin/samtools faidx $i; done
echo "Installation completed."
cd ..
else
echo "Installing $software_install..."
${software_install}_install
echo "Installation completed."
fi
SETUP_FILE=${MTOOLBOX_DIR}/MToolBox/setup.sh
cat <<EOF > $SETUP_FILE
#! /bin/bash
export MTOOLBOX_DIR=$MTOOLBOX_DIR
export MTOOLBOX_BIN=$MTOOLBOX_BIN
export PATH=\$MTOOLBOX_BIN/anaconda/bin:\$PATH
export PYTHONUSERBASE=\$MTOOLBOX_BIN/anaconda
export LD_LIBRARY_PATH=\$MTOOLBOX_BIN/zlib/lib:\$LD_LIBRARY_PATH:/usr/local/lib
export CFLAGS="-I\$MTOOLBOX_BIN/zlib/include \$CFLAGS"
export samtoolsexe=\$MTOOLBOX_BIN/samtools-${samtools_version}/samtools
export muscleexe=\$MTOOLBOX_BIN/$muscle_file
export gsnapexe=\$MTOOLBOX_BIN/gmap/bin/gsnap
fasta_path=\$MTOOLBOX_DIR/$GENOME_FASTA/
gsnapdb=\$MTOOLBOX_DIR/$gmap_db/
samtools_version=$samtools_version
mtdb_fasta=chrRSRS.fa
hg19_fasta=hg19RSRS.fa
mtdb=chrRSRS
humandb=hg19RSRS
EOF
exit 0