[chimera-dev] Help with "looping through PDB IDs" script
pett at cgl.ucsf.edu
Wed Apr 16 17:41:38 PDT 2014
This later mail of yours provides some additional details that help. So for one thing you might also want to look at the Programmer's Examples (Examples), particularly the first one ("Chimera's Object Model"). At any rate, the obvious problem with the script you have so far is that you haven't defined the 'residues' variable. Let's say you are trying to work with residues 50.A, 55.A, and 70.A. Here's a little code snippet that will get those residues into the 'residues' variable once you've opened your structure:
from chimera.selection import currentResidues
residues = currentResidues()
Now, I don't know where you're storing your lists of residues. Are they in the same file as the IDs? A separate file? I don't know if you need more help with that or not.
So once you have the residues, then printing the atomic surface areas and bfactors is:
for r in residues:
for a in r.atoms:
print>>outf, a, a.areaSAS, a.bfactor
Getting the CASTp information is another whole can of worms however, since Chimera stores that info in the CASTp dialog rather than with the atoms and residues. Nonetheless, once you've got the rest of your script working you could try to do that part. In would involve copying the processCastpID function from CASTp/__init__.py (in your Chimera installation's 'share' folder) and deleting the last two lines and instead return the cavity list. Each CastpCavity instance has 'mouthInfo' and 'pocketInfo' attributes which are dictionaries that have an 'atoms' key. The value for the 'atoms' key is a chimera.selection.ItemizedSelection instance. You can use the contains() method of those ItemizedSelections to see if a particular atom is in the ItemizedSelection. The pocketInfo dictionary also has 'SA volume' and 'MS volume' keys you can use to get the desired volume info.
UCSF Computer Graphics Lab
On Apr 16, 2014, at 12:44 PM, Navya Shilpa Josyula <njosyu2 at uic.edu> wrote:
> I need a help in chimera scripting. I have text file with list of PDB IDs and corresponding residue list. I am trying to write a chimera command which will scan this file, open each PDB ID and select the corresponding residues listed in the file. After selecting, it should write out the values of atomic areaSAS, atomic Bfactor and which atom belong to CASTp identified pockets (with pocket volume). I know I am asking a lot here but I am new to chimera scripting and I searched the users mailing list and found the "looping" script,
> but it is not working for me. Attached is the script I have till now.
> Please help me on this.
> Thank you in advance,
from chimera import runCommand as rc # use 'rc' as shorthand for runCommand
from chimera import replyobj # for emitting status messages
# change to folder with data files
# open file of PDB IDs
f = open("C:/Users/Navya Shilpa/Desktop/thesis/All_Proteins/nonred/nr-list.txt", 'r')
# loop through the IDs, opening, processing, and closing each in turn
for line in f:
pdbID = line.strip()
replyobj.status("Processing " + pdbID) # show what PDB we're working on
rc("open " + pdbID)
rc("surf") # surface receptor
outf = open(pdbID, "w")
for r in residues:
print>>outf, r, r.areaSAS
# uncommenting the line below will cause Chimera to exit when the script is done
# note that indentation is significant in Python; the fact that
# the above command is exdented means that it is executed after
# the loop completes, whereas the indented commands that
# preceded it are executed as part of the loop.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chimera-dev