You run a python file simply by opening it, either with the “open” command or with File->Open.  Another option here, since you aren’t creating images or doing anything graphical, is to run it entirely from the command line and not even bring up the graphical interface:  chimera —nogui DistSing.py

Looking at your script, it mostly looks good except the for the writing to the file.  It looks like you give two ‘{}’s in the format string but then provide 4 arguments to the format() call.  I think those have to match, though I’m no format() guru.

—Eric

On Aug 21, 2015, at 11:18 AM, Feixia <feixia.chu@unh.edu> wrote:

Thank you, Eric.

I got a prototype program based on your suggestions (see attachment).  But, I can't get it to run.  I tried the 'Tools / General Controls / IDLE Python shell" by enter "import DistSing.py".  The error message I got, "ImportError: No module named DistSing.py".

I have Python27, and Chimera 1.7.  Any suggestion to move forward?  I ended PDB downloading at  ~107,000 entires when most of the rest structures are gigantic ribosome, virus etc.  Thanks.

Feixia


On Thu, 20 Aug 2015 15:35:55 -0400, Eric Pettersen <pett@cgl.ucsf.edu> wrote:

Probably the simplest way is to just see if you wound up with multiple models or not (i.e. len(openModels.list(modelTypes=Molecule)) > 1).  If you just want to use one model per entry regardless of it being NMR or not, don’t loop over the model list but just use the first model in it, i.e. instead of:

for mol in openModels.list(modelTypes=[Molecule]):
indented analysis code

use:

mol = openModels.list(modelTypes=[Molecule])[0]
unindented analysis code

—Eric

On Aug 19, 2015, at 9:10 PM, Feixia <feixia.chu@unh.edu> wrote:

Thank you, Eric!  
I am still downloading PDB files through Bio.python. I am just interested in the overall distance distribution of residues, say Lys alpha carbon. NMR entries might end up over-representing due to their multiple models.  Thank you for pointing it out.  Is there a quick way to distinguish crystal structures from NMR structures?

Best,
Feixia

On Wed, 19 Aug 2015 14:17:35 -0400, Eric Pettersen <pett@cgl.ucsf.edu> wrote:

Hi Feixia,
You could certainly use Chimera to do that.  You need to know some Python.  Take a look at the Programmer’s Guide:


In particular, the “basic primer” discusses how to loop over files in a directory and do things to them one by one.
Here’s some example code for printing the lysine CA-CA distances for a single open file.  You could take that and move it into the loop described in the basic primer — customizing it as you wish…

from chimera import openModels, Molecule
# opening NMR files can produce multiple models, so use a loop...
for mol in openModels.list(modelTypes=[Molecule]):
lysCas = [a for a in mol.atoms if a.name == “CA” and a.residue.type == “LYS”]
for i, ca1 in enumerate(lysCas):
for ca2 in lysCas[i+1:]:
print mol.name, ca1, ca2, ca1.coord().distance(ca2.coord())

—Eric

Eric Pettersen
UCSF Computer Graphics Lab

On Aug 18, 2015, at 8:36 AM, Feixia <feixia.chu@unh.edu> wrote:

Hi there,

I am interested in retrieving distance information from large dataset in an automatic fashion.  For instance, can we use Chimera to get the distances between lysine alpha-carbons of current PDB entries.  Presumably, we can download all PDB structures on our local desktop, and just call functions one structure at a time.  I wonder if we can do that with Chimera.  Your advice will be highly appreciated.

Best,
Feixia

 
_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev




-- 
Feixia Chu, Ph.D.
Associate Professor 
Molecular, Cellular & Biomedical Sciences
University of New Hampshire
Gregg Hall, Rm436
35 Colovos Rd
Durham, NH 03824
Tel 603 862 2436
<DistSing.py>