[Chimera-users] Script

Damien Larivière damien.lariviere at fourmentinguilbert.org
Thu Aug 20 11:23:40 PDT 2009

Hi Eric and Elaine,

Thank you very much for your answers !

I was blocked in fact by the "cd command" that does not work on my 
machine for opening a file. I reported the bug this morning.

So, I have used Eric's suggestions and it works very well.

I am not a python programmer (but I know Matlab well enough). So in 
Chimera I would like to open successive pdb files (dock000i.pdb with i = 
1 to 20) and perform some actions on each one and then close each 
session that are previously saved in a Chimera session. The loop "for" 
in Matlab starts with "for i = 1:20" then the block of actions and ends 
with "end". What's about in Python programming ?

I suggest the following but I know it can't work:

for i = 1 to 20
    open C:\Users\damien\Fondation\LifeExplorer\3D 
    color orange red :38-227.A
    color blue :228-356.A
    color magenta :203-227.A
    color green :261-271.A
    color green :297-307.A
    save C:\Users\damien\Fondation\LifeExplorer\3D 
    close session

Many thanks for your help


Eric Pettersen a écrit :
> Hi Damien,
> You can use "open" with the full path to the file, or you can "cd" to 
> the folder and then just use the file's name.  See below...
> On Aug 19, 2009, at 6:44 AM, Damien Larivière wrote:
>> Dear all,
>> Sorry for this simple question : Is there an example of how to use a
>> command in a script ? For example, the command "open" is described in
>> the documentation but I confess (i'm not a programmer) that I do not
>> understand how to use it for opening a pdb file in a specific directory
>> : C:\Users\damien\Fondation\LifeExplorer\3D
>> models\FtsZ_ring\Bond_Set\Docking_Hex\Results_190809\dock0001.pdb
>> I would like to create a script that does :
>> 1/ Open a PDB file (dock0001.pdb)
> Either:
> open C:\Users\damien\ ... \Results_190809\dock001.pdb
> -or-:
> cd C:\Users\damien\ ... \Docking_Hex\Results_190809
> open dock001.pdb
> The latter might be better if you are going to save files and would 
> like them to go into that folder as well without specifying a big long 
> path.
>> 2/ open Tools - Structure analysis - Sequence
>> 3/ select residues 203 to 227 chain A
> sel :203-227.A
> ":203-227.A" is the "atom specifier" for residues 203 to 227 of chain 
> A.  There is an extensive explanation of atom specifiers 
> here: http://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/frameatom_spec.html
>> 4/ Actions Color Red
> color red sel
>> 5/ open Tools - Structure analysis - Sequence
>> 6/ select residues 54 to 87 chain A
> sel :54-87.A
>> 7/ Actions Color Magenta
> color magenta sel
> If the only reason you are making the selection is in order to color 
> it magenta (i.e. you aren't going to do any other operations on it) 
> then you could just cut out the selection step and:
> color magenta :54-87.A
> --Eric
>                         Eric Pettersen
>                         UCSF Computer Graphics Lab
>                         http://www.cgl.ucsf.edu

More information about the Chimera-users mailing list