Skip to content

Commit f3109e8

Browse files
committed
address #201
1 parent 21da88d commit f3109e8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

alphafold3_pytorch/alphafold3.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,20 @@ def distance_to_bins(
462462
) -> Int['... dist']:
463463
"""
464464
converting from distance to discrete bins, for distance_labels and pae_labels
465+
using the same logic as openfold
465466
"""
466467

467-
dist_from_dist_bins = einx.subtract('... dist, dist_bins -> ... dist dist_bins', distance, bins).abs()
468-
return dist_from_dist_bins.argmin(dim = -1)
468+
distance = distance ** 2
469+
470+
bins = F.pad(bins ** 2, (0, 1), value = float('inf'))
471+
low, high = bins[:-1], bins[1:]
472+
473+
one_hot = (
474+
einx.greater_equal('..., bin_low -> ... bin_low', distance, low) &
475+
einx.less('..., bin_high -> ... bin_high', distance, high)
476+
).long()
477+
478+
return one_hot.argmax(dim = -1)
469479

470480
# linear and outer sum
471481
# for single repr -> pairwise pattern throughout this architecture

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.4.30"
3+
version = "0.4.31"
44
description = "Alphafold 3 - Pytorch"
55
authors = [
66
{ name = "Phil Wang", email = "[email protected]" },

0 commit comments

Comments
 (0)