/
install_slam.sh
executable file
·127 lines (121 loc) · 2.94 KB
/
install_slam.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
#!/bin/bash
# Copyright 2014 David Ainsworth
#
# This file is part of SLAM
#
# SLAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SLAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with SLAM. If not, see <http://www.gnu.org/licenses/>.
set -e
WORKING_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SLAM="$WORKING_DIR"/SLAM
if [[ $# -eq 0 ]] ; then
echo 'Please provide directory name'
exit 0
fi
mkdir -p $1
cd $1
if (( $# >= 1 ))
then
shift
else
echo "Please give install directory e.g. \"./install_slam.sh INSTALL_DIR bacteria viruses\""
exit 1
fi
NCBI_FTP="ftp://ftp.ncbi.nih.gov"
DB_FILE_NAME="all.gbk.tar.gz"
TAX_DB_FILE_NAME="taxdump.tar.gz"
BACTERIA=false
VIRUSES=false
while (( $# > 0 ))
do
case $1 in
"bacteria")
BACTERIA=true
;;
"viruses")
VIRUSES=true
;;
*)
echo "Unknown option" $1
;;
esac
shift
done
mkdir -p taxonomy
cd taxonomy
if [ ! -e "taxdownloaded" ]
then
echo "Downloading RefSeq taxonomy"
wget ${NCBI_FTP}/pub/taxonomy/$TAX_DB_FILE_NAME
echo "Decompressing"
tar xvf $TAX_DB_FILE_NAME
# rm $TAX_DB_FILE_NAME
echo "Done"
touch "taxdownloaded"
else
echo "Already downloaded taxonomy"
fi
cd ..
if [ "$BACTERIA" = "true" ]
then
mkdir -p bacteria
cd bacteria
#rm -f $DB_FILE_NAME
if [ ! -e "baclibrarydownloaded" ]
then
echo "Downloading RefSeq bacterial genomes"
wget ${NCBI_FTP}/genomes/archive/old_refseq/Bacteria/$DB_FILE_NAME
echo "Decompressing"
tar xf $DB_FILE_NAME
# rm $DB_FILE_NAME
echo "Done"
touch "baclibrarydownloaded"
else
echo "Already downloaded bacterial genomes"
fi
cd ..
fi
if [ "$VIRUSES" = "true" ]
then
mkdir -p viruses
cd viruses
#rm -f $DB_FILE_NAME
if [ ! -e "virlibrarydownloaded" ]
then
echo "Downloading RefSeq viral genomes"
wget ${NCBI_FTP}/genomes/Viruses/$DB_FILE_NAME
echo "Decompressing"
tar xf $DB_FILE_NAME
# rm $DB_FILE_NAME
echo "Done"
touch "virlibrarydownloaded"
else
echo "Already downloaded viral genomes"
fi
cd ..
fi
echo "Creating taxonomy database"
"$SLAM" --parse-taxonomy taxonomy/names.dmp taxonomy/nodes.dmp --output-file taxDB
echo "Creating sequence database"
if [ "$VIRUSES" = "true" ]
then
if [ "$BACTERIA" = "true" ]
then
"$SLAM" --output-file database --parse-genbank bacteria/*/*.gbk viruses/*/*.gbk
else
"$SLAM" --output-file database --parse-genbank viruses/*/*.gbk
fi
elif [ "$BACTERIA" = "true" ]
then
"$SLAM" --output-file database --parse-genbank bacteria/*/*.gbk
fi
#rm -rf taxonomy bacteria