Wednesday 19 June 2019

biochemistry - How do I get the current "camera position" in PyMol so I can reuse it in scripts?


I have a few protein models I want to take pictures of with various ligands bound. It would be nice if I could do it from the same "position", but the only way I can figure out to repeat the same view is with zoom resi. 64, 152, 150 or the like, which isn't framed that well.


How can I manually position the viewport, capture it's parameters, and repeat it in the script?





I have found get_view, e.g.


PyMOL>get_view
### cut below here and paste into script ###
set_view (\
0.590180993, 0.670941532, 0.448923886,\
-0.507570565, 0.740831316, -0.439937204,\
-0.627747774, 0.031782545, 0.777776182,\
0.000000000, 0.000000000, -417.497009277,\
0.741809845, 7.078243256, 16.473480225,\
329.157806396, 505.836212158, -20.000000000 )

### cut above here and paste into script ###

but this doesn't work in a .py script, where I need to modify it to cmd.set_view(...), as it complains it wants just (or up to 5) arguments, not 18. The wiki is vague about it, it just says



PYMOL API


cmd.set_view(string-or-sequence view)


Answer



Try to pass the matrix as a String containing 18 floats separated by commas, e.g. like


cmd.set_view ('''

0.590180993, 0.670941532, 0.448923886,\
-0.507570565, 0.740831316, -0.439937204,\
-0.627747774, 0.031782545, 0.777776182,\
0.000000000, 0.000000000, -417.497009277,\
0.741809845, 7.078243256, 16.473480225,\
329.157806396, 505.836212158, -20.000000000 ''')

cmd.get_view() seems to return a tuple, so you'll have to convert that to a String if you want to pass the same position to cmd.set_view().


I tried it in Pymol 1.3 on the command line (not in a script though) and it seemed to work.


No comments:

Post a Comment

evolution - Are there any multicellular forms of life which exist without consuming other forms of life in some manner?

The title is the question. If additional specificity is needed I will add clarification here. Are there any multicellular forms of life whic...