15
15
"""Singularity launch script for Alphafold Singularity image."""
16
16
17
17
import os
18
+ import sys
18
19
import pathlib
19
20
import signal
20
21
from typing import Tuple
21
22
22
23
from absl import app
23
24
from absl import flags
24
25
from absl import logging
26
+ from spython .main import Client
25
27
26
28
import tempfile
27
- from spython .main import Client
29
+ import subprocess
30
+
28
31
29
32
#### USER CONFIGURATION ####
30
33
34
37
singularity_image = Client .load (os .path .join (os .environ ['ALPHAFOLD_DIR' ], 'alphafold.sif' ))
35
38
36
39
# Path to a directory that will store the results.
37
- if 'TMPDIR' in os .environ :
40
+ if 'TMP' in os .environ :
41
+ output_dir = os .environ ['TMP' ]
42
+ elif 'TMPDIR' in os .environ :
38
43
output_dir = os .environ ['TMPDIR' ]
39
44
else :
40
45
output_dir = tempfile .mkdtemp (dir = '/tmp' , prefix = 'alphafold-' )
41
46
47
+ # set tmp dir the same as output dir
48
+ tmp_dir = output_dir
49
+
42
50
#### END USER CONFIGURATION ####
43
51
44
52
62
70
'separated by commas. All FASTA paths must have a unique basename as the '
63
71
'basename is used to name the output directories for each prediction.' )
64
72
flags .DEFINE_string (
65
- 'output_dir' , '/tmp/alphafold' ,
73
+ 'output_dir' , output_dir ,
66
74
'Path to a directory that will store the results.' )
67
75
flags .DEFINE_string (
68
76
'data_dir' , None ,
113
121
114
122
115
123
def _create_bind (bind_name : str , path : str ) -> Tuple [str , str ]:
124
+ """Create a bind point for each file and directory used by the model."""
116
125
path = os .path .abspath (path )
117
126
source_path = os .path .dirname (path ) if bind_name != 'data_dir' else path
118
127
target_path = os .path .join (_ROOT_MOUNT_DIRECTORY , bind_name )
@@ -145,7 +154,7 @@ def main(argv):
145
154
146
155
# Path to the MGnify database for use by JackHMMER.
147
156
mgnify_database_path = os .path .join (
148
- FLAGS .data_dir , 'mgnify' , 'mgy_clusters_2018_12 .fa' )
157
+ FLAGS .data_dir , 'mgnify' , 'mgy_clusters_2022_05 .fa' )
149
158
150
159
# Path to the BFD database for use by HHblits.
151
160
bfd_database_path = os .path .join (
@@ -156,9 +165,9 @@ def main(argv):
156
165
small_bfd_database_path = os .path .join (
157
166
FLAGS .data_dir , 'small_bfd' , 'bfd-first_non_consensus_sequences.fasta' )
158
167
159
- # Path to the Uniclust30 database for use by HHblits.
160
- uniclust30_database_path = os .path .join (
161
- FLAGS .data_dir , 'uniclust30 ' , 'uniclust30_2018_08' , 'uniclust30_2018_08 ' )
168
+ # Path to the Uniref30 database for use by HHblits.
169
+ uniref30_database_path = os .path .join (
170
+ FLAGS .data_dir , 'uniref30 ' , 'UniRef30_2021_03 ' )
162
171
163
172
# Path to the PDB70 database for use by HHsearch.
164
173
pdb70_database_path = os .path .join (FLAGS .data_dir , 'pdb70' , 'pdb70' )
@@ -178,7 +187,7 @@ def main(argv):
178
187
if alphafold_path == data_dir_path or alphafold_path in data_dir_path .parents :
179
188
raise app .UsageError (
180
189
f'The download directory { FLAGS .data_dir } should not be a subdirectory '
181
- f'in the AlphaFold repository directory. If it is, the Docker build is '
190
+ f'in the AlphaFold repository directory. If it is, the Singularity build is '
182
191
f'slow since the large databases are copied during the image creation.' )
183
192
184
193
binds = []
@@ -211,7 +220,7 @@ def main(argv):
211
220
database_paths .append (('small_bfd_database_path' , small_bfd_database_path ))
212
221
else :
213
222
database_paths .extend ([
214
- ('uniclust30_database_path ' , uniclust30_database_path ),
223
+ ('uniref30_database_path ' , uniref30_database_path ),
215
224
('bfd_database_path' , bfd_database_path ),
216
225
])
217
226
for name , path in database_paths :
@@ -222,6 +231,11 @@ def main(argv):
222
231
223
232
output_target_path = os .path .join (_ROOT_MOUNT_DIRECTORY , 'output' )
224
233
binds .append (f'{ output_dir } :{ output_target_path } ' )
234
+ logging .info ('Binding %s -> %s' , output_dir , output_target_path )
235
+
236
+ tmp_target_path = '/tmp'
237
+ binds .append (f'{ tmp_dir } :{ tmp_target_path } ' )
238
+ logging .info ('Binding %s -> %s' , tmp_dir , tmp_target_path )
225
239
226
240
use_gpu_relax = FLAGS .enable_gpu_relax and FLAGS .use_gpu
227
241
@@ -240,9 +254,11 @@ def main(argv):
240
254
241
255
options = [
242
256
'--bind' , f'{ "," .join (binds )} ' ,
257
+ '--env' , f'NVIDIA_VISIBLE_DEVICES={ FLAGS .gpu_devices } ' ,
258
+ # The following flags allow us to make predictions on proteins that
259
+ # would typically be too long to fit into GPU memory.
243
260
'--env' , 'TF_FORCE_UNIFIED_MEMORY=1' ,
244
261
'--env' , 'XLA_PYTHON_CLIENT_MEM_FRACTION=4.0' ,
245
- '--env' , 'OPENMM_CPU_THREADS=12'
246
262
]
247
263
248
264
# Run the container.
0 commit comments