3

I would like to add some 3D elements (balls and lines) to the PyMOL visualization to highlight some "holes" in the structure. Say I fetch 1tqn and I want to add a yellow ball somewhere (to specific coordinates, say [-19, -23, -14]) in the view. Or a bar from - to coordinates.

enter image description here

I was going through wiki, did a online search but have not found a way how to add these simple 3D entities into the scene. I guess it should be trivial and I'm just using wrong queries. Because I need to add lots of these, I need to be able to do that via scripting interface.

Thank you in advance for any help!

jhutar
  • 165
  • 3
  • 1
    see here https://stackoverflow.com/questions/2060582/draw-a-colored-sphere-from-cartesian-coordinates-in-pymol/76749167#76749167 Draw a colored sphere from cartesian coordinates in pymol and here https://pymolwiki.org/index.php/Load_CGO and https://pymolwiki.org/index.php/CGO_Shapes – pippo1980 Oct 16 '23 at 08:59

1 Answers1

2

my attempt :

import pymol

from pymol.cgo import *

from pymol import (

                cmd ,
                )


print('########## PYMOL VERSION ##########################################') print(' ', cmd.get_version() ) print('###################################################################')

pymol.finish_launching()

cmd.fetch('1tqn')

cmd.remove('solvent')

pos = cmd.get_position()

r = 3

print('###############################################################################\n')

print('### POSITION : ' , pos,' ###\n')

print('###############################################################################\n')

spherelist = [ [COLOR, 1.000, 1.000, 0.000, SPHERE, pos[0] , pos[1] , pos[2] , r ],

]

for i in spherelist:

a = str(spherelist.index(i))

cmd.load_cgo(i, 'sphere_'+a )


cmd.zoom()

cmd.set('cartoon_transparency' , '0.5')

result:

enter image description here

pippo1980
  • 1,088
  • 3
  • 14
  • Aaah, load_cgo() https://pymolwiki.org/index.php/Load_CGO ("Compiled Graphics Objects"). There are also other shapes: https://pymolwiki.org/index.php/CGO_Shapes. Thank you! – jhutar Oct 16 '23 at 16:08