Take the 2-minute tour ×
Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. It's 100% free, no registration required.

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)
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
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...)) –  Nick T Jan 20 '12 at 14:30
    
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. –  Jan-Philip Gehrcke Mar 4 at 15:07
    
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/pymol-users@lists.sourceforge.net/… –  Jan-Philip Gehrcke Mar 4 at 15:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.