| 1 |
--- |
| 2 |
layout: post |
| 3 |
title: "Coot Graphics Tutorials" |
| 4 |
date: Tue 13 Sep 00:00:43 BST 2022 |
| 5 |
--- |
| 6 |
|
| 7 |
Lucrezia Catapano has made some introductory tutorials for Coot 1. |
| 8 |
|
| 9 |
 |
| 10 |
|
| 11 |
Here is the video to cover the basics: |
| 12 |
|
| 13 |
[Coot 1 Tutorial: Basics](https://www.youtube.com/watch?v=Xhonm4K1y0c) |
| 14 |
|
| 15 |
Here is the new (Sept 2022) graphics tutorial - map masking, Shader Preferences and scripting: |
| 16 |
|
| 17 |
[Coot 1 Tutorial: Graphics Part 1](https://www.youtube.com/watch?v=tCpCmBTgt6s) |
| 18 |
|
| 19 |
[Coot 1 Tutorial: Graphics Part 2](https://www.youtube.com/watch?v=OL5-aSZ-p9I) |
| 20 |
|
| 21 |
Here is Lucrezia's script for the masking and colours: |
| 22 |
|
| 23 |
{% highlight python %} |
| 24 |
|
| 25 |
import coot |
| 26 |
import coot_utils |
| 27 |
|
| 28 |
# resize window |
| 29 |
coot.set_graphics_window_size(880, 1000) |
| 30 |
|
| 31 |
# read model and mapn |
| 32 |
imol = coot.read_pdb('7p9b.pdb') |
| 33 |
imol_map = coot.read_ccp4_map('emd_13261.map', 0) |
| 34 |
|
| 35 |
# set map radius |
| 36 |
coot.set_map_radius_em(99.0) |
| 37 |
|
| 38 |
# mask map by chains |
| 39 |
def make_masked_map_using_active_atom(): |
| 40 |
active_atom = coot.active_residue_py() |
| 41 |
if active_atom: |
| 42 |
imol = active_atom[0] |
| 43 |
coot.make_masked_maps_split_by_chain(imol, coot.imol_refinement_map()) |
| 44 |
make_masked_map_using_active_atom() |
| 45 |
|
| 46 |
# make maps as surface |
| 47 |
coot_utils.solidify_maps() |
| 48 |
|
| 49 |
# undisplay original map and model |
| 50 |
coot.set_map_displayed(1, 0) |
| 51 |
coot.set_mol_displayed(0, 0) |
| 52 |
|
| 53 |
# set center and zoom |
| 54 |
#coot.set_rotation_centre(166.403, 166.418, 166.409) |
| 55 |
#coot.set_view_quaternion(1.000000, 0.000000, 0.000000, 0.000000) |
| 56 |
coot.set_zoom(381.078) |
| 57 |
|
| 58 |
# decrease clipping front |
| 59 |
for i in range(12): |
| 60 |
coot.decrease_clipping_front() |
| 61 |
|
| 62 |
# color maps |
| 63 |
coot.set_map_hexcolour(2, '#A36352') |
| 64 |
coot.set_map_hexcolour(3, '#A36352') |
| 65 |
coot.set_map_hexcolour(4, '#D4992E') |
| 66 |
coot.set_map_hexcolour(5, '#D4992E') |
| 67 |
coot.set_map_hexcolour(6, '#B8A152') |
| 68 |
coot.set_map_hexcolour(7, '#B8A152') |
| 69 |
coot.set_map_hexcolour(8, '#B2B896' ) |
| 70 |
coot.set_map_hexcolour(9,'#B2B896' ) |
| 71 |
coot.set_map_hexcolour(10, '#CF9EB5') |
| 72 |
coot.set_map_hexcolour(11,'#CF9EB5' ) |
| 73 |
|
| 74 |
# shader preferences |
| 75 |
coot.set_effects_shader_brightness(1.43) |
| 76 |
coot.set_effects_shader_gamma(0.48) |
| 77 |
coot.set_focus_blur_z_depth(0.15) |
| 78 |
coot.set_focus_blur_strength(1.0) |
| 79 |
|
| 80 |
coot.graphics_draw() |
| 81 |
|
| 82 |
{% endhighlight %} |
| 83 |
|
| 84 |
And here is Lucrezia's script for the background colours |
| 85 |
|
| 86 |
{% highlight python %} |
| 87 |
|
| 88 |
import coot |
| 89 |
import gi |
| 90 |
gi.require_version('Gtk', '3.0') |
| 91 |
from gi.repository import Gtk |
| 92 |
import coot_gui_api |
| 93 |
import coot_utils |
| 94 |
|
| 95 |
|
| 96 |
main_menubar = coot_gui_api.main_menubar() |
| 97 |
menu_label = "Background" |
| 98 |
menu = Gtk.Menu() |
| 99 |
menuitem = Gtk.MenuItem(menu_label) |
| 100 |
menuitem.set_submenu(menu) |
| 101 |
main_menubar.append(menuitem) |
| 102 |
menuitem.show() |
| 103 |
|
| 104 |
|
| 105 |
def add_simple_coot_menu_menuitem(menu, menu_item_label, activate_function): |
| 106 |
submenu = Gtk.Menu() |
| 107 |
sub_menuitem = Gtk.MenuItem(menu_item_label) |
| 108 |
menu.append(sub_menuitem) |
| 109 |
sub_menuitem.show() |
| 110 |
sub_menuitem.connect("activate", activate_function) |
| 111 |
|
| 112 |
add_simple_coot_menu_menuitem(menu, 'Red', lambda widget: coot.set_background_colour(1,0,0)) |
| 113 |
add_simple_coot_menu_menuitem(menu, 'Blue', lambda widget: coot.set_background_colour(0,0,1)) |
| 114 |
add_simple_coot_menu_menuitem(menu, 'Aqua', lambda widget: coot.set_background_colour(0,1,1)) |
| 115 |
add_simple_coot_menu_menuitem(menu, 'White', lambda widget: coot.set_background_colour(1,1,1)) |
| 116 |
add_simple_coot_menu_menuitem(menu, 'Fuchsia', lambda widget: coot.set_background_colour(1,0,1)) |
| 117 |
add_simple_coot_menu_menuitem(menu, 'Green', lambda widget: coot.set_background_colour(0,1,0)) |
| 118 |
add_simple_coot_menu_menuitem(menu, 'Yellow', lambda widget: coot.set_background_colour(1,1,0)) |
| 119 |
|
| 120 |
red_submenu = Gtk.Menu() |
| 121 |
red_menuitem_sub = Gtk.MenuItem(label="Other Reds") |
| 122 |
red_menuitem_sub.set_submenu(red_submenu) |
| 123 |
menu.append(red_menuitem_sub) |
| 124 |
red_menuitem_sub.show() |
| 125 |
|
| 126 |
green_submenu = Gtk.Menu() |
| 127 |
green_menuitem_sub = Gtk.MenuItem(label="Other Greens") |
| 128 |
green_menuitem_sub.set_submenu(green_submenu) |
| 129 |
menu.append(green_menuitem_sub) |
| 130 |
green_menuitem_sub.show() |
| 131 |
|
| 132 |
blue_submenu = Gtk.Menu() |
| 133 |
blue_menuitem_sub = Gtk.MenuItem(label="Other Blues") |
| 134 |
blue_menuitem_sub.set_submenu(blue_submenu) |
| 135 |
menu.append(blue_menuitem_sub) |
| 136 |
blue_menuitem_sub.show() |
| 137 |
|
| 138 |
grey_submenu = Gtk.Menu() |
| 139 |
grey_menuitem_sub = Gtk.MenuItem(label="Other Greys") |
| 140 |
grey_menuitem_sub.set_submenu(grey_submenu) |
| 141 |
menu.append(grey_menuitem_sub) |
| 142 |
grey_menuitem_sub.show() |
| 143 |
|
| 144 |
aqua_submenu = Gtk.Menu() |
| 145 |
aqua_menuitem_sub = Gtk.MenuItem(label="Other Aquas") |
| 146 |
aqua_menuitem_sub.set_submenu(aqua_submenu) |
| 147 |
menu.append(aqua_menuitem_sub) |
| 148 |
aqua_menuitem_sub.show() |
| 149 |
|
| 150 |
yellow_submenu = Gtk.Menu() |
| 151 |
yellow_menuitem_sub = Gtk.MenuItem(label="Other Yellows") |
| 152 |
yellow_menuitem_sub.set_submenu(yellow_submenu) |
| 153 |
menu.append(yellow_menuitem_sub) |
| 154 |
yellow_menuitem_sub.show() |
| 155 |
|
| 156 |
fuchsia_submenu = Gtk.Menu() |
| 157 |
fuchsia_menuitem_sub = Gtk.MenuItem(label="Other Fuchsias") |
| 158 |
fuchsia_menuitem_sub.set_submenu(fuchsia_submenu) |
| 159 |
menu.append(fuchsia_menuitem_sub) |
| 160 |
fuchsia_menuitem_sub.show() |
| 161 |
|
| 162 |
for i in range(1, 11): |
| 163 |
f = i/10 |
| 164 |
label = "Background colour Red " + str(f) |
| 165 |
add_simple_coot_menu_menuitem(red_submenu, label, lambda widget,f1=f: coot.set_background_colour(f1,0,0)) |
| 166 |
|
| 167 |
for i in range(1, 21): |
| 168 |
f = i/20 |
| 169 |
label = "Background colour Blue " + str(f) |
| 170 |
add_simple_coot_menu_menuitem(blue_submenu, label, lambda widget,f1=f: coot.set_background_colour(0,0,f1)) |
| 171 |
|
| 172 |
for i in range(1, 21): |
| 173 |
f = i/20 |
| 174 |
if i == 0: |
| 175 |
f = 0.03 |
| 176 |
label = "Background colour Grey " + str(f) |
| 177 |
add_simple_coot_menu_menuitem(grey_submenu, label, lambda widget,f1=f: coot.set_background_colour(f1,f1,f1)) |
| 178 |
|
| 179 |
for i in range(1, 11): |
| 180 |
f = i/10 |
| 181 |
label = "Background colour Aqua " + str(f) |
| 182 |
add_simple_coot_menu_menuitem(aqua_submenu, label, lambda widget,f1=f: coot.set_background_colour(0,f1,f1)) |
| 183 |
|
| 184 |
for i in range(1, 11): |
| 185 |
f = i/10 |
| 186 |
label = "Background colour Fuchsia " + str(f) |
| 187 |
add_simple_coot_menu_menuitem(fuchsia_submenu, label, lambda widget,f1=f: coot.set_background_colour(f1,0,f1)) |
| 188 |
|
| 189 |
for i in range(1, 11): |
| 190 |
f = i/10 |
| 191 |
label = "Background colour Green " + str(f) |
| 192 |
add_simple_coot_menu_menuitem(green_submenu, label, lambda widget,f1=f: coot.set_background_colour(0,f1,0)) |
| 193 |
|
| 194 |
for i in range(1, 11): |
| 195 |
f = i/10 |
| 196 |
label = "Background colour Yellow " + str(f) |
| 197 |
add_simple_coot_menu_menuitem(yellow_submenu, label, lambda widget,f1=f: coot.set_background_colour(f1,f1,0)) |
| 198 |
|
| 199 |
|
| 200 |
{% endhighlight %} |