├── .gitignore ├── base.def ├── README.md ├── alphafold.def └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.sif 2 | -------------------------------------------------------------------------------- /base.def: -------------------------------------------------------------------------------- 1 | Bootstrap: docker 2 | From: nvcr.io/nvidia/tensorflow:21.06-tf2-py3 3 | 4 | # used 21.06 to meet cudnn==8.2.1.32 cudatoolkit==11.0.3 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AlphaFold Singularity Container 2 | 3 | This repo provides definition files to build a singularity container of AlphaFold v2 (https://github.com/deepmind/alphafold). 4 | 5 | Build instructions from [non-docker setting](https://github.com/kalininalab/alphafold_non_docker) by kalininalab were used. 6 | 7 | ## Build container 8 | ``` 9 | # build base container 10 | singularity build --fakeroot base.sif base.def 11 | 12 | # build alphafold container 13 | singularity build --fakeroot alphafold.sif alphafold.def 14 | ``` 15 | 16 | ## Run Alphafold 17 | ``` 18 | singularity exec --nv -B alphafold.sif bash 19 | source /opt/miniconda3/etc/profile.d/conda.sh 20 | conda activate alphafold 21 | cd /opt/alphafold/ 22 | ./run.sh -d -o -m model_1 -f -t 2020-05-14 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /alphafold.def: -------------------------------------------------------------------------------- 1 | Bootstrap: localimage 2 | From: base.sif 3 | 4 | # Build instructions from 5 | # https://github.com/kalininalab/alphafold_non_docker 6 | 7 | %files 8 | run.sh /opt/run.sh 9 | 10 | %post 11 | # miniconda setup 12 | cd /opt/ 13 | wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/miniconda3 14 | source /opt/miniconda3/etc/profile.d/conda.sh 15 | conda create --name alphafold python==3.8 16 | conda update -n base conda 17 | conda activate alphafold 18 | 19 | conda install -y -c conda-forge openmm==7.5.1 cudnn==8.2.1.32 cudatoolkit==11.0.3 pdbfixer==1.7 20 | conda install -y -c bioconda hmmer==3.3.2 hhsuite==3.3.0 kalign2==2.04 21 | 22 | # alphafold setup 23 | cd /opt/ 24 | git clone https://github.com/deepmind/alphafold.git 25 | alphafold_path="/opt/alphafold" 26 | 27 | wget -q -P alphafold/alphafold/common/ https://git.scicore.unibas.ch/schwede/openstructure/-/raw/7102c63615b64735c4941278d92b554ec94415f8/modules/mol/alg/src/stereo_chemical_props.txt 28 | 29 | pip install absl-py==0.13.0 biopython==1.79 chex==0.0.7 dm-haiku==0.0.4 dm-tree==0.1.6 immutabledict==2.0.0 jax==0.2.14 ml-collections==0.1.0 numpy==1.19.5 scipy==1.7.0 tensorflow==2.5.0 30 | pip install --upgrade jax jaxlib==0.1.69+cuda111 -f https://storage.googleapis.com/jax-releases/jax_releases.html 31 | pip install -r alphafold/requirements.txt 32 | 33 | cd /opt/miniconda3/envs/alphafold/lib/python3.8/site-packages/ && patch -p0 < $alphafold_path/docker/openmm.patch 34 | mv /opt/run.sh /opt/alphafold/run.sh 35 | 36 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Description: AlphaFold non-docker version 3 | # Author: Sanjay Kumar Srikakulam 4 | 5 | usage() { 6 | echo "" 7 | echo "Please make sure all required parameters are given" 8 | echo "Usage: $0 " 9 | echo "Required Parameters:" 10 | echo "-d Path to directory of supporting data" 11 | echo "-o Path to a directory that will store the results." 12 | echo "-m Names of models to use (a comma separated list)" 13 | echo "-f Path to a FASTA file containing one sequence" 14 | echo "-t Maximum template release date to consider (ISO-8601 format - i.e. YYYY-MM-DD). Important if folding historical test sets" 15 | echo "Optional Parameters:" 16 | echo "-b Run multiple JAX model evaluations to obtain a timing that excludes the compilation time, which should be more indicative of the time required for inferencing many 17 | proteins (default: 'False')" 18 | echo "-g Enable NVIDIA runtime to run with GPUs (default: True)" 19 | echo "-a Comma separated list of devices to pass to 'CUDA_VISIBLE_DEVICES' (default: 0)" 20 | echo "-p Choose preset model configuration - no ensembling (full_dbs) or 8 model ensemblings (casp14) (default: 'full_dbs')" 21 | echo "" 22 | exit 1 23 | } 24 | 25 | while getopts ":d:o:m:f:t:a:p:g:b" i; do 26 | case "${i}" in 27 | d) 28 | data_dir=$OPTARG 29 | ;; 30 | o) 31 | output_dir=$OPTARG 32 | ;; 33 | m) 34 | model_names=$OPTARG 35 | ;; 36 | f) 37 | fasta_path=$OPTARG 38 | ;; 39 | t) 40 | max_template_date=$OPTARG 41 | ;; 42 | b) 43 | benchmark=true 44 | ;; 45 | g) 46 | use_gpu=$OPTARG 47 | ;; 48 | a) 49 | gpu_devices=$OPTARG 50 | ;; 51 | p) 52 | preset=$OPTARG 53 | ;; 54 | esac 55 | done 56 | 57 | # Parse input and set defaults 58 | if [[ "$data_dir" == "" || "$output_dir" == "" || "$model_names" == "" || "$fasta_path" == "" || "$max_template_date" == "" ]] ; then 59 | usage 60 | fi 61 | 62 | if [[ "$benchmark" == "" ]] ; then 63 | benchmark=false 64 | fi 65 | 66 | if [[ "$use_gpu" == "" ]] ; then 67 | use_gpu=true 68 | fi 69 | 70 | if [[ "$gpu_devices" == "" ]] ; then 71 | gpu_devices=0 72 | fi 73 | 74 | if [[ "$preset" == "" ]] ; then 75 | preset="full_dbs" 76 | fi 77 | 78 | if [[ "$preset" != "full_dbs" && "$preset" != "casp14" ]] ; then 79 | echo "Unknown preset! Using default ('full_dbs')" 80 | preset="full_dbs" 81 | fi 82 | 83 | # This bash script looks for the run_alphafold.py script in its current working directory, if it does not exist then exits 84 | current_working_dir=$(pwd) 85 | alphafold_script="$current_working_dir/run_alphafold.py" 86 | 87 | if [ ! -f "$alphafold_script" ]; then 88 | echo "Alphafold python script $alphafold_script does not exist." 89 | exit 1 90 | fi 91 | 92 | # Export ENVIRONMENT variables and set CUDA devices for use 93 | export CUDA_VISIBLE_DEVICES=-1 94 | if [[ "$use_gpu" == true ]] ; then 95 | export CUDA_VISIBLE_DEVICES=0 96 | 97 | if [[ "$gpu_devices" ]] ; then 98 | export CUDA_VISIBLE_DEVICES=$gpu_devices 99 | fi 100 | fi 101 | 102 | export TF_FORCE_UNIFIED_MEMORY='1' 103 | export XLA_PYTHON_CLIENT_MEM_FRACTION='4.0' 104 | 105 | # Path and user config (change me if required) 106 | bfd_database_path="$data_dir/bfd/bfd_metaclust_clu_complete_id30_c90_final_seq.sorted_opt" 107 | mgnify_database_path="$data_dir/mgnify/mgy_clusters_2018_12.fa" 108 | template_mmcif_dir="$data_dir/pdb_mmcif/mmcif_files" 109 | obsolete_pdbs_path="$data_dir/pdb_mmcif/obsolete.dat" 110 | pdb70_database_path="$data_dir/pdb70/pdb70" 111 | uniclust30_database_path="$data_dir/uniclust30/uniclust30_2018_08/uniclust30_2018_08" 112 | uniref90_database_path="$data_dir/uniref90/uniref90.fasta" 113 | 114 | # Binary path (change me if required) 115 | hhblits_binary_path=$(which hhblits) 116 | hhsearch_binary_path=$(which hhsearch) 117 | jackhmmer_binary_path=$(which jackhmmer) 118 | kalign_binary_path=$(which kalign) 119 | 120 | # Run AlphaFold with required parameters 121 | $(python $alphafold_script --hhblits_binary_path=$hhblits_binary_path --hhsearch_binary_path=$hhsearch_binary_path --jackhmmer_binary_path=$jackhmmer_binary_path --kalign_binary_path=$kalign_binary_path --bfd_database_path=$bfd_database_path --mgnify_database_path=$mgnify_database_path --template_mmcif_dir=$template_mmcif_dir --obsolete_pdbs_path=$obsolete_pdbs_path --pdb70_database_path=$pdb70_database_path --uniclust30_database_path=$uniclust30_database_path --uniref90_database_path=$uniref90_database_path --data_dir=$data_dir --output_dir=$output_dir --fasta_paths=$fasta_path --model_names=$model_names --max_template_date=$max_template_date --preset=$preset --benchmark=$benchmark --logtostderr) 122 | --------------------------------------------------------------------------------