[Chimera-users] python code to loop over molecules

Julian Tirado-Rives julian.tirado-rives at yale.edu
Mon May 3 09:14:17 PDT 2021


Hi Elaine,

     I did consider the "forEachFile" option, but the drawbacks you 
mentioned yourself did not
make it an attractive alternative.  Also, we do mostly visual inspection 
at the end of the process, so
we need them open to be able to check each one and "cherry-pick" (or 
something like that).

Thanks, anyway!

                                    - Julian -

On 5/3/2021 12:04 PM, Elaine Meng wrote:
> Hi Julian,
> Thanks for the kind words!
>
> Someone will be responding in more detail about Chimera.
>
> In the meanwhile, thought I should mention that in ChimeraX, we just added an option to the "open" command that allows running the same command script on each of a list of inputs (typically atomic structures or maps) without resorting to python.  If you get a new daily build of ChimeraX, then you could use a command something like
>
> open my-command-file.cxc forEachFile ~/Desktop/data/*.pdb
>
> and it would open the first pdb file, run the command file, close everything, open the next data file, run the command file, [...]  as explained here:
> <https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile>
>
> I didn't know if using ChimeraX was a possibility for you at this point, but may be useful down the line. ChimeraX has "hbonds" "clashes" and "contacts" commands which work much the same as in Chimera, except with improvements (at least in my opinion) on how the sets of atoms are specified.
> <https://rbvi.ucsf.edu/chimerax/docs/user/commands/hbonds.html>
> <https://rbvi.ucsf.edu/chimerax/docs/user/commands/clashes.html>
>
> The main impediments to using forEachFile out of the box for the ligand-receptor case is that the ligands would need to be in separate files and the command script would have to open the receptor since it would get closed between script executions. So python might still be better in ChimeraX than trying to use that option.
>
> Best,
> Elaine
> -----
> Elaine C. Meng, Ph.D.
> UCSF Chimera(X) team
> Department of Pharmaceutical Chemistry
> University of California, San Francisco
>
>
>> On May 3, 2021, at 5:10 AM, Julian Tirado-Rives <julian.tirado-rives at yale.edu> wrote:
>>
>> Dear Chimera (and ChimeraX) team:
>>
>>     I need to find some python example or code snippet capable of
>> looping over all the molecules in a particular model and do some actions
>> separately in each one.
>>
>>      In our research we use several different docking programs and other
>> ways of generating poses of protein-ligand complexes, and using several
>> different programs to analyze them gets quite complicated. Instead,
>> we've found that the easiest way is to generate from each code, or using
>> conversion utilities such as babel, a pdb file of the host and a sdf or
>> mol2 file containing all the ligand poses and read them into chimera.
>> An excellent program, by the way. We use it all the time.
>>
>>     I would love to automate the process even further by doing all the
>> coloring, rendering, Hydrogen Bond and contact analysis, etc. in Python
>> rather than manually. I have been trying to do this, but have not found a way to do the following:
>>
>> If we have, for instance, the host in model #0, and the ligand poses in model #1 (#1.1, #1.2, ..., #1.N):
>>
>> - Get from chimera the number of molecules in model #1 (e.g what is N)
>> - loop from the first #1.1 to the last #1.N molecule
>> - do some cations there (e.g select, color, find HB's, etc)
>>
>>    I think this should be a problem other people have encountered and
>> solved  before, but I have not been able to find an example in your
>> depository, the mailing lists, or even the book ... I would appreciate
>> your input.
>>
>> Thanks for your help, and for an excellent program!
>>
>>                                              - Julian -
>> -- 
>>
>>   -----------------------------------------------------------------
>> | Julian Tirado-Rives      |                                      |
>> | Department of Chemistry  | Phone: (203)432-3356                 |
>> | Yale University          | Fax:   (203)432-6144                 |
>> | P. O. Box 208107         | email:  Julian.Tirado-Rives at yale.edu |
>> | New Haven, CT 06520-8107 |                                      |
>>   -----------------------------------------------------------------

-- 
-------------------------------------------------------------------------------------------
  | Julian Tirado-Rives                  |                                                                   |
  | Department of Chemistry     | Phone: (203)432-3356                          |
  | Yale University                         | Fax:   (203)432-6144                             |
  | P. O. Box 208107                     | email:  Julian.Tirado-Rives at yale.edu |
  | New Haven, CT 06520-8107 |                                                                    |
   -------------------------------------------------------------------------------------------

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


More information about the Chimera-users mailing list