On Nov 14, 2007, at 12:20 AM, Jean Didier Pie Marechal wrote:

I am trying to get deeper into chimera and to develop a "simple" algorithm for drug optimization. Something flying in my mind for a while...

First though, I need to understand how to manipulate atom coordinates, bond angle and the general building. I went to the index of the chimera modules. My first objective is to generate a molecule from scratch and I thought that the molEdit module would provide me with the right tools to do so.

However, when trying to call this module by a chimera.molEdit.XXXX type of command, it seems that molEdit is not a correct object.

Are you getting ImportError?  The chimera module only imports the submodules it needs at startup in order to try to reduce the startup time, and molEdit is one of the modules it does not import.  So if you have code like this:

import chimera
chimera.molEdit.blah()

you will get an ImportError.  You either need to do this:

import chimera.molEdit
chimera.molEdit.blah()

or this:

from chimera.molEdit import blah
blah()

Could you give me some pointers on the correct way to generate small ligand or how to add groups to a given one?

molEdit certainly has the very basic functions for working on a molecule:

addAtom:  add an atom to a molecule at a specific Point, optionally bonded to a specified atom
addDihedralAtom:  as above except positioned at a specific dihedral, angle, and bond length from 3 given Atoms/Points
addBond:  bond two atoms

However, the BuildStructure module also has some pertinent functions.  In it's __init__.py:

placeHelium:  start a Molecule from scratch by placing a helium atom at the given Point
changeAtom:  change the element, number of bonds, and bond geometry of a given Atom.  Hydrogens will be added as necessary to fill out the bonds.  If the 'autoClose' keyword is true, then bonds will be made to existing Atoms if appropriate (e.g. closing a ring).
setBondLength:  pretty self-explanatory

It's too bad we're in a code freeze right now (due to the pending production release) because I've added some helpful functionality to BuildStructure:

placeFragment:  start a Molecule with any of the rings systems seen here: http://en.wikipedia.org/wiki/Simple_aromatic_ring
changeAtom:  as above, but also returns a list of the Atoms that were changed/created

In the near future I anticipate adding the ability to generate structures from PubChem IDs or SMARTS strings to BuildStructure.  Anyway, I can send you a current version of BuildStructure if you would like to use that.  Otherwise, it should be available in the first daily build we make after the production release.

--Eric

                        Eric Pettersen

                        UCSF Computer Graphics Lab

                        http://www.cgl.ucsf.edu