-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·207 lines (171 loc) · 5.27 KB
/
install.sh
File metadata and controls
executable file
·207 lines (171 loc) · 5.27 KB
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
#!/bin/bash
# Absolute path to this script.
SCRIPT=$(readlink -f $0)
# Absolute path this script is in.
SCRIPTPATH=$(dirname "$SCRIPT")
#Init constants
current_python_version="3.12"
username=$(whoami)
#Init default arguments
env_name=""
storage_folder=""
verbose=false
overwrite=false
rewrite=false
installer_temp_folder=$(mktemp -d -t structguy.XXXXXXX)
trap 'rm -rf -- "$installer_temp_folder"' EXIT
#Parse arguments
while getopts s:e:vor flag
do
case "${flag}" in
e) env_name=${OPTARG};;
s) storage_folder=${OPTARG};;
v) verbose=true;;
o) overwrite=true;;
r) rewrite=true;;
esac
done
verbose_stdout=3
verbose_stderr=4
if [ "$verbose" = true ]; then
eval "exec $verbose_stdout>&1"
eval "exec $verbose_stderr>&2"
else
eval "exec $verbose_stdout>/dev/null"
eval "exec $verbose_stderr>/dev/null"
fi
#Check if conda environment already exits, create it if not
env_list_result=$(conda env list | grep -w "$env_name")
if [ -z "$env_list_result" ]
then
echo "Conda environment with name $env_name not in current environment list, please provide a valid environment including a StructMAn installation"
exit 1
fi
#Locate conda source to activate conda inside bash script shell
conda_base_path=$(conda info --base)
conda_bash_path="$conda_base_path"/etc/profile.d/conda.sh
current_env=$(conda info | grep 'active environment' | awk '{sub(/^[ \t\r\n]+active environment.:./,""); print}')
if ! [ "$current_env" = "base" ]
then
echo "Conda needs to be in base environment, but is $current_env"
echo "Please call 'conda deactivate'."
echo "exiting installer ..."
exit 1
fi
#activate the environment
{
echo "Activating environment inside shell ..."
source "$conda_bash_path"
current_env=$(conda info | grep 'active environment' | awk '{sub(/active environment.:./,""); print}')
if ! [ "$current_env" = "base" ]
then
conda deactivate
fi
new_env_path=$(conda env list | awk -v name="$env_name" '/^[^#]/{ if ($1 == name) {print $2} }')
conda activate "$env_name"
echo "$env_name" activated
} >&$verbose_stdout
conda_list_result=$(conda list | grep structman)
if [ -z "$env_list_result" ]
then
echo "StructMAn seems not be installed in $env_name environment, please provide a valid environment including a StructMAn installation"
exit 1
fi
mamba_version_test_output=$(mamba --version 2>/dev/null)
if [ -z "$mamba_version_test_output" ]
then
conda install -y -c conda-forge mamba >&$verbose_stdout 2>&$verbose_stderr
fi
#install dependencies
{
mamba install -y -c conda-forge scip==9.0.0
echo "Installing package DataSAIL ..."
mamba install -y -c conda-forge -c kalininalab -c bioconda -c mosek datasail==1.2.1
pip install grakel
} >&$verbose_stdout
#install the main package
echo "Installing StructGuy source code using pip ..."
pip install "$SCRIPTPATH" >&$verbose_stdout
if [ -z $storage_folder ]
then
storage_folder="$new_env_path"/share/structguy
if ! [ -d "$storage_folder" ]
then
mkdir "$storage_folder"
fi
fi
if [ -d $storage_folder ]
then
storage_folder=$(realpath "$storage_folder")
else
mkdir "$storage_folder"
storage_folder=$(realpath "$storage_folder")
fi
if ! [ -d "$storage_folder/$username" ]
then
mkdir "$storage_folder/$username"
echo "Needed to create a user-specific folder on scratch to locate the tmp folder:"
echo " $storage_folder/$username"
fi
tmp_folder_path="$storage_folder/$username/tmp"
if ! [ -d "$tmp_folder_path" ]
then
mkdir "$tmp_folder_path"
echo "Needed to create the tmp folder:"
echo " $tmp_folder_path"
fi
#install psic
psic_folder_path="$new_env_path"/lib/python"$current_python_version"/site-packages/structguy/resources/psic/
pushd $psic_folder_path
make psic
popd
#Download and construct the indices for the search databases UniRef50 and UniRef90
#resources_folder_path="$new_env_path"/lib/python"$current_python_version"/site-packages/structguy/resources/
resources_folder_path="$new_env_path"/lib/python"$current_python_version"/site-packages/
pushd $storage_folder
if [ "$overwrite" = true ]; then
rm -rf *.gz
fi
do_ref50=false
if [ "$rewrite" = true ]
then
do_ref50=true
fi
if ! [ -f uniref50.fasta.gz ]
then
do_ref50=true
fi
if [ $do_ref50 = true ]
then
if ! [ -f uniref50.fasta.gz ]
then
wget ftp://ftp.ebi.ac.uk/pub/databases/uniprot/uniref/uniref50/uniref50.fasta.gz
fi
split_fasta_db uniref50.fasta.gz "$tmp_folder_path"
#mmseqs createdb uniref50.fasta.gz uniref50_search_db
#mmseqs createindex uniref50_search_db "$tmp_folder_path" -s 7.5
fi
do_ref90=false
if [ "$rewrite" = true ]
then
do_ref90=true
fi
if ! [ -f uniref90.fasta.gz ]
then
do_ref90=true
fi
if [ $do_ref90 = true ]
then
if ! [ -f uniref90.fasta.gz ]
then
wget ftp://ftp.ebi.ac.uk/pub/databases/uniprot/uniref/uniref90/uniref90.fasta.gz
fi
split_fasta_db uniref90.fasta.gz "$tmp_folder_path"
#mmseqs createdb uniref90.fasta.gz uniref90_search_db
#mmseqs createindex uniref90_search_db "$tmp_folder_path" -s 7.5
fi
echo "search_db_folder=$storage_folder" > "$resources_folder_path"search_db_settings.conf
popd
echo "StructGuy successfully installed, please activate the right conda environment before using it:"
echo " conda activate $env_name"
exit 0