#!/usr/bin/env python # from openeye.oechem import * import os,sys import math def DoubleArrayFromList(alist): array = DoubleArray(len(alist)) for i in xrange(len(alist)): array[i] = alist[i] return array # open our trusty example file ifs=oemolistream("drugs.sdf") mol=OECreateOEGraphMol() # get acetsali OEReadMolecule(ifs, mol) OETriposAtomNames(mol) # open an output file for the modified geometries ofs=oemolostream("newgeom.sdf") # write out the original molecule for reference OEWriteMolecule(ofs, mol) # get some atom references c1 = mol.GetAtom(OEHasAtomName("C1")) c2 = mol.GetAtom(OEHasAtomName("C2")) o1 = mol.GetAtom(OEHasAtomName("O1")) c8 = mol.GetAtom(OEHasAtomName("C8")) print "c1->c2 distance = %6.3f A" % OEGetDistance(mol, c1, c2) print "c1->c2 dist. squared = %6.3f A" % OEGetDistance2(mol, c1, c2) print "c1-c2-o1 angle = %6.3f" % OEGetAngle(mol, c1, c2, o1) tor = OEGetTorsion(mol, c1, c2, o1, c8) * cvar.Rad2Deg print "c1-c2-o1-c8 torsion = %6.3f deg." % tor print "Setting torsion to 90 deg." OESetTorsion(mol, c1, c2, o1, c8, 90.0 * cvar.Deg2Rad) tor = OEGetTorsion(mol, c1, c2, o1, c8) * cvar.Rad2Deg print "c1-c2-o1-c8 torsion now = %6.3f deg." % tor OEWriteMolecule(ofs, mol) trans = DoubleArray(3) OECenter(mol, trans) print trans[0], trans[1], trans[2] OEWriteMolecule(ofs, mol) trans = DoubleArrayFromList((-3.0, -3.0, -3.0)) OETranslate(mol, trans) OEWriteMolecule(ofs, mol) trans = DoubleArrayFromList((3.0, 3.0, 3.0)) OETranslate(mol,trans) OEWriteMolecule(ofs, mol) rmat = DoubleArrayFromList((0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 )) OERotate(mol, rmat) OEWriteMolecule(ofs, mol)