66from rdkit import Chem
77from rdkit .Chem import Lipinski , rdmolops
88from scitbx .array_family import flex
9+ import mmtbx .ligands .rdkit_utils as rdkit_utils
910
1011# ------------------------------------------------------------------------------
1112
@@ -102,7 +103,7 @@ def run_fragmentation(ligand_isel, model):
102103 rd_j = name_to_rdkit [atom_2 ]
103104 # Check existing to prevent duplicates
104105 if mol .GetBondBetweenAtoms (rd_i , rd_j ) is None :
105- mol .AddBond (rd_i , rd_j , get_rdkit_bond_type (order_str ))
106+ mol .AddBond (rd_i , rd_j , rdkit_utils . get_rdkit_bond_type (order_str ))
106107
107108 # 4. Sanitize (Important for implicit valence calculation)
108109 try :
@@ -122,7 +123,7 @@ def run_fragmentation(ligand_isel, model):
122123 if bond is None : continue
123124
124125 # Filter 1: Protect Amides
125- if is_amide_bond (mol , bond ): continue
126+ if rdkit_utils . is_amide_bond (mol , bond ): continue
126127
127128 bidx = bond .GetIdx ()
128129
@@ -170,41 +171,6 @@ def run_fragmentation(ligand_isel, model):
170171
171172 return cctbx_rigid_components
172173
173- def get_rdkit_bond_type (cif_order ):
174- """
175- Maps CCTBX CIF bond orders to RDKit BondType enum.
176- """
177- if not cif_order : return Chem .BondType .SINGLE
178- order = cif_order .lower ()
179- if 'sing' in order : return Chem .BondType .SINGLE
180- if 'doub' in order : return Chem .BondType .DOUBLE
181- if 'trip' in order : return Chem .BondType .TRIPLE
182- if 'deloc' in order or 'arom' in order : return Chem .BondType .AROMATIC
183- return Chem .BondType .SINGLE
184-
185- def is_amide_bond (mol , bond ):
186- """
187- Checks if a bond is a C-N amide bond to prevent cutting peptides.
188- """
189- a1 = bond .GetBeginAtom ()
190- a2 = bond .GetEndAtom ()
191-
192- c_atom , n_atom = None , None
193- if a1 .GetSymbol () == 'C' and a2 .GetSymbol () == 'N' :
194- c_atom , n_atom = a1 , a2
195- elif a2 .GetSymbol () == 'C' and a1 .GetSymbol () == 'N' :
196- c_atom , n_atom = a2 , a1
197-
198- if c_atom is None : return False
199-
200- for nbr in c_atom .GetNeighbors ():
201- if nbr .GetIdx () == n_atom .GetIdx (): continue
202- if nbr .GetSymbol () == 'O' :
203- bond_to_o = mol .GetBondBetweenAtoms (c_atom .GetIdx (), nbr .GetIdx ())
204- if bond_to_o is not None and bond_to_o .GetBondType () == Chem .BondType .DOUBLE :
205- return True
206- return False
207-
208174# ------------------------------------------------------------------------------
209175
210176pdb_str_01 = '''
0 commit comments