if old_roots:
current_root = old_roots.pop()
else: // go to next disconnected fragment
next_frag = (frag for frag_num, frag in enumerate(frags)
if frag_num not in visited_frags)[0]
current_root = frags[next_frag]
visited_frags.append(next_frag)
// close opened branches if any is open
After Change
mol_rigid_frags = Chem.FragmentOnBonds(mol, bond_ids, addDummies=False)
else:
mol_rigid_frags = mol
frags = list(Chem.GetMolFrags(mol_rigid_frags))
def weigh_frags(frag):
sort by the fragment size and the number of bonds (secondary)
num_bonds = 0