[Chimera-users] using IDLE

Ben Keshet keshet1 at umbc.edu
Thu Feb 7 09:32:43 PST 2008

Hi Eric,


Thanks for the detailed answer.  I think the .cmd script will be sufficient
for my purpose, however I was unable to write it correctly.  What I want to
do is slightly more complex than I outlined - I need to: open a mol2
structure, select certain residues (say select: 69-70), save the selected
residues as a mol2 file, and select different residues and save them several
more times.  The .cmd looks something like that: 


alias ^process open $1.mol2; sel : 69-70; write selected 0 $1.his_CEGI.mol2;

process p2


However, I was unable to create a proper mol2 file (I tried different
options but my guess is that I have a syntax error).  In some cases I was
able to write out a file, but it was never a proper mol2 file.
Alternatively, I tried: 


alias ^process open $1.mol2; sel : 69-70; select invert; del sel; write 0

process p2


which generated p2.his_CEGI.mol2, but the file could not be viewed with
Chimera, and when inspected it looked different (no charge column and extra
3 columns: 1.00, 0.00, atom name).  The whole script should be able to save
mol2 files of several subsequences of several different structures.  I would
appreciate if you could help me identify what missing in the script.  


On a related note, the name of my structures have an underline in them (_),
I noticed that Chimera puts a space instead.  How do I make Chimera read,
for example, p2_3.mol2 as it is (and not as p2 3.mol2)?


Thanks a lot for you help,







From: Eric Pettersen [mailto:pett at cgl.ucsf.edu] 
Sent: Wednesday, February 06, 2008 5:34 PM
To: Ben Keshet
Cc: Chimera-users at cgl.ucsf.edu
Subject: Re: [Chimera-users] using IDLE


Hi Ben,

            IDLE is basically for interactive debugging or discovery of
information in the Python layer (the latter via the help() function). For
what you want to do you either want to write a Chimera-command script (.cmd
suffix) or a Python script (.py suffix). Either kind can be run by opening
the script with File...Open or the "open" command or by supplying the
filename as an argument on the Chimera startup command line (the latter
typically used more in Linux or IRIX environments).

            If what you want to do is no more complicated than what you
outlined, you can get away with using a Chimera-command script. In
particular you can use the "alias" command to construct a compound command
that takes arguments. For example:


            alias ^process open $1.pdb; sel :HIS; del sel; write 0
$1.mod.pdb; close 0


creates an alias named "process" that if you execute it as "process 1gcn"
will open the file 1gcn.pdb, select the histidines, delete the selected
atoms, write the result to a file named 1gcn.mod.pdb, and then close the
opened model. Aliases are saved in sessions and can be made available at
startup. See the documention for the alias command for details on that.

            So you might make a command file like this:


alias ^process open $1.pdb; sel :HIS; del sel; write 0 $1.mod.pdb; close 0

process 1gcn

process 3fx2

process 1www



            You would have to use Python if you needed to loop through a
range of values in your script, or only execute certain commands if some
condition was true, or do something for which there is no equivalent Chimera
command. We having some basic information for getting started in the Chimera
Programmer's Guide:


The programmer documentation isn't nearly as extensive as the user
documentation, so feel to ask questions -- either here or on the chimera-dev
mailing list.





Eric Pettersen

UCSF Computer Graphics Lab



On Feb 6, 2008, at 12:41 PM, Ben Keshet wrote:


I am interested in performing the same actions several times on several
different structures. For example: open a file, select the histidines,
delete them, save and close. Is IDLE the right tool for that? I opened the
python shell (Tools-> General Controls-> IDLE) but could not open files or
manipulate them using the shell. I have no knowledge in python. What is the
best way to write scripts to execute commands repeatedly? If IDLE is the
tool, how can use it to do that? Is there a written source for that? Do I
need to master python first?

Many thanks,



Chimera-users mailing list

Chimera-users at cgl.ucsf.edu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20080207/68cf5284/attachment.html>

More information about the Chimera-users mailing list