15
$\begingroup$

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)
$\endgroup$

1 Answer 1

10
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Ah, I guess if I translated the "command line/interactive form" of the commands into the API version, I should have also kept those parenthesis that get_view returns so they're really nested (so you do pass it a tuple). Would look like cmd.set_view((1,2,3...)) $\endgroup$
    – Nick T
    Commented Jan 20, 2012 at 14:30
  • $\begingroup$ Note that you might also want to make use of get_viewport and viewport in case you do not only need the same perspective, but also the same paddings to the outer boundary. $\endgroup$ Commented Mar 4, 2014 at 15:07
  • $\begingroup$ I should add that get_view seems to be undocumented at the moment. It works for me with PyMOL 1.5. Looks like this or a related command does not work reliably in all situations. You might also want to read mail-archive.com/[email protected]/… $\endgroup$ Commented Mar 4, 2014 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .