Talk:Label: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
This is the content for the new labels page.
This is the content for the new labels page.


=Overview=
[[Image:Pl.png|right|500px]]


 
= Old Page =
The [[Label]] command controls how PyMOL draws text labels for PyMOL objects. Labeling is important so there are many options for your fine tuning needs.  You can change the [[Label_size|label size]], [[Label_color|label color]], positioning, [[Label_font_id|font]], the [[Label_outline_color|label outline color]] that masks the font and much, much more.
[[Image:Label_pre.png|200px|right|PyMol Labels]]
 
===DESCRIPTION===
You can have PyMOL label atoms by properties or arbitrary strings as you want; you can even use Unicode fonts for special symbols like, <math>\alpha, \beta, \pm, \textrm{\AA}</math>, etc.
'''label''' allows one to configure the appearance of text labels for PyMOL objects. It labels one or more atoms properties over a selection using the python evaluator with a separate name space for each atom.  The symbols defined in the name space are:
 
The following gallery shows some examples of how extensible the [[Label]] command is. 
<gallery heights="180px" widths="200px" align="center" perrow="3">
Image:Label_pre.png|Simple label
Image:New_fonts.jpeg|Example showing usage of Unicode fonts for special characters
Image:Font_ex.png|Another example with Unicode fonts
Image:Label_ex.png|Example label
Image:Ls0.png|Label shadows turned off
Image:Ls2.png|Label shadows turned on
</gallery>
 
==Object Properties==
Aside from arbitrary string labels, like "This is the catalytic residue" for an atom/residue you can also use the following built-in molecular properties:
* '''name''', the atom name
* '''name''', the atom name
* '''resn''', the residue name
* '''resn''', the residue name
*'''resi''', the residue number/identifier
*'''resi''', the residue number/identifier
*'''chain''', the chain name
*'''chain''', the chain name
*'''q''', charge
*'''q''',
*'''b''', the occupancy/b-factor
*'''b''', the occupancy/b-factor
*'''segi''', the segment identifier
*'''segi''', the segment identifier
Line 39: Line 24:
*'''text_type''', the text type
*'''text_type''', the text type


You can use one of these properties as:
All strings in the expression must be explicitly quoted.  This operation typically takes several seconds per thousand atoms altered.  To clear labels, simply omit the expression or set it to ''.
 
[[Label]] is great for labeling atoms, residues and objects.  For a scene label, see [[Pseudoatom]].
 
===USAGE===
label (selection),expression
 
 
===SETTINGS===
====FONT====
There are 10 different scalable fonts.
<source lang="python">set label_font_id, number</source>
where number is 5 through 14.
=====UTF8 Fonts=====
 
[[Image:New_fonts.jpeg|thumb|New fonts in PyMol.  Notice the alpha and beta characters.]]
 
Newer versions support UTF8 fonts; use '''label_font_id''' from above to 15 or 16.  The good news about the UTF8 fonts is that they support the alpha and beta characters. (See image.)
 
Here's some example code for the image at right:
<source lang="python">
<source lang="python">
# simple example: label residue 22's atoms with their names
# roman
label i. 22, name
set label_font_id, 15
set label_shadow_mode, 3
label 5/CA, "\316\261-Helix"
label 10/CA, "\316\262-Sheet"


# Label residue #44's alpha carbon with it's residue name, residue number and B-factor.
# italic
label n. CA and i. 44, "(%s, %s, %s") % (resn, resi, b)
set label_font_id, 16
 
# make bigger
set label_size, 50
</source>
</source>


See the syntax and examples below for more info.
=====Unicode Fonts=====
[[Image:Font_ex.png|300px|thumb|right|Notice the Angstrom and superscript 2 characters.  You can add other characters as well.]]


=Syntax=
PyMOL gives you the flexibility to use encoded unicode fonts.  This allows us to insert various symbols, like the symbol used for Angstrom.  Here are the steps to insert a character from the unicode character set.
To use the label command follow this syntax:
 
* Find the code for your character at [http://www.unicode.org/charts Unicode Charts].  The Angstrom character, <math>\textrm{\AA}</math> is u"\u00c5" and <math>\pm</math> is u"\u00b1".
* Label the selection.  For simple strings, just type the string in double quote, -- "like this" -- and append to the end of that .encode('utf-8') -- "like this".encode('utf-8').  A working example is shown here,
<source lang="python">
<source lang="python">
# labeling syntax
# label residue 30 with "4.1 Ang^2 +/- 0.65 Ang^2; see the image at right
label [ selection[, expression]]
label i. 30, "4.1" + u"\u00c5\u00b2  \u00b1 0.65 \u00c5\u00b2 ".encode('utf-8')
</source>
</source>
where '''selection''' is some object/selection you want to label and '''expression''' is some string (or set of strings) which PyMOL is to use to label the given selection.


We have plenty of examples.  See [[#Examples|the examples]] below.
====SIZE====
The font size can be adjusted
<source lang="python">set label_size, number</source>
where number is the point size (or -number for Angstroms)


=Settings=
====COLOR====
Here are all the label settings and their general effect. For each label setting, see the respective web page for more details.
Set a label's color by
  set label_color, color
where color is a valid PyMol color.


'''[[label_angle_digits]]'''
If the coloring of the labels is not ''exactly'' the same as you'd expect (say black turns out grey, or red turns out pink), then try the following settings:
:: (no idea)
<source lang="python">
'''[[label_distance_digits]]'''
unset depth_cue
:: (no idea)
unset ray_label_specular
'''[[label_shadow_mode]]'''
</source>
:: sets whether or not PyMOL will ray trace shadows for your label text.  Eg: <source lang="python">set label_shadow_mode, 2</source>
'''[[label_color]]'''
:: sets the color of the label text.  Eg: <source lang="python">set label_color, magenta</source>
'''[[label_font_id]]'''
:: sets the font to render your label.  There are 12 different fonts from 5&mdash;16.  Numbers 15 and 16 are special for unicode.  Eg: <source lang="python">set label_font_id, 12</source>
'''[[label_size]]'''
:: sets the size of the text.  You can use positive numbers 2, 3, 4, etc for point sizes, or negative sizes for Angstrom-based sizes: A 2Ang font woukld then be -2.  Eg: <source lang="python">set label_size, -2</source>
'''[[label_digits]]'''
:: (no idea)
'''[[label_outline_color]]'''
:: each label is outlined (so you can do white-on-white labels, for example).  This options sets the color of the label outline.  Eg. <source lang="python">set label_outline_color, orange</source>
'''[[label_dihedral_digits]]'''
:: (no idea)
'''[[label_position]]'''
:: sets any offset from the original X,Y,Z coordinates for the label.  If you like to use the mouse, you can enter [[edit_mode]] and '''ctrl-middle-click''' to drag labels around; '''ctrl-shift-left_click''' will let you move the labels in the z-direction.


=Examples=
====EXPRESSION====
To set what the label reads (see above)
<source lang="python">label selection, expression</source>
For example
<source lang="python">
<source lang="python">
#1.
label all, name
# make a very simple label on the 14th alpha carbon.
label resi 10, b
label n. CA and i. 14, "This is carbon 14."
</source>


#2.
====POSITION====
# make a fake scene label; use this to label entire scenes, not just atoms/bonds.
To position labels
pseudoatom foo
edit_mode
label foo, "Once upon a time..."
then
ctrl-middle-click-and-drag to position the label in space. (On Windows systems this appears to be shift-left-click-and-drag, presumably because those mice lack a true middle button.)


#3.
ctrl-shift-left-click-and-drag alters a label's z-plane. (Windows only? This may use the middle button, rather than shift-left, under *NIX / 3-button mice systems.)
# make a huge label
set label_size, -5
pseudoatom foo
label foo, "This is large text"


#4. Partial Charge
===EXAMPLES===
==== Partial Charge ====
<source lang="python">
label (chain A),chain
label (chain A),chain
label (n;ca),"%s-%s" % (resn,resi)
label (n;ca),"%s-%s" % (resn,resi)
label (resi 200),"%1.3f" % partial_charge
label (resi 200),"%1.3f" % partial_charge
</source>


 
==== Example 2 ====
#5. The gallery image above Label_ex.png was created with this code
The following image was created with
#  and finally, some labels were moved around in '''edit_mode'''.
<source lang="python">
label (resi 200),"%1.3f" % b
label (resi 200),"%1.3f" % b
set label_font_id, 10
set label_font_id, 10
set label_size, 10
set label_size, 10
</source>
and finally, some labels were moved around in '''edit_mode'''.
[[Image:Label_ex.png|thumb|Labels.]]


#6. This example shows how to label a selection with the  
 
XYZ coordinates of the atoms  
==== More Advanced ====
This example shows how to label a selection with the XYZ coordinates of the atoms
<source lang="python">
from pymol import stored
from pymol import stored
stored.pos = []
stored.pos = []
# select the carbon atoms in my hetero atoms to label
# select the carbon atoms in my hetero atoms to label
select nn, het and e. C
select nn, het and e. C
# get the XYZ coordinates and put htem into stored.pos
# get the XYZ coordinates and put htem into stored.pos
iterate_state 1, (nn), stored.pos.append((x,y,z))
iterate_state 1, (nn), stored.pos.append((x,y,z))
# label all N atoms.  You need the pop() function or else
# label all N atoms.  You need the pop() function or else
# PyMOL will complain b/c you didn't provide enough coords.
# PyMOL will complain b/c you didn't provide enough coords.
Line 126: Line 139:
</source>
</source>


= User Comments =
===Users Comments===
==Labels Using ID Numbers==
====Labels Using ID Numbers====
The following commnent,
The following commnent,
<source lang="python">
label SELECTION, " %s" % ID  
label SELECTION, " %s" % ID  
</source>
labels the SELECTION with atom ID numbers.
labels the SELECTION with atom ID numbers.


You can make more complicated selections/lables such as
You can make more complicated selections/lables such as
<source lang="python">
label SELECTION, " %s:%s %s" % (resi, resn, name)
label SELECTION, " %s:%s %s" % (resi, resn, name)
</source>
which will give you something like "GLU:139 CG"
which will give you something like "GLU:139 CG"


==Labels Using One Letter Abbreviations==
====Labels Using One Letter Abbreviations====
* First, Add this to your $HOME/.pymolrc  file:
* First, Add this to your $HOME/.pymolrc  file:
<source lang="python">
<source lang="python">
Line 151: Line 160:
</source>
</source>


* Second, instead of:
*. Second, instead of:
<source lang="python">
label n. ca, resn
label n. ca, resn
</source>
use:
use:
<source lang="python">
label n. ca, one_letter[resn]
label n. ca, one_letter[resn]
</source>
 
=See Also=
[[:Category:Labeling]]


All the settings posted above.
[[Category:Commands|Label]]
[[Category:Labeling|Label]]

Latest revision as of 10:50, 27 May 2016

Fixes

  • Updates needed

New Page Content

New Page Overview

This is the content for the new labels page.


Old Page

PyMol Labels

DESCRIPTION

label allows one to configure the appearance of text labels for PyMOL objects. It labels one or more atoms properties over a selection using the python evaluator with a separate name space for each atom. The symbols defined in the name space are:

  • name, the atom name
  • resn, the residue name
  • resi, the residue number/identifier
  • chain, the chain name
  • q,
  • b, the occupancy/b-factor
  • segi, the segment identifier
  • type (ATOM,HETATM), the type of atom
  • formal_charge, the formal charge
  • partial_charge, the partial charge
  • numeric_type, the numeric type
  • text_type, the text type

All strings in the expression must be explicitly quoted. This operation typically takes several seconds per thousand atoms altered. To clear labels, simply omit the expression or set it to .

Label is great for labeling atoms, residues and objects. For a scene label, see Pseudoatom.

USAGE

label (selection),expression


SETTINGS

FONT

There are 10 different scalable fonts.

set label_font_id, number

where number is 5 through 14.

UTF8 Fonts
New fonts in PyMol. Notice the alpha and beta characters.

Newer versions support UTF8 fonts; use label_font_id from above to 15 or 16. The good news about the UTF8 fonts is that they support the alpha and beta characters. (See image.)

Here's some example code for the image at right:

# roman
set label_font_id, 15
set label_shadow_mode, 3
label 5/CA, "\316\261-Helix"
label 10/CA, "\316\262-Sheet"

# italic
set label_font_id, 16

# make bigger
set label_size, 50
Unicode Fonts
Notice the Angstrom and superscript 2 characters. You can add other characters as well.

PyMOL gives you the flexibility to use encoded unicode fonts. This allows us to insert various symbols, like the symbol used for Angstrom. Here are the steps to insert a character from the unicode character set.

  • Find the code for your character at Unicode Charts. The Angstrom character, is u"\u00c5" and is u"\u00b1".
  • Label the selection. For simple strings, just type the string in double quote, -- "like this" -- and append to the end of that .encode('utf-8') -- "like this".encode('utf-8'). A working example is shown here,
# label residue 30 with "4.1 Ang^2 +/- 0.65 Ang^2; see the image at right
label i. 30, "4.1" + u"\u00c5\u00b2  \u00b1 0.65 \u00c5\u00b2 ".encode('utf-8')

SIZE

The font size can be adjusted

set label_size, number

where number is the point size (or -number for Angstroms)

COLOR

Set a label's color by

set label_color, color

where color is a valid PyMol color.

If the coloring of the labels is not exactly the same as you'd expect (say black turns out grey, or red turns out pink), then try the following settings:

unset depth_cue
unset ray_label_specular

EXPRESSION

To set what the label reads (see above)

label selection, expression

For example

 label all, name
 label resi 10, b

POSITION

To position labels

edit_mode

then ctrl-middle-click-and-drag to position the label in space. (On Windows systems this appears to be shift-left-click-and-drag, presumably because those mice lack a true middle button.)

ctrl-shift-left-click-and-drag alters a label's z-plane. (Windows only? This may use the middle button, rather than shift-left, under *NIX / 3-button mice systems.)

EXAMPLES

Partial Charge

label (chain A),chain
label (n;ca),"%s-%s" % (resn,resi)
label (resi 200),"%1.3f" % partial_charge

Example 2

The following image was created with

label (resi 200),"%1.3f" % b
set label_font_id, 10
set label_size, 10

and finally, some labels were moved around in edit_mode.

Labels.


More Advanced

This example shows how to label a selection with the XYZ coordinates of the atoms

from pymol import stored
stored.pos = []

# select the carbon atoms in my hetero atoms to label
select nn, het and e. C

# get the XYZ coordinates and put htem into stored.pos
iterate_state 1, (nn), stored.pos.append((x,y,z))

# label all N atoms.  You need the pop() function or else
# PyMOL will complain b/c you didn't provide enough coords.
label nn, ("%5.5s, %5.5s, %5.5s") %  stored.pos.pop()

Users Comments

Labels Using ID Numbers

The following commnent,

label SELECTION, " %s" % ID 

labels the SELECTION with atom ID numbers.

You can make more complicated selections/lables such as

label SELECTION, " %s:%s %s" % (resi, resn, name)

which will give you something like "GLU:139 CG"

Labels Using One Letter Abbreviations

  • First, Add this to your $HOME/.pymolrc file:
# start $HOME/.pymolrc modification
one_letter ={'VAL':'V', 'ILE':'I', 'LEU':'L', 'GLU':'E', 'GLN':'Q', \
'ASP':'D', 'ASN':'N', 'HIS':'H', 'TRP':'W', 'PHE':'F', 'TYR':'Y',    \
'ARG':'R', 'LYS':'K', 'SER':'S', 'THR':'T', 'MET':'M', 'ALA':'A',    \
'GLY':'G', 'PRO':'P', 'CYS':'C'}
# end modification
  • . Second, instead of:
label n. ca, resn

use:

label n. ca, one_letter[resn]