[Chimera-users] Measuring dihedral angles using chimera

Aswani Kumar Kancherla ashwin2952 at gmail.com
Sat Aug 30 04:00:26 PDT 2014


Hi Elaine and Eric,

Many thanks for the prompt reply.

@Elaine:
thanks for the link. I have decided to start off from script given in the
link sent by you.

You said:
"The script that you included gives specific residue numbers for the four
atoms.  You would need to know the residue numbers for the CB-SG-SG-CB in
each structure.  I’m not sure how you would get that or pass it in.  (also:
the script has four different residue numbers, which doesn’t really make
sense to me; if it’s really a disulfide dihedral you would just have two
residue numbers, one cysteine CB,SG and the other cysteine SG,CB)"

You have got my problem right. I was hoping to get the specific residue
numbers for four atoms (CB,SG,SG'.CB') for each pdb using "molmol" (which I
am used to using for analysing NMR structures) and then some how pass the
information to chimera in each iteration. I didn't know how to do the
latter part. But with the code that Eric has sent, I can do everything
using chimera itself and I don't need to pass the residue numbers from
outside.

​Yeah, you are right that residue numbers in the script that I had sent do
not make sense for measuring chiSS. There should just be two residue
numbers. It was my fault: by mistake I had pasted an uncorrected script; my
apologies.


​@Eric:​
​Many thanks for the code that you gave for extracting disulfide bonds and
measuring the chiSS. I incorporated it in the code from the link sent by
Elaine and executed it on a list of pdb ids. ​It worked fine on most of pdb
files. However, for a few pdb files, some of the disulfide bonds are not
recognized. Could it be due to the bad geometry in those structures?

If I understand the code right, it  extracts pairs of SG atoms that are
bonded together in each model "m" by looking in "m.bonds". Then it goes on
to identify the attached beta carbons and then finally calculates the
chiSS.

My suspicion is that, in some of the NMR structures (the pdb ids on which
the script failed to identify all the disulfide bonds), the disulfide bond
geometry is not good and hence SS bond is not listed in "m.bonds".

How do I go about, if I want to identify all the pairs of Cysteine SG atoms
which are closer than say 2.5A and then calculate the appropriate dihedral
angle about CB-SG-SG'-CB'? I will first need to calculate pairwise
distances for SG atoms of all cysteines, select those pairs which are much
nearer than allowed by their non-bonded distance (sum of van der waal
radii) and then calculate the dihedral angle. This exercise will be useful
for me to identify pairs of those Cysteines whose SG atoms have optimal
geometry for formation of disulfide bond.

Once again many thanks for your valuable time and prompt help. I am pasting
the script that I have used below. It worked fine and hence the indentation
must be fine.

with regards,
Aswani

code:
=================================================================================================
import os
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
os.chdir("/home/aswani/Downloads/test")

# gather the names of .pdb files in the folder
file_names = [fn for fn in os.listdir(".") if fn.endswith(".pdb")]

# loop through the files, opening, processing, and closing each in turn
for fn in file_names:
        replyobj.status("Processing " + fn) # show what file we're working
on
        rc("open " + fn)
        from chimera import openModels, Molecule
        for m in openModels.list(modelTypes=[Molecule]):
              for b in m.bonds:
                    if b.atoms[0].name == "SG" and b.atoms[1].name == "SG":
                           sg1, sg2 = b.atoms
                           cbs = []
                           for sg in [sg1, sg2]:
                                 if len(sg.neighbors) != 2:
                                       break
                                 for nb in sg.neighbors:
                                       if nb.name == "CB":
                                             cbs.append(nb)
                                             break
                                 else:
                                      # not bonded to a CB
                                      break
                           if len(cbs) != 2:
                                  continue
                           cb1, cb2 =  cbs
                           from chimera import dihedral
                           print cb1, sg1, sg2, cb2, dihedral(cb1.coord(),
sg1.coord(), sg2.coord(), cb2.coord())
        rc("close all")
# uncommenting the line below will cause Chimera to exit when the script is
done
#rc("stop now")
# 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.
===========================================================================================



On 29 August 2014 23:45, Eric Pettersen <pett at cgl.ucsf.edu> wrote:

