[Chimera-users] Export idatmType

Eric Pettersen pett at cgl.ucsf.edu
Thu Jan 18 12:49:11 PST 2007

On Jan 17, 2007, at 10:47 PM, Brady Bernard wrote:

> is there a way to do this with --nogui so that i can automate it in  
> a script?
> thanks,
> brady

It's pretty easy to make a Python script that opens a file, loops  
through open molecules and then their atoms, and prints our the atom  
identifier and IDATM type to that file.  Here's an example:

import chimera
f = open("types.txt", "w")
for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
	for a in m.atoms:
		print>>f, a, a.idatmType

If you save the above into a file with a ".py" suffix (e.g.  
types.py), then you could save all the types of 1gcn with "chimera -- 
nogui pdb:1gcn types.py", which would create a file named  
"types.txt" (in the same folder as types.py) with the types listed.   
BTW, you need to preserve the indentation of the Python code above --  
it matters to Python.

If you're automating this in a shell script, it may be simpler to  
just print the info to standard output and redirect that into a file,  
rather than open the file in the Python script.  The command would  
then be "chimera --nogui --nostatus pdb:1gcn types.py >  
1gcn_types.txt" (note the "--nostatus" flag so that status messages  
don't get mixed into the output).  The Python script becomes:

import chimera
for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
	for a in m.atoms:
		print a, a.idatmType

> ----- Original Message -----
> From: Eric Pettersen
> To: Brady Bernard
> Cc: Thomas Goddard ; Elaine Meng
> Sent: Tuesday, January 16, 2007 4:40 PM
> Subject: Re: Export idatmType
> Hi Brady,
> Tom forwarded your mail to me.  There almost is a way.  In the  
> 1.2318 snapshot, the Render By Attribute tool allows you to save  
> attribute values to a file using that tool's "File->Save  
> Attributes..." menu item (saved in the format that Define Attribute  
> accepts).  So, why "almost"?  The idatmType attribute is screened  
> out of the list of available attributes since it can be expensive  
> to compute the values -- and since you could already select by  
> IDATM type using the regular selection menu.  But now that save  
> exists I will have to improve Render By Attribute so that it can  
> know that idatmType values are strings ahead of time (so it doesn't  
> have to ask for any values to figure that out).
> Anyway, for your purposes it is not too hard to force Render By  
> Attribute to show you idatmType.  First, get the 1.2318 release.   
> Then edit the file <your Chimera>/share/ShowAttr/__init__.py (on a  
> Mac:  Chimera.app/Contents/Resources/share/ShowAttr/__init__.py)  
> and edit line 24.  It will look like this:
> 'name': False, 'idatmType': False, 'idatmIsExplicit': False,
> change it to:
> 'name': False, 'idatmIsExplicit': False,
> Save the file and thereafter Render By Attribute should show you  
> the idatmType attribute.
> --Eric
>> hi tom - is there a quick way to save the atom types from  
>> idatmType to a text/log file along with the atom name or number?

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

More information about the Chimera-users mailing list