11.07.2015 Views

OEChem -- Python Theory Manual

OEChem -- Python Theory Manual

OEChem -- Python Theory Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50 Chapter 11. Creating Atoms, Bonds and Conformersvalue is found for the parent atom then the hybridization will be assigned, if possible, from the molecule graph.If hybridization assignment fails then new coordinates will not be assigned for the hydrogen atom. An additionalfunction is provided which allows specification of the hydrogen for which new coordinates are to be assigned. Newcoordinates for the hydrogen atom will be computed regardless of whether the current coordinates of the hydrogenare identical to the atom to which it is attached. If coordinates are assigned correctly the method will return booleanTrue. If the function fails to compute a geometrically reasonable position the method will return boolean False.11.7 Using NewConfThe most common method to create conformers in a molecule is by reading a molecule from a file (see chapter”Reading and Writing Molecules”). However, when manipulating molecules it is often necessary to createconformers on-the-fly. In <strong>OEChem</strong>, this is done with the NewConf method of OEMCMolBases. There are fiveprominent overloads of NewConf. All of the versions create conformers with the capacity to store coordinatesfor the current number of atoms in the molecule. NewAtom and NewBond adjust this capacity as necessary.The default OEMCMolBase constructor puts the molecule in a state with a single empty conformer (as does theOEMCMolBase::Clear function). The DeleteConfs function of the OEMCMolBase removes all of theconformers of the molecule.1 #!/usr/bin/env python2 # ch10-5.py3 from openeye . oechem import ∗45 mol = OEMol ( )67 print "Default NumConfs = " , mol . NumConfs ( )8109 mol . NewConf ( )11 print "After one additional, NumConfs = " , mol . NumConfs ( )1213 mol . DeleteConfs ( )1415 print "After deletion, NumConfs = " , mol . NumConfs ( )The code about will produce the output:Default NumConfs = 1After one additional , NumConfs = 2After deletion , NumConfs = 0The versions of the NewConf method are:NewConf ( )NewConf ( OEFloatArray )NewConf ( OEMolBase )NewConf ( OEConfBase )Listing 11.5: Deleting ConformersAfter the NewConf with no arguments has been called, the coordinates of individual atoms can be set using theSetCoords method which takes an atom, or all of the atoms can be set at once with the SetCoords whichtakes only a OEFloatArray or only a OEDoubleArray.The NewConf overload which takes an argument OEFloatArray is expecting a OEFloatArray ofsize 3*GetMaxAtomIdx() with the Cartesian coordinates of each atom of the new conformer incoords[atom->GetIdx()*3].

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!