Skip to content

Commit

Permalink
get_flexible_torsions, keep track of the central bond. (#221)
Browse files Browse the repository at this point in the history
Co-authored-by: nicolas.brosse <nicolas.brosse@iktos.com>
  • Loading branch information
nbrosse and nicolas.brosse authored May 13, 2024
1 parent 31df659 commit 3997c1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion unimol/unimol/utils/conformer_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ def get_flexible_torsions(mol: Chem.Mol) -> th.Tensor:
i_, l_ = (dist_mat.triu() == 3).bool().nonzero().T.tolist()
# Shortest path, where rotatable bond in the middle is a torsion
flex_unique_torsions = []
central_bond_torsions = set()
for i, l in zip(i_, l_):
i, j, k, l = Chem.GetShortestPath(mol, i, l)
if {(j, k), (k, j)}.intersection(matches):
if {(j, k), (k, j)}.intersection(matches) and (j, k) not in central_bond_torsions:
# Register the central bond
central_bond_torsions.update([(j, k), (k, j)])
# torsion in the direction that leaves lesser atoms to later rotate: towards the periphery
if (dist_mat[j] < dist_mat[k]).sum() > (dist_mat[j] > dist_mat[k]).sum():
flex_unique_torsions.append([i, j, k, l])
Expand Down

0 comments on commit 3997c1c

Please sign in to comment.