Skip to content

Commit f48c90e

Browse files
authored
Add test file
1 parent beaa5d8 commit f48c90e

1 file changed

Lines changed: 175 additions & 0 deletions

File tree

install-nplinker-deps

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/bin/bash
2+
3+
# User should create virutal env to install nplinker and dependencies
4+
# Do not use pip install --user nplinker
5+
6+
# Set script to exit immediately if any command fails
7+
set -e
8+
9+
#------------------------------------------------------------------------------
10+
# Creat installation path
11+
#------------------------------------------------------------------------------
12+
13+
# Get python install prefix
14+
if command -v python &> /dev/null; then
15+
PY_PATH=$(python -c "import sys; print(sys.prefix)")
16+
elif command -v python3 &> /dev/null; then
17+
PY_PATH=$(python3 -c "import sys; print(sys.prefix)")
18+
else
19+
echo "❌ Error: python NOT FOUND"
20+
exit
21+
fi
22+
23+
# check the path of this script
24+
if [[ $(command -v install-nplinker-deps) != $PY_PATH/bin/install-nplinker-deps ]]; then
25+
echo "❌ Error: command `install-nplinker-deps` invoked from bad path;"
26+
echo "Please install nplinker with `pip install nplinker` and then re-run this command."
27+
exit
28+
fi
29+
30+
# create dependecy install path
31+
cd $PY_PATH
32+
[[ -d nplinker_lib ]] || mkdir nplinker_lib
33+
LIB_PATH=$PY_PATH/nplinker_lib
34+
cd $LIB_PATH
35+
echo -e "✅ NPLinker dependecies and databases will be installed in: $LIB_PATH\n"
36+
37+
38+
#------------------------------------------------------------------------------
39+
# Check OS system and package manager
40+
# Not support Windows
41+
#------------------------------------------------------------------------------
42+
43+
if [[ "$OSTYPE" == "linux"* ]]; then
44+
# detect package manager for Linux
45+
if command -v apt &> /dev/null; then
46+
echo -e "✅ Package manager is 'apt'\n"
47+
apt update &> /dev/null
48+
do_install="apt install -y"
49+
elif command -v dnf &> /dev/null; then
50+
echo -e "✅ Package manager is 'dnf'\n"
51+
do_install="dnf install -y"
52+
elif command -v yum &> /dev/null; then
53+
echo -e "✅ Package manager is 'yum'\n"
54+
do_install="yum install -y"
55+
else
56+
echo "Package manager command 'apt' or 'dnf' or 'yum' NOT found."
57+
exit
58+
fi
59+
elif [[ "$OSTYPE" == "darwin"* ]]; then
60+
# install package manager brew for MacOS if not exist
61+
! command -v brew &> /dev/null && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
62+
do_install="brew install"
63+
echo -e "✅ Package manager is 'brew'\n"
64+
else
65+
echo "Error: NPLinker is not supported on $OSTYPE system, use linux or MacOS system please."
66+
exit 0
67+
fi
68+
69+
install_it(){
70+
echo -e "🔥 Start installing $1 ..."
71+
$do_install $1
72+
echo -e "$1 installed successfully\n"
73+
}
74+
#------------------------------------------------------------------------------
75+
# Install base dependencies if not exist
76+
#------------------------------------------------------------------------------
77+
BASE_DEPS="
78+
git
79+
wget
80+
gunzip
81+
unzip
82+
"
83+
84+
for cmd in $BASE_DEPS; do
85+
if ! command -v $cmd &> /dev/null; then
86+
install_it $cmd
87+
fi
88+
done
89+
90+
# install gcc compiler (required by FastTree)
91+
if command -v gcc &> /dev/null; then
92+
gcc="gcc"
93+
elif command -v gcc-10 &> /dev/null; then
94+
gcc="gcc-10"
95+
elif command -v gcc-11 &> /dev/null; then
96+
gcc="gcc-11"
97+
else
98+
install_it gcc
99+
gcc="gcc"
100+
fi
101+
102+
# upgrade pip and setuptools
103+
pip install -q -U pip setuptools
104+
105+
#------------------------------------------------------------------------------
106+
# Install NPLinker dependencies
107+
#------------------------------------------------------------------------------
108+
109+
#--- Install BigScape
110+
## Note: DO NOT pip install bigscape until its modular version
111+
echo "🔥 Start installing BigScape ..."
112+
[[ -d BiG-SCAPE ]] || git clone https://github.com/medema-group/BiG-SCAPE.git
113+
cd BiG-SCAPE
114+
git config --add advice.detachedHead false # disable advice
115+
git config pull.ff only
116+
git checkout master
117+
git pull
118+
git checkout a3ea8c5a4ef0abdb3b6b043a0f2657d3d778ca20 # tag v1.1.4
119+
pip install -q -U -r requirements.txt
120+
chmod 754 bigscape.py
121+
chmod 664 domains_color_file.tsv
122+
chmod 775 Annotated_MIBiG_reference
123+
ln -sf $LIB_PATH/BiG-SCAPE/bigscape.py $PY_PATH/bin
124+
cd ..
125+
echo -e "✅ BigScape installed successfully\n"
126+
127+
#--- Install FastTree (not support Windows, required by BigScape)
128+
# http://www.microbesonline.org/fasttree/
129+
echo "🔥 Start installing FastTree ..."
130+
if [[ "$OSTYPE" == "linux"* ]]; then
131+
$do_install fasttree
132+
elif [[ "$OSTYPE" == "darwin"* ]]; then
133+
wget -q --show-progress http://www.microbesonline.org/fasttree/FastTree.c
134+
$gcc -DNO_SSE -O3 -finline-functions -funroll-loops -Wall -o $PY_PATH/bin/fasttree FastTree.c -lm
135+
rm FastTree.c
136+
fi
137+
echo -e "✅ FastTree installed successfully\n"
138+
139+
#--- Install Hmmer (not support Windows and ARM64, required by BigScape)
140+
# brew hmmer not available ARM64 platform (e.g. Apple silicon)
141+
if ! command -v hmmpress &> /dev/null; then
142+
install_it hmmer
143+
fi
144+
145+
#--- Prepare Pfam database (required by BigScape)
146+
echo "🔥 Start installing Pfam database ..."
147+
[[ -e Pfam-A.hmm.gz ]] || wget -q --show-progress ftp://ftp.ebi.ac.uk/pub/databases/Pfam/releases/Pfam34.0/Pfam-A.hmm.gz
148+
gunzip -f Pfam-A.hmm.gz
149+
hmmpress -f Pfam-A.hmm
150+
echo -e "✅ Pfam database installed successfully\n"
151+
152+
153+
#--- Install canopus_treemap
154+
echo "🔥 Start installing Canopus"
155+
pip install -U -q canopus@git+https://github.com/kaibioinfo/canopus_treemap.git
156+
echo -e "✅ Canopus installed successfully\n"
157+
158+
159+
#--- Install SIRIUS
160+
echo "🔥 Start installing Sirius"
161+
if [[ "$OSTYPE" == "linux"* ]]; then
162+
wget -q --show-progress https://github.com/boecker-lab/sirius/releases/download/v5.5.5/sirius-5.5.5-linux64-headless.zip
163+
unzip -q -o sirius-5.5.5-linux64-headless.zip
164+
ln -sf $LIB_PATH/sirius/bin/sirius $PY_PATH/bin
165+
rm sirius-5.5.5-linux64-headless.zip
166+
elif [[ "$OSTYPE" == "darwin"* ]]; then
167+
wget -q --show-progress https://github.com/boecker-lab/sirius/releases/download/v5.5.5/sirius-5.5.5-osx64-headless.zip
168+
unzip -q -o sirius-5.5.5-osx64-headless.zip
169+
ln -sf $LIB_PATH/sirius.app/Contents/MacOS/sirius $PY_PATH/bin
170+
rm sirius-5.5.5-osx64-headless.zip
171+
fi
172+
echo -e "✅ Sirius installed successfully\n"
173+
174+
175+
echo -e "✅ 🎉 Successfully installed all NPLinker dependencies and databases!\n"

0 commit comments

Comments
 (0)