forked from limix/struct-lmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·146 lines (124 loc) · 3.45 KB
/
install
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
#!/usr/bin/env bash
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
esac
done
}
function getfile {
command -v wget >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Downloading $1"
wget -O $2 $1 -q --show-progress
return $?
fi
command -v curl >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Downloading $1"
curl -o $2 $1 --progress-bar
return $?
fi
echo "Could not find wget nor curl command line tools for downloading file."
exit 1
}
function check_conda_env
{
conda info --envs | grep -e "^$1 "
if [ $? -eq 0 ]
then
echo "Conda environment $1 already exists."
echo "I would like to use it in the installation process."
msg="Shall I proceeed?"
yes_or_no $msg && answer="yes" || answer="no"
if [[ $answer == "no" ]]
then
echo "Goodbye!"
exit 1
fi
return 1
fi
return 0
}
function anaconda_url
{
if [ "$(uname)" == "Darwin" ]; then
url=https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
url=https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
else
echo -n "Unrecognized Operating system. This installer is for"
echo " Linux and macOS only."
exit 1
fi
echo $url
}
echo "[0/4] Installing StructLMM..."
command -v conda >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo "I could not find the required conda package manager."
msg="Shall I install it for you?"
yes_or_no $msg && answer="yes" || answer="no"
if [[ $answer == "no" ]]
then
echo "Goodbye!"
exit 0
else
getfile $(anaconda_url) Miniconda.sh
if [ $? -ne 0 ]
then
echo "Failed to download the conda package manager."
exit 1
fi
bash Miniconda.sh -b
if [ $? -ne 0 ]
then
exit 1
fi
. $HOME/miniconda2/etc/profile.d/conda.sh
conda activate base
hash -r
command -v conda >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo "I still cannot find the conda package manager."
echo -n "Please, make sure it is properly installed so we can "
echo "proceed."
exit 1
fi
fi
fi
. $CONDA_PREFIX/etc/profile.d/conda.sh
conda activate base
echo "[1/4] Trying to update the conda package manager..."
conda update -n base conda --yes > /dev/null 2>&1 || true
conda deactivate
check_conda_env struct-lmm
if [ $? -eq 0 ]
then
echo "[2/4] Creating struct-lmm environment..."
conda create -n struct-lmm python=2.7 --yes
else
echo "[2/4] Activating struct-lmm environment..."
fi
conda activate struct-lmm
echo "[3/4] Installing dependencies into the struct-lmm environment..."
conda install -c conda-forge limix r r-base r-essentials rpy2 \
r-compquadform sphinx sphinx_rtd_theme pip setuptools --yes
echo "[4/4] Installing struct-lmm itself..."
pip install git+https://github.com/limix/struct-lmm.git
echo
echo "Done. To use struct-lmm, please, enter"
echo " conda activate struct-lmm"
echo "Further information can be found at"
echo " https://struct-lmm.readthedocs.io/"
function cleanup
{
rm -rf Anaconda.sh >/dev/null 2>&1 || true
}
trap cleanup EXIT