forked from Pymol-Scripts/Pymol-script-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_colors.py
96 lines (85 loc) · 3.14 KB
/
get_colors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'''
get_colors.py
Described at: http://www.pymolwiki.org/get_colors
Version 1.0 (2014)
##################################################
Includes two functions:
get_colors: returns a list of defined pymol colors
get_random_color: returns a random color
##################################################
Plugin contributed by Andreas Warnecke
##################################################
VERSION NOTES:
1.0 2014 First release
'''
#-------------------------------------------------------------------------------
from pymol import cmd
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
<<<<<<< HEAD
def get_colors(selection='', quiet=1):
=======
def get_colors(selection='', output=True):
>>>>>>> autopep8
'''
DESCRIPTION:
returns a list of available pymol colors
USAGE:
get_colors [ selection [, quiet ]]
EXAMPLES:
get_colors # basic colors
get colors all # larger range with intermediates
'''
import pymol
pymol_color_list = []
for tuplepair in pymol.querying.get_color_indices(selection):
pymol_color_list.append(tuplepair[0])
pymol_color_list.sort()
<<<<<<< HEAD
if not int(quiet): print pymol_color_list
return pymol_color_list
cmd.extend('get_colors',get_colors)
cmd.auto_arg[0]['get_colors']=[lambda: cmd.Shortcut(['""','all']), 'selection=', ',']
cmd.auto_arg[1]['get_colors']=[lambda: cmd.Shortcut(['0']), 'quiet=', '']
=======
# the str() is due to pymol passing aruments as strings,
# thus True becomes 'True'
if str(output) == 'True':
print pymol_color_list
return pymol_color_list
cmd.extend('get_colors', get_colors)
cmd.auto_arg[0]['get_colors'] = [lambda: cmd.Shortcut(['""', 'all']), 'selection=', ',']
cmd.auto_arg[1]['get_colors'] = [lambda: cmd.Shortcut(['True']), 'output=', '']
>>>>>>> autopep8
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def get_random_color(selection='', quiet=1):
'''
DESCRIPTION:
returns a random color name available in pymol
! Requires get_colors !Indended mostly for use in Python
USAGE:
get_random_color [ selection [, quiet ]]
EXAMPLES:
# print a random color name:
get_random_color
# color object randomly:
fetch 1hpv, async=0
cmd.color(get_random_color())
'''
import random
<<<<<<< HEAD
randomcolor=random.choice(get_colors(selection, 1))
if not int(quiet): print randomcolor
=======
randomcolor = random.choice(get_colors(selection, False))
if str(output) != 'False':
print randomcolor
>>>>>>> autopep8
return randomcolor
cmd.extend('get_random_color', get_random_color)
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------