mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* 3D Descriptors Dragons * stripped down, not yet working * get this building on a non C++-11 compiler * move the python test to the python directory * move the python test to the python directory * add the python test * now at least those tests runn * warning comment * some basic refactoring and cleanup * get python wrapper "working" (completely untested) * fix Name * fixing AutoCorr & RDF * AutoCorr test added * RDF reviewed based on AutoCorr comments * fix Morse code * Morse reviewed * Correct Morse & start Getaway * correct MORSE test * start Getaway clean up * simplification of Whim * better * fix Getaway * fix RCON * merge repaired * adding Dragon 2D autocorrelations descriptors * fix the 3D autocorrelation descriptors based on the modification in Dragon. * Adding the 2D autocorrelation descriptors (no need of Eigen dependency for this one) * Adding 2D test case * IState … no idea for the moment * there is an error in 2D computation (memory error ???) * fix the IState for molecules with Hs * need to use getTotalNumHs(true) not getTotalNumHs() * also need to remove Hs in both dv and d! * fixing Rcov values I fix the Rcov values * fix Getaway * remove push_back * remove call to sum * improve tests * fix getaway * adding precision parameter to GETAWAY * adding rouding (1e-3) * fix WHIM * use void in declarations of function * update MolDescriptors link * remove print option in WHIM * fix python wrapper to 3D descriptors. - all modifications reduce computation time by a factor of 3! * final fix for Getaway * all output are fixed except the 2 first values due to clustering approach. * cluster cannot be fixed du tu float precision issue between Java & c++ * best fix of ITH and ISH * use the same algorithm as in Dragon 6 but there is still a deviation * remove std::move * std:move only works on c++ 11 * fixing issue based on Greg Comments * auto2D still not working on my env * update 3d test.py * auto 2D not working after the first loop test * tighten up the tests * change name * update, but still does not pass * make this run (though it does not work) * re-enable test3D * some cleanup * add GETAWAY test data. Note that the tests fail * fix the ATS and ATSC autocorrelation 2D Broto Moreau and Geary autocorrelation are not correct again a specificity of Dragon to compute them. The result are not consistant with Padel because we use the relative weigth not in Padel. * one minor change to get things to compile * fix the M & G matrix computation fix inversion in the computation of the equations for both M & G matrixes * update autocorr2d tests * 192 examples * fix issue in cluster 0.01 0.009 case this is not correct all the cases * update GETAWAY expected values to reflect the fact that we cannot reproduce the literature values exactly fix a leak in GETAWAY * fix the negative values in gamma this is strickly the implementation that we find in the book molecular descriptors for chemoinformatics (except the case where an atom is already in the axis in this case it should be added in the symetric list which is not the case in this implementation) * Update WHIM.cpp adding the axis atoms to the symetrical list * update WHIM tests * add AUTOCORR2D to MolDescriptors and the python wrappers * start adding tests * test the python versions of the new descriptors * update list of descriptors
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
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) |