Skip to content

Commit

Permalink
sync torsion tree update from nashtools (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong-Rui authored Sep 26, 2023
1 parent 84f3e88 commit 8b4181b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions unidock_tools/unidock_tools/ligand_prepare/rotatable_bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ def __init__(self,
max_breaks=4):

self.rotatable_bond_smarts = '[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]'
self.amide_bond_smarts = '[C&$(C=O)]-[N&$(NC=O);v3;H1,H2;0]'
self.conjugate_bond_smarts = '*=*[*]=,#,:[*]'
self.rotatable_bond_pattern = Chem.MolFromSmarts(self.rotatable_bond_smarts)
self.amide_bond_pattern = Chem.MolFromSmarts(self.amide_bond_smarts)
self.conjugate_bond_pattern = Chem.MolFromSmarts(self.conjugate_bond_smarts)

self.min_macrocycle_size = min_macrocycle_size
Expand All @@ -19,4 +21,13 @@ def __init__(self,

def identify_rotatable_bonds(self, mol):
default_rotatable_bond_info_list = list(mol.GetSubstructMatches(self.rotatable_bond_pattern))
amide_rotatable_bond_info_list = list(mol.GetSubstructMatches(self.amide_bond_pattern))

for amide_rotatable_bond_info in amide_rotatable_bond_info_list:
amide_rotatable_bond_info_reversed = tuple(reversed(amide_rotatable_bond_info))
if amide_rotatable_bond_info in default_rotatable_bond_info_list:
default_rotatable_bond_info_list.remove(amide_rotatable_bond_info)
elif amide_rotatable_bond_info_reversed in default_rotatable_bond_info_list:
default_rotatable_bond_info_list.remove(amide_rotatable_bond_info_reversed)

return default_rotatable_bond_info_list
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def build_molecular_graph(self):
if bond_info in rotatable_bond_info_list or bond_info_reversed in rotatable_bond_info_list:
rotatable_bond_idx_list.append(bond.GetIdx())

splitted_mol = FragmentOnBonds(mol, rotatable_bond_idx_list, addDummies=False)
splitted_mol_list = list(GetMolFrags(splitted_mol, asMols=True, sanitizeFrags=False))
if len(rotatable_bond_idx_list) != 0:
splitted_mol = FragmentOnBonds(mol, rotatable_bond_idx_list, addDummies=False)
splitted_mol_list = list(GetMolFrags(splitted_mol, asMols=True, sanitizeFrags=False))
else:
splitted_mol_list = [mol]

num_fragments = len(splitted_mol_list)

Expand Down

0 comments on commit 8b4181b

Please sign in to comment.