> Hi Aswani,
>         I would recommend basing your script off the link that Elaine
> sent, since I think it is a little easier to understand, but you could use
> your original one if you like.  In either case, in the main loop of the
> script, after either the "open" command or the "openModels" call (depending
> on which script you use), this code would identify and print out the
> disulphide dihedrals:
>
>         from chimera import openModels, Molecule
>         for m in openModels.list(modelTypes=[Molecule]):
>                 for b in m.bonds:
>                         if b.atoms[0].name == "SG" and b.atoms[1].name ==
> "SG":
>                                 sg1, sg2 = b.atoms
>                                 cbs = []
>                                 for sg in [sg1, sg2]:
>                                         if len(sg.neighbors) != 2:
>                                                 break
>                                         for nb in sg.neighbors:
>                                                 if nb.name == "CB":
>                                                         cbs.append(nb)
>                                                         break
>                                         else:
>                                                 # not bonded to a CB
>                                                 break
>                                 if len(cbs) != 2:
>                                         continue
>                                 cb1, cb2 =  cbs
>                                 from chimera import dihedral
>                                 print cb1, sg1, sg2, cb2,
> dihedral(cb1.coord(), sg1.coord(), sg2.coord(), cb2.coord())
>
> Make sure you maintain the relative indentation of the code and the the
> 'from' and first 'for' statements above are indented the same amount as the
> other statements in your loop.
>
> --Eric
>
>                         Eric Pettersen
>                         UCSF Computer Graphics Lab
>                         http://www.cgl.ucsf.edu
>
> On Aug 29, 2014, at 10:35 AM, Elaine Meng <meng at cgl.ucsf.EDU> wrote:
>
> > Hi Aswani,
> > I can answer only part of the question.
> >
> > For writing scripts to loop through multiple PDBs please see:
> > <http://www.rbvi.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html
> >
> >
> > The script that you included gives specific residue numbers for the four
> atoms.  You would need to know the residue numbers for the CB-SG-SG-CB in
> each structure.  I’m not sure how you would get that or pass it in.  (also:
> the script has four different residue numbers, which doesn’t really make
> sense to me; if it’s really a disulfide dihedral you would just have two
> residue numbers, one cysteine CB,SG and the other cysteine SG,CB).
> >
> > Best,
> > Elaine
> > -----
> > Elaine C. Meng, Ph.D.
> > UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab
> > Department of Pharmaceutical Chemistry
> > University of California, San Francisco
> >
> > On Aug 28, 2014, at 10:13 PM, Aswani Kumar Kancherla <
> ashwin2952 at gmail.com> wrote:
> >
> >> ​Hello Chimera Users,
> >> ​
> >> ​I have recently installed chimera ​version 1.9 in Linux OpenSuSe 11.4
> and am trying to get acquainted with its features.
> >>
> >> I am trying to measure dihedral angles (specifically the angle chiSS
> defined by Cb-Sg-Sg'-Cb' about disulfide bonds) for a list of pdb files
> containing NMR structure ensembles. ​I was trying to ​do this using a
> script (kindly given by a friend and pasted below) to which I can pass the
> coordinates of the four atoms and get the measured values for the "reply
> log" information.
> >>
> >> ​I need to put the files in a directory called pdb_files, open ​chimera
> and call the script and retrieve information from the "reply log". However,
> there is a problem:
> >>
> >> Since the coordinates of (Cb,Sg, etc ) will be different for each of
> the ensemble (since each ensemble is structure of a different molecule), I
> need to pass the coordinates dynamically for each pdbid.
> >>
> >> ​I have found from Chimera User group  archives that reply log can be
> saved using a function.
> >>
> http://plato.cgl.ucsf.edu/pipermail/chimera-users/2008-October/003184.html
> >> So that should solve one issue. I can save the reply log and parse it
> later.
> >>
> >> ​What is the best way to ​m​easure specific dihedral angles from
> multiple pdb files? Is it possible to invoke ​ ​chimera in tty mode and
> make it execute functions? In that case, I could probably write a shell
> script​ to invoke chimera once for each pdb and ask it to execute python
> script having appropriate atom coordinates.
> >>
> >> I apologize for slightly long an e-mail. Any hints or directions to
> enable me figure out how to get this done efficiently in chimera will be of
> great help to me.
> >>
> >> ​with regards,
> >> Aswani
> >>
> >> ​script:
> >> ================================================================​
> >>
> >> import os
> >> import Matrix
> >> from chimera import openModels, selection, runCommand
> >>
> >> #angle #0:resno at CB :resno at SG :resno at SG :resno at CB  34.6289
> >>
> >>
> >> # Directory containing PDB files
> >> directory = 'pdb_files'
> >>
> >> # Get paths to all files in the specfied directory
> >> paths = [os.path.join(directory,f) for f in os.listdir(directory) if
> f.endswith('.pdb')]
> >>
> >> for pdbfilename in paths:
> >>    filename = pdbfilename.split("/")[1]
> >>    openModels.open(pdbfilename, baseId = 0)  # Open as model #2
> >>    runCommand('angle #0:863 at CB :980 at SG :1130 at SG :1235 at CB')
>       # calculate torsion angle
> >>
> >>    runCommand('close #0')                  # close molecule and map
> >> ​=================================================================​
> >>
> >>
> >>
> >>
> >> --
> >> K.Aswani Kumar
> >> ​Graduate Student
> >> Molecular Biophysics Unit
> >> Indian Institute of Science
> >> Bangalore-560012
> >> Karnataka, India.
> >> _______________________________________________
> >> Chimera-users mailing list
> >> Chimera-users at cgl.ucsf.edu
> >> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
> >
> >
> > _______________________________________________
> > Chimera-users mailing list
> > Chimera-users at cgl.ucsf.edu
> > http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
> >
>
>
>
>


-- 
K.Aswani Kumar
Prof. Siddhartha P Sarma's Group
Molecular Biophysics Unit
Indian Institute of Science
Bangalore-560012
Karnataka, India.
Ph: +91-9945633467    (mobile)
       +91-80-22933454  (lab)
       +91-8814-278410  (home)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20140830/4509b247/attachment-0001.html>


More information about the Chimera-users mailing list