import os, sys, math import cPickle from rdkit import Chem from rdkit import RDConfig from rdkit import Geometry from rdkit.Chem import AllChem from rdkit.Chem import ChemicalFeatures from rdkit.Chem.Pharm3D import Pharmacophore from rdkit.Chem.FeatMaps import FeatMapPoint # feature Def feat_def = "BaseFeatures_seri.fdef" feat_fact = AllChem.BuildFeatureFactoryFromString(file(feat_def, "r").read()) # Get Pharmacophore from q_mol q_mol = Chem.SDMolSupplier(sys.argv[1])[0] feats = feat_fact.GetFeaturesForMol(q_mol) pcophore = Pharmacophore.Pharmacophore(feats) # GetFeatures As nested list # [[x,y,x], # [x,y,z], # [x,y,z]] pos_list = [] for feat in feats: geom = list(feat.GetPos()) pos_list.append(geom) for i in range(len(pos_list)): print pos_list[i], feats[i].GetFamily()
v = MolViewer() except Exception: logger.error( 'Unable to connect to PyMol server.\nPlease run ~landrgr1/extern/PyMol/launch.sh to start it.' ) sys.exit(1) if options.clearAll: v.DeleteAll() try: fdef = open(options.fdef, 'r').read() except IOError: logger.error('ERROR: Could not open fdef file %s' % options.fdef) sys.exit(1) factory = AllChem.BuildFeatureFactoryFromString(fdef) if options.writeFeats: print('# Family \tX \tY \tZ \tRadius\t # Atom_ids') if options.featMapFile: if options.featMapFile == '-': options.featMapFile = sys.stdout else: options.featMapFile = file(options.featMapFile, 'w+') print('# Feature map generated by ShowFeats v%s' % _version, file=options.featMapFile) print("ScoreMode=All", file=options.featMapFile) print("DirScoreMode=Ignore", file=options.featMapFile) print("BeginParams", file=options.featMapFile) for family in factory.GetFeatureFamilies():
def get_feats(molecule): fdef = open(os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef'), 'r').read() factory = AllChem.BuildFeatureFactoryFromString(fdef) return ShowMolFeats(molecule, factory, transparency=0.25, showOnly=False, includeArrowheads=True, writeFeats=True, showMol=True)