[Chimera-users] Measuring dihedral angles using chimera

Eric Pettersen pett at cgl.ucsf.edu
Fri Aug 29 11:15:07 PDT 2014


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
> 







More information about the Chimera-users mailing list