File size: 5,258 Bytes
89d9c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c62447
fd3ab5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c62447
84cfbe1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89d9c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
171
172
173
174
175
176
177
FROM condaforge/miniforge3:24.11.3-0

WORKDIR /app

ENV DEBIAN_FRONTEND=noninteractive
ENV PATH=/opt/conda/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/conda/envs/ailixir/lib:/opt/conda/envs/dp/lib:/opt/conda/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu

SHELL ["/bin/bash", "-lc"]

RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    wget \
    curl \
    ca-certificates \
    build-essential \
    make \
    procps \
    ocl-icd-opencl-dev \
    pocl-opencl-icd \
    clinfo \
    && rm -rf /var/lib/apt/lists/*

# -----------------------------
# Generation / REINVENT env
# -----------------------------
RUN conda create -n ailixir python=3.10 -y && conda clean -afy

SHELL ["conda", "run", "--no-capture-output", "-n", "ailixir", "/bin/bash", "-lc"]

RUN set -eux; \
    for i in 1 2 3 4 5; do \
      if conda install -y -c conda-forge \
        pandas \
        numpy \
        scikit-learn \
        rdkit \
        fastapi \
        uvicorn \
        requests \
        tqdm \
        pip; then \
        conda clean -afy; \
        exit 0; \
      fi; \
      echo "conda install failed on attempt ${i}, retrying..."; \
      conda clean -i -y || true; \
      sleep $((i * 20)); \
    done; \
    echo "conda install failed after retries"; \
    exit 1

RUN git clone --depth 1 https://github.com/MolecularAI/REINVENT4.git /opt/REINVENT4 \
    && cd /opt/REINVENT4 \
    && python install.py cpu

RUN python -c "from rdkit import Chem; print('RDKit import OK')"
RUN python -c "import importlib.metadata as m; print('REINVENT version', m.version('reinvent'))"

# Meeko provides mk_prepare_ligand.py for PDBQT ligand preparation used by docking
# Install with required runtime dependencies because pip meeko may not pull all of them.
RUN set -eux; \
    for i in 1 2 3 4 5; do \
      if conda install -y -c conda-forge meeko gemmi scipy; then \
        conda clean -afy; \
        which mk_prepare_ligand.py; \
        mk_prepare_ligand.py -h >/tmp/mk_prepare_ligand_help.txt; \
        exit 0; \
      fi; \
      echo "meeko install failed on attempt ${i}, retrying..."; \
      conda clean -i -y || true; \
      sleep $((i * 20)); \
    done; \
    echo "meeko install failed after retries"; \
    exit 1

# Open Babel provides obabel for MOL2 ligand export
RUN set -eux; \
    for i in 1 2 3 4 5; do \
      if conda install -y -c conda-forge openbabel; then \
        conda clean -afy; \
        which obabel; \
        obabel -V; \
        exit 0; \
      fi; \
      echo "openbabel install failed on attempt ${i}, retrying..."; \
      conda clean -i -y || true; \
      sleep $((i * 20)); \
    done; \
    echo "openbabel install failed after retries"; \
    exit 1


# -----------------------------
# DeepPurpose affinity env
# -----------------------------
SHELL ["/bin/bash", "-lc"]

RUN conda create -n dp python=3.8 -y && conda clean -afy

SHELL ["conda", "run", "--no-capture-output", "-n", "dp", "/bin/bash", "-lc"]

RUN set -eux; \
    for i in 1 2 3 4 5; do \
      if conda install -y -c conda-forge \
        pandas \
        numpy \
        scikit-learn \
        rdkit \
        fastapi \
        uvicorn \
        requests \
        tqdm \
        pip; then \
        conda clean -afy; \
        exit 0; \
      fi; \
      echo "conda install failed on attempt ${i}, retrying..."; \
      conda clean -i -y || true; \
      sleep $((i * 20)); \
    done; \
    echo "conda install failed after retries"; \
    exit 1

ENV PIP_DEFAULT_TIMEOUT=1000
ENV PIP_RETRIES=10
ENV PIP_DISABLE_PIP_VERSION_CHECK=1

RUN pip install --no-cache-dir --default-timeout=1000 --retries=10 \
    git+https://github.com/bp-kelley/descriptastorus

RUN pip install --no-cache-dir --default-timeout=1000 --retries=10 \
    torch==2.1.0 \
    --index-url https://download.pytorch.org/whl/cpu

RUN python -c "import torch; print('Torch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available())"

RUN pip install --no-cache-dir --default-timeout=1000 --retries=10 \
    DeepPurpose

# -----------------------------
# AutoDock-GPU CPU/OpenCL build
# -----------------------------
SHELL ["/bin/bash", "-lc"]

RUN set -eux; \
    clinfo || true; \
    rm -rf /opt/AutoDock-GPU; \
    git clone --depth 1 https://github.com/ccsb-scripps/AutoDock-GPU.git /opt/AutoDock-GPU; \
    cd /opt/AutoDock-GPU; \
    make DEVICE=CPU NUMWI=1 GPU_INCLUDE_PATH=/usr/include GPU_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu; \
    find /opt/AutoDock-GPU -maxdepth 3 -type f -name "autodock_*" -print; \
    test -f /opt/AutoDock-GPU/bin/autodock_cpu_1wi; \
    chmod +x /opt/AutoDock-GPU/bin/autodock_cpu_1wi

COPY api.py /app/api.py
COPY bundle /app/bundle
COPY start_hf.sh /app/start_hf.sh

RUN sed -i 's/\r$//' /app/start_hf.sh \
    && chmod +x /app/start_hf.sh \
    && mkdir -p /app/outputs/jobs /app/outputs/deeppurpose \
    && mkdir -p /home/abdullah/projects/egfr_drug_discovery/runs/deeppurpose


ENV PUBLIC_BASE_URL=http://localhost:7860
ENV REINVENT_DEVICE=cpu
ENV DEEPPURPOSE_URL=http://127.0.0.1:8001/reinvent_predict
ENV ADGPU_BIN=/opt/AutoDock-GPU/bin/autodock_cpu_1wi
ENV PYTHON=python
ENV LD_PRELOAD=/opt/conda/envs/ailixir/lib/libstdc++.so.6
ENV PYTHONPATH=/app/bundle

EXPOSE 7860

CMD ["/app/start_hf.sh"]