Hi Shay,

cmd.do() allows you to run pml code.

Try

cmd.do("fetch 1lw9;show cell;png testcell.png")

Best regards,

Blaine

Blaine Mooers, Ph.D.
Associate Professor
Department of Biochemistry and Molecular Biology
College of Medicine
University of Oklahoma Health Sciences Center
S.L. Young Biomedical Research Center (BRC) Rm. 466
975 NE 10th Street, BRC 466
Oklahoma City, OK 73104-5419

________________________________________
From: CHAUDHURI, SHAY (PGR) [s.chaudh...@warwick.ac.uk]
Sent: Wednesday, September 30, 2020 9:42 AM
To: pymol-users@lists.sourceforge.net
Subject: [EXTERNAL] [PyMOL] Rendering Unit Cell in API

Hi all,

I'm trying to generate a series of rendered images using the API. The script 
itself works fine but the only thing that isn't being rendered is the unit 
cell. I have been using the cmd.show(representation='cell') command to try and 
get the unit cell to show but it doesn't appear to be working and there is no 
documentation on how to show the unit cell using the API.

This is one of the structures I have been trying to render (called 
"structure.pdb"):
CRYST1 2.526 3.572 40.104 90.00 90.00 90.00 P 1
MODEL 1
ATOM 0 C MOL 1 -0.018 2.808 5.068 1.00 0.00 C
ATOM 1 C MOL 1 1.245 1.012 6.314 1.00 0.00 C
ATOM 2 C MOL 1 1.245 1.920 5.067 1.00 0.00 C
ATOM 3 C MOL 1 -0.018 0.143 6.315 1.00 0.00 C
ATOM 4 C MOL 1 -0.017 2.833 7.563 1.00 0.00 C
ATOM 5 C MOL 1 1.245 1.895 7.564 1.00 0.00 C
ATOM 6 O MOL 1 -0.017 -0.218 8.794 1.00 0.00 O
ATOM 7 O MOL 1 1.245 1.373 8.794 1.00 0.00 O
ATOM 8 C MOL 1 -0.018 6.380 5.068 1.00 0.00 C
ATOM 9 C MOL 1 1.245 4.584 6.314 1.00 0.00 C
ATOM 10 C MOL 1 1.245 5.492 5.067 1.00 0.00 C
ATOM 11 C MOL 1 -0.018 3.715 6.315 1.00 0.00 C
ATOM 12 C MOL 1 -0.017 6.405 7.563 1.00 0.00 C
ATOM 13 C MOL 1 1.245 5.467 7.564 1.00 0.00 C
ATOM 14 O MOL 1 -0.017 3.354 8.794 1.00 0.00 O
ATOM 15 O MOL 1 1.245 4.945 8.794 1.00 0.00 O
ATOM 16 C MOL 1 2.508 2.808 5.068 1.00 0.00 C
ATOM 17 C MOL 1 3.771 1.012 6.314 1.00 0.00 C
ATOM 18 C MOL 1 3.771 1.920 5.067 1.00 0.00 C
ATOM 19 C MOL 1 2.508 0.143 6.315 1.00 0.00 C
ATOM 20 C MOL 1 2.509 2.833 7.563 1.00 0.00 C
ATOM 21 C MOL 1 3.771 1.895 7.564 1.00 0.00 C
ATOM 22 O MOL 1 2.509 -0.218 8.794 1.00 0.00 O
ATOM 23 O MOL 1 3.771 1.373 8.794 1.00 0.00 O
ATOM 24 C MOL 1 2.508 6.380 5.068 1.00 0.00 C
ATOM 25 C MOL 1 3.771 4.584 6.314 1.00 0.00 C
ATOM 26 C MOL 1 3.771 5.492 5.067 1.00 0.00 C
ATOM 27 C MOL 1 2.508 3.715 6.315 1.00 0.00 C
ATOM 28 C MOL 1 2.509 6.405 7.563 1.00 0.00 C
ATOM 29 C MOL 1 3.771 5.467 7.564 1.00 0.00 C
ATOM 30 O MOL 1 2.509 3.354 8.794 1.00 0.00 O
ATOM 31 O MOL 1 3.771 4.945 8.794 1.00 0.00 O
ENDMDL

This is my rendering script:


from pymol import cmd

#Viewing settings
cmd.load("structure.pdb")
cmd.set('orthoscopic', 1)
cmd.show(representation='cell')

#Ball-and-stick model
cmd.show('spheres')
cmd.set('sphere_scale', 0.33)
cmd.show('sticks')
cmd.set('stick_radius', 0.2)

#Colours
cmd.color('grey', 'name C*')
cmd.set('stick_transparency', 0.05)
cmd.bg_color('white')
cmd.set('ray_opaque_background', 0)
cmd.set('ray_shadow', 0)

#Render image
basename = 'Structure'
cmd.zoom(complete=1)
cmd.ray(1024, 1024)
cmd.png(basename+'_Z'+'.png', dpi=600)

cmd.rotate('y',-90)
cmd.rotate('z',-90)
cmd.ray(1024, 1024)
cmd.zoom(complete=1)
cmd.png(basename+'_X'+'.png', dpi=600)

cmd.rotate('z',-90)
cmd.rotate('x',-90)
cmd.rotate('z', 90)
cmd.ray(1024)
cmd.zoom(complete=1)
cmd.png(basename+'_Y'+'.png', dpi=600)

cmd.quit()


Many thanks,


Shay Chaudhuri



_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Unsubscribe: 
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe

Reply via email to