File size: 4,375 Bytes
d766458 | 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 | #!/usr/bin/env bash
# download_model_weights.sh
#
# Usage:
# bash download_model_weights.sh # Download into ./tool_weights
# bash download_model_weights.sh /path/to/dir # Custom download root directory
#
# The final directory structure will look like:
# MODELS_ROOT/
# af2/
# params_model_{1..5}.npz
# params_model_{1..5}_ptm.npz
# params_model_{1..5}_multimer_v3.npz
# LICENSE
# esmfold/
# config.json
# pytorch_model.bin
# ...
# mpnn/
# ca_model_weights/
# soluble_model_weights/
# vanilla_model_weights/
#
# After downloading, update pxdbench/globals.py to point to these locations.
set -euo pipefail
# Set root directory for storing all model weights
MODELS_ROOT="${1:-$(pwd)/tool_weights}"
AF2_DIR="${MODELS_ROOT}/af2"
ESMFOLD_DIR="${MODELS_ROOT}/esmfold"
MPNN_DIR="${MODELS_ROOT}/mpnn"
echo "Model root directory: ${MODELS_ROOT}"
mkdir -p "${AF2_DIR}" "${ESMFOLD_DIR}" "${MPNN_DIR}"
# ===============================
# Git LFS Hard Check
# ===============================
if ! command -v git-lfs >/dev/null 2>&1 && ! command -v git-lfs >/dev/null 2>&1; then
echo -e "\n❌ ERROR: git-lfs is NOT installed."
echo
echo "Large model weights are managed by Git LFS."
echo "Without git-lfs, all downloaded weight files will be INVALID."
echo
echo "✅ Please install git-lfs first:"
echo
echo " Ubuntu/Debian:"
echo " sudo apt install git-lfs"
echo
echo " macOS (brew):"
echo " brew install git-lfs"
echo
echo " Then run:"
echo " git lfs install"
echo
exit 1
fi
git lfs install >/dev/null
echo "✅ git-lfs detected."
########################################
# 1. AlphaFold2 parameters
########################################
echo "==> Downloading AlphaFold2 parameters ..."
AF2_TAR="alphafold_params_2022-12-06.tar"
AF2_URL="https://storage.googleapis.com/alphafold/${AF2_TAR}"
# If AF2 parameters already exist, skip download
if compgen -G "${AF2_DIR}/params_model_1*.npz" > /dev/null; then
echo " AlphaFold2 params appear to already exist — skipping download."
else
tmp_tar="${MODELS_ROOT}/${AF2_TAR}"
echo " Downloading from: ${AF2_URL}"
curl -L "${AF2_URL}" -o "${tmp_tar}"
echo " Extracting to: ${AF2_DIR}"
tar -xf "${tmp_tar}" -C "${AF2_DIR}"
rm -f "${tmp_tar}"
echo " AlphaFold2 parameters downloaded successfully."
fi
########################################
# 2. ESMFold weights (HuggingFace)
########################################
echo "==> Downloading ESMFold weights (HuggingFace, requires git-lfs) ..."
# Check git installation
if ! command -v git >/dev/null 2>&1; then
echo " ERROR: git is not installed. Please install git and re-run the script." >&2
exit 1
fi
# If folder already cloned, just update it
if [ -d "${ESMFOLD_DIR}/.git" ]; then
echo " ESMFold directory already exists — pulling latest..."
(cd "${ESMFOLD_DIR}" && git pull --ff-only || true)
else
echo " Cloning facebook/esmfold_v1 into ${ESMFOLD_DIR}"
git clone https://huggingface.co/facebook/esmfold_v1 "${ESMFOLD_DIR}"
fi
echo " ESMFold weights are ready in: ${ESMFOLD_DIR}"
########################################
# 3. ProteinMPNN weights
########################################
echo "==> Downloading ProteinMPNN weights ..."
TMP_DIR="$(mktemp -d)"
cleanup() {
rm -rf "${TMP_DIR}"
}
trap cleanup EXIT
echo " Cloning dauparas/ProteinMPNN (shallow clone)..."
git clone --depth 1 https://github.com/dauparas/ProteinMPNN.git "${TMP_DIR}"
# Copy each weight directory
for subdir in ca_model_weights soluble_model_weights vanilla_model_weights; do
src="${TMP_DIR}/${subdir}"
dst="${MPNN_DIR}/${subdir}"
if [ -d "${dst}" ]; then
echo " ${subdir} already exists — skipping."
else
echo " Copying ${subdir} → ${dst}"
mkdir -p "${MPNN_DIR}"
cp -r "${src}" "${dst}"
fi
done
echo " ProteinMPNN weights are ready in: ${MPNN_DIR}"
########################################
echo "==> All downloads completed."
echo "Model weight directories:"
echo " AF2: ${AF2_DIR}"
echo " ESMFold: ${ESMFOLD_DIR}"
echo " MPNN: ${MPNN_DIR}"
echo
echo "Remember to update pxdbench/globals.py to reflect these paths."
|