[Chimera-users] placing a helium atom at a given position.
Eric Pettersen
pett at cgl.ucsf.edu
Fri Feb 22 11:30:31 PST 2008
On Feb 22, 2008, at 7:59 AM, Jean-Didier Maréchal wrote:
> Hi again,
>
> that follows an e-mail exchange with Eric a while ago.
>
> I am trying to place a given atom (for the moment, helium is fine) to
> given x,y,z coordinates. You told me that the new BuildStructure
> module
> could do that, unfortunately after having imported the module
> import BuildStructure
> when I do
> BuildStructure.placeHelium
> (res,model=0,position=13.2909,75.4474,25.4248)
> I have
> SyntaxError: non-keyword arg after keyword arg
> I tried different argumentations of this but I can't have it
> working, if
> you can tell me how to do this, that would be perfect.
>
> All the best,
> JD
Hi JD,
The are a few things wrong with your placeHelium() call, some of
them due to incorrect Python syntax (thereby producing the
SyntaxError) and some from not providing the kind of input the
routine expects. They are actually interrelated in your case.
As mentioned in the doc string for the placeHelium() function, the
'model' argument has to be a string or a chimera.Molecule instance,
not an integer. If it's a string, a new Molecule will be created
with that string as its name. If you want to put the atom in model 0
(it seems like you do), you need to get the Molecule instance of
model 0. Like so:
from chimera import openModels, Molecule
model0 = openModels.list(id=0, modelTypes=[Molecule])[0]
The 'modelTypes=' part isn't necessary if the only thing in model 0
is a structure, but if you have a surface on the structure (which is
a separate model of type MSMSModel) then you do need it.
Similarly, the 'position' argument needs to be a chimera.Point
instance or None. If None, the atom will be placed in the center of
the view. Clearly, you want a Point, like so:
from chimera import Point
pt = Point(13.2909,75.4474,25.4248)
This also where the syntax error occurred. Commas separate arguments
in Python calls, so the second and third numbers in your placeHelium
() call were interpreted as additional arguments, not as part of the
value being specified for the 'position' keyword. You would have
needed to surround the three numbers with parentheses to have them
treated as a single argument (which would have avoided the
SyntaxError but would have still failed since it wasn't a Point
instance).
With the above, your call to placeHelium would be:
BuildStructure.placeHelium(res, model=model0, position=pt)
--Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20080222/43bb09b5/attachment.html>
More information about the Chimera-users
mailing list