[Chimera-users] SplitCommand python

Tom Goddard goddard at sonic.net
Fri Feb 14 10:33:48 PST 2020


Here is a bit a Python code to count the number of chains in a molecule m.

>>> import chimera
>>> m = chimera.openModels.list()[0]
>>> m
<_molecule.Molecule object at 0x7fb988fed620>
>>> len(set(r.id.chainId for r in m.residues))
4

We have been working on ChimeraX the replacement for Chimera for a few years and it is quite a bit nicer.  In ChimeraX the code would be

m = session.models.list()[0]
m.num_chains

  Tom

> On Feb 14, 2020, at 2:09 AM, Healey, Joseph <J.Healey.1 at warwick.ac.uk> wrote:
> 
> Hi Chimera Team,
>  
> I’m trying to reduce some overheads in one of my scripts part of which is coming from my use of `runCommand`. At the moment, I’m only using it for `split`, but I’d like to first test whether a model is already split to avoid unnecessary invocation.
>  
> I’m aware the python equivalent of the command is buried inside chimera.SplitMolecule and the command split_command, however it doesn’t seem to be importable, as when I try:
>  
> >>> from chimera import SplitMolecule
> Traceback (most recent call last):
>   File "<pyshell#25>", line 2, in <module>
> ImportError: cannot import name SplitMolecule
>  
> I’m getting the above ImportError. I can import other members of the chimera class (e.g. chimera.openModels or chimera.Molecule and chimera itself without issue). I’ve seen in the source code that SplitMolecule gets imported elsewhere, and it has the __init__ file, so I assume I’m just doing something stupid with paths or similar. That said, SplitMolecule is clearly within the main chimera modules directory, so I would have expected it to only be one ‘layer’ below `chimera` itself. Can you elighten me?
>  
> I’m currently on chimera production version 1.14 (build 42094) 2019-11-13 06:05:13 UTC if that helps.
>  
> If you could point me in the right direction to understand how the code will check for multiple chains and decide to split by chain, that would also be a massive help.
>  
> Many thanks,
>  
> Joe
>  
>                                                                                    
> Dr. Joseph Healey Ph.D. M.Sc. B.Sc. (Hons) MRSB
> Research Fellow
> Warwick Medical School
> University of Warwick
> Coventry
> CV47AL
> Mob: +44 (0) 7536 042620  | Twitter: @JRJHealey <https://twitter.com/JRJHealey>  |  Website <http://www2.warwick.ac.uk/fac/sci/moac/people/students/2013/joseph_healey>
> Email: J.Healey.1 at warwick.ac.uk <mailto:J.Healey.1 at warwick.ac.uk> | ORCID: orcid.org/0000-0002-9569-6738 <http://orcid.org/0000-0002-9569-6738>
>  
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu <mailto:Chimera-users at cgl.ucsf.edu>
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users <http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20200214/a4c1cd54/attachment.html>


More information about the Chimera-users mailing list