Skip to content

Commit 8baf83f

Browse files
committed
fix the use of asym_id for figuring out the first molecule in each chain
1 parent cc4773d commit 8baf83f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

alphafold3_pytorch/inputs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,18 @@ def molecule_to_atom_input(
211211

212212
offset = 0
213213

214-
# need the asym_id (each molecule for each chain ascending) as well as `is_protein | is_dna | is_rna` for is_molecule_types (chainable biomolecules)
215-
# will do a single bond from a peptide or nucleotide to the one before, if `asym_id` != 0 (first in the chain)
214+
# need the asym_id (to keep track of each molecule for each chain ascending) as well as `is_protein | is_dna | is_rna` for is_molecule_types (chainable biomolecules)
215+
# will do a single bond from a peptide or nucleotide to the one before. derive a `is_first_mol_in_chain` from `asym_ids`
216216

217217
asym_ids = i.additional_molecule_feats[..., 2]
218+
asym_ids = F.pad(asym_ids, (1, 0), value = -1)
219+
is_first_mol_in_chains = (asym_ids[1:] - asym_ids[:-1]) == 1
220+
218221
is_chainable_biomolecules = i.is_molecule_types[..., :3].any(dim = -1)
219222

220-
for idx, (mol, asym_id, is_chainable_biomolecule) in enumerate(zip(molecules, asym_ids, is_chainable_biomolecules)):
223+
# for every molecule, build the bonds id matrix and add to `atompair_ids`
224+
225+
for idx, (mol, is_first_mol_in_chain, is_chainable_biomolecule) in enumerate(zip(molecules, is_first_mol_in_chains, is_chainable_biomolecules)):
221226

222227
coordinates = []
223228
updates = []
@@ -250,7 +255,7 @@ def molecule_to_atom_input(
250255
# if is chainable biomolecule
251256
# and not the first biomolecule in the chain, add a single covalent bond between first atom of incoming biomolecule and the last atom of the last biomolecule
252257

253-
if is_chainable_biomolecule and asym_id != 0:
258+
if is_chainable_biomolecule and not is_first_mol_in_chain:
254259
atompair_ids[offset, offset - 1] = 1
255260
atompair_ids[offset - 1, offset] = 1
256261

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alphafold3-pytorch"
3-
version = "0.1.88"
3+
version = "0.1.89"
44
description = "Alphafold 3 - Pytorch"
55
authors = [
66
{ name = "Phil Wang", email = "[email protected]" }

0 commit comments

Comments
 (0)