def check_mol( mol ): match, mList = EmbedLib.MatchPharmacophoreToMol( mol, feat_fact, pcophore) if match: res = [] num_match = len( mList ) for i in range( num_match ): num_feature = len( mList[i] ) for j in range( num_feature ): print mList[i][j].GetAtomIds(), mList[i][j].GetFamily() bounds = rdDistGeom.GetMoleculeBoundsMatrix( mol ) pList = EmbedLib.GetAllPharmacophoreMatches( mList, bounds, pcophore ) #pList = EmbedLib.MatchPharmacophore( mList, bounds, pcophore ) print pList #print raw_input("-----") num_match = len( pList ) print num_match phMatches = [] for i in range( num_match ): num_feature = len( pList[i] ) phMatch = [] for j in range( num_feature ): phMatch.append( pList[i][j].GetAtomIds() ) phMatches.append( phMatch ) for phMatch in phMatches: bm, embeds, nFail = EmbedLib.EmbedPharmacophore( mol, phMatch, pcophore, count=20, silent=1 ) print "-----> embeds num:", len( embeds ) for embed in embeds: AllChem.UFFOPtimizeMolecule( embed ) align_data = rdAliginment.GetAlignmetTransform( bm, bounds ) AllChem.TransformMol( embed, align_data[1] ) res.append( embed ) return res
def check_mol(mol): res = [] mol.RemoveAllConformers() match, mList = EmbedLib.MatchPharmacophoreToMol(mol, feat_fact, pcophore) #mList = [ m for m in Set( mList ) ] if match: num_match = len(mList) for i in range(num_match): num_feature = len(mList[i]) for j in range(num_feature): print mList[i][j].GetAtomIds(), mList[i][j].GetFamily() bounds = rdDistGeom.GetMoleculeBoundsMatrix(mol) pList = EmbedLib.GetAllPharmacophoreMatches(mList, bounds, pcophore) num_match = len(pList) phMatches = [] for i in range(num_match): num_feature = len(pList[i]) phMatch = [] for j in range(num_feature): phMatch.append(pList[i][j].GetAtomIds()) phMatches.append(phMatch) for phMatch in phMatches: bm, embeds, nFail = EmbedLib.EmbedPharmacophore(mol, phMatch, pcophore, count=5, silent=1) print "-----> embeds num:", len(embeds) for embed in embeds: AllChem.UFFOptimizeMolecule(embed) feats = feat_fact.GetFeaturesForMol(embed) feats_dict = GetFeatsPerAtoms(feats) match_feats = [feats_dict[atomid] for atomid in phMatch] pro_mat = [list(feat.GetPos()) for feat in match_feats] align_data = rdAlignment.GetAlignmentTransform( ref_mat, pro_mat, maxIterations=200) AllChem.TransformMol(embed, align_data[1]) print align_data[0] print align_data[1] res.append(embed) else: print "no hits" return res