Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help
Special pages
SBGrid Resources
SBGrid Consortium
SBGrid Data Bank
Software Webinars
PyMOL Webinar
PyMOL Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Cart to frac
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= The Code = <source lang="python"> from pymol import cmd def cart_to_frac(objSel,quiet=0,_self=cmd): """ Returns an array of fractional atomic coordinates for a given object or selection. PARAMS objSel -- any object or selection quiet -- suppress output (default, no) _self -- core CMD object; or none RETURNS Python list of fractional coordinates NOTES/EXAMPLES cart_to_frac org x = cart_to_frac("solvent", quiet=1) """ import numpy from numpy import cos, sin, sqrt a2r = numpy.pi / 180.0 # get the model and coordinates m = _self.get_model(objSel) cart_coord = numpy.matrix(m.get_coord_list()) # get the symmetry information try: a,b,c,alpha,beta,gamma,gp = _self.get_symmetry(objSel) except: print "Error-Failed to get symmetry. Please ensure you have a" print "valid object with proper crystal symmetry loaded." return None # convert to radians alpha = a2r * alpha beta = a2r * beta gamma = a2r * gamma # (scaled) volume of the cell v = sqrt(1 -cos(alpha)*cos(alpha) - cos(beta)*cos(beta) - cos(gamma)*cos(gamma) + 2*cos(alpha)*cos(beta)*cos(gamma)) tmat = numpy.matrix( [ [ 1.0 / a, -cos(gamma)/(a*sin(gamma)), (cos(alpha)*cos(gamma)-cos(beta)) / (a*v*sin(gamma)) ], [ 0.0, 1.0 / (b*sin(gamma)), (cos(beta) *cos(gamma)-cos(alpha))/ (b*v*sin(gamma)) ], [ 0.0, 0.0, sin(gamma) / (c*v) ] ] ) r = cart_coord * tmat.T if not quiet: for (x,y,z) in r.tolist(): print '%8.5f %8.5f %8.5f' % (x,y,z) # return the Nx3 results return r cmd.extend("cart_to_frac", cart_to_frac) </source> [[Category:Script_Library]] [[Category:Structural_Biology_Scripts]] [[Category:Math_Scripts]]
Summary:
Please note that all contributions to PyMOL Wiki are considered to be released under the GNU Free Documentation License 1.2 (see
PyMOL Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Cart to frac
(section)
Add topic