-
Notifications
You must be signed in to change notification settings - Fork 14
/
install.sh
92 lines (87 loc) · 3.77 KB
/
install.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
#!/bin/bash
# Lingfei Wang, 2022, 2023. All rights reserved.
function usage()
{
fmt=' %-25s%s\n'
echo "Usage: $(basename "$0") [-h]" >&2
echo "Installing Dictys as a conda environment" >&2
echo "" >&2
echo "Parameters" >&2
printf "$fmt" '-h' 'Display this help.' >&2
echo "" >&2
echo "Accepted environmental variables" >&2
printf "$fmt" 'CONDAENV_NAME' 'Name of conda environment' >&2
printf "$fmt" 'PYTHONVERSION_CONDA' 'Python version' >&2
printf "$fmt" 'CUDAVERSION_CONDA' 'CUDA version for GPU enabled pytorch. Omit or set to null str for CPU powered pytorch.' >&2
printf "$fmt" '' 'You need a version supported by your driver and by pytorch.' >&2
printf "$fmt" '' 'See https://stackoverflow.com/questions/9727688/how-to-get-the-cuda-version' >&2
printf "$fmt" 'COMMIT_VERSION' 'Dictys commit to install. Accepts hash, branch name, and tag. Defaults to master.' >&2
echo '' >&2
echo "Advanced options in environmental variables" >&2
printf "$fmt" 'LOCAL_VERSION' 'Use a local folder to intall Dictys from. If specified, does not download from repo and ignores COMMIT_VERSION.' >&2
printf "$fmt" 'STEPS' 'Binary keys for which installation steps to perform. Accepts:' >&2
printf "$fmt" '' '1: conda steps' >&2
printf "$fmt" '' '2: pip steps' >&2
printf "$fmt" '' '4: homer update' >&2
printf "$fmt" '' 'Default: all steps' >&2
printf "$fmt" 'PIP_OPTIONS' 'Options for pip install' >&2
exit 1
}
#Parse arguments
while getopts ':h' o; do case "$o" in
:) echo "Error: -${OPTARG} requires an argument." >&2;echo >&2;usage;;
*) usage;;
esac
done
shift $((OPTIND-1))
set -ex -o pipefail
if [ "a$CONDAENV_NAME" == "a" ]; then
CONDAENV_NAME="dictys"
fi
if [ "a$PYTHONVERSION_CONDA" == "a" ]; then
PYTHONVERSION_CONDA="3.9"
fi
if [ "a$COMMIT_VERSION" == "a" ]; then
COMMIT_VERSION="master"
fi
if [ "a$CUDAVERSION_CONDA" == "a" ]; then
conda_deps="pytorch torchvision torchaudio cpuonly"
conda_channels="-c conda-forge -c pytorch"
elif [ "a$CUDAVERSION_CONDA" == "a11.3" ]; then
conda_deps="pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3"
conda_channels="-c pytorch -c conda-forge"
elif [ "a$CUDAVERSION_CONDA" == "a11.6" ]; then
conda_deps="pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6"
conda_channels="-c pytorch -c conda-forge"
elif [ "a$CUDAVERSION_CONDA" == "a11.7" ]; then
conda_deps="pytorch torchvision torchaudio pytorch-cuda=11.7"
conda_channels="-c conda-forge -c pytorch -c nvidia"
else
echo "This installation script only supports the following CUDA versions: 11.7 (with pytorch 2), 11.6 (with pytorch 1.12.1), 11.3 (with pytorch 1.12.1), and '' (CPU with pytorch 2)"
fi
if [ "a$STEPS" == "a" ] || [ "a$(( STEPS & 1 ))" != "a0" ]; then
#Install non-pypi dependencies: pytorch, bedtools, homer, samtools, macs2, ffmpeg
conda create -y -n $CONDAENV_NAME -c bioconda $conda_channels python=$PYTHONVERSION_CONDA $conda_deps bedtools homer samtools macs2 ffmpeg
#You may need "conda activate ..." instead
. activate $CONDAENV_NAME
fi
if [ "a$STEPS" == "a" ] || [ "a$(( STEPS & 2 ))" != "a0" ]; then
#Install Dictys and pyDNase with correct matplotlib
if [ "a$LOCAL_VERSION" == "a" ]; then
pip install $PIP_OPTIONS --no-deps pyDNase git+https://github.com/pinellolab/dictys.git@$COMMIT_VERSION
else
pip install $PIP_OPTIONS --no-deps pyDNase "$LOCAL_VERSION"
fi
pip install $PIP_OPTIONS $(pip check | grep ', which is not installed[.]$' | awk -F ',' '{print $(NF-1)}' | awk '{print $NF}' | grep -vi '^pyDNase$')
fi
if [ "a$STEPS" == "a" ] || [ "a$(( STEPS & 4 ))" != "a0" ]; then
#Update homer
pushd . &> /dev/null
cd "$(dirname "$(dirname "$(realpath "$(which homer)")")")"
./configureHomer.pl -update
chmod u+x configureHomer.pl
popd &> /dev/null
fi
if [ "a$STEPS" == "a" ] || [ "a$(( STEPS & 1 ))" != "a0" ]; then
conda deactivate
fi