-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathconfigs_data.py
216 lines (204 loc) · 7.53 KB
/
configs_data.py
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Copyright 2024 ByteDance and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=C0114,C0301
import os
from copy import deepcopy
from protenix.config.extend_types import GlobalConfigValue, ListValue
default_test_configs = {
"sampler_configs": {
"sampler_type": "uniform",
},
"cropping_configs": {
"method_weights": [
0.0, # ContiguousCropping
0.0, # SpatialCropping
1.0, # SpatialInterfaceCropping
],
"crop_size": -1,
},
"lig_atom_rename": GlobalConfigValue("test_lig_atom_rename"),
"shuffle_mols": GlobalConfigValue("test_shuffle_mols"),
"shuffle_sym_ids": GlobalConfigValue("test_shuffle_sym_ids"),
}
default_weighted_pdb_configs = {
"sampler_configs": {
"sampler_type": "weighted",
"beta_dict": {
"chain": 0.5,
"interface": 1,
},
"alpha_dict": {
"prot": 3,
"nuc": 3,
"ligand": 1,
},
"force_recompute_weight": True,
},
"cropping_configs": {
"method_weights": ListValue([0.2, 0.4, 0.4]),
"crop_size": GlobalConfigValue("train_crop_size"),
},
"sample_weight": 0.5,
"limits": -1,
"lig_atom_rename": GlobalConfigValue("train_lig_atom_rename"),
"shuffle_mols": GlobalConfigValue("train_shuffle_mols"),
"shuffle_sym_ids": GlobalConfigValue("train_shuffle_sym_ids"),
}
DATA_ROOT_DIR = "/af3-dev/release_data/"
# Use CCD cache created by scripts/gen_ccd_cache.py priority. (without date in filename)
# See: docs/prepare_data.md
CCD_COMPONENTS_FILE_PATH = os.path.join(DATA_ROOT_DIR, "components.cif")
CCD_COMPONENTS_RDKIT_MOL_FILE_PATH = os.path.join(
DATA_ROOT_DIR, "components.cif.rdkit_mol.pkl"
)
if (not os.path.exists(CCD_COMPONENTS_FILE_PATH)) or (
not os.path.exists(CCD_COMPONENTS_RDKIT_MOL_FILE_PATH)
):
CCD_COMPONENTS_FILE_PATH = os.path.join(DATA_ROOT_DIR, "components.v20240608.cif")
CCD_COMPONENTS_RDKIT_MOL_FILE_PATH = os.path.join(
DATA_ROOT_DIR, "components.v20240608.cif.rdkit_mol.pkl"
)
# This is a patch in inference stage for users that do not have root permission.
# If you run
# ```
# bash inference_demo.sh
# ```
# or
# ```
# protenix predict --input examples/example.json --out_dir ./output
# ````
# The checkpoint and the data cache will be downloaded to the current code directory.
if (not os.path.exists(CCD_COMPONENTS_FILE_PATH)) or (
not os.path.exists(CCD_COMPONENTS_RDKIT_MOL_FILE_PATH)
):
print("Try to find the ccd cache data in the code directory for inference.")
current_file_path = os.path.abspath(__file__)
current_directory = os.path.dirname(current_file_path)
code_directory = os.path.dirname(current_directory)
data_cache_dir = os.path.join(code_directory, "release_data/ccd_cache")
CCD_COMPONENTS_FILE_PATH = os.path.join(data_cache_dir, "components.cif")
CCD_COMPONENTS_RDKIT_MOL_FILE_PATH = os.path.join(
data_cache_dir, "components.cif.rdkit_mol.pkl"
)
if (not os.path.exists(CCD_COMPONENTS_FILE_PATH)) or (
not os.path.exists(CCD_COMPONENTS_RDKIT_MOL_FILE_PATH)
):
CCD_COMPONENTS_FILE_PATH = os.path.join(
data_cache_dir, "components.v20240608.cif"
)
CCD_COMPONENTS_RDKIT_MOL_FILE_PATH = os.path.join(
data_cache_dir, "components.v20240608.cif.rdkit_mol.pkl"
)
data_configs = {
"num_dl_workers": 16,
"epoch_size": 10000,
"train_ref_pos_augment": True,
"test_ref_pos_augment": True,
"train_sets": ListValue(["weightedPDB_before2109_wopb_nometalc_0925"]),
"train_sampler": {
"train_sample_weights": ListValue([1.0]),
"sampler_type": "weighted",
},
"test_sets": ListValue(["recentPDB_1536_sample384_0925"]),
"weightedPDB_before2109_wopb_nometalc_0925": {
"base_info": {
"mmcif_dir": os.path.join(DATA_ROOT_DIR, "mmcif"),
"bioassembly_dict_dir": os.path.join(DATA_ROOT_DIR, "mmcif_bioassembly"),
"indices_fpath": os.path.join(
DATA_ROOT_DIR,
"indices/weightedPDB_indices_before_2021-09-30_wo_posebusters_resolution_below_9.csv.gz",
),
"pdb_list": "",
"random_sample_if_failed": True,
"max_n_token": -1, # can be used for removing data with too many tokens.
"use_reference_chains_only": False,
"exclusion": { # do not sample the data based on ions.
"mol_1_type": ListValue(["ions"]),
"mol_2_type": ListValue(["ions"]),
},
},
**deepcopy(default_weighted_pdb_configs),
},
"recentPDB_1536_sample384_0925": {
"base_info": {
"mmcif_dir": os.path.join(DATA_ROOT_DIR, "mmcif"),
"bioassembly_dict_dir": os.path.join(
DATA_ROOT_DIR, "recentPDB_bioassembly"
),
"indices_fpath": os.path.join(
DATA_ROOT_DIR, "indices/recentPDB_low_homology_maxtoken1536.csv"
),
"pdb_list": os.path.join(
DATA_ROOT_DIR,
"indices/recentPDB_low_homology_maxtoken1024_sample384_pdb_id.txt",
),
"max_n_token": GlobalConfigValue("test_max_n_token"), # filter data
"sort_by_n_token": False,
"group_by_pdb_id": True,
"find_eval_chain_interface": True,
},
**deepcopy(default_test_configs),
},
"posebusters_0925": {
"base_info": {
"mmcif_dir": os.path.join(DATA_ROOT_DIR, "posebusters_mmcif"),
"bioassembly_dict_dir": os.path.join(
DATA_ROOT_DIR, "posebusters_bioassembly"
),
"indices_fpath": os.path.join(
DATA_ROOT_DIR, "indices/posebusters_indices_mainchain_interface.csv"
),
"pdb_list": "",
"find_pocket": True,
"find_all_pockets": False,
"max_n_token": GlobalConfigValue("test_max_n_token"), # filter data
},
**deepcopy(default_test_configs),
},
"msa": {
"enable": True,
"enable_rna_msa": False,
"prot": {
"pairing_db": "uniref100",
"non_pairing_db": "mmseqs_other",
"pdb_mmseqs_dir": os.path.join(DATA_ROOT_DIR, "mmcif_msa"),
"seq_to_pdb_idx_path": os.path.join(DATA_ROOT_DIR, "seq_to_pdb_index.json"),
"indexing_method": "sequence",
},
"rna": {
"seq_to_pdb_idx_path": "",
"rna_msa_dir": "",
"indexing_method": "sequence",
},
"strategy": "random",
"merge_method": "dense_max",
"min_size": {
"train": 1,
"test": 2048,
},
"max_size": {
"train": 16384,
"test": 16384,
},
"sample_cutoff": {
"train": 2048,
"test": 2048,
},
},
"template": {
"enable": False,
},
"ccd_components_file": CCD_COMPONENTS_FILE_PATH,
"ccd_components_rdkit_mol_file": CCD_COMPONENTS_RDKIT_MOL_FILE_PATH,
}