Dear Greg
Using the script below from Marschall
I got the following error
CC[C@@H]1COP23OC[C@@H](CC)N2CCN13 |r|
Traceback (most recent call last):
File "/home/bouille/DescriptorsCalcul/test3D.py", line 59, in <module>
if optimizesubroutine(molH)==0:
File "/home/bouille/DescriptorsCalcul/test3D.py", line 25, in
optimizesubroutine
optimizeresult = AllChem.UFFOptimizeMolecule(mol,1000)
RuntimeError: Invariant Violation
Thank you for your help
Best Regards
Christian de Bouille
import sys
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import AvailDescriptors
from rdkit.ML.Cluster import Murtagh
from rdkit.ML.Cluster import ClusterUtils
import unicodedata
import re
#from hcluster import *
#from IPython import Shell
import MySQLdb
import sys
def embedsubroutine(mol):
num = mol.GetNumAtoms()
if num > 500:
#embed with randcoords
embedresult =
AllChem.EmbedMolecule(mol,useRandomCoords=True)
if embedresult == 0:
return embedresult
#embed normally
embedresult = AllChem.EmbedMolecule(mol)
return embedresult
def optimizesubroutine(mol):
optimizeresult = AllChem.UFFOptimizeMolecule(mol,1000)
return optimizeresult
count =0
# Establich a connection
row = 'CC[C@@H]1COP23OC[C@@H](CC)N2CCN13 |r|'
#row = 'CC(=C\C(O)=O)\C(=C/c1ccc(Br)o1)C(O)=O'
#row = 'CC(C)(C)c1ccc(c2OP(Oc12)(c1ccccc1)(c1ccccc1)c1ccccc1)C(C)(C)C'
print row
count+=1
if row is not None:
result = row
#print result
moly = re.split('\|', result)
#print moly
moly[0].encode('utf8')
#print moly[0]
flag = 0
try:
#Shell.IPShellEmbed()()
mol = Chem.MolFromSmiles(moly[0])
if mol is None:
flag = 1
except ValueError:
flag=1
if (flag == 0):
#print "c'est bon"
mol = Chem.MolFromSmiles(moly[0])
molH = Chem.AddHs(mol)
#print molH
if embedsubroutine(molH) == 0:
#print 'Embeded, now optimizing: ',count
if optimizesubroutine(molH)==0:
sdf3D = Chem.MolToMolBlock(molH)
print sdf3D
#cursor.execute (" insert into 3dStock SET cd_id
= %s, mon3D = %s ", (row[0],sdf3D ))
#cursor.execute (" UPDATE montests SET MASS = %s
WHERE cd_id = %s ", (mass1, row[0]))
else:
print 'Failure with optimzation',count
else:
print 'Due failed embed, cannot optimze',count
else:
flag = 0
#count += 1
print "mauvais"+ str(row[0])
#break
------------------------------------------------------------------------------
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss