-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
284 lines (215 loc) · 7.04 KB
/
Copy path__init__.py
File metadata and controls
284 lines (215 loc) · 7.04 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# To initialize the plugin to be installed by PyMOL
from __future__ import absolute_import
from __future__ import print_function
# To provide an entry point to PyMOL's API
import os
import math
#must do .module import
from .calc_miv import *
# pylint: disable=wrong-import-order
from pymol import cmd
from pymol.Qt import QtWidgets
from pymol.Qt.utils import loadUi
from pymol.Qt.utils import *
from pymol.plugins import addmenuitemqt
import pymol._gui
Qt = QtCore.Qt
QFileDialog = QtWidgets.QFileDialog
getOpenFileNames = QFileDialog.getOpenFileNames
############################################################
################### Initialize Plugin #####################
############################################################
# pylint: disable=unused-argument
def __init_plugin__(app=None):
'''
This function will add an entry into the PyMOL architecture
**Parameters**
app: *filet*
The application to be loaded for plugin initialization
**Returns**
Menu item `PyMIV` under the `Plugins` menu item bar
'''
addmenuitemqt('PyMIV', run_plugin_gui)
# To create global reference of the dialog variables
# pylint: disable=invalid-name
dialog = None
# to give filename of the UI file
uifile = os.path.join(os.path.dirname(__file__), 'PyMIV_GUI.ui')
# To load the UI dialog
form = loadUi(uifile, dialog)
def run_plugin_gui():
'''
This function will open the custom dialog window
**Parameters**
None
**Returns**
Dialog window `PyMIV`
'''
# pylint: disable=global-statement
global dialog
if dialog is None:
dialog = make_dialog()
dialog.show()
def make_dialog():
'''
This function will make the dialog window if there is no window open
**Parameters**
None
**Returns**
Dialog window tasks `PyMIV`
'''
# To create a new UI window
# pylint: disable= redefined-outer-name
dialog = QtWidgets.QDialog()
# To populate the Window from our .ui file
uifile = os.path.join(os.path.dirname(__file__), 'PyMIV_GUI.ui')
form = loadUi(uifile, dialog)
# To create buttons in the GUI
def browse_filename():
'''
This function will allow selection of a valid PDB file when `Broswe` is clicked
**Parameters**
None
**Returns**
None
'''
filename = getOpenFileNames(
dialog)
clean_filename=(clean_file_path(str(filename)))
form.lineEdit.setText(clean_filename)
def disulfide_finder_button():
'''
This function will run the disulfide_finder function and
load `disulfide_bonds.pml when `Disulfide Finder` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
calc_disulfide(pdb_file)
cmd.run("disulfide_bonds.pml")
print('Yellow = Cysteine Sulfur Atoms')
def wc_nwc_button():
'''
This function will run the calc_wc_nwc function and
load `get_bonds.pml when `WC vs Non-WC` is clicked
**Parameters**
None
**Returns**
None
'''
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
calc_wc_nwc(pdb_file)
cmd.run("get_bonds.pml")
print('Yellow = WC\nRed=Non-WC')
def alpha_helix_button():
'''
This function will run alpha_helice function and
load `helix_bonds.pml when `Alpha Helix` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
alpha_helice(pdb_file)
cmd.run("helix_bonds.pml")
def calc_mw_button():
'''
This function will run calc_peptide_mw function and
when `Alpha Helix` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
calc_peptide_mw(pdb_file)
cmd.load(pdb_file)
def end_to_end_button():
'''
This function will run end_to_end_dist function and
load `end_to_end.pml when `End to End Distance` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
end_to_end_dist(pdb_file)
cmd.run("end_to_end.pml")
def output_fasta_button():
'''
This function will run end_to_end_dist function and
load `end_to_end.pml when `End to End Distance` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
output_fasta(pdb_file)
def map_site_button():
'''
This function will run map_site function and
load `mapped_site.pml when `PARmap` is clicked
**Parameters**
None
**Returns**
None
'''
# retreive PDB file data
pdb_file = form.lineEdit.text()
# Error Code
if pdb_file == "":
print("Please input a valid .pdb file name")
else:
print('User Entered Filename:', pdb_file)
end_to_end_dist(pdb_file)
cmd.run("mapped_site.pml")
# To connect clicking buttons to a value, text or command
form.browse.clicked.connect(browse_filename)
form.done.clicked.connect(dialog.close)
form.disulfideFinder.clicked.connect(disulfide_finder_button)
form.calculateMW.clicked.connect(calc_mw_button)
form.wcAndNonWC.clicked.connect(wc_nwc_button)
form.hydrogenBond.clicked.connect(alpha_helix_button)
form.endToEndDistance.clicked.connect(end_to_end_button)
form.fasta.clicked.connect(output_fasta_button)
form.PARmap.clicked.connect(map_site_button)
return dialog