-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
executable file
·188 lines (160 loc) · 5.91 KB
/
__init__.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
'''
Collection of PyMOL scripts
A reference document with all commands can be generated with:
PyMOL> psico.helping.write_html_ref('psico-commands.html')
(c) 2010-2012 Thomas Holder <[email protected]>
Steffen Schmidt <[email protected]>
Max Planck Institute for Developmental Biology
License: BSD-2-Clause
'''
__version__ = '3.2'
try:
from pymol import cmd
pymol_version = cmd.get_version()[1]
except:
pymol_version = 1.6
__all__ = [
'aaindex',
'contactmap',
'contactmap_yang',
'conservation',
'creating',
'editing',
'electrostatics',
'exporting',
'fasta',
'fitting',
'geometry',
'orientation',
'helping',
'importing',
'minimizing',
'modelling',
'morphing',
'moving',
'msms',
'nma',
'plotting',
'pymol_silent',
'querying',
'selecting',
'setting',
'snp',
'viewing',
'wizards',
'xtal',
'load_mtz_cctbx',
]
if pymol_version < 1.6:
__all__.append('morphing')
def make_global():
'''
"psico" might be installed as submodule of something else (PyMOL plugin).
Invoke this function if you want to do "from psico import ...".
'''
import sys
if sys.modules.get('psico') != sys.modules[__name__]:
sys.modules['psico'] = sys.modules[__name__]
def init(save=0, fetch=0, pymolapi=0):
'''
DESCRIPTION
Imports all psico submodules and puts "psico" into the pymol namespace
for GUI menus. Also enables "help psico" in the PyMOL command line.
ARGUMENTS
save = bool: Overload "save" command with psico.exporting.save (writes
secondary structure and crystal records to PDB header)
fetch = bool: Overload "fetch" command with psico.importing.fetch (can
fetch from local mirror, knows SCOP and CATH identifiers)
pymolapi = 0/1/2: Add all psico functions to PyMOL API (pymol.cmd)
'''
import pymol
from pymol import cmd
# init all submodules
psico = __import__(__name__, fromlist=__all__)
# pymol namespace
if not hasattr(pymol, 'psico'):
pymol.psico = psico
# pymol help
if 'psico' not in cmd.help_only:
cmd.help_only['psico'] = [psico]
cmd.help_sc.append('psico')
if save:
cmd.extend('save', psico.exporting.save)
if fetch:
cmd.extend('fetch', psico.importing.fetch)
if pymolapi:
init_cmd(pymolapi == 2)
# PyMOL Plugin hook
def __init_plugin__(self=None):
init(1, 0, 0)
make_global()
def init_cmd(force=0):
'''
Adds all psico functions to PyMOL API (pymol.cmd)
If force is True, overwrite existing names.
'''
from pymol import cmd
for name, value in cmd.keyword.items():
function = value[0]
if function.__module__.startswith(__name__):
if force or not hasattr(cmd, function.__name__):
setattr(cmd, function.__name__, function)
# See also http://pymolwiki.org/index.php/Aa_codes
one_letter = {
'PAQ': 'Y', 'AGM': 'R', 'ILE': 'I', 'PR3': 'C', 'GLN': 'Q', 'DVA': 'V',
'CCS': 'C', 'ACL': 'R', 'GLX': 'Z', 'GLY': 'G', 'GLZ': 'G', 'DTH': 'T',
'OAS': 'S', 'C6C': 'C', 'NEM': 'H', 'DLY': 'K', 'MIS': 'S', 'SMC': 'C',
'GLU': 'E', 'NEP': 'H', 'BCS': 'C', 'ASQ': 'D', 'ASP': 'D', 'SCY': 'C',
'SER': 'S', 'LYS': 'K', 'SAC': 'S', 'PRO': 'P', 'ASX': 'B', 'DGN': 'Q',
'DGL': 'E', 'MHS': 'H', 'ASB': 'D', 'ASA': 'D', 'NLE': 'L', 'DCY': 'C',
'ASK': 'D', 'GGL': 'E', 'STY': 'Y', 'SEL': 'S', 'CGU': 'E', 'ASN': 'N',
'ASL': 'D', 'LTR': 'W', 'DAR': 'R', 'VAL': 'V', 'CHG': 'A', 'TPO': 'T',
'CLE': 'L', 'GMA': 'E', 'HAC': 'A', 'AYA': 'A', 'THR': 'T', 'TIH': 'A',
'SVA': 'S', 'MVA': 'V', 'SAR': 'G', 'LYZ': 'K', 'BNN': 'A', '5HP': 'E',
'IIL': 'I', 'SHR': 'K', 'HAR': 'R', 'FME': 'M', 'PYX': 'C', 'ALO': 'T',
'PHI': 'F', 'ALM': 'A', 'PHL': 'F', 'MEN': 'N', 'TPQ': 'A', 'GSC': 'G',
'PHE': 'F', 'ALA': 'A', 'MAA': 'A', 'MET': 'M', 'UNK': 'X', 'LEU': 'L',
'ALY': 'K', 'SET': 'S', 'GL3': 'G', 'TRG': 'K', 'CXM': 'M', 'TYR': 'Y',
'SCS': 'C', 'DIL': 'I', 'TYQ': 'Y', '3AH': 'H', 'DPR': 'P', 'PRR': 'A',
'CME': 'C', 'IYR': 'Y', 'CY1': 'C', 'TYY': 'Y', 'HYP': 'P', 'DTY': 'Y',
'2AS': 'D', 'DTR': 'W', 'FLA': 'A', 'DPN': 'F', 'DIV': 'V', 'PCA': 'E',
'MSE': 'M', 'MSA': 'G', 'AIB': 'A', 'CYS': 'C', 'NLP': 'L', 'CYQ': 'C',
'HIS': 'H', 'DLE': 'L', 'CEA': 'C', 'DAL': 'A', 'LLP': 'K', 'DAH': 'F',
'HMR': 'R', 'TRO': 'W', 'HIC': 'H', 'CYG': 'C', 'BMT': 'T', 'DAS': 'D',
'TYB': 'Y', 'BUC': 'C', 'PEC': 'C', 'BUG': 'L', 'CYM': 'C', 'NLN': 'L',
'CY3': 'C', 'HIP': 'H', 'CSO': 'C', 'TPL': 'W', 'LYM': 'K', 'DHI': 'H',
'MLE': 'L', 'CSD': 'A', 'HPQ': 'F', 'MPQ': 'G', 'LLY': 'K', 'DHA': 'A',
'DSN': 'S', 'SOC': 'C', 'CSX': 'C', 'OMT': 'M', 'DSP': 'D', 'PTR': 'Y',
'TRP': 'W', 'CSW': 'C', 'EFC': 'C', 'CSP': 'C', 'CSS': 'C', 'SCH': 'C',
'OCS': 'C', 'NMC': 'G', 'SEP': 'S', 'BHD': 'D', 'KCX': 'K', 'SHC': 'C',
'C5C': 'C', 'HTR': 'W', 'ARG': 'R', 'TYS': 'Y', 'ARM': 'R', 'DNP': 'A',
}
three_letter = {
'A': 'ALA', 'C': 'CYS', 'E': 'GLU', 'D': 'ASP', 'G': 'GLY', 'F': 'PHE',
'I': 'ILE', 'H': 'HIS', 'K': 'LYS', 'M': 'MET', 'L': 'LEU', 'N': 'ASN',
'Q': 'GLN', 'P': 'PRO', 'S': 'SER', 'R': 'ARG', 'T': 'THR', 'W': 'TRP',
'V': 'VAL', 'Y': 'TYR',
}
# matplotlib_fix preferences
matplotlib_fix_prefs = {
'verbose': True,
'force_tkagg': False,
'force_show': False,
'tkagg_overload': True,
}
def which(*names, **kw):
'''
Return full path to executable or empty string if not found in PATH.
'''
import os
if 'PATHEXT' in os.environ:
pathext = [''] + os.environ['PATHEXT'].split(';')
names = [n + ext for n in names for ext in pathext]
path = kw.get('path') or os.environ['PATH'].split(os.pathsep)
for n in names:
for p in path:
full = os.path.join(p, n)
if os.path.isfile(full):
return full
return ''
# vi: ts=4:sw=4:smarttab:expandtab