def _generateFPs(mol, fragmentMethod='Morgan'): aBits = {} fp = None # circular Morgan fingerprint fragmentation, we use a simple invariant than ususal here if fragmentMethod == 'Morgan': tmp = {} fp = AllChem.GetMorganFingerprint( mol, radius=2, invariants=utilsFP.generateAtomInvariant(mol), bitInfo=tmp) aBits = utilsFP.getMorganEnvironment(mol, tmp, fp=fp, minRad=2) fp = fp.GetNonzeroElements() # path-based RDKit fingerprint fragmentation elif fragmentMethod == 'RDK': fp = AllChem.UnfoldedRDKFingerprintCountBased(mol, maxPath=5, minPath=3, bitInfo=aBits) fp = fp.GetNonzeroElements() # get the final BRICS fragmentation (= smallest possible BRICS fragments of a molecule) elif fragmentMethod == 'Brics': fragMol = BRICS.BreakBRICSBonds(mol) propSmi = _prepBRICSSmiles(fragMol) fp = Counter(propSmi.split('.')) else: print("Unknown fragment method") return fp, aBits
def getBits(mol): ''' Parameters ---------- mol : rdkit mol object to be broken up into fragments by breaking rotable bonds Returns ------- mols : A list of rdkit mol objects ''' # find the rotatable bonds bonds = mol.GetSubstructMatches(RotatableBondSmarts) bonds = [((x, y), (0, 0)) for x, y in bonds] p = BRICS.BreakBRICSBonds(mol, bonds=bonds) mols = [mol for mol in Chem.GetMolFrags(p, asMols=True)] return mols
if tests[9]: logger.info('Writing: Mol blocks') t1 = time.time() for mol in mols: mb = Chem.MolToMolBlock(mol) t2 = time.time() logger.info('Results10: %.2f seconds' % (t2 - t1)) ts.append(t2 - t1) if tests[10]: from rdkit.Chem import BRICS logger.info('BRICS decomposition') t1 = time.time() for mol in mols: d = BRICS.BreakBRICSBonds(mol) t2 = time.time() logger.info('Results11: %.2f seconds' % (t2 - t1)) ts.append(t2 - t1) if tests[11]: logger.info('Generate 2D coords') t1 = time.time() for mol in mols: AllChem.Compute2DCoords(mol) t2 = time.time() logger.info('Results12: %.2f seconds' % (t2 - t1)) ts.append(t2 - t1) if tests[12]: logger.info('Generate topological fingerprints')
tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i],sanitize=False) newFragmentMol.append(tempFragMol) # return tuple mol-objects return tuple(newFragmentMol) suppl2 = rdmolops.RemoveHs(suppl) new2 = BRICS.BreakBRICSBonds(suppl2) mfl2 = Chem.GetMolFrags(new2, asMols=True, sanitizeFrags=False) mfl3 = ReconnectDoubleBond(suppl2,mfl2) for i in range(len(mfl3)): print(Chem.MolToMolBlock(mfl3[i])) pass #FindDoubleBonds(mfl2[i])