BiologicalUnit: Difference between revisions
Jump to navigation
Jump to search
(assembly) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<div style="background-color: #9f9; padding: 10px; margin-bottom: 20px; text-align: center"> | |||
'''Note:''' PyMOL 1.8 can load biological units from mmCIF files with the '''[[assembly]]''' setting. | |||
</div> | |||
This script can be used to re-create biological units for proteins. (This was created as a workaround of PyMOL's semi-functioning [[Symexp]] command.) It's also a fun script to play with for learning about symmetry. | This script can be used to re-create biological units for proteins. (This was created as a workaround of PyMOL's semi-functioning [[Symexp]] command.) It's also a fun script to play with for learning about symmetry. | ||
Line 9: | Line 13: | ||
= Usage = | = Usage = | ||
<source lang="python"> | <source lang="python"> | ||
load /path/to/some/pdbFile.pdb | |||
symMat = readSymmetry("/path/to/some/pdbFile.pdb","pdbFile") | symMat = readSymmetry("/path/to/some/pdbFile.pdb","pdbFile") | ||
biologicalUnit("mates", "pdbFile", symMat) | biologicalUnit("mates", "pdbFile", symMat) | ||
Line 18: | Line 23: | ||
# Jason Vertrees <Jason-dot-Vertrees-at-schrodinger_dot_com>, 2010. | # Jason Vertrees <Jason-dot-Vertrees-at-schrodinger_dot_com>, 2010. | ||
# | # | ||
import pymol | import pymol | ||
from pymol import cmd | from pymol import cmd | ||
Line 52: | Line 56: | ||
for l in thePDB: | for l in thePDB: | ||
tokens = | tokens = l.split() | ||
if len(tokens)!=8: | if len(tokens)!=8: | ||
continue | continue | ||
Line 97: | Line 101: | ||
s3 = "%s + (x*%s + y*%s + z*%s)" % (m[2][3], m[2][0], m[2][1], m[2][2]) | s3 = "%s + (x*%s + y*%s + z*%s)" % (m[2][3], m[2][0], m[2][1], m[2][2]) | ||
cmd.alter_state(1, n, "(x,y,z) = (%s, %s, %s)" % (s1, s2, s3) ) | cmd.alter_state(1, n, "(x,y,z) = (%s, %s, %s)" % (s1, s2, s3) ) | ||
</source> | </source> | ||
Line 106: | Line 107: | ||
= See Also = | = See Also = | ||
*[[BiologicalUnit/Quat]] (alternative implementation) | |||
*[[Symexp]] | *[[Symexp]] | ||
*[[SuperSym]] | *[[SuperSym]] | ||
*[http:// | *[http://www.rcsb.org/pdb/static.do?p=education_discussion/Looking-at-Structures/bioassembly_tutorial.html PDB Tutorial Biol. Units] | ||
*[http://en.wikipedia.org/wiki/Fiber_diffraction Wikipedia article] | *[http://en.wikipedia.org/wiki/Fiber_diffraction Wikipedia article] | ||
*[[assembly]] | |||
[[Category:Script_Library]] | [[Category:Script_Library]] | ||
[[Category:Math_Scripts]] | [[Category:Math_Scripts]] | ||
[[Category:Structural_Biology_Scripts]] | [[Category:Structural_Biology_Scripts]] |
Latest revision as of 08:42, 1 September 2016
Note: PyMOL 1.8 can load biological units from mmCIF files with the assembly setting.
This script can be used to re-create biological units for proteins. (This was created as a workaround of PyMOL's semi-functioning Symexp command.) It's also a fun script to play with for learning about symmetry.
Usage
load /path/to/some/pdbFile.pdb
symMat = readSymmetry("/path/to/some/pdbFile.pdb","pdbFile")
biologicalUnit("mates", "pdbFile", symMat)
The Code
#
# Jason Vertrees <Jason-dot-Vertrees-at-schrodinger_dot_com>, 2010.
#
import pymol
from pymol import cmd
def readSymmetry(inFile, verbose=None):
"""
This function will read "inFile" and glean the
symmetry operations, if any, from it.
PARAMS
inFile
(string) path to PDB file
verbose
(boolean) if verbose is not None, print more
RETURNS
matrix
Array of lists. One 16-element list per symmetry operation. Feed this matrix
into manualSymExp in order to make the other symmetry mates in the biological unit
"""
# a remark-350 lines has:
# REMARK 350 BIOMTn TAGn X Y Z Tx
REM, TAG, BIOMT, OPNO, X, Y, Z, TX = range(8)
thePDB = open(inFile, 'rb').readlines()
matrices = []
curTrans = -1
# The transformation is,
# output = U*input + Tx
for l in thePDB:
tokens = l.split()
if len(tokens)!=8:
continue
if tokens[REM]=="REMARK" and tokens[TAG]=="350" and tokens[BIOMT].startswith("BIOMT"):
if tokens[OPNO]!=curTrans:
# new transformation matrix
matrices.append([])
matrices[-1].append( map( lambda s: float(s), tokens[X:]))
curTrans = tokens[OPNO]
if verbose!=None:
print "Found %s symmetry operators in %s." % (len(matrices), inFile)
return matrices
def biologicalUnit(prefix, objSel, matrices ):
"""
Manually expands the object in "objSel" by the symmetry operations provided in "matrices" and
prefixes the new objects with "prefix".
PARAMS
prefix
(string) prefix name for new objects
objSel
(string) name of object to expand
matrices
(list of 16-element lists) array of matrices from readSymmetry
RETUNRS
None
SIDE EFFECTS
Creates N new obects each rotated and translated according to the symmetry operators, where N
equals len(matrices).
"""
for m in matrices:
n = cmd.get_unused_name(prefix)
cmd.create(n, objSel)
s1 = "%s + (x*%s + y*%s + z*%s)" % (m[0][3], m[0][0], m[0][1], m[0][2])
s2 = "%s + (x*%s + y*%s + z*%s)" % (m[1][3], m[1][0], m[1][1], m[1][2])
s3 = "%s + (x*%s + y*%s + z*%s)" % (m[2][3], m[2][0], m[2][1], m[2][2])
cmd.alter_state(1, n, "(x,y,z) = (%s, %s, %s)" % (s1, s2, s3) )
Notes
This is slow compared to Symexp; use the above for learning, playing and when Symexp doesn't work as advertised.
See Also
- BiologicalUnit/Quat (alternative implementation)
- Symexp
- SuperSym
- PDB Tutorial Biol. Units
- Wikipedia article
- assembly