def test4Github252(self): fdef = os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef') feat_factory = ChemicalFeatures.BuildFeatureFactory(fdef) m1 = Chem.MolFromSmiles('Cc1ccccc1') feats = feat_factory.GetFeaturesForMol(m1) self.assertRaises(RuntimeError, lambda: Pharmacophore.Pharmacophore(feats)) AllChem.Compute2DCoords(m1) Pharmacophore.Pharmacophore(feats)
def setUp(self): self.dataDir = os.path.join(RDConfig.RDCodeDir, 'Chem/Pharm3D/test_data') self.fdefBlock = """ DefineFeature HAcceptor1 [N,O;H0] Family HBondAcceptor Weights 1.0 EndFeature DefineFeature HDonor1 [N,O;!H0] Family HBondDonor Weights 1.0 EndFeature DefineFeature Aromatic1 c1ccccc1 Family Aromatic Weights 1.,1.,1.,1.,1.,1. EndFeature\n""" self.featFactory = ChemicalFeatures.BuildFeatureFactoryFromString( self.fdefBlock) self.feats = [ ChemicalFeatures.FreeChemicalFeature( 'HBondAcceptor', 'HAcceptor1', Geometry.Point3D(0.0, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'HBondDonor', 'HDonor1', Geometry.Point3D(2.65, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'Aromatic', 'Aromatic1', Geometry.Point3D(5.12, 0.908, 0.0)), ] self.pcophore = Pharmacophore.Pharmacophore(self.feats) self.pcophore.setLowerBound(0, 1, 2.0) self.pcophore.setUpperBound(0, 1, 3.3) self.pcophore.setLowerBound(0, 2, 5.0) self.pcophore.setUpperBound(0, 2, 5.4) self.pcophore.setLowerBound(1, 2, 2.6) self.pcophore.setUpperBound(1, 2, 3.0)
def setUp(self): self.fdefBlock = """ DefineFeature HAcceptor1 [N,O;H0] Family HBondAcceptor Weights 1.0 EndFeature DefineFeature HDonor1 [N,O;!H0] Family HBondDonor Weights 1.0 EndFeature DefineFeature Aromatic1 c1ccccc1 Family Aromatic Weights 1.0,1.0,1.0,1.0,1.0,1.0 EndFeature\n""" self.featFactory = ChemicalFeatures.BuildFeatureFactoryFromString( self.fdefBlock) self.feats = [ ChemicalFeatures.FreeChemicalFeature( 'HBondAcceptor', 'HAcceptor1', Geometry.Point3D(0.0, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'HBondDonor', 'HDonor1', Geometry.Point3D(2.65, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'Aromatic', 'Aromatic1', Geometry.Point3D(5.12, 0.908, 0.0)), ] self.pcophore = Pharmacophore.Pharmacophore(self.feats)
def to_rdkit(self) -> Tuple[rdkitPharmacophore.Pharmacophore, List[float]]: """ Returns an rdkit pharmacophore with the pharmacophoric_points from the original pharmacophore. rdkit pharmacophores do not store the pharmacophoric_points radii, so they are returned as well. Returns ------- rdkit_pharmacophore : rdkit.Chem.Pharm3D.Pharmacophore The rdkit pharmacophore. radii : list of float List with the radius in angstroms of each pharmacophoric point. """ rdkit_element_name = { # dictionary to map openpharmacophore feature names to rdkit feature names "aromatic ring": "Aromatic", "hydrophobicity": "Hydrophobe", "hb acceptor": "Acceptor", "hb donor": "Donor", "positive charge": "PosIonizable", "negative charge": "NegIonizable", } points = [] radii = [] for element in self._pharmacophoric_points: feat_name = rdkit_element_name[element.feature_name] center = puw.get_value(element.center, to_unit="angstroms") center = Geometry.Point3D(center[0], center[1], center[2]) points.append(ChemicalFeatures.FreeChemicalFeature( feat_name, center )) radius = puw.get_value(element.radius, to_unit="angstroms") radii.append(radius) rdkit_pharmacophore = rdkitPharmacophore.Pharmacophore(points) return rdkit_pharmacophore, radii
def test4Search(self): featFactory = ChemicalFeatures.BuildFeatureFactory( os.path.join(self.dataDir, 'BaseFeatures.fdef')) activeFeats = [ ChemicalFeatures.FreeChemicalFeature( 'Acceptor', Geometry.Point3D(0.0, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'Donor', Geometry.Point3D(0.0, 0.0, 0.0)), ChemicalFeatures.FreeChemicalFeature( 'Aromatic', Geometry.Point3D(0.0, 0.0, 0.0)) ] pcophore = Pharmacophore.Pharmacophore(activeFeats) pcophore.setLowerBound(0, 1, 2.251) pcophore.setUpperBound(0, 1, 2.451) pcophore.setUpperBound2D(0, 1, 3) pcophore.setLowerBound(0, 2, 4.970) pcophore.setUpperBound(0, 2, 5.170) pcophore.setUpperBound2D(0, 2, 6) pcophore.setLowerBound(1, 2, 2.681) pcophore.setUpperBound(1, 2, 2.881) pcophore.setUpperBound2D(1, 2, 6) inF = gzip.open(os.path.join(self.dataDir, 'cdk2-syn-clip100.pkl.gz'), 'rb') nDone = 0 nMatches = 0 nHits = 0 while 1: try: _, molPkl, boundsMat = pickle.load(inF, encoding='latin1') molPkl = bytes(molPkl, encoding='latin1') except Exception: break nDone += 1 mol = Chem.Mol(molPkl) boundsMat = rdDistGeom.GetMoleculeBoundsMatrix(mol) DG.DoTriangleSmoothing(boundsMat) canMatch, matches = EmbedLib.MatchPharmacophoreToMol( mol, featFactory, pcophore) if canMatch: nMatches += 1 r = EmbedLib.MatchPharmacophore(matches, boundsMat, pcophore, useDownsampling=True, use2DLimits=True, mol=mol) failed = r[0] if not failed: nHits += 1 self.assertEqual(nDone, 100) self.assertEqual(nMatches, 93) # print 'nhits:',nHits self.assertEqual(nHits, 67)
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() def get_distance(feats): dist_list = []