File: test3D_old.py

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (96 lines) | stat: -rw-r--r-- 3,359 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from rdkit import Chem
from rdkit import rdBase

from rdkit.Chem import rdMolDescriptors as rdMD
from rdkit.Chem import AllChem
from rdkit.Chem.EState import EStateIndices 
from rdkit.Chem.EState import AtomTypes 
   
import time
print rdBase.rdkitVersion
print rdBase.boostVersion

def getEState(mol):

	return EStateIndices(mol) 

def localopt(mol, steps = 500):
    if mol.GetNumConformers() == 0:
        mol=make3D(mol)
    AllChem.MMFFOptimizeMolecule(mol, maxIters = steps)
    return mol

def make3D(mol, steps = 50):
	mol = Chem.AddHs(mol)
	success = AllChem.EmbedMolecule(mol)
	if success == -1: # Failed
		success = AllChem.EmbedMolecule(mol, useRandomCoords = True)
		if success == -1:
			raise Error, "Embedding failed!"
	mol = localopt(mol, steps)
	return mol

def get3D(m,is3d):
	if not is3d:
		m = Chem.AddHs(m)
		AllChem.EmbedMolecule(m)
		AllChem.MMFFOptimizeMolecule(m)
	r= rdMD.CalcAUTOCORR3D(m)+rdMD.CalcRDF(m)+rdMD.CalcMORSE(m)+rdMD.CalcWHIM(m)+rdMD.CalcGETAWAY(m)
	return r

def generateALL():
	m = Chem.MolFromSmiles('Cc1ccccc1')
	thefile = open('testAC.txt', 'w')
	filename="/Users/mbp/Github/rdkit_mine/Code/GraphMol/Descriptors/test_data/PBF_egfr.sdf"
	suppl = Chem.SDMolSupplier(filename,removeHs=False)
	mols = [x for x in suppl]
	start = time.time()
	for m in mols:
		r= get3D(m,True)
		for item in r:
	  		thefile.write("%.3f," % item)
	  	thefile.write("\n")

	end = time.time()
	print end - start

thefile = open('testSMWHIM.txt', 'w')
writer = Chem.SDWriter('3Dsmallmol.sdf')
A=['[H][H]','B','O=O','C','CC','CCC','CCCC','CCCCC','CCCCCC','CO','CCO','CCCO','CCCCO','CCCCCO','CCCCCCO','CCl','CCCl','CCCCl','CCCCCl','CCCCCCl','CCCCCCCl','CBr','CCBr','CCCBr','CCCCBr','CCCCCBr','CCCCCCBr','CI','CCI','CCCI','CCCCI','CCCCCI','CCCCCCI','CF','CCF','CCCF','CCCCF','CCCCCF','CCCCCCF','CS','CCS','CCCS','CCCCS','CCCCCS','CCCCCCS','CN','CCN','CCCN','CCCCN','CCCCCN','CCCCCCN']
for smi in A:
	m = Chem.MolFromSmiles(smi)
 	m=localopt(m,100)
 	#r=get3D(m,True)
 	print smi
 	print "---------"
 	r=rdMD.CalcWHIM(m)
 	print "Ei:"+str(r[0])+ "," + str(r[1]) + "," + str(r[2])+ "\n"
 	print "Gi:"+str(r[5])+ "," + str(r[6]) + "," + str(r[7])+ "\n"
	print "SI:"+str(rdMD.CalcSpherocityIndex(m))
	print "AS:"+str(rdMD.CalcAsphericity(m))
	print "EX:"+str(rdMD.CalcEccentricity(m))
 	for item in r:
   		thefile.write("%.3f," % item)
	thefile.write("\n")
	   	#m.SetProp("smi", smi)
	   	#writer.write(m)


thefile = open('testBPA.txt', 'w')
writer = Chem.SDWriter('3DBPAmol.sdf')
B=['CN(C)CC(Br)c1ccccc1','CN(C)CC(Br)c1ccc(F)cc1','CN(C)CC(Br)c1ccc(Cl)cc1','CN(C)CC(Br)c1ccc(Cl)cc1','CN(C)CC(Br)c1ccc(I)cc1','CN(C)CC(Br)c1ccc(C)cc1','CN(C)CC(Br)c1cccc(F)c1','CN(C)CC(Br)c1cccc(Cl)c1','CN(C)CC(Br)c1cccc(Br)c1','CN(C)CC(Br)c1cccc(I)c1','CN(C)CC(Br)c1cccc(C)c1','CN(C)CC(Br)c1ccc(F)c(Cl)c1','CN(C)CC(Br)c1ccc(F)c(Br)c1','CN(C)CC(Br)c1ccc(F)c(C)c1','CN(C)CC(Br)c1ccc(Cl)c(Cl)c1','CN(C)CC(Br)c1ccc(Cl)c(Br)c1','CN(C)CC(Br)c1ccc(Cl)c(C)c1','CN(C)CC(Br)c1ccc(Br)c(Cl)c1','CN(C)CC(Br)c1ccc(Br)c(Br)c1','CN(C)CC(Br)c1ccc(Br)c(C)c1','CN(C)CC(Br)c1ccc(C)c(C)c1','CN(C)CC(Br)c1ccc(C)c(Br)c1']
for smi in B:
 	m = Chem.MolFromSmiles(smi)
 	m=localopt(m,100)
 	#r=get3D(m,True)
 	r=rdMD.CalcWHIM(m)
 	for item in r:
   		thefile.write("%.3f," % item)
	thefile.write("\n")
	   	#m.SetProp("smi", smi)
	   	#writer.write(m)



A="G1w,G2w,G3w,Gw"
print dir(rdMD)