Skip to content

Commit 5c9b205

Browse files
authored
Add updated template indices for distograms and token center atoms in life.py (#84)
* Add updated template indices for distograms and token center atoms in `life.py` * Update amino_acid_constants.py * Update dna_constants.py * Update ligand_constants.py * Update rna_constants.py * Update life.py * Update 7a4d-assembly1.cif * Update life.py
1 parent c8c73bc commit 5c9b205

File tree

6 files changed

+444
-340
lines changed

6 files changed

+444
-340
lines changed

alphafold3_pytorch/common/amino_acid_constants.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amino acid constants used in AlphaFold."""
22

3+
import numpy as np
4+
35
from typing import Final
46

57
# This mapping is used when we need to store atom data in a format that requires
@@ -173,5 +175,21 @@
173175
],
174176
"TYR": ["N", "CA", "C", "O", "CB", "CG", "CD1", "CD2", "CE1", "CE2", "CZ", "OH", "", ""],
175177
"VAL": ["N", "CA", "C", "O", "CB", "CG1", "CG2", "", "", "", "", "", "", ""],
176-
"UNK": ["", "", "", "", "", "", "", "", "", "", "", "", "", ""],
178+
"UNK": ["N", "CA", "C", "O", "CB", "", "", "", "", "", "", "", "", ""],
177179
}
180+
181+
restype_atom47_to_compact_atom = np.zeros([21, 47], dtype=int)
182+
183+
184+
def _make_constants():
185+
"""Fill the array(s) above."""
186+
for restype, restype_letter in enumerate(restypes):
187+
resname = restype_1to3[restype_letter]
188+
for compact_atomidx, atomname in enumerate(restype_name_to_compact_atom_names[resname]):
189+
if not atomname:
190+
continue
191+
atomtype = atom_order[atomname]
192+
restype_atom47_to_compact_atom[restype, atomtype] = compact_atomidx
193+
194+
195+
_make_constants()

alphafold3_pytorch/common/dna_constants.py

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Deoxyribonucleic acid (DNA) constants used in AlphaFold."""
22

3+
import numpy as np
4+
35
from typing import Final
46

57
from alphafold3_pytorch.common import amino_acid_constants, rna_constants
@@ -209,29 +211,45 @@
209211
"",
210212
],
211213
"DN": [
212-
"",
213-
"",
214-
"",
215-
"",
216-
"",
217-
"",
218-
"",
219-
"",
220-
"",
221-
"",
222-
"",
223-
"",
224-
"",
225-
"",
226-
"",
227-
"",
228-
"",
229-
"",
230-
"",
231-
"",
232-
"",
233-
"",
214+
"OP3",
215+
"P",
216+
"OP1",
217+
"OP2",
218+
"O5'",
219+
"C5'",
220+
"C4'",
221+
"O4'",
222+
"C3'",
223+
"O3'",
224+
"C2'",
225+
"C1'",
226+
"N9",
227+
"C8",
228+
"N7",
229+
"C5",
230+
"C6",
231+
"N6",
232+
"N1",
233+
"C2",
234+
"N3",
235+
"C4",
234236
"",
235237
"",
236238
],
237239
}
240+
241+
restype_atom47_to_compact_atom = np.zeros([5, 47], dtype=int)
242+
243+
244+
def _make_constants():
245+
"""Fill the array(s) above."""
246+
for restype, restype_letter in enumerate(restypes):
247+
resname = restype_1to3[restype_letter]
248+
for atomname in restype_name_to_compact_atom_names[resname]:
249+
if not atomname:
250+
continue
251+
atomtype = atom_order[atomname]
252+
compact_atom_idx = restype_name_to_compact_atom_names[resname].index(atomname)
253+
restype_atom47_to_compact_atom[restype, atomtype] = compact_atom_idx
254+
255+
_make_constants()

alphafold3_pytorch/common/ligand_constants.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Ligand constants used in AlphaFold."""
22

3+
import numpy as np
4+
35
from typing import Final
46

57
from alphafold3_pytorch.common import amino_acid_constants, dna_constants
@@ -62,11 +64,14 @@
6264

6365

6466
# All ligand residues are mapped to the unknown amino acid type index (:= 20).
65-
restypes = ["UNL"]
67+
restypes = ["X"]
6668
min_restype_num = len(amino_acid_constants.restypes) # := 20.
6769
restype_order = {restype: min_restype_num + i for i, restype in enumerate(restypes)}
6870
restype_num = len(amino_acid_constants.restypes) # := 20.
6971

72+
73+
restype_1to3 = {"X": "UNL"}
74+
7075
BIOMOLECULE_CHAIN: Final[str] = "other"
7176
POLYMER_CHAIN: Final[str] = "non-polymer"
7277

@@ -89,3 +94,19 @@
8994
restype_name_to_compact_atom_names = {
9095
"UNL": atom_types,
9196
}
97+
98+
restype_atom47_to_compact_atom = np.zeros([1, 47], dtype=int)
99+
100+
101+
def _make_constants():
102+
"""Fill the array(s) above."""
103+
for restype, restype_letter in enumerate(restypes):
104+
resname = restype_1to3[restype_letter]
105+
for atomname in restype_name_to_compact_atom_names[resname]:
106+
if not atomname:
107+
continue
108+
atomtype = atom_order[atomname]
109+
compact_atom_idx = restype_name_to_compact_atom_names[resname].index(atomname)
110+
restype_atom47_to_compact_atom[restype, atomtype] = compact_atom_idx
111+
112+
_make_constants()

alphafold3_pytorch/common/rna_constants.py

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Ribonucleic acid (RNA) constants used in AlphaFold."""
22

3+
import numpy as np
4+
35
from typing import Final
46

57
from alphafold3_pytorch.common import amino_acid_constants
@@ -201,29 +203,45 @@
201203
"",
202204
],
203205
"N": [
204-
"",
205-
"",
206-
"",
207-
"",
208-
"",
209-
"",
210-
"",
211-
"",
212-
"",
213-
"",
214-
"",
215-
"",
216-
"",
217-
"",
218-
"",
219-
"",
220-
"",
221-
"",
222-
"",
223-
"",
224-
"",
225-
"",
226-
"",
206+
"OP3",
207+
"P",
208+
"OP1",
209+
"OP2",
210+
"O5'",
211+
"C5'",
212+
"C4'",
213+
"O4'",
214+
"C3'",
215+
"O3'",
216+
"C2'",
217+
"O2'",
218+
"C1'",
219+
"N9",
220+
"C8",
221+
"N7",
222+
"C5",
223+
"C6",
224+
"N6",
225+
"N1",
226+
"C2",
227+
"N3",
228+
"C4",
227229
"",
228230
],
229231
}
232+
233+
restype_atom47_to_compact_atom = np.zeros([5, 47], dtype=int)
234+
235+
236+
def _make_constants():
237+
"""Fill the array(s) above."""
238+
for restype, restype_letter in enumerate(restypes):
239+
resname = restype_1to3[restype_letter]
240+
for atomname in restype_name_to_compact_atom_names[resname]:
241+
if not atomname:
242+
continue
243+
atomtype = atom_order[atomname]
244+
compact_atom_idx = restype_name_to_compact_atom_names[resname].index(atomname)
245+
restype_atom47_to_compact_atom[restype, atomtype] = compact_atom_idx
246+
247+
_make_constants()

0 commit comments

Comments
 (0)