-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·170 lines (152 loc) · 3.56 KB
/
setup.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
#!/usr/bin/env bash
ENV_NAME="soprano"
DEPS_FILE="src/SOPRANO/local.yml"
DEPS_FATAL=false
# Parse installation method for pip
if [ "$#" -eq 0 ]
then
echo "Will install standard flavour dependencies"
INSTALL_METHOD=""
elif [ "$1" == "dev" ] || [ "$1" == "ci" ] || [ "$1" == "mpi" ]
then
echo "Will install $1 flavour dependencies"
INSTALL_METHOD="[$1]"
else
echo "Unrecognized flavour..."
echo "Will install standard flavour dependencies"
INSTALL_METHOD=""
fi
_PIP_CMD="pip install -e .$INSTALL_METHOD"
if [ ! -f "$DEPS_FILE" ]
then
echo "Fatal: Conda dependencies file not found"
DEPS_FATAL=true
else
echo "Conda dependencies file detected: $DEPS_FILE"
fi
# Get os type
case "$OSTYPE" in
darwin*)
OS="osx" ;;
linux*)
OS="linux" ;;
*)
echo "OS $OSTYPE not implemented."
OS="other" ;;
esac
# Flag whether to run update
built_from_scratch=false
function _create_for_osx() {
echo "Creating env for osx"
built_from_scratch=true
conda create --name $ENV_NAME
conda activate $ENV_NAME
conda config --env --set subdir osx-64
if command -v mamba &> /dev/null
then
echo " ... building with mamba"
mamba env update --file $DEPS_FILE
else
conda env update --file $DEPS_FILE
fi
conda activate $ENV_NAME
}
function _create_for_linux() {
echo "Creating env for linux"
built_from_scratch=true
if command -v mamba &> /dev/null
then
echo " ... building with mamba"
mamba env create -f $DEPS_FILE --name $ENV_NAME
else
conda env create -f $DEPS_FILE --name $ENV_NAME
fi
conda activate $ENV_NAME
}
function _update() {
if command -v mamba &> /dev/null
then
echo " ... updating with mamba"
mamba env update --file $DEPS_FILE --prune
else
conda env update --file $DEPS_FILE --prune
fi
}
function _update_for_osx() {
echo "Updating env for osx"
conda config --env --set subdir osx-64
_update
}
function _update_for_linux() {
echo "Updating env for linux"
_update
}
function activate_env() {
echo "Attempting activation"
if [ "$OS" == "osx" ]
then
echo "... osx"
conda activate $ENV_NAME || _create_for_osx
if [ $built_from_scratch == false ]
then
_update_for_osx
fi
elif [ "$OS" == "linux" ]
then
echo "... linux"
conda activate $ENV_NAME || _create_for_linux
if [ $built_from_scratch == false ]
then
_update_for_linux
fi
else
exit 1
fi
if [ $? == 0 ]
then
echo "Installing SOPRANO Python packages"
eval "$_PIP_CMD"
fi
if [ $? == 0 ]
then
echo "Installing SOPRANO R packages"
Rscript "src/SOPRANO/R/pkgs.R"
fi
}
if command -v conda &> /dev/null
then
echo "Conda detected: Running environment setup"
echo "OS system $OS: $OSTYPE"
if [ $DEPS_FATAL == true ]
then
echo " ... but unable to build due to missing dependencies file."
else
activate_env
if [ $? == 0 ]
then
echo ""
echo "Installation procedure complete."
echo "After pulling an updated version of the repository"
echo "run this setup script. Otherwise, call"
echo ""
echo "conda activate $ENV_NAME"
echo ""
echo "to load the environment."
else
echo ""
echo "Installation failed."
fi
fi
else
echo "Fatal: Conda not detected."
fi
fasta_file="src/SOPRANO/data/ensemble_transcriptID.fasta"
zipped_fasta_file="src/SOPRANO/data/ensemble_transcriptID.fasta.gz"
if [ ! -f "$fasta_file" ]
then
echo "Decompressing transcript IDs"
gunzip -k "$zipped_fasta_file"
echo "Decompressed: $fasta_file"
else
echo "Decompressed transcript IDs detected: $fasta_file"
fi