https://pymolwiki.org/api.php?action=feedcontributions&user=Spencer&feedformat=atomPyMOLWiki - User contributions [en]2024-03-29T09:49:43ZUser contributionsMediaWiki 1.35.7https://pymolwiki.org/index.php?title=Ray_Tracing&diff=4440Ray Tracing2007-11-13T21:32:47Z<p>Spencer: /* Adjusting ray trace-image size */</p>
<hr />
<div>==Adjusting ray trace-image size==<br />
<br />
More at [[Ray]].<br />
<br />
The pymol ray tracer can generate an image of any size.<br />
<source lang="python"><br />
ray height,width<br />
</source><br />
<br />
Example:<br />
<source lang="python"><br />
ray 3000,2400<br />
png filename.png<br />
</source><br />
<br />
==Ray tracing maps==<br />
For better quality maps with a white background.<br />
<source lang="python"><br />
set ray_trace_fog,0<br />
set ray_shadows,0<br />
set antialias,1<br />
ray 1600,1200<br />
png img.png<br />
</source><br />
(This will take quite a while...)<br />
<br />
==CGO label orientation==<br />
You could use the cmd.rotate and cmd.translate to position the labels, but it is likely to be somewhat painful. If I'm not mistaken, the rotation will always be about and axis through the origin and so you may need to translate the label into the correct position.<br />
<br />
Thus if you have your label in an object called 'text', you could do,<br />
<source lang="python"><br />
cmd.rotate(axis='x',angle=20.,object='text')<br />
</source><br />
<br />
and repeat this with different angles, until you get the orientation correct. Then use:<br />
<source lang="python"><br />
cmd.translate(vector='[1.,2.,3.]',object='text')<br />
</source><br />
(using the appropriate vector, of course!) to position the label.<br />
Not ideal, but if it is sufficiently important, it can be done!<br />
<br />
[[Category:Using_Pymol|Ray Tracing]]</div>Spencerhttps://pymolwiki.org/index.php?title=Ray&diff=4439Ray2007-11-13T21:32:35Z<p>Spencer: /* SEE ALSO */</p>
<hr />
<div>==DESCRIPTION==<br />
'''ray''' creates a ray-traced image of the current frame. This command is used to make high-resolution photos fit for publication and formal movies. Please note, the '''ray''' command can take some time (up to several minutes, depending on image complexity and size).<br />
<br />
For those who are making movies with PyMOL, '''Ray''' is one of the most commonly used last steps before stitching the frames together to compile the movie. '''Ray''' has many powerful features such as setting the size of the image -- and it still works even if the [[Viewport]] or screen is smaller than the requested output file dimensions.<br />
<br />
==USAGE==<br />
ray [width,height [,renderer [,angle [,shift ]]]<br />
'''angle''' and '''shift''' can be used to generate matched stereo pairs<br />
<br />
<br />
==PYMOL API==<br />
<source lang="python">cmd.ray(int width,int height,int renderer=-1,float shift=0)</source><br />
<br />
==SETTINGS==<br />
===Modes===<br />
Setting the '''[[Ray_trace_mode]]''' variable in PyMOL changes the way PyMOL's internal renderer represents proteins in the final output. New modes were recently added to give the user more options of molecular representation. New modes are: normal rendering, but with a black outline (nice for presentations); black and white only; quantized color with black outline (also, very nice for presentations; more of a ''cartoony'' appearance).<br />
<br />
<source lang="python"><br />
# normal color<br />
set ray_trace_mode, 0<br />
<br />
# normal color + black outline<br />
set ray_trace_mode, 1<br />
<br />
# black outline only<br />
set ray_trace_mode, 2<br />
<br />
# quantized color + black outline<br />
set ray_trace_mode, 3<br />
<br />
set ray_trace_mode, 1 # (or 2 or 3; best with "bg_color white;set antialias,2")<br />
# These two new modes -- 2 and 3 -- are cool cartoon looking modes.<br />
</source><br />
<br />
Here are the example images for the new modes<br />
<gallery><br />
Image:Ray_mode_1_ex.png|set ray_trace_mode,1<br />
Image:Ray_mode_2_ex.png|set ray_trace_mode,2<br />
Image:Ray_mode_3_ex.png|set ray_trace_mode,3<br />
</gallery><br />
<br />
===Perspective===<br />
====Perspective Example Images====<br />
<gallery><br />
Image:No_persp.png|Example with Perspective Turned Off<br />
Image:Persp1.png|Example with Perspective Turned On<br />
Image:Persp2.png|Example with Perspective Turned On and Field of View Set High (70).<br />
</gallery><br />
<br />
=====Notes=====<br />
PyMol 0.97 and prior used '''orthoscopic''' rendering -- that is, no perspective. Upon the arrival of 0.98 and later, we get perspective based rendering at a cost of a 4x decrease in render speed. If you want perspective<br />
set orthoscopic, off<br />
Otherwise<br />
set orthoscopic, on<br />
To magnify the effect of perspective on the scene,<br />
set field_of_view, X<br />
where 50<X<70. Default is 20. 50-70 gives a very strong perspective effect. Nb. the field of view is in Y, not X as one would expect.<br />
<br />
<br />
<br />
===Renderer===<br />
'''renderer = -1''' is default (use value in ray_default_renderer)<br />
<br />
'''renderer = 0''' uses PyMOL's internal renderer<br />
<br />
'''renderer = 1''' uses PovRay's renderer. This is Unix-only and you must have "x-povray" in your path. It utilizes two temporary files: "tmp_pymol.pov" and "tmp_pymol.png".<br />
<br />
==Examples==<br />
===Simple===<br />
<source lang="python"><br />
# ray trace the current scene using the default size of the viewport<br />
ray<br />
</source><br />
<br />
===Specify Image Size===<br />
<source lang="python"><br />
# ray trace the current scene, but scaled to 1024x768 pixels<br />
ray 1024,768<br />
</source><br />
<br />
===Specify Renderer===<br />
<source lang="python"><br />
# ray trace with an external renderer.<br />
ray renderer=0<br />
</source><br />
<br />
===High Quality B&W Rendering===<br />
[[Image:1l9l.png|thumb|center|Black and White (ray_trace_mode,2); click to see full image]]<br />
<source lang="python"><br />
# Black and White Script<br />
load /tmp/3fib.pdb;<br />
show cartoon;<br />
set ray_trace_mode, 2; # black and white cartoon<br />
bg_color white;<br />
set antialias, 2;<br />
ray 600,600<br />
png /tmp/1l9l.png<br />
</source><br />
<br />
===High Quality Color===<br />
[[Image:1l9l_2.png|thumb|center|Color mode (ray_trace_mode,3); click to see full image]]<br />
<source lang="python"><br />
# Color Script<br />
load /tmp/thy_model/1l9l.pdb;<br />
hide lines;<br />
show cartoon;<br />
set ray_trace_mode, 3; # color<br />
bg_color white;<br />
set antialias, 2;<br />
remove resn HOH<br />
remove resn HET<br />
ray 600,600<br />
png /tmp/1l9l.png<br />
</source><br />
<br />
===Ray Tracing Stereo Images===<br />
See [[Stereo_Ray]].<br />
<br />
==SEE ALSO==<br />
"help faster" for optimization tips with the builtin renderer. "help povray" for how to use PovRay instead of PyMOL's built-in ray-tracing engine. For high-quality photos, please also see the [[Antialias]] command. [[Ray shadows]] for controlling shadows.<br />
<br />
<br />
See also [[Ray Tracing]].<br />
<br />
==USER Comments==<br />
====How do I ray trace a publication-ready (~300dpi) image using PyMol?====<br />
This answer is in the [[:Category:Advanced_Issues|Advanced Issues]] (Image Manipulation Section).<br />
<br />
[[Category:Commands|ray]]<br />
[[Category:Publication_Quality|ray]]</div>Spencerhttps://pymolwiki.org/index.php?title=Color&diff=4371Color2007-11-05T22:20:14Z<p>Spencer: /* B-Factors */</p>
<hr />
<div>===DESCRIPTION===<br />
'''color''' changes the color of an object or an atom selection.<br />
<br />
===USAGE===<br />
color color-name<br />
color color-name, object-name<br />
color color-name, (selection)<br />
<br />
===PYMOL API===<br />
<source lang="python">cmd.color( string color, string selection )</source><br />
<br />
==Using RGB for Color==<br />
If you prefer RGB to color any object<br />
<source lang="python"><br />
set_color newcolor, [r,g,b]<br />
color newcolor<br />
</source><br />
List of [[Color Values]]<br />
<br />
==EXAMPLES==<br />
===Color all carbons yellow===<br />
<source lang="python">color yellow, (name C*)</source><br />
<br />
===RGB Example===<br />
<source lang="python"><br />
set_color khaki, [195,176,145]<br />
color khaki<br />
</source><br />
<br />
===Color by Spectrum Example===<br />
Color by spectrum is in the GUI menu but did you realize that the spectrum is not limited to a simple rainbow?<br />
<source lang="python"><br />
spectrum count, x, object_name<br />
</source><br />
x can can be anyone of the following:<br />
blue_green, green_white_magenta, red_cyan, blue_magenta, green_white_red, red_green, blue_red, green_white_yellow, red_white_blue, blue_white_green, green_yellow, red_white_cyan, blue_white_magenta, green_yellow_red, red_white_green, blue_white_red, magenta_blue, red_white_yellow, blue_white_yellow, magenta_cyan, red_yellow, blue_yellow, magenta_green, red_yellow_green, cbmr, magenta_white_blue, rmbc, cyan_magenta, magenta_white_cyan, yellow_blue, cyan_red, magenta_white_green, yellow_cyan, cyan_white_magenta, magenta_white_yellow, yellow_cyan_white, cyan_white_red, magenta_yellow, yellow_green, cyan_white_yellow, rainbow, yellow_magenta, cyan_yellow, rainbow2, yellow_red, gcbmry, rainbow2_rev, yellow_white_blue, green_blue, rainbow_cycle, yellow_white_green, green_magenta, rainbow_cycle_rev, yellow_white_magenta, green_red, rainbow_rev, yellow_white_red, green_white_blue, red_blue, yrmbcg <br />
<br />
===B-Factors===<br />
The command to color a molecule by B-Factors (B Factors) is:<br />
<source lang="python"><br />
cmd.spectrum("b", selection="SEL");<br />
</source><br />
where '''SEL''' is a valid selection, for example, "protA and n. CA", for protein A's alpha carbons.<br />
<br />
You can choose the spectrum you want with the command:<br />
<source lang="python"><br />
cmd.spectrum("b", 'rainbow', selection="SEL");<br />
</source><br />
<br />
where '''rainbow''' is a valid selection from the list:<br />
<pre><br />
blue_green green_white_magenta red_cyan <br />
blue_magenta green_white_red red_green <br />
blue_red green_white_yellow red_white_blue <br />
blue_white_green green_yellow red_white_cyan <br />
blue_white_magenta green_yellow_red red_white_green <br />
blue_white_red magenta_blue red_white_yellow <br />
blue_white_yellow magenta_cyan red_yellow <br />
blue_yellow magenta_green red_yellow_green <br />
cbmr magenta_white_blue rmbc <br />
cyan_magenta magenta_white_cyan yellow_blue <br />
cyan_red magenta_white_green yellow_cyan <br />
cyan_white_magenta magenta_white_yellow yellow_cyan_white <br />
cyan_white_red magenta_yellow yellow_green <br />
cyan_white_yellow rainbow yellow_magenta <br />
cyan_yellow rainbow2 yellow_red <br />
gcbmry rainbow2_rev yellow_white_blue <br />
green_blue rainbow_cycle yellow_white_green <br />
green_magenta rainbow_cycle_rev yellow_white_magenta<br />
green_red rainbow_rev yellow_white_red <br />
green_white_blue red_blue yrmbcg <br />
</pre><br />
<br />
====Reassigning B-Factors and Coloring====<br />
It is commonplace to replace the B-Factor column of a protein with some other biochemical property at that residue, observed from some calculation or experiment. PyMOL can easily reassign the B-Factors and color them, too. The following example will load a protein, set ALL it's B Factors to "0", read in a list of properties for each alpha carbon in the proteins, assign those new values as the B-Factor values and color by the new values. This example is possible because commands PyMOL does not recognize are passed to the Python interpreter --- a very powerful tool.<br />
<source lang="python"><br />
# load the protein<br />
cmd.load("protA.pdb")<br />
<br />
# open the file of new values (just 1 column of numbers, one for each alpha carbon)<br />
inFile = open("newBFactors", 'r')<br />
<br />
# create the global, stored array<br />
stored.newB = []<br />
<br />
# read the new B factors from file<br />
for line in inFile.readlines(): stored.newB.append( float(line) )<br />
<br />
# close the input file<br />
inFile.close()<br />
<br />
# clear out the old B Factors<br />
alter protA, b=0.0<br />
<br />
# update the B Factors with new properties<br />
alter protA and n. CA, b=stored.newB.pop(0)<br />
<br />
# color the protein based on the new B Factors of the alpha carbons<br />
cmd.spectrum("b", "protA and n. CA")<br />
</source><br />
<br />
If you want to save the file with the new B Factor values for each alpha carbon,<br />
<source lang="python"><br />
cmd.save("protA_newBFactors.pdb", "protA")<br />
</source><br />
or similar is all you need.<br />
<br />
<br />
[[Category:Objects_and_Selections]]<br />
[[Category:Commands|color]]</div>Spencer