Skip to content

Commit d41ffaa

Browse files
authored
Fix case where individual chains are sampled (#145)
* Update inputs.py * Update mocks.py
1 parent 511d57a commit d41ffaa

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

alphafold3_pytorch/inputs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,10 +2142,16 @@ def pdb_input_to_molecule_input(
21422142
chain_id: chain_idx
21432143
for (chain_id, chain_idx) in zip(biomol.chain_id, biomol.chain_index)
21442144
}
2145-
if exists(chain_id_1):
2145+
# NOTE: we have to manually nullify a chain ID value
2146+
# e.g., if an empty string is passed in as a "null" chain ID
2147+
if chain_id_1:
21462148
chain_id_1 = chain_id_to_idx[chain_id_1]
2147-
if exists(chain_id_2):
2149+
else:
2150+
chain_id_1 = None
2151+
if chain_id_2:
21482152
chain_id_2 = chain_id_to_idx[chain_id_2]
2153+
else:
2154+
chain_id_2 = None
21492155
chains = (chain_id_1, chain_id_2)
21502156

21512157
# crop the `Biomolecule` object during training only

alphafold3_pytorch/mocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ def __init__(
1818
data_length,
1919
max_seq_len = 16,
2020
atoms_per_window = 4,
21+
dim_atom_inputs = 77,
2122
has_molecule_mods = True
2223
):
2324
self.data_length = data_length
2425
self.max_seq_len = max_seq_len
2526
self.atoms_per_window = atoms_per_window
27+
self.dim_atom_inputs = dim_atom_inputs
2628
self.has_molecule_mods = has_molecule_mods
2729

2830
def __len__(self):
@@ -32,7 +34,7 @@ def __getitem__(self, idx):
3234
seq_len = randrange(1, self.max_seq_len)
3335
atom_seq_len = self.atoms_per_window * seq_len
3436

35-
atom_inputs = torch.randn(atom_seq_len, 77)
37+
atom_inputs = torch.randn(atom_seq_len, self.dim_atom_inputs)
3638
atompair_inputs = torch.randn(atom_seq_len, atom_seq_len, 5)
3739

3840
molecule_atom_lens = torch.randint(1, self.atoms_per_window, (seq_len,))

0 commit comments

Comments
 (0